File:
[gforth] /
gforth /
more.fs
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Sun Jan 7 17:22:13 1996 UTC (28 years, 2 months ago) by
anton
Branches:
MAIN
CVS tags:
v0-4-0,
v0-3-0,
v0-2-1,
v0-2-0,
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.
use AC_DECL_SYS_SIGLIST test in configure.in.
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?.
1: \ Forth output paging add-on (like more(1))
2:
3: \ Copyright (C) 1996 Free Software Foundation, Inc.
4:
5: \ This file is part of Gforth.
6:
7: \ Gforth is free software; you can redistribute it and/or
8: \ modify it under the terms of the GNU General Public License
9: \ as published by the Free Software Foundation; either version 2
10: \ of the License, or (at your option) any later version.
11:
12: \ This program is distributed in the hope that it will be useful,
13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: \ GNU General Public License for more details.
16:
17: \ You should have received a copy of the GNU General Public License
18: \ along with this program; if not, write to the Free Software
19: \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20:
21:
22: \ This add-on is for those poor souls whose terminals cannot scroll
23: \ back but who want to read the output of 'words' at their leisure.
24:
25: \ currently this is very primitive: it just counts newlines, and only
26: \ allows continuing for another page (and of course, terminating
27: \ processing by sending a signal (^C))
28:
29: \ Some things to do:
30: \ allow continuing for one line (Enter)
31: \ count lines produced by wraparound (note tabs and backspaces)
32: \ allow continuing silently
33: \ fancy features like searching, scrollback etc.
34:
35: \ one more-or-less simple way to achieve all this is to
36: \ popen("less","w") and output there. Before getting the next `key`,
37: \ we would perform a pclose. This idea due to Marcel Hendrix.
38:
39: require termsize.fs
40:
41: variable last-#lines 0 last-#lines !
42:
43: :noname ( -- c )
44: 1 last-#lines !
45: defers key ;
46: is key
47:
48: :noname ( c -- )
49: dup defers emit
50: #lf =
51: if
52: 1 last-#lines +!
53: last-#lines @ rows >=
54: if
55: ." ... more ?" key drop 10 backspaces 10 spaces 10 backspaces
56: endif
57: endif ;
58: is emit
59:
60: :noname ( c-addr u -- )
61: bounds
62: ?DO
63: I c@ emit
64: LOOP ;
65: is type
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>