Annotation of gforth/kernel/accept.fs, revision 1.7
1.1 anton 1: \ Input 13feb93py
2:
1.6 anton 3: \ Copyright (C) 1995,1996,1997,1999 Free Software Foundation, Inc.
1.1 anton 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
1.7 ! anton 19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.1 anton 20:
21: : (ins) ( max span addr pos1 key -- max span addr pos2 )
22: >r 2dup + r@ swap c! r> emit 1+ rot 1+ -rot ;
23: : (bs) ( max span addr pos1 -- max span addr pos2 flag )
24: dup IF
1.5 anton 25: #bs emit space #bs emit 1- rot 1- -rot
1.1 anton 26: THEN false ;
1.5 anton 27: : (ret) ( max span addr pos1 -- max span addr pos2 flag )
28: true space ;
1.1 anton 29:
30: Create ctrlkeys
31: ] false false false false false false false false
32: (bs) false (ret) false false (ret) false false
33: false false false false false false false false
34: false false false false false false false false [
35:
36: defer insert-char
37: ' (ins) IS insert-char
38: defer everychar
39: ' noop IS everychar
40:
41: : decode ( max span addr pos1 key -- max span addr pos2 flag )
42: everychar
43: dup #del = IF drop #bs THEN \ del is rubout
1.3 pazsan 44: dup bl u< IF cells ctrlkeys + perform EXIT THEN
1.1 anton 45: >r 2over = IF rdrop bell 0 EXIT THEN
46: r> insert-char 0 ;
47:
1.4 crook 48: : accept ( c-addr +n1 -- +n2 ) \ core
49: \G Receive a string of at most @var{+n2} characters, and store it
50: \G in memory starting at @var{c-addr}. The string is
51: \G displayed. Input terminates when the <return> key is pressed or
52: \G @var{n1} characters have been received. The normal Gforth line
53: \G editing capabilites are available. @var{+n2} is the length of
54: \G the string; it does not include the <return> character.
55: dup 0< IF abs over dup 1 chars - c@ tuck type
56: \ this allows to edit given strings
57: ELSE 0 THEN rot over
58: BEGIN key decode UNTIL
59: 2drop nip ;
1.1 anton 60:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>