X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Ftinfo_driver.c;h=18c7e2fd024b9a15d9b60cd02e553f4bf0fb3a2f;hp=f239b699ebb4b3ac9ec4c5af4b0195e2650b0daa;hb=90d42867e1296bc79021006a92032c76e59068b6;hpb=e2e9c09c48b19b24979cafb2d4864f538b5ddd1c diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c index f239b699..18c7e2fd 100644 --- a/ncurses/tinfo/tinfo_driver.c +++ b/ncurses/tinfo/tinfo_driver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2008-2015,2016 Free Software Foundation, Inc. * + * Copyright (c) 2008-2016,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 * @@ -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.45 2017/02/28 22:10:05 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 @@ -262,8 +300,8 @@ drv_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB, int fg, int bg) sp->_has_sgr_39_49 = (NCURSES_SP_NAME(tigetflag) (NCURSES_SP_ARGx "AX") == TRUE); - sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK); - sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK); + sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg; + sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg; if (sp->_color_pairs != 0) { bool save = sp->_default_color; sp->_default_color = TRUE; @@ -359,7 +397,7 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) if (sp) { useEnv = sp->_use_env; - useTioctl = sp->_use_tioctl; + useTioctl = sp->use_tioctl; } else { useEnv = _nc_prescreen.use_env; useTioctl = _nc_prescreen.use_tioctl;