X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_options.c;h=908ee1b07a98bae4d2f07aacfb01c73923a9474a;hp=eb170354f4dc630e15509c8799edd4d4ac26f797;hb=5b7f4de105080e2a715b0564ede4bb7eb6767659;hpb=3ce60e9f58cc00309981ed711d0b0d3362105881 diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index eb170354..908ee1b0 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -30,6 +30,7 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * ****************************************************************************/ /* @@ -43,14 +44,20 @@ #include -MODULE_ID("$Id: lib_options.c,v 1.57 2008/06/28 23:31:15 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_options.c,v 1.65 2009/07/04 18:14:31 tom Exp $") -static int _nc_curs_set(SCREEN *, int); static int _nc_meta(SCREEN *, bool); NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif T((T_CALLED("idlok(%p,%d)"), win, flag)); if (win) { @@ -63,6 +70,9 @@ idlok(WINDOW *win, bool flag) NCURSES_EXPORT(void) idcok(WINDOW *win, bool flag) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif T((T_CALLED("idcok(%p,%d)"), win, flag)); if (win) @@ -72,18 +82,26 @@ idcok(WINDOW *win, bool flag) } NCURSES_EXPORT(int) -halfdelay(int t) +NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t) { T((T_CALLED("halfdelay(%d)"), t)); - if (t < 1 || t > 255 || SP == 0) + if (t < 1 || t > 255 || SP_PARM == 0) returnCode(ERR); cbreak(); - SP->_cbreak = t + 1; + SP_PARM->_cbreak = t + 1; returnCode(OK); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +halfdelay(int t) +{ + return NCURSES_SP_NAME(halfdelay) (CURRENT_SCREEN, t); +} +#endif + NCURSES_EXPORT(int) nodelay(WINDOW *win, bool flag) { @@ -148,27 +166,64 @@ meta(WINDOW *win GCC_UNUSED, bool flag) /* curs_set() moved here to narrow the kernel interface */ NCURSES_EXPORT(int) -curs_set(int vis) +NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis) { - int result; + int result = ERR; + + T((T_CALLED("curs_set(%p,%d)"), SP_PARM, vis)); + if (SP_PARM != 0 && vis >= 0 && vis <= 2) { + int cursor = SP_PARM->_cursor; - T((T_CALLED("curs_set(%d)"), vis)); - result = _nc_curs_set(SP, vis); + if (vis == cursor) { + result = cursor; + } else { + switch (vis) { + case 2: + result = _nc_putp_flush("cursor_visible", cursor_visible); + break; + case 1: + result = _nc_putp_flush("cursor_normal", cursor_normal); + break; + case 0: + result = _nc_putp_flush("cursor_invisible", cursor_invisible); + break; + } + if (result != ERR) + result = (cursor == -1 ? 1 : cursor); + SP_PARM->_cursor = vis; + } + } returnCode(result); } +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) -typeahead(int fd) +curs_set(int vis) +{ + return (NCURSES_SP_NAME(curs_set) (CURRENT_SCREEN, vis)); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd) { T((T_CALLED("typeahead(%d)"), fd)); - if (SP != 0) { - SP->_checkfd = fd; + if (SP_PARM != 0) { + SP_PARM->_checkfd = fd; returnCode(OK); } else { returnCode(ERR); } } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +typeahead(int fd) +{ + return NCURSES_SP_NAME(typeahead) (CURRENT_SCREEN, fd); +} +#endif + /* ** has_key() ** @@ -189,12 +244,20 @@ has_key_internal(int keycode, TRIES * tp) || has_key_internal(keycode, tp->sibling)); } +NCURSES_EXPORT(int) +NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode) +{ + T((T_CALLED("has_key(%p,%d)"), SP_PARM, keycode)); + returnCode(SP != 0 ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE); +} + +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) has_key(int keycode) { - T((T_CALLED("has_key(%d)"), keycode)); - returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE); + return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode); } +#endif #endif /* NCURSES_EXT_FUNCS */ /* @@ -202,29 +265,26 @@ has_key(int keycode) * than cur_term. */ #undef CUR -#define CUR (sp->_term)->type. +#define CUR SP_TERMTYPE -static int -_nc_putp(const char *name GCC_UNUSED, const char *value) +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_DCLx + const char *name, const char *value) { - int rc = ERR; - - if (value) { - TPUTS_TRACE(name); - rc = putp(value); + int rc = _nc_putp(name, value); + if (rc != ERR) { + _nc_flush(); } return rc; } -static int +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) _nc_putp_flush(const char *name, const char *value) { - int rc = _nc_putp(name, value); - if (rc != ERR) { - _nc_flush(); - } - return rc; + return NCURSES_SP_NAME(_nc_putp_flush) (CURRENT_SCREEN, name, value); } +#endif /* Turn the keypad on/off * @@ -245,12 +305,12 @@ _nc_keypad(SCREEN *sp, bool flag) * has wgetch() reading in more than one thread. putp() and below * may use SP explicitly. */ - if (sp != SP) { + if (_nc_use_pthreads && sp != CURRENT_SCREEN) { SCREEN *save_sp; /* cannot use use_screen(), since that is not in tinfo library */ _nc_lock_global(curses); - save_sp = SP; + save_sp = CURRENT_SCREEN; _nc_set_screen(sp); rc = _nc_keypad(sp, flag); _nc_set_screen(save_sp); @@ -275,37 +335,6 @@ _nc_keypad(SCREEN *sp, bool flag) return (rc); } -static int -_nc_curs_set(SCREEN *sp, int vis) -{ - int result = ERR; - - T((T_CALLED("curs_set(%d)"), vis)); - if (sp != 0 && vis >= 0 && vis <= 2) { - int cursor = sp->_cursor; - - if (vis == cursor) { - result = cursor; - } else { - switch (vis) { - case 2: - result = _nc_putp_flush("cursor_visible", cursor_visible); - break; - case 1: - result = _nc_putp_flush("cursor_normal", cursor_normal); - break; - case 0: - result = _nc_putp_flush("cursor_invisible", cursor_invisible); - break; - } - if (result != ERR) - result = (cursor == -1 ? 1 : cursor); - sp->_cursor = vis; - } - } - returnCode(result); -} - static int _nc_meta(SCREEN *sp, bool flag) { @@ -313,8 +342,8 @@ _nc_meta(SCREEN *sp, bool flag) /* Ok, we stay relaxed and don't signal an error if win is NULL */ - if (SP != 0) { - SP->_use_meta = flag; + if (sp != 0) { + sp->_use_meta = flag; if (flag) { _nc_putp("meta_on", meta_on);