* Bug 16190 fixed: console width was fixed at 75 in nw and nwni mode
[scilab.git] / scilab / modules / ast / src / cpp / system_env / configvariable.cpp
index 89c746a..e27d008 100644 (file)
@@ -32,6 +32,9 @@ extern "C"
 #include "os_string.h"
 #include "sci_malloc.h"
 #include "strsubst.h"
+#ifdef HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
 }
 
 /*
@@ -199,7 +202,22 @@ void ConfigVariable::setConsoleWidth(int _iConsoleWidth)
 
 int ConfigVariable::getConsoleWidth(void)
 {
+#ifndef _MSC_VER
+    if (getScilabMode() == SCILAB_NWNI || getScilabMode() == SCILAB_NW)
+    {
+        char tc_buf[1024];       /* holds termcap buffer */
+        if (tgetent(tc_buf, getenv("TERM")) == 1)
+        {
+            return tgetnum((char *)"co");
+        }
+        else
+        {
+            return m_iConsoleWidth;
+        }
+    }    
+#else
     return m_iConsoleWidth;
+#endif
 }
 /*
 ** \}