--- gforth/history.fs 2005/01/26 21:41:27 1.41 +++ gforth/history.fs 2006/05/01 09:45:56 1.48 @@ -1,6 +1,6 @@ \ command line edit and history support 16oct94py -\ Copyright (C) 1995,2000,2003,2004 Free Software Foundation, Inc. +\ Copyright (C) 1995,2000,2003,2004,2005 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -69,9 +69,16 @@ s" os-class" environment? [IF] s" unix" \ moving in history file 16oct94py -: clear-line ( max span addr pos1 -- max addr ) - backspaces over spaces swap backspaces ; +defer back-restore ( u -- ) +' backspaces is back-restore +[IFDEF] x-width +: clear-line ( max span addr pos1 -- max addr ) + back-restore over over swap x-width spaces swap back-restore ; +[ELSE] +: clear-line ( max span addr pos1 -- max addr ) + back-restore over spaces swap back-restore ; +[THEN] \ : clear-tib ( max span addr pos -- max 0 addr 0 false ) \ clear-line 0 tuck dup ; @@ -197,6 +204,11 @@ require utf-8.fs restore-cursor 2dup type ; : .all ( span addr pos1 -- span addr pos1 ) restore-cursor >r 2dup swap type r> ; +: xback-restore ( u -- ) + drop 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. : ( max span addr pos1 xc -- max span addr pos2 ) >r 2over r@ xc-size + u< IF ( max span addr pos1 R:xc ) @@ -274,7 +286,9 @@ require utf-8.fs ['] xtab-expand #tab bindkey ['] (xins) IS insert-char ['] kill-prefix IS everychar - ['] save-cursor IS everyline ; + ['] save-cursor IS everyline + ['] xback-restore IS back-restore +; xchar-history @@ -300,8 +314,12 @@ xchar-history ; : history-cold ( -- ) - history-file get-history ; + history-file get-history xchar-history ; + +:noname ( -- ) + defers 'cold + history-cold +; is 'cold -' history-cold INIT8 chained history-cold