X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_options.c;h=017a34aac6e712e07899c9bc1c63f3198c2296d7;hp=f22d6c5c2fc617adc7a1511b5347a71040fe8591;hb=c2650100f80134924eda8f22cd7cc1d1d919ee3d;hpb=18865150079f74b17047633094e3994516af8a41 diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index f22d6c5c..017a34aa 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. * + * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 1998-2014,2017 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 * @@ -42,51 +43,55 @@ #include -#include - #ifndef CUR #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_options.c,v 1.64 2009/05/23 23:58:07 tom Exp $") - -static int _nc_meta(SCREEN *, bool); +MODULE_ID("$Id: lib_options.c,v 1.82 2021/02/14 00:17:35 tom Exp $") 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)); + int res = ERR; + T((T_CALLED("idlok(%p,%d)"), (void *) win, flag)); if (win) { - _nc_idlok = win->_idlok = (flag && (has_il() || change_scroll_region)); - returnCode(OK); - } else - returnCode(ERR); + SCREEN *sp = _nc_screen_of(win); + if (sp != 0 +#ifdef USE_TERM_DRIVER + && IsTermInfo(sp) +#endif + ) { + sp->_nc_sp_idlok = + win->_idlok = (flag && (NCURSES_SP_NAME(has_il) (NCURSES_SP_ARG) + || change_scroll_region)); + res = OK; + } + } + returnCode(res); } NCURSES_EXPORT(void) idcok(WINDOW *win, bool flag) { - T((T_CALLED("idcok(%p,%d)"), win, flag)); - - if (win) - _nc_idcok = win->_idcok = (flag && has_ic()); + T((T_CALLED("idcok(%p,%d)"), (void *) win, flag)); + if (win) { + SCREEN *sp = _nc_screen_of(win); + sp->_nc_sp_idcok = win->_idcok = (flag && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)); + } returnVoid; } NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t) { - T((T_CALLED("halfdelay(%d)"), t)); + T((T_CALLED("halfdelay(%p,%d)"), (void *) SP_PARM, t)); - if (t < 1 || t > 255 || SP_PARM == 0) + if (t < 1 || t > 255 || !SP_PARM || !IsValidTIScreen(SP_PARM)) returnCode(ERR); - cbreak(); + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); SP_PARM->_cbreak = t + 1; returnCode(OK); } @@ -102,7 +107,7 @@ halfdelay(int t) NCURSES_EXPORT(int) nodelay(WINDOW *win, bool flag) { - T((T_CALLED("nodelay(%p,%d)"), win, flag)); + T((T_CALLED("nodelay(%p,%d)"), (void *) win, flag)); if (win) { if (flag == TRUE) @@ -117,7 +122,7 @@ nodelay(WINDOW *win, bool flag) NCURSES_EXPORT(int) notimeout(WINDOW *win, bool f) { - T((T_CALLED("notimeout(%p,%d)"), win, f)); + T((T_CALLED("notimeout(%p,%d)"), (void *) win, f)); if (win) { win->_notimeout = f; @@ -129,7 +134,7 @@ notimeout(WINDOW *win, bool f) NCURSES_EXPORT(void) wtimeout(WINDOW *win, int delay) { - T((T_CALLED("wtimeout(%p,%d)"), win, delay)); + T((T_CALLED("wtimeout(%p,%d)"), (void *) win, delay)); if (win) { win->_delay = delay; @@ -140,11 +145,11 @@ wtimeout(WINDOW *win, int delay) NCURSES_EXPORT(int) keypad(WINDOW *win, bool flag) { - T((T_CALLED("keypad(%p,%d)"), win, flag)); + T((T_CALLED("keypad(%p,%d)"), (void *) win, flag)); if (win) { win->_use_keypad = flag; - returnCode(_nc_keypad(SP, flag)); + returnCode(_nc_keypad(_nc_screen_of(win), flag)); } else returnCode(ERR); } @@ -152,11 +157,33 @@ keypad(WINDOW *win, bool flag) NCURSES_EXPORT(int) meta(WINDOW *win GCC_UNUSED, bool flag) { - int result; + int result = ERR; + SCREEN *sp = (win == 0) ? CURRENT_SCREEN : _nc_screen_of(win); /* Ok, we stay relaxed and don't signal an error if win is NULL */ - T((T_CALLED("meta(%p,%d)"), win, flag)); - result = _nc_meta(SP, flag); + T((T_CALLED("meta(%p,%d)"), (void *) win, flag)); + + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + + if (sp != 0) { + sp->_use_meta = flag; +#ifdef USE_TERM_DRIVER + if (IsTermInfo(sp)) { + if (flag) { + NCURSES_PUTP2("meta_on", meta_on); + } else { + NCURSES_PUTP2("meta_off", meta_off); + } + } +#else + if (flag) { + NCURSES_PUTP2("meta_on", meta_on); + } else { + NCURSES_PUTP2("meta_off", meta_off); + } +#endif + result = OK; + } returnCode(result); } @@ -165,32 +192,42 @@ meta(WINDOW *win GCC_UNUSED, bool flag) NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis) { - int result = ERR; + int code = ERR; + T((T_CALLED("curs_set(%p,%d)"), (void *) SP_PARM, vis)); - T((T_CALLED("curs_set(%p,%d)"), SP_PARM, vis)); if (SP_PARM != 0 && vis >= 0 && vis <= 2) { int cursor = SP_PARM->_cursor; - if (vis == cursor) { - result = cursor; + code = 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; +#ifdef USE_TERM_DRIVER + code = CallDriver_1(SP_PARM, td_cursorSet, vis); +#else + if (IsValidTIScreen(SP_PARM)) { + switch (vis) { + case 2: + code = NCURSES_PUTP2_FLUSH("cursor_visible", + cursor_visible); + break; + case 1: + code = NCURSES_PUTP2_FLUSH("cursor_normal", + cursor_normal); + break; + case 0: + code = NCURSES_PUTP2_FLUSH("cursor_invisible", + cursor_invisible); + break; + } + } else { + code = ERR; } - if (result != ERR) - result = (cursor == -1 ? 1 : cursor); +#endif + if (code != ERR) + code = (cursor == -1 ? 1 : cursor); SP_PARM->_cursor = vis; } } - returnCode(result); + returnCode(code); } #if NCURSES_SP_FUNCS @@ -204,8 +241,8 @@ curs_set(int vis) NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd) { - T((T_CALLED("typeahead(%d)"), fd)); - if (SP_PARM != 0) { + T((T_CALLED("typeahead(%p, %d)"), (void *) SP_PARM, fd)); + if (SP_PARM && IsValidTIScreen(SP_PARM)) { SP_PARM->_checkfd = fd; returnCode(OK); } else { @@ -241,10 +278,18 @@ has_key_internal(int keycode, TRIES * tp) || has_key_internal(keycode, tp->sibling)); } +#ifdef USE_TERM_DRIVER +NCURSES_EXPORT(int) +TINFO_HAS_KEY(SCREEN *sp, int keycode) +{ + return IsValidTIScreen(sp) ? + has_key_internal(keycode, sp->_keytry) : 0; +} +#else NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode) { - T((T_CALLED("has_key(%p,%d)"), SP_PARM, keycode)); + T((T_CALLED("has_key(%p,%d)"), (void *) SP_PARM, keycode)); returnCode(SP != 0 ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE); } @@ -255,27 +300,21 @@ has_key(int keycode) return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode); } #endif +#endif #endif /* NCURSES_EXT_FUNCS */ -/* - * Internal entrypoints use SCREEN* parameter to obtain capabilities rather - * than cur_term. - */ -#undef CUR -#define CUR SP_TERMTYPE - NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_DCLx const char *name, const char *value) { - int rc = _nc_putp(name, value); + int rc = NCURSES_PUTP2(name, value); if (rc != ERR) { _nc_flush(); } return rc; } -#if NCURSES_SP_FUNCS +#if 0 && NCURSES_SP_FUNCS NCURSES_EXPORT(int) _nc_putp_flush(const char *name, const char *value) { @@ -291,7 +330,7 @@ _nc_putp_flush(const char *name, const char *value) * the terminal state _before_ switching modes. */ NCURSES_EXPORT(int) -_nc_keypad(SCREEN *sp, bool flag) +_nc_keypad(SCREEN *sp, int flag) { int rc = ERR; @@ -315,10 +354,15 @@ _nc_keypad(SCREEN *sp, bool flag) } else #endif { +#ifdef USE_TERM_DRIVER + rc = CallDriver_1(sp, td_kpad, flag); + if (rc == OK) + sp->_keypad_on = flag; +#else if (flag) { - (void) _nc_putp_flush("keypad_xmit", keypad_xmit); - } else if (!flag && keypad_local) { - (void) _nc_putp_flush("keypad_local", keypad_local); + (void) NCURSES_PUTP2_FLUSH("keypad_xmit", keypad_xmit); + } else if (keypad_local) { + (void) NCURSES_PUTP2_FLUSH("keypad_local", keypad_local); } if (flag && !sp->_tried) { @@ -327,27 +371,8 @@ _nc_keypad(SCREEN *sp, bool flag) } sp->_keypad_on = flag; rc = OK; +#endif } } return (rc); } - -static int -_nc_meta(SCREEN *sp, bool flag) -{ - int result = ERR; - - /* Ok, we stay relaxed and don't signal an error if win is NULL */ - - if (sp != 0) { - sp->_use_meta = flag; - - if (flag) { - _nc_putp("meta_on", meta_on); - } else { - _nc_putp("meta_off", meta_off); - } - result = OK; - } - return result; -}