X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_raw.c;h=928692b0cb272ad52433dbb98ad2502dd5866303;hp=5d5a53327c3b82ddd74a92d08afd79f6a227c636;hb=8789460c7ae8e812ec444304cad5e23df1d70fc8;hpb=78e49873c69dc0494bb34c62f897f8b446584a33 diff --git a/ncurses/tinfo/lib_raw.c b/ncurses/tinfo/lib_raw.c index 5d5a5332..928692b0 100644 --- a/ncurses/tinfo/lib_raw.c +++ b/ncurses/tinfo/lib_raw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 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 * @@ -48,13 +48,8 @@ */ #include -#include /* cur_term */ -MODULE_ID("$Id: lib_raw.c,v 1.15 2009/02/15 00:49:02 tom Exp $") - -#if SVR4_TERMIO && !defined(_POSIX_SOURCE) -#define _POSIX_SOURCE -#endif +MODULE_ID("$Id: lib_raw.c,v 1.21 2012/01/21 19:21:29 KO.Myung-Hun Exp $") #if HAVE_SYS_TERMIO_H #include /* needed for ISC */ @@ -67,6 +62,11 @@ MODULE_ID("$Id: lib_raw.c,v 1.15 2009/02/15 00:49:02 tom Exp $") #define _nc_setmode(mode) /* nothing */ #endif +#if USE_KLIBC_KBD +#define INCL_KBD +#include +#endif + #define COOKED_INPUT (IXON|BRKINT|PARMRK) #ifdef TRACE @@ -81,28 +81,40 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("raw()"))); - - if (SP_PARM != 0 && cur_term != 0) { + T((T_CALLED("raw(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("raw"); _nc_setmode(O_BINARY); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS - buf.c_lflag &= ~(ICANON | ISIG | IEXTEN); - buf.c_iflag &= ~(COOKED_INPUT); + buf.c_lflag &= (unsigned) ~(ICANON | ISIG | IEXTEN); + buf.c_iflag &= (unsigned) ~(COOKED_INPUT); buf.c_cc[VMIN] = 1; buf.c_cc[VTIME] = 0; #else buf.sg_flags |= RAW; #endif - if ((result = _nc_set_tty_mode(&buf)) == OK) { + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { +#if USE_KLIBC_KBD + KBDINFO kbdinfo; + + kbdinfo.cb = sizeof(kbdinfo); + KbdGetStatus(&kbdinfo, 0); + + kbdinfo.cb = sizeof(kbdinfo); + kbdinfo.fsMask &= ~KEYBOARD_ASCII_MODE; + kbdinfo.fsMask |= KEYBOARD_BINARY_MODE; + KbdSetStatus(&kbdinfo, 0); +#endif SP_PARM->_raw = TRUE; SP_PARM->_cbreak = 1; - cur_term->Nttyb = buf; + termp->Nttyb = buf; } AFTER("raw"); } @@ -121,28 +133,29 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("cbreak()"))); - - if (SP_PARM != 0 && cur_term != 0) { + T((T_CALLED("cbreak(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("cbreak"); _nc_setmode(O_BINARY); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS - buf.c_lflag &= ~ICANON; - buf.c_iflag &= ~ICRNL; + buf.c_lflag &= (unsigned) ~ICANON; + buf.c_iflag &= (unsigned) ~ICRNL; buf.c_lflag |= ISIG; buf.c_cc[VMIN] = 1; buf.c_cc[VTIME] = 0; #else buf.sg_flags |= CBREAK; #endif - if ((result = _nc_set_tty_mode(&buf)) == OK) { + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { SP_PARM->_cbreak = 1; - cur_term->Nttyb = buf; + termp->Nttyb = buf; } AFTER("cbreak"); } @@ -165,22 +178,22 @@ NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (NCURSES_SP_DCL0) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("qiflush()"))); - - if (cur_term != 0) { + T((T_CALLED("qiflush(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("qiflush"); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS - buf.c_lflag &= ~(NOFLSH); - result = _nc_set_tty_mode(&buf); + buf.c_lflag &= (unsigned) ~(NOFLSH); + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); #else /* FIXME */ #endif if (result == OK) - cur_term->Nttyb = buf; + termp->Nttyb = buf; AFTER("qiflush"); } returnVoid; @@ -198,27 +211,39 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("noraw()"))); - - if (SP_PARM != 0 && cur_term != 0) { + T((T_CALLED("noraw(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("noraw"); _nc_setmode(O_TEXT); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS buf.c_lflag |= ISIG | ICANON | - (cur_term->Ottyb.c_lflag & IEXTEN); + (termp->Ottyb.c_lflag & IEXTEN); buf.c_iflag |= COOKED_INPUT; #else buf.sg_flags &= ~(RAW | CBREAK); #endif - if ((result = _nc_set_tty_mode(&buf)) == OK) { + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { +#if USE_KLIBC_KBD + KBDINFO kbdinfo; + + kbdinfo.cb = sizeof(kbdinfo); + KbdGetStatus(&kbdinfo, 0); + + kbdinfo.cb = sizeof(kbdinfo); + kbdinfo.fsMask &= ~KEYBOARD_BINARY_MODE; + kbdinfo.fsMask |= KEYBOARD_ASCII_MODE; + KbdSetStatus(&kbdinfo, 0); +#endif SP_PARM->_raw = FALSE; SP_PARM->_cbreak = 0; - cur_term->Nttyb = buf; + termp->Nttyb = buf; } AFTER("noraw"); } @@ -237,25 +262,26 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("nocbreak()"))); - - if (SP_PARM != 0 && cur_term != 0) { + T((T_CALLED("nocbreak(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("nocbreak"); _nc_setmode(O_TEXT); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS buf.c_lflag |= ICANON; buf.c_iflag |= ICRNL; #else buf.sg_flags &= ~CBREAK; #endif - if ((result = _nc_set_tty_mode(&buf)) == OK) { + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); + if (result == OK) { SP_PARM->_cbreak = 0; - cur_term->Nttyb = buf; + termp->Nttyb = buf; } AFTER("nocbreak"); } @@ -270,31 +296,26 @@ nocbreak(void) } #endif -/* - * Note: - * this implementation may be wrong. See the comment under intrflush(). - */ NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("noqiflush()"))); - - if (cur_term != 0) { + T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM)); + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("noqiflush"); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS buf.c_lflag |= NOFLSH; - result = _nc_set_tty_mode(&buf); + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); #else /* FIXME */ #endif - if (result == OK) { - cur_term->Nttyb = buf; - } + if (result == OK) + termp->Nttyb = buf; AFTER("noqiflush"); } returnVoid; @@ -319,25 +340,28 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (NCURSES_SP_DCLx WINDOW *win GCC_UNUSED, bool flag) { int result = ERR; + TERMINAL *termp; - T((T_CALLED("intrflush(%d)"), flag)); + T((T_CALLED("intrflush(%p,%d)"), (void *) SP_PARM, flag)); + if (SP_PARM == 0) + returnCode(ERR); - if (cur_term != 0) { + if ((termp = TerminalOf(SP_PARM)) != 0) { TTY buf; BEFORE("intrflush"); - buf = cur_term->Nttyb; + buf = termp->Nttyb; #ifdef TERMIOS if (flag) - buf.c_lflag &= ~(NOFLSH); + buf.c_lflag &= (unsigned) ~(NOFLSH); else buf.c_lflag |= (NOFLSH); - result = _nc_set_tty_mode(&buf); + result = NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); #else /* FIXME */ #endif if (result == OK) { - cur_term->Nttyb = buf; + termp->Nttyb = buf; } AFTER("intrflush"); }