File:  [gforth] / gforth / termsize.fs
Revision 1.1: download - view: text, annotated - select for diffs
Sun Jan 7 17:22:16 1996 UTC (27 years, 8 months ago) by anton
Branches: MAIN
CVS tags: HEAD
added more.fs for people with old terminals.
WORDS and SEE now now respect the terminal size.
a lot of reordering in the Makefile, approaching the GNU standards.
factored NAME>STRING out of many words.
removed emitcounter (it was not used anyway).
SYSTEM now unpreps and repreps the terminal.
fixed byg in prims2x.fs.
added NEEDS, ?CSP, !CSP.
rewrote ALIAS?.

\ terminal size stuff

\ Copyright (C) 1996 Free Software Foundation, Inc.

\ This file is part of Gforth.

\ Gforth is free software; you can redistribute it and/or
\ modify it under the terms of the GNU General Public License
\ as published by the Free Software Foundation; either version 2
\ of the License, or (at your option) any later version.

\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ GNU General Public License for more details.

\ 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.

\ # 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
	0. 2swap >number 0=
	IF ( udefault d c-addr2 )
	    drop drop nip
	ELSE ( udefault djunk c-addr2 )
	    drop 2drop
    ELSE ( udefault c-addr ucount )
    ENDIF ;

:noname ( -- )
    defers 'cold
    cols s" COLUMNS" getenv-unum TO cols
    rows s" LINES" getenv-unum TO rows ;
IS 'cold

FreeBSD-CVSweb <>