X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Ftinfo_driver.c;h=4a6426fcb08f80181e1d79f64c67cb162297fd30;hp=f239b699ebb4b3ac9ec4c5af4b0195e2650b0daa;hb=62ca6190a9a8ddccb2c4d5ca7b2ef9f88432da65;hpb=e2e9c09c48b19b24979cafb2d4864f538b5ddd1c diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c index f239b699..4a6426fc 100644 --- a/ncurses/tinfo/tinfo_driver.c +++ b/ncurses/tinfo/tinfo_driver.c @@ -34,6 +34,7 @@ #include #define CUR ((TERMINAL*)TCB)->type. #include +#include /* ospeed */ #if HAVE_NANOSLEEP #include @@ -50,7 +51,7 @@ # endif #endif -MODULE_ID("$Id: tinfo_driver.c,v 1.41 2016/09/10 20:14:56 tom Exp $") +MODULE_ID("$Id: tinfo_driver.c,v 1.43 2016/12/24 23:20:08 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -113,6 +114,33 @@ drv_Name(TERMINAL_CONTROL_BLOCK * TCB) return "tinfo"; } +static void +get_baudrate(TERMINAL * termp) +{ + int my_ospeed; + int result; + if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) { +#ifdef TERMIOS + termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS); +#else + termp->Nttyb.sg_flags &= (unsigned) (~XTABS); +#endif + } +#ifdef USE_OLD_TTY + result = (int) cfgetospeed(&(termp->Nttyb)); + my_ospeed = (NCURSES_OSPEED) _nc_ospeed(result); +#else /* !USE_OLD_TTY */ +#ifdef TERMIOS + my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb)); +#else + my_ospeed = (NCURSES_OSPEED) termp->Nttyb.sg_ospeed; +#endif + result = _nc_baudrate(my_ospeed); +#endif + termp->_baudrate = result; + ospeed = (NCURSES_OSPEED) my_ospeed; +} + #undef SETUP_FAIL #define SETUP_FAIL FALSE @@ -166,6 +194,16 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) if (command_character) _nc_tinfo_cmdch(termp, *command_character); + /* + * If an application calls setupterm() rather than initscr() or + * newterm(), we will not have the def_prog_mode() call in + * _nc_setupscreen(). Do it now anyway, so we can initialize the + * baudrate. + */ + if (sp == 0 && NC_ISATTY(termp->Filedes)) { + get_baudrate(termp); + } + if (generic_type) { /* * BSD 4.3's termcap contains mis-typed "gn" for wy99. Do a sanity