2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2007 - INRIA - Allan CORNET
4 * Copyright (C) 2008 - INRIA - Sylvestre LEDRU (Detection of the term size)
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 /*--------------------------------------------------------------------------*/
27 # if defined(HAVE_CURSES_H)
29 # elif defined(HAVE_NCURSES_H)
38 #ifndef HAVE_TERMCAP_H
44 #endif /* !defined(_MSC_VER) */
47 #include "core_math.h"
49 #include "../../../windows_tools/src/c/scilab_windows/console.h"
51 #include "configvariable_interface.h"
52 /*--------------------------------------------------------------------------*/
53 #define DEFAULT_NUMBERS_LINES 28
54 #define DEFAULT_NUMBERS_COLUMNS 80
55 #define MIN_NUMBERS_LINES 0
56 #define MIN_NUMBERS_COLUMNS 10
57 /*--------------------------------------------------------------------------*/
58 int scilines(int nblines, int nbcolumns)
60 setConsoleLines(nblines);
61 setConsoleWidth(nbcolumns);
64 /*--------------------------------------------------------------------------*/
65 int scilinesdefault(void)
69 char tc_buf[1024]; /* holds termcap buffer */
70 if (tgetent(tc_buf, getenv("TERM")) == 1)
72 setConsoleLines(tgetnum("li")); /* retrieve from the term info the number
74 setConsoleWidth(tgetnum("co")); /* And the number of columns */
78 /* Haven't been able to detect the terminal */
79 setConsoleLines(DEFAULT_NUMBERS_LINES);
80 setConsoleWidth(DEFAULT_NUMBERS_COLUMNS);
84 if ( (getScilabMode() != SCILAB_STD) && (getScilabMode() != SCILAB_API) )
86 /* -NW or -NWNI mode */
87 int X = getXConsoleScreenSize();
88 int Y = getYConsoleScreenSize();
90 if (X < DEFAULT_NUMBERS_COLUMNS)
92 X = DEFAULT_NUMBERS_COLUMNS;
94 if (Y < DEFAULT_NUMBERS_LINES)
96 Y = DEFAULT_NUMBERS_LINES;
103 setConsoleLines(DEFAULT_NUMBERS_LINES);
104 setConsoleWidth(DEFAULT_NUMBERS_COLUMNS);
109 /*--------------------------------------------------------------------------*/
110 int C2F(scilines)(int *nblines, int *nbcolumns)
112 return scilines(*nblines, *nbcolumns);
114 /*--------------------------------------------------------------------------*/
115 int C2F(scilinesdefault)(void)
117 return scilinesdefault();
119 /*--------------------------------------------------------------------------*/