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 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 /*--------------------------------------------------------------------------*/
24 # if defined(HAVE_CURSES_H)
26 # elif defined(HAVE_NCURSES_H)
35 #ifndef HAVE_TERMCAP_H
41 #endif /* !defined(_MSC_VER) */
44 #include "core_math.h"
45 #include "stack-def.h"
47 #include "../../../windows_tools/src/c/scilab_windows/console.h"
48 #include "scilabmode.h"
50 /*--------------------------------------------------------------------------*/
51 #define DEFAULT_NUMBERS_LINES 28
52 #define DEFAULT_NUMBERS_COLUMNS 80
53 #define MIN_NUMBERS_LINES 0
54 #define MIN_NUMBERS_COLUMNS 10
55 /*--------------------------------------------------------------------------*/
56 int scilines(int nblines, int nbcolumns)
58 setLinesSize(nblines);
59 setColumnsSize(nbcolumns);
62 /*--------------------------------------------------------------------------*/
63 int scilinesdefault(void)
67 char tc_buf[1024]; /* holds termcap buffer */
68 if(tgetent(tc_buf, getenv("TERM")) == 1) {
69 setLinesSize(tgetnum("li")); /* retrieve from the term info the number
71 setColumnsSize(tgetnum("co")); /* And the number of columns */
73 /* Haven't been able to detect the terminal */
74 setLinesSize(DEFAULT_NUMBERS_LINES);
75 setColumnsSize(DEFAULT_NUMBERS_COLUMNS);
79 if ( (getScilabMode() != SCILAB_STD) && (getScilabMode() != SCILAB_API) )
81 /* -NW or -NWNI mode */
82 int X = getXConsoleScreenSize();
83 int Y = getYConsoleScreenSize();
85 if (X < DEFAULT_NUMBERS_COLUMNS) X = DEFAULT_NUMBERS_COLUMNS;
86 if (Y < DEFAULT_NUMBERS_LINES) Y = DEFAULT_NUMBERS_LINES;
92 setLinesSize(DEFAULT_NUMBERS_LINES);
93 setColumnsSize(DEFAULT_NUMBERS_COLUMNS);
98 /*--------------------------------------------------------------------------*/
99 int C2F(scilines)(int *nblines, int *nbcolumns)
101 return scilines(*nblines,*nbcolumns);
103 /*--------------------------------------------------------------------------*/
104 int C2F(scilinesdefault)(void)
106 return scilinesdefault();
108 /*--------------------------------------------------------------------------*/
109 BOOL setColumnsSize(int colums)
111 C2F(iop).lct[4] = Max(MIN_NUMBERS_COLUMNS,colums);
114 /*--------------------------------------------------------------------------*/
115 BOOL setLinesSize(int lines_)
117 C2F(iop).lct[1] = Max(MIN_NUMBERS_LINES,lines_);
120 /*--------------------------------------------------------------------------*/
121 int getColumnsSize(void)
123 return C2F(iop).lct[4];
125 /*--------------------------------------------------------------------------*/
126 int getLinesSize(void)
128 return C2F(iop).lct[1];
130 /*--------------------------------------------------------------------------*/