--- gforth/history.fs 2007/05/05 17:26:02 1.51 +++ gforth/history.fs 2007/06/07 20:57:13 1.54 @@ -200,6 +200,11 @@ require utf-8.fs Variable curpos +s" os-type" environment? [IF] s" cygwin" str= [IF] +: save-cursor ( -- ) #esc emit '7 emit ; +: restore-cursor ( -- ) #esc emit '8 emit ; +: cur-correct ( addr u -- ) 2drop ; +[ELSE] : at-xy? ( -- x y ) key? drop #esc emit ." [6n" 0 0 @@ -212,15 +217,18 @@ Variable curpos : cursor! ( n -- ) form nip /mod at-xy ; : cur-correct ( addr u -- ) x-width curpos @ + cursor@ - form nip >r r@ 2/ + r@ / r> * negate curpos +! ; - : save-cursor ( -- ) cursor@ curpos ! ; : restore-cursor ( -- ) curpos @ cursor! ; +[THEN] : .rest ( addr pos1 -- addr pos1 ) + key? ?EXIT restore-cursor 2dup type 2dup cur-correct ; : .all ( span addr pos1 -- span addr pos1 ) + key? ?EXIT restore-cursor >r 2dup swap type 2dup swap cur-correct r> ; : xback-restore ( u -- ) - drop restore-cursor ; + drop key? ?EXIT + restore-cursor ; \ 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. @@ -232,7 +240,7 @@ Variable curpos 2dup chars + r@ swap r@ xc-size xc!+? 2drop drop r> xc-size >r rot r@ chars + -rot r> chars + ; : (xins) ( max span addr pos1 xc -- max span addr pos2 ) - key? ?EXIT .all .rest ; + .all .rest ; : xback ( max span addr pos1 -- max span addr pos2 f ) dup IF over + xchar- over - 0 max .all .rest ELSE bell THEN 0 ;