]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/tinfo_driver.c
ncurses 5.9 - patch 20120714
[ncurses.git] / ncurses / tinfo / tinfo_driver.c
index 05cba8eb65cd4d2fd198b74c08879ba889b77be5..6d49c000271ae1615bfa5720dab49e3fed59ca20 100644 (file)
@@ -50,7 +50,7 @@
 # endif
 #endif
 
-MODULE_ID("$Id: tinfo_driver.c,v 1.18 2012/02/18 20:34:55 tom Exp $")
+MODULE_ID("$Id: tinfo_driver.c,v 1.21 2012/07/15 00:20:43 tom Exp $")
 
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
@@ -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));
@@ -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,6 +400,20 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
        }
 #endif /* HAVE_SIZECHANGE */
 
+       if (useTioctl) {
+           char buf[128];
+
+           /*
+            * 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.
         *
@@ -753,7 +773,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))