-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblock-021.fth
32 lines (25 loc) · 1.27 KB
/
block-021.fth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
block-fn( --fn )p2 z" block-" s-cpy blk <# # # #s #> s-cat z" .fth" s-cat ;
t1( ch-- )dup 10 =ifdrop row++ 0 >col rc>pos t! exitthendup 4 >if32 maxthen!t+ ;
t2atdrop nt-lines ;
work->blockwork >a block >t 0 dup >row/col
begin @a+ ?dupif0t2 exitthent1 row rows < while t2 ;
clear-block( addr-- )block-sz 32 fill ;
rl( reload block )work clear-block block clear-block
block-fn fopen-rb ?dupif
>t work block-sz t@ fread drop t> fclose
thenwork->block clean show! 0 dup >row/col ;
ed!( blk-- )>blk rl ;
normal-mode 0 ; insert-mode 1 ; replace-mode 2 ; quit-mode99 ;
normal-mode? normal-mode ed-mode = ; normal-mode! normal-mode >ed-mode ;
insert-mode? insert-mode ed-mode = ; insert-mode! insert-mode >ed-mode ;
replace-mode?replace-mode ed-mode = ; replace-mode!replace-mode >ed-mode ;
quit? quit-mode ed-mode = ; q! quit-mode >ed-mode ;
.modespace normal-mode?if." -normal-" exitthen
red insert-mode?if." -insert-"then
replace-mode?if." -replace-"then
white ;
insert-toggle
normal-mode?ifinsert-mode! exitthen
insert-mode?ifreplace-mode! exitthen
normal-mode! ;
ks( -- )yellow ." %n(press a key ...)" white key drop cls show! ;