version 1.7, 2000/09/23 15:47:09
|
version 1.8, 2000/10/28 08:49:03
|
Line 45 defer everychar
|
Line 45 defer everychar
|
>r 2over = IF rdrop bell 0 EXIT THEN |
>r 2over = IF rdrop bell 0 EXIT THEN |
r> insert-char 0 ; |
r> insert-char 0 ; |
|
|
: accept ( c-addr +n1 -- +n2 ) \ core |
: edit-line ( c-addr n1 n2 -- n3 ) \ gforth |
\G Receive a string of at most @var{+n2} characters, and store it |
\G edit the string with length @var{n2} in the buffer @var{c-addr |
\G in memory starting at @var{c-addr}. The string is |
\G n1}, like @code{accept}. |
\G displayed. Input terminates when the <return> key is pressed or |
rot over |
\G @var{n1} characters have been received. The normal Gforth line |
2dup type |
\G editing capabilites are available. @var{+n2} is the length of |
|
\G the string; it does not include the <return> character. |
|
dup 0< IF abs over dup 1 chars - c@ tuck type |
|
\ this allows to edit given strings |
|
ELSE 0 THEN rot over |
|
BEGIN key decode UNTIL |
BEGIN key decode UNTIL |
2drop nip ; |
2drop nip ; |
|
|
|
: accept ( c-addr +n1 -- +n2 ) \ core |
|
\G Get a string of up to @var{n1} characters from the user input |
|
\G device and store it at @var{c-addr}. @var{n2} is the length of |
|
\G the received string. The user indicates the end by pressing |
|
\G @key{RET}. Gforth supports all the editing functions available |
|
\G on the Forth command line (including history and word |
|
\G completion) in @code{accept}. |
|
dup 0< -&24 and throw \ use edit-line to edit given strings |
|
0 edit-line ; |