\ SAVE-INPUT and RESTORE-INPUT
: save-buffer ( -- column source-id 2 ) >in @ source-id 2 ;
: restore-column ( column -- flag )
\ Return the file-position of the beginning of the current line in
\ file SOURCE-ID. Assume that the current line is stored in SOURCE
\ and that the current file-position is at an end-of-line (or
: line-start-position ( -- ud )
source-id file-position throw
\ unless at end-of-file, subtract newline
source-id file-size throw 2over d= 0= IF 1 s>d d- THEN
: save-file ( column line filepos:ud source-id 5 -- )
: restore-file ( column line filepos:ud -- flag )
source-id reposition-file IF 2drop true exit THEN
refill 0= IF 2drop true exit THEN
: ndrop ( n*x n -- ) 0 ?do drop loop ;
\ EVALUATE >IN SourceID=(-1) 2
\ keyboard >IN SourceID=(0) 2
\ file >IN lineNumber filePos SourceID=(fileID) 5
: SAVE-INPUT ( -- column {line filepos}? source-id n )
: RESTORE-INPUT ( column {line filepos}? source-id n -- flag )
over source-id <> IF ndrop true exit THEN
-1 of restore-column endof
0 of restore-column endof