]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/tinfo_driver.c
ncurses 5.9 - patch 20120728
[ncurses.git] / ncurses / tinfo / tinfo_driver.c
index 8e2f74f50c7580383c7df0a07a126ac1bd384e0d..0118f20226345705adbc47ee5a69907a20c7c33a 100644 (file)
@@ -50,7 +50,7 @@
 # endif
 #endif
 
-MODULE_ID("$Id: tinfo_driver.c,v 1.19 2012/06/30 22:01:10 tom Exp $")
+MODULE_ID("$Id: tinfo_driver.c,v 1.24 2012/07/28 20:12:11 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));
@@ -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;