Skip to content

Commit 8f4624e

Browse files
committed
Take commands instead of search on command line.
1 parent 500374e commit 8f4624e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

be2

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/gforth
1+
#! /usr/bin/env gforth
22
( vim: set syntax=colorforth: )
33

44
\ be2 - a.k.a. Block Editor II
@@ -215,7 +215,7 @@ variable color-stuck
215215

216216
( Emit syntax highlighted characters )
217217

218-
: cemit ( n -- )
218+
: clemit ( n -- )
219219
dup color-char-first color-char-last in-range? if
220220
color-dump
221221
color-char-first - 1+ dup color-stuck ! fg bl emit exit
@@ -227,7 +227,7 @@ variable color-stuck
227227
identifier-char? 0= if color-dump then
228228
;
229229

230-
: ctype ( a n -- ) 0 ?do dup i + c@ cemit loop drop lf cemit ;
230+
: cltype ( a n -- ) 0 ?do dup i + c@ clemit loop drop lf clemit ;
231231

232232

233233

@@ -239,7 +239,7 @@ variable color-stuck
239239

240240
( Command prompt handling )
241241

242-
create prompt-text columns allot
242+
create prompt-text block-size allot ( extra space for cmd line )
243243
variable prompt-length
244244

245245
( workaround bug in history.fs )
@@ -252,15 +252,15 @@ action-of everyline is old-everyline
252252
: prompt-buffer ( -- a n ) prompt-text columns ;
253253
: goto-prompt ( -- a n ) 0 screen-lines 1- at-xy prompt-color clear-to-end ;
254254
: setup-prompt ( -- a n ) goto-prompt prompt-buffer ;
255+
: prompt+! ( a n -- ) dup >r prompt-text prompt-length @ + swap cmove
256+
r> prompt-length +! ;
255257

256258
: accept-cmd setup-prompt accept prompt-length ! ;
257259
: edit-cmd setup-prompt prompt-length @ edit-line prompt-length ! ;
258260
: do-cmd flush prompt-text prompt-length @ ['] evaluate catch drop ;
259261

260262

261263

262-
263-
264264
( Row access )
265265

266266
: block-uninit? ( n -- f ) block columns' + 1- c@ lf <> ;
@@ -303,7 +303,7 @@ variable margins-on
303303
: goto-row ( n -- ) lmargin swap at-xy ;
304304
: row-string ( n -- a n ) top-row columns rtrim ;
305305
: finish-row 7 fg clear-to-end ; \ white foreground to show cursor
306-
: print-row ( n -- ) dup goto-row dup row-color row-string ctype finish-row ;
306+
: print-row ( n -- ) dup goto-row dup row-color row-string cltype finish-row ;
307307
: park-cursor caret @ columns /mod swap lmargin + swap at-xy ;
308308
: draw-row ( n -- ) dup left-margin dup print-row right-margin ;
309309
: draw-rows ( n n -- ) do i draw-row loop ;
@@ -722,18 +722,17 @@ variable clipboard-last
722722
: handle-key input-mode @ if input-key else navigate-key then refresh ;
723723
: editor full-refresh begin ekey show handle-key again ;
724724

725-
: usage s" Usage: be2 [search]" etype ecr 1 (bye) ;
726-
: arg-check argc @ 2 > if usage then ;
727-
725+
: arg-cmd s" " prompt!
726+
begin next-arg 2dup 0 0 d<> while s" " prompt+! prompt+!
727+
repeat 2drop do-cmd ;
728728
: block-filename ( -- a n)
729729
s" BE2_BLOCKS" getenv dup 0= if 2drop 0 filename-length !
730730
s" PWD" getenv +filename s" /.be2_blocks" +filename filename@ then ;
731731
: setup-blocks
732732
0 block-offset !
733733
block-filename open-blocks
734734
update-row-count
735-
arg-check
736-
argc @ 2 >= if 1 arg search! search-for flush-top then
735+
arg-cmd
737736
;
738737
: main setup-blocks editor ;
739738
: reset-terminal normal page ;

0 commit comments

Comments
 (0)