--- gforth/history.fs 1994/10/18 15:57:17 1.1 +++ gforth/history.fs 1994/11/15 15:55:37 1.4 @@ -15,6 +15,11 @@ s" gforth.history" get-history +: history-cold Defers 'cold + s" gforth.history" get-history ; + +' history-cold IS 'cold + \ moving in history file 16oct94py : clear-line ( max span addr pos1 -- max addr ) @@ -36,12 +41,12 @@ s" gforth.history" get-history : prev-line ( max span addr pos1 -- max span addr pos2 false ) clear-line over 2 + negate s>d backward^ 2@ d+ 0. dmax - history reposition-file throw 0. - BEGIN 2over swap history read-line throw nip WHILE - history file-position throw - 2dup backward^ 2@ d< WHILE 2swap 2drop - REPEAT 2drop THEN - history reposition-file throw get-line 0 ; + 2dup history reposition-file throw + BEGIN 2over swap history read-line throw WHILE + >r history file-position throw + 2dup backward^ 2@ d< WHILE 2swap 2drop rdrop + REPEAT ELSE >r history file-position throw THEN + forward^ 2! backward^ 2! r> tuck 2dup type 0 ; : ctrl ( "" -- ctrl-code ) char [char] @ - postpone Literal ; immediate @@ -75,18 +80,19 @@ Create prefix-found 0 , 0 , IF r> char+ capscomp 0<= EXIT THEN nip r> c@ $1F and < ; -: search-prefix ( addr len1 -- suffix len2 ) - context @ @ 0 >r - BEGIN dup WHILE - >r dup r@ cell+ c@ $1F and <= - IF 2dup r@ cell+ char+ capscomp 0= - IF r> dup r@ word-lex - IF dup prefix-found @ word-lex - 0>= IF rdrop dup >r THEN - THEN >r - THEN - THEN r> @ - REPEAT drop r> dup prefix-found ! ?dup +: search-prefix ( addr len1 -- suffix len2 ) 0 >r context + BEGIN BEGIN dup @ over cell - @ = WHILE cell - REPEAT + dup >r -rot r> @ @ + BEGIN dup WHILE >r dup r@ cell+ c@ $1F and <= + IF 2dup r@ cell+ char+ capscomp 0= + IF r> dup r@ word-lex + IF dup prefix-found @ word-lex + 0>= IF rdrop dup >r THEN + THEN >r + THEN + THEN r> @ + REPEAT drop rot cell - dup vp u> 0= + UNTIL drop r> dup prefix-found ! ?dup IF cell+ count $1F and rot /string rot drop ELSE 2drop s" " THEN ;