--- gforth/termsize.fs 1996/01/07 17:22:16 1.1 +++ gforth/termsize.fs 2000/09/23 15:46:59 1.5 @@ -1,6 +1,6 @@ \ terminal size stuff -\ Copyright (C) 1996 Free Software Foundation, Inc. +\ Copyright (C) 1996,1997 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -16,36 +16,17 @@ \ You should have received a copy of the GNU General Public License \ along with this program; if not, write to the Free Software -\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - -\ Currently we get the size from the environment. If the variables -\ LINES and COLUMNS are not set or wrong, do an "eval `resize`" before -\ starting Gforth. If you change the window size after starting -\ Gforth, you are out of luck. - -\ To do: An implementation that uses termcap and/or ioctl TIOCGWINSZ. +\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. \ # rows and columns that the terminal has. \ these words are also present in PFE. -&80 Value cols -&24 Value rows -: getenv-unum ( udefault c-addr ucount -- u ) - getenv over - IF - 0. 2swap >number 0= - IF ( udefault d c-addr2 ) - drop drop nip - ELSE ( udefault djunk c-addr2 ) - drop 2drop - ENDIF - ELSE ( udefault c-addr ucount ) - 2drop - ENDIF ; - -:noname ( -- ) - defers 'cold - cols s" COLUMNS" getenv-unum TO cols - rows s" LINES" getenv-unum TO rows ; -IS 'cold +[IFUNDEF] form : form &24 &80 ; [THEN] + +[IFUNDEF] rows +: rows ( -- u ) + form drop ; + +: cols ( -- u ) + form nip ; +[THEN]