version 1.54, 2007/06/07 20:57:13
|
version 1.61, 2007/07/01 20:01:32
|
Line 70 s" os-class" environment? [IF] s" unix"
|
Line 70 s" os-class" environment? [IF] s" unix"
|
\ moving in history file 16oct94py |
\ moving in history file 16oct94py |
|
|
defer back-restore ( u -- ) |
defer back-restore ( u -- ) |
' backspaces is back-restore |
defer cur-correct ( addr u -- ) |
|
' backspaces IS back-restore |
|
' 2drop IS cur-correct |
|
|
[IFDEF] x-width |
[IFDEF] x-width |
: clear-line ( max span addr pos1 -- max addr ) |
: clear-line ( max span addr pos1 -- max addr ) |
Line 93 defer back-restore ( u -- )
|
Line 95 defer back-restore ( u -- )
|
forward^ 2@ 2dup hist-setpos backward^ 2! |
forward^ 2@ 2dup hist-setpos backward^ 2! |
2dup get-line drop |
2dup get-line drop |
hist-pos forward^ 2! |
hist-pos forward^ 2! |
tuck 2dup type 0 ; |
tuck 2dup type 2dup cur-correct 0 ; |
|
|
: find-prev-line ( max addr -- max span addr pos2 ) |
: find-prev-line ( max addr -- max span addr pos2 ) |
backward^ 2@ forward^ 2! |
backward^ 2@ forward^ 2! |
Line 105 defer back-restore ( u -- )
|
Line 107 defer back-restore ( u -- )
|
REPEAT 2drop THEN tuck ; |
REPEAT 2drop THEN tuck ; |
|
|
: prev-line ( max span addr pos1 -- max span addr pos2 false ) |
: prev-line ( max span addr pos1 -- max span addr pos2 false ) |
clear-line find-prev-line 2dup type 0 ; |
clear-line find-prev-line 2dup type 2dup cur-correct 0 ; |
|
|
\ Create lfpad #lf c, |
\ Create lfpad #lf c, |
|
|
Line 199 require utf-8.fs
|
Line 201 require utf-8.fs
|
[IFUNDEF] #esc 27 Constant #esc [THEN] |
[IFUNDEF] #esc 27 Constant #esc [THEN] |
|
|
Variable curpos |
Variable curpos |
|
Variable screenw |
|
|
s" os-type" environment? [IF] s" cygwin" str= [IF] |
: cygwin? ( -- flag ) s" TERM" getenv s" cygwin" str= ; |
: save-cursor ( -- ) #esc emit '7 emit ; |
|
: restore-cursor ( -- ) #esc emit '8 emit ; |
|
: cur-correct ( addr u -- ) 2drop ; |
|
[ELSE] |
|
: at-xy? ( -- x y ) |
: at-xy? ( -- x y ) |
key? drop |
key? drop \ make sure prep_terminal() is executed |
#esc emit ." [6n" 0 0 |
#esc emit ." [6n" 0 0 |
BEGIN key dup 'R <> WHILE |
BEGIN key dup 'R <> WHILE |
dup '; = IF drop swap ELSE |
dup '; = IF drop swap ELSE |
dup '0 '9 1+ within IF '0 - swap 10 * + ELSE |
dup '0 '9 1+ within IF '0 - swap 10 * + ELSE |
drop THEN THEN |
drop THEN THEN |
REPEAT drop 1- swap 1- ; |
REPEAT drop 1- swap 1- ; |
: cursor@ ( -- n ) at-xy? form nip * + ; |
: cursor@ ( -- n ) at-xy? screenw @ * + ; |
: cursor! ( n -- ) form nip /mod at-xy ; |
: cursor! ( n -- ) screenw @ /mod at-xy ; |
: cur-correct ( addr u -- ) x-width curpos @ + cursor@ - |
: xcur-correct ( addr u -- ) |
form nip >r r@ 2/ + r@ / r> * negate curpos +! ; |
cygwin? curpos @ -1 = or IF 2drop EXIT THEN |
: save-cursor ( -- ) cursor@ curpos ! ; |
x-width curpos @ + cursor@ - |
: restore-cursor ( -- ) curpos @ cursor! ; |
screenw @ >r r@ 2/ + r@ / r> * negate curpos +! ; |
[THEN] |
: save-cursor ( -- ) |
|
cygwin? IF #esc emit '7 emit ELSE |
|
key? IF -1 ELSE form nip screenw ! cursor@ THEN curpos ! THEN ; |
|
: restore-cursor ( -- ) |
|
cygwin? IF #esc emit '8 emit ELSE |
|
curpos @ dup -1 = IF drop ELSE cursor! THEN THEN ; |
|
|
|
' xcur-correct IS cur-correct |
|
|
: .rest ( addr pos1 -- addr pos1 ) |
: .rest ( addr pos1 -- addr pos1 ) |
key? ?EXIT |
key? ?EXIT |
restore-cursor 2dup type 2dup cur-correct ; |
restore-cursor 2dup type 2dup cur-correct ; |
Line 230 s" os-type" environment? [IF] s" cygwin"
|
Line 237 s" os-type" environment? [IF] s" cygwin"
|
drop key? ?EXIT |
drop key? ?EXIT |
restore-cursor ; |
restore-cursor ; |
|
|
|
: xretype ( max span addr pos1 -- max span addr pos1 ) |
|
restore-cursor screenw @ >r save-cursor |
|
.all 2 pick r@ / screenw @ r> - * 0 max spaces .rest false ; |
|
|
\ In the following, addr max is the buffer, addr span is the current |
\ In the following, addr max is the buffer, addr span is the current |
\ string in the buffer, and pos1 is the cursor position in the buffer. |
\ string in the buffer, and pos1 is the cursor position in the buffer. |
|
|
Line 273 s" os-type" environment? [IF] s" cygwin"
|
Line 284 s" os-type" environment? [IF] s" cygwin"
|
>r end^ 2@ hist-setpos |
>r end^ 2@ hist-setpos |
2dup swap history write-line drop ( throw ) \ don't worry about errors |
2dup swap history write-line drop ( throw ) \ don't worry about errors |
hist-pos 2dup backward^ 2! end^ 2! |
hist-pos 2dup backward^ 2! end^ 2! |
r> .all space true ; |
r> curpos @ -1 = key? or IF |
|
>r 2dup swap type r> |
|
ELSE |
|
.all |
|
THEN space true ; |
|
|
: xkill-expand ( max span addr pos1 -- max span addr pos2 ) |
: xkill-expand ( max span addr pos1 -- max span addr pos2 ) |
prefix-found cell+ @ ?dup IF >r |
prefix-found cell+ @ ?dup IF >r |
Line 304 s" os-type" environment? [IF] s" cygwin"
|
Line 319 s" os-type" environment? [IF] s" cygwin"
|
['] xclear-tib ctrl K bindkey |
['] xclear-tib ctrl K bindkey |
['] xfirst-pos ctrl A bindkey |
['] xfirst-pos ctrl A bindkey |
['] xend-pos ctrl E bindkey |
['] xend-pos ctrl E bindkey |
|
['] xretype ctrl L bindkey |
history IF ['] (xenter) #lf bindkey THEN |
history IF ['] (xenter) #lf bindkey THEN |
history IF ['] (xenter) #cr bindkey THEN |
history IF ['] (xenter) #cr bindkey THEN |
['] xtab-expand #tab bindkey |
['] xtab-expand #tab bindkey |
Line 311 s" os-type" environment? [IF] s" cygwin"
|
Line 327 s" os-type" environment? [IF] s" cygwin"
|
['] kill-prefix IS everychar |
['] kill-prefix IS everychar |
['] save-cursor IS everyline |
['] save-cursor IS everyline |
['] xback-restore IS back-restore |
['] xback-restore IS back-restore |
|
['] xcur-correct IS cur-correct |
; |
; |
|
|
xchar-history |
xchar-history |