From abdd829e6e0d66902e655f040ce24acbeaaca7c3 Mon Sep 17 00:00:00 2001 From: crc Date: Sun, 12 Nov 2017 04:40:20 +0000 Subject: [PATCH] editor now has delete command, fixed line selection FossilOrigin-Name: 730d77cf6ea0c1eb25092c0908daad450da043ad2d4413d7325ccd2f4e5ea51c --- wip/edit.forth | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wip/edit.forth b/wip/edit.forth index c7c95ab..5f326eb 100755 --- a/wip/edit.forth +++ b/wip/edit.forth @@ -6,10 +6,10 @@ Interface: : : --------------------------------------------------------------- - 99: + * 99: 100: :n:square dup * ; 101: - * 102: This is the current line + 102: This is the current line 103: --------------------------------------------------------------- @@ -19,6 +19,7 @@ And it's visual, with some simple key bindings. ~~~ 'SourceFile var 'FID var +'FOUT var #0 sys:argv s:keep !SourceFile @@ -36,7 +37,7 @@ And it's visual, with some simple key bindings. dup @CurrentLine eq? [ '*_ puts ] [ '__ puts ] choose ; :skip-to - @CurrentLine n:dec #0 n:max [ @FID file:read-line drop ] times ; + @CurrentLine #0 n:max [ @FID file:read-line drop ] times ; :display @SourceFile file:R file:open !FID @@ -44,8 +45,15 @@ And it's visual, with some simple key bindings. @CurrentLine count-lines MAX-LINES n:min [ dup current pad putn n:inc ':_ puts @FID file:read-line puts nl ] times drop @FID file:close ; +:delete-line + '/tmp/rre.edit file:W file:open !FID + #0 @SourceFile [ over @CurrentLine eq? [ drop ] [ [ @FID file:write ] s:for-each ] choose ASCII:LF @FID file:write n:inc ] file:for-each-line drop + @FID file:close + @SourceFile 'mv_/tmp/rre.edit_%s s:with-format unix:system ; + :handler getc + $d [ delete-line ] case $j [ &CurrentLine v:inc ] case $k [ &CurrentLine v:dec ] case $q [ 'stty_-cbreak unix:system #0 unix:exit ] case