X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Ftinfo_driver.c;h=5f2051b5b2eec7c119496745fe91e0c4b281d2bb;hp=6bca8ac821858f9c7ce704c6fb45e1e71b8b89e8;hb=925cd3b851aa2c58529dfaba8ed2c727e718a1e0;hpb=5e36f11feab6f790e0cc6f2c882a67b7b65e3b6b diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c index 6bca8ac8..5f2051b5 100644 --- a/ncurses/tinfo/tinfo_driver.c +++ b/ncurses/tinfo/tinfo_driver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2008-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 2008-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 * @@ -50,7 +50,7 @@ # endif #endif -MODULE_ID("$Id: tinfo_driver.c,v 1.17 2011/12/17 20:40:33 tom Exp $") +MODULE_ID("$Id: tinfo_driver.c,v 1.25 2012/12/22 21:44:10 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -93,7 +93,7 @@ NCURSES_EXPORT_VAR(int) COLORS = 0; #define TCBMAGIC NCDRV_MAGIC(NCDRV_TINFO) #define AssertTCB() assert(TCB!=0 && TCB->magic==TCBMAGIC) -#define SetSP() assert(TCB->csp!=0); sp = TCB->csp +#define SetSP() assert(TCB->csp!=0); sp = TCB->csp; (void) sp /* * This routine needs to do all the work to make curscr look @@ -342,14 +342,18 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) { SCREEN *sp; bool useEnv = TRUE; + bool useTioctl = TRUE; AssertTCB(); sp = TCB->csp; /* can be null here */ if (sp) { useEnv = sp->_use_env; - } else + useTioctl = sp->_use_tioctl; + } else { useEnv = _nc_prescreen.use_env; + useTioctl = _nc_prescreen.use_tioctl; + } /* figure out the size of the screen */ T(("screen size: terminfo lines = %d columns = %d", lines, columns)); @@ -357,7 +361,7 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) *linep = (int) lines; *colp = (int) columns; - if (useEnv) { + if (useEnv || useTioctl) { int value; #ifdef __EMX__ @@ -365,7 +369,9 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) int screendata[2]; _scrsize(screendata); *colp = screendata[0]; - *linep = screendata[1]; + *linep = ((sp != 0 && sp->_filtered) + ? 1 + : screendata[1]); T(("EMX screen size: environment LINES = %d COLUMNS = %d", *linep, *colp)); } @@ -394,19 +400,33 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) } #endif /* HAVE_SIZECHANGE */ - /* - * Finally, look for environment variables. - * - * Solaris lets users override either dimension with an environment - * variable. - */ - if ((value = _nc_getenv_num("LINES")) > 0) { - *linep = value; - T(("screen size: environment LINES = %d", *linep)); - } - if ((value = _nc_getenv_num("COLUMNS")) > 0) { - *colp = value; - T(("screen size: environment COLUMNS = %d", *colp)); + if (useEnv) { + if (useTioctl) { + /* + * If environment variables are used, update them. + */ + if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) { + _nc_setenv_num("LINES", *linep); + } + if (_nc_getenv_num("COLUMNS") > 0) { + _nc_setenv_num("COLUMNS", *colp); + } + } + + /* + * Finally, look for environment variables. + * + * Solaris lets users override either dimension with an environment + * variable. + */ + if ((value = _nc_getenv_num("LINES")) > 0) { + *linep = value; + T(("screen size: environment LINES = %d", *linep)); + } + if ((value = _nc_getenv_num("COLUMNS")) > 0) { + *colp = value; + T(("screen size: environment COLUMNS = %d", *colp)); + } } /* if we can't get dynamic info about the size, use static */ @@ -614,13 +634,11 @@ drv_screen_init(SCREEN *sp) static void drv_init(TERMINAL_CONTROL_BLOCK * TCB) { - SCREEN *sp; TERMINAL *trm; AssertTCB(); trm = (TERMINAL *) TCB; - sp = TCB->csp; TCB->info.initcolor = VALID_STRING(initialize_color); TCB->info.canchange = can_change; @@ -753,7 +771,7 @@ drv_do_color(TERMINAL_CONTROL_BLOCK * TCB, if (old_pair >= 0 && sp != 0 && NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx - old_pair, + (short) old_pair, &old_fg, &old_bg) !=ERR) { if ((isDefaultColor(fg) && !isDefaultColor(old_fg)) @@ -1132,7 +1150,8 @@ _nc_cookie_init(SCREEN *sp) /* initialize normal acs before wide, since we use mapping in the latter */ #if !USE_WIDEC_SUPPORT - if (_nc_unicode_locale() && _nc_locale_breaks_acs(sp->_term)) { + sp->_screen_unicode = _nc_unicode_locale(); + if (sp->screen_unicode && _nc_locale_breaks_acs(sp->_term)) { acs_chars = NULL; ena_acs = NULL; enter_alt_charset_mode = NULL;