2022-02-09 20:04:12 -05:00
|
|
|
( femto.tal )
|
|
|
|
( )
|
|
|
|
( requires terminal to be in raw mode )
|
2022-02-07 22:57:34 -05:00
|
|
|
( see femto launcher script for more details )
|
2022-02-09 20:04:12 -05:00
|
|
|
( )
|
|
|
|
( ANSI sequences )
|
|
|
|
( )
|
|
|
|
( goto $row,$col ESC [ $row ; $col H )
|
|
|
|
( goto home ESC [ H )
|
|
|
|
( go up ESC [ A )
|
|
|
|
( go down ESC [ B )
|
|
|
|
( go right ESC [ C )
|
|
|
|
( go left ESC [ D )
|
|
|
|
( )
|
|
|
|
( query cursor ESC [ 6 n )
|
|
|
|
( )
|
|
|
|
( all scroll on ESC [ r )
|
|
|
|
( region scroll on ESC [ $y0 ; $y1 r )
|
|
|
|
( scroll down ESC D )
|
|
|
|
( scroll up ESC M )
|
|
|
|
( )
|
|
|
|
( erase cur->eol ESC [ K )
|
|
|
|
( erase cur->sol ESC [ 1 K )
|
|
|
|
( erase line ESC [ 2 K )
|
|
|
|
( erase line->bot ESC [ J )
|
|
|
|
( erase line->top ESC [ 1 J )
|
|
|
|
( erase all ESC [ 2 J )
|
|
|
|
( )
|
|
|
|
( set attrs ESC [ $at1 ; ... m )
|
|
|
|
( reset ESC [ m )
|
|
|
|
( 0 reset, 1 bright, 2 dim, )
|
|
|
|
( 4 underscore, 5 blink, )
|
|
|
|
( 7 reverse, 8 hidden )
|
|
|
|
( )
|
|
|
|
( fg (30-37), bg (40-47) )
|
|
|
|
( black, red, green, yellow, )
|
|
|
|
( blue, magenta, cyan, white )
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-11 19:15:40 -05:00
|
|
|
( TODO: )
|
|
|
|
( - optimize term drawing )
|
|
|
|
( - get long line truncation/scrolling working )
|
2022-03-24 01:42:20 -04:00
|
|
|
( - allow line numbers to be toggled off )
|
2022-02-11 19:15:40 -05:00
|
|
|
( - help text )
|
|
|
|
( - open file command? )
|
|
|
|
( - close file command? )
|
|
|
|
( - move by word/paragraph )
|
|
|
|
( - search )
|
|
|
|
( - search&replace )
|
|
|
|
( - windows line-ending support (CRLF) )
|
2022-02-15 21:19:44 -05:00
|
|
|
|
2022-02-06 17:07:11 -05:00
|
|
|
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|
|
|
|
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|
|
|
|
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
|
|
|
|
|
|
|
|
%dbg { #ff .System/debug DEO }
|
|
|
|
%emit { .Console/write DEO }
|
|
|
|
%sp { #2018 DEO }
|
|
|
|
%nl { #0a18 DEO }
|
|
|
|
%cr { #0d18 DEO }
|
|
|
|
%ansi { #1b18 DEO #5b18 DEO }
|
|
|
|
|
2022-03-25 02:22:28 -04:00
|
|
|
( emit macros )
|
|
|
|
( )
|
|
|
|
( these save one byte and are easier to read. )
|
|
|
|
%emit-! { LIT2 '! 18 DEO }
|
|
|
|
%emit-$ { LIT2 '$ 18 DEO }
|
|
|
|
%emit-( { LIT2 '( 18 DEO }
|
|
|
|
%emit-) { LIT2 ') 18 DEO }
|
|
|
|
%emit-, { LIT2 ', 18 DEO }
|
|
|
|
%emit-0 { LIT2 '0 18 DEO }
|
|
|
|
%emit-1 { LIT2 '1 18 DEO }
|
|
|
|
%emit-2 { LIT2 '2 18 DEO }
|
|
|
|
%emit-3 { LIT2 '3 18 DEO }
|
|
|
|
%emit-6 { LIT2 '6 18 DEO }
|
|
|
|
%emit-7 { LIT2 '7 18 DEO }
|
|
|
|
%emit-; { LIT2 '; 18 DEO }
|
|
|
|
%emit-C { LIT2 'C 18 DEO }
|
|
|
|
%emit-H { LIT2 'H 18 DEO }
|
|
|
|
%emit-J { LIT2 'J 18 DEO }
|
|
|
|
%emit-K { LIT2 'K 18 DEO }
|
|
|
|
%emit-[ { LIT2 '[ 18 DEO }
|
|
|
|
%emit-m { LIT2 'm 18 DEO }
|
|
|
|
%emit-n { LIT2 'n 18 DEO }
|
|
|
|
%emit-~ { LIT2 '~ 18 DEO }
|
|
|
|
|
2022-03-08 23:31:12 -05:00
|
|
|
%quit! { #01 .System/halt DEO BRK }
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-03-07 12:56:52 -05:00
|
|
|
( zero page )
|
|
|
|
|0000
|
|
|
|
|
2022-04-01 12:11:09 -04:00
|
|
|
@counter $2
|
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
@term [
|
2022-03-24 01:42:20 -04:00
|
|
|
&cols $2 ( relative x coordinate of cursor, from 0 )
|
|
|
|
&rows $2 ( relative y coordinaet of cursor, from 1 )
|
|
|
|
&lmargin $2 ( left padding needed for line numbers )
|
2022-03-07 22:38:02 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
@config [
|
|
|
|
&tab-width $2 ( how many spaces to display tab chars )
|
|
|
|
&insert-tabs $1 ( tab key inserts tabs when true )
|
|
|
|
&color $2 ( digits of highlight color in reverse order )
|
|
|
|
]
|
|
|
|
|
|
|
|
@buffer [
|
|
|
|
&limit $2 ( last byte of actual data (not including \0) + 1 )
|
|
|
|
&offset $2 ( first byte of data visible in terminal )
|
|
|
|
&line-count $2 ( total number of lines in file )
|
|
|
|
&line-offset $2 ( first line of text visible in terminal )
|
|
|
|
]
|
|
|
|
|
|
|
|
( relative cursor positions, e.g. 0 to cols-1 )
|
|
|
|
@cursor [
|
|
|
|
&col $2 ( current column value 0-n (may exceed lenght of row) )
|
|
|
|
&row $2 ( current relative row value, 0-(height-1) )
|
|
|
|
]
|
|
|
|
|
|
|
|
@state [
|
2022-03-30 23:41:16 -04:00
|
|
|
&key $1 ( last key read )
|
2022-03-07 22:38:02 -05:00
|
|
|
&saw-esc $1 ( did we just see ESC? )
|
2022-03-24 01:26:06 -04:00
|
|
|
&saw-xterm $1 ( did we just see an ESC [ xterm sequence? )
|
|
|
|
&saw-vt $1 ( did we just see an ESC [ $N vt sequence? )
|
2022-03-30 01:26:33 -04:00
|
|
|
&redraw $1 ( redrawing: bits determine which parts )
|
|
|
|
( 0x01 cursor )
|
|
|
|
( 0x02 statusbar )
|
|
|
|
( 0x04 prompt )
|
|
|
|
( 0x08 matches )
|
|
|
|
( 0x10 body and everything else )
|
2022-03-23 22:55:03 -04:00
|
|
|
&modified $1 ( has the buffer been modified? )
|
|
|
|
&quitting $1 ( are we in the process of quitting? )
|
2022-03-07 22:38:02 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
( prompt uses .tmp/pos and .tmp/data to track user input )
|
|
|
|
@prompt [
|
|
|
|
&active $1 ( is prompt currently active? )
|
|
|
|
&vector $2 ( what code to run when user responds )
|
2022-03-23 21:46:59 -04:00
|
|
|
&string $2 ( string to print for the prompt )
|
2022-03-07 22:38:02 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
@tmp [
|
|
|
|
&pos $2 ( temporary pointer to address when reading data )
|
|
|
|
&data $40 ( small scratch pad when reading data )
|
|
|
|
]
|
|
|
|
|
2022-03-29 00:02:22 -04:00
|
|
|
( search uses .tmp/pos and .tmp/data to track query string )
|
|
|
|
@searching [
|
2022-03-31 23:21:49 -04:00
|
|
|
&active $1 ( are we displaying search results? )
|
|
|
|
&orig-row $2 ( row we began the search at )
|
|
|
|
&orig-col $2 ( col we began the search at )
|
2022-04-01 12:11:09 -04:00
|
|
|
®ex $2 ( regex to be stored if any )
|
2022-03-29 00:02:22 -04:00
|
|
|
]
|
|
|
|
|
2022-02-17 23:33:48 -05:00
|
|
|
( startup )
|
2022-03-07 22:38:02 -05:00
|
|
|
|0100
|
|
|
|
;init-zero-page JSR2
|
|
|
|
;startup JMP2
|
|
|
|
|
2022-04-01 12:11:09 -04:00
|
|
|
~regex.tal
|
2022-03-31 23:21:49 -04:00
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
( intialize zero page variables )
|
|
|
|
( )
|
|
|
|
( everything not specified starts as zero )
|
|
|
|
@init-zero-page ( -> )
|
|
|
|
#0050 .term/cols STZ2
|
|
|
|
#0018 .term/rows STZ2
|
|
|
|
#0006 .term/lmargin STZ2
|
|
|
|
|
|
|
|
#0004 .config/tab-width STZ2
|
2022-03-25 00:12:09 -04:00
|
|
|
#00 .config/insert-tabs STZ
|
2022-03-07 22:38:02 -05:00
|
|
|
#3333 .config/color STZ2
|
|
|
|
|
|
|
|
;data .buffer/offset STZ2
|
|
|
|
JMP2r
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-03-06 15:35:14 -05:00
|
|
|
( code to run on startup )
|
2022-03-07 22:38:02 -05:00
|
|
|
@startup
|
|
|
|
;filename .tmp/pos STZ2
|
|
|
|
;read-filename .Console/vector DEO2
|
|
|
|
BRK
|
2022-02-09 02:35:46 -05:00
|
|
|
|
2022-02-13 14:46:50 -05:00
|
|
|
( ERROR HANDLING )
|
|
|
|
|
|
|
|
( using error! will print the given message before causing )
|
|
|
|
( the interpreter to halt. )
|
|
|
|
@error! ( msg* -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
emit-! sp
|
2022-02-13 14:46:50 -05:00
|
|
|
&loop LDAk ,&continue JCN ,&done JMP
|
|
|
|
&continue LDAk emit INC2 ,&loop JMP
|
|
|
|
&done POP2 nl
|
|
|
|
dbg BRK
|
|
|
|
|
2022-02-09 02:35:46 -05:00
|
|
|
@open-file ( filename* -> )
|
2022-02-09 20:04:12 -05:00
|
|
|
.File/name DEO2
|
2022-03-03 21:12:26 -05:00
|
|
|
#f000 .File/length DEO2
|
2022-03-07 22:38:02 -05:00
|
|
|
;data .File/read DEO2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
|
|
|
.File/success DEI2 #0000 GTH2 ,&ok JCN
|
2022-03-08 23:31:12 -05:00
|
|
|
;messages/input-error ;print JSR2
|
|
|
|
;filename ;print JSR2 nl quit!
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-09 20:04:12 -05:00
|
|
|
( calculate buffer limit address using start + size )
|
2022-03-07 22:38:02 -05:00
|
|
|
&ok .File/success DEI2 ;data ADD2 .buffer/limit STZ2
|
2022-02-09 02:35:46 -05:00
|
|
|
JMP2r
|
2022-02-09 01:05:11 -05:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@setup-terminal-size ( -> )
|
2022-03-25 23:17:34 -04:00
|
|
|
#03e7 DUP2 ;term-move-cursor JSR2
|
2022-02-09 02:35:46 -05:00
|
|
|
;term-get-cursor-position JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
;tmp/data .tmp/pos STZ2
|
2022-02-09 02:35:46 -05:00
|
|
|
;receive-terminal-size .Console/vector DEO2
|
|
|
|
JMP2r
|
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@receive-terminal-size ( -> )
|
2022-03-30 23:41:16 -04:00
|
|
|
.Console/read DEI .state/key STZ
|
|
|
|
.state/key LDZ .tmp/pos LDZ2 STA
|
2022-03-07 22:38:02 -05:00
|
|
|
.tmp/pos LDZ2 INC2 .tmp/pos STZ2
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ LIT 'R EQU ;parse-terminal-size JCN2
|
2022-02-09 02:35:46 -05:00
|
|
|
BRK
|
|
|
|
|
|
|
|
@parse-terminal-size ( -> )
|
|
|
|
LIT2r 0000 LIT2r 0000
|
2022-03-07 22:38:02 -05:00
|
|
|
.tmp/data LDZk #1b NEQ ,&parse-error JCN ( i ) INC
|
|
|
|
LDZk LIT '[ NEQ ,&parse-error JCN ( i ) INC
|
2022-02-09 02:35:46 -05:00
|
|
|
&loop
|
2022-03-07 22:38:02 -05:00
|
|
|
LDZk LIT '; EQU ,&parse-col JCN
|
2022-02-09 02:35:46 -05:00
|
|
|
LIT2r 000a MUL2r
|
2022-03-07 22:38:02 -05:00
|
|
|
LDZk LIT '0 SUB #00 SWP STH2 ADD2r
|
|
|
|
INC ,&loop JMP
|
2022-02-09 02:35:46 -05:00
|
|
|
&parse-col
|
2022-03-07 22:38:02 -05:00
|
|
|
INC STH2r #0002 SUB2 .term/rows STZ2
|
2022-02-09 02:35:46 -05:00
|
|
|
&loop2
|
2022-03-07 22:38:02 -05:00
|
|
|
LDZk LIT 'R EQU ,&done JCN
|
2022-02-09 02:35:46 -05:00
|
|
|
LIT2r 000a MUL2r
|
2022-03-07 22:38:02 -05:00
|
|
|
LDZk LIT '0 SUB #00 SWP STH2 ADD2r
|
|
|
|
INC ,&loop2 JMP
|
2022-02-09 02:35:46 -05:00
|
|
|
&done
|
2022-03-07 22:38:02 -05:00
|
|
|
STH2r .term/cols STZ2 POP
|
2022-02-09 02:35:46 -05:00
|
|
|
;on-key .Console/vector DEO2
|
|
|
|
;draw-all JSR2
|
|
|
|
BRK
|
2022-03-07 22:38:02 -05:00
|
|
|
&parse-error POP .tmp/data LDZ2
|
2022-03-25 00:12:09 -04:00
|
|
|
;messages/term-size-parse-error ;error! JMP2
|
2022-02-09 02:35:46 -05:00
|
|
|
|
2022-02-11 15:39:49 -05:00
|
|
|
@setup-linecount ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
;data LIT2r 0001
|
|
|
|
&loop DUP2 .buffer/limit LDZ2 EQU2 ,&done JCN
|
2022-02-11 15:39:49 -05:00
|
|
|
LDAk #00 EQU ,&done JCN
|
2022-03-25 00:12:09 -04:00
|
|
|
LDAk #09 NEQ ,&next JCN #01 .config/insert-tabs STZ
|
|
|
|
&next LDAk #0a NEQ JMP INC2r
|
2022-02-11 15:39:49 -05:00
|
|
|
INC2 ,&loop JMP
|
|
|
|
&done POP2
|
2022-03-07 22:38:02 -05:00
|
|
|
STH2r .buffer/line-count STZ2
|
2022-02-11 15:39:49 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-02-09 02:35:46 -05:00
|
|
|
@read-filename ( -> )
|
2022-02-11 15:39:49 -05:00
|
|
|
#12 DEI #0a EQU ,&execute JCN ( did we read \n ? )
|
2022-03-07 22:38:02 -05:00
|
|
|
#12 DEI .tmp/pos LDZ2 STA ( no, so save in buffer )
|
|
|
|
.tmp/pos LDZ2 INC2 .tmp/pos STZ2 ( pos++ )
|
2022-02-11 15:39:49 -05:00
|
|
|
BRK ( return )
|
|
|
|
|
|
|
|
&execute ( we saw a newline, so do something )
|
2022-03-07 22:38:02 -05:00
|
|
|
#00 .tmp/pos LDZ2 STA ( null terminate str )
|
2022-02-11 15:39:49 -05:00
|
|
|
;filename ;open-file JSR2 ( open file )
|
|
|
|
;setup-linecount JSR2 ( determine # of lines )
|
|
|
|
;setup-terminal-size JSR2 ( detect terminal dimensions )
|
2022-02-06 17:07:11 -05:00
|
|
|
BRK
|
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@bol ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-statusbar-and-cursor JSR2
|
|
|
|
;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
|
|
|
( FIXME: handle long lines )
|
2022-02-18 00:20:09 -05:00
|
|
|
@eol ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
;cur-line JSR2 ;line-len JSR2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-statusbar-and-cursor JSR2
|
|
|
|
;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
|
|
|
( FIXME: handle long lines )
|
2022-02-18 00:20:09 -05:00
|
|
|
@forward ( -> )
|
2022-02-14 16:47:36 -05:00
|
|
|
;cur-pos JSR2 ;last-pos JSR2 GTH2 ,&skip JCN
|
2022-04-01 12:11:09 -04:00
|
|
|
;cur-col JSR2 ;cur-len JSR2 LTH2 ,&normal JCN
|
|
|
|
#0000 .cursor/col STZ2
|
|
|
|
.cursor/row LDZ2 INC2 .cursor/row STZ2
|
|
|
|
;ensure-visible-cursor JSR2
|
|
|
|
,&skip JMP
|
2022-03-25 23:17:34 -04:00
|
|
|
&normal
|
2022-04-01 12:11:09 -04:00
|
|
|
;cur-col JSR2 INC2 .cursor/col STZ2
|
|
|
|
;redraw-statusbar-and-cursor JSR2
|
|
|
|
&skip
|
|
|
|
;redraw-cursor JSR2
|
|
|
|
;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
|
|
|
( FIXME: handle long lines )
|
2022-03-30 01:26:33 -04:00
|
|
|
@go-back ( -> )
|
2022-03-25 23:17:34 -04:00
|
|
|
;cur-col JSR2 #0001 LTH2 ,&next-line JCN
|
2022-03-07 22:38:02 -05:00
|
|
|
;cur-col JSR2 #0001 SUB2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-statusbar-and-cursor JSR2 JMP2r
|
2022-03-25 23:17:34 -04:00
|
|
|
&next-line
|
2022-04-01 00:44:07 -04:00
|
|
|
.cursor/row LDZ2 #0001 SUB2 .cursor/row STZ2
|
2022-03-25 23:17:34 -04:00
|
|
|
;cur-len JSR2 .cursor/col STZ2
|
|
|
|
;ensure-visible-cursor JSR2 ( FIXME )
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-cursor JSR2
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@back ( -> )
|
|
|
|
;go-back JSR2 ;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@up ( -> )
|
2022-02-18 00:34:42 -05:00
|
|
|
;cur-abs-row JSR2 #0000 EQU2 ,&done JCN
|
2022-04-01 00:44:07 -04:00
|
|
|
.cursor/row LDZ2 #0001 SUB2 .cursor/row STZ2
|
2022-03-26 15:29:00 -04:00
|
|
|
;ensure-visible-cursor JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-statusbar JSR2
|
|
|
|
&done ;redraw-cursor JSR2 ;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@down ( -> )
|
2022-02-13 14:46:50 -05:00
|
|
|
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
2022-04-01 00:44:07 -04:00
|
|
|
.cursor/row LDZ2 INC2 .cursor/row STZ2
|
2022-02-14 16:47:36 -05:00
|
|
|
;ensure-visible-cursor JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-statusbar JSR2
|
|
|
|
&done ;redraw-cursor JSR2 ;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-03-26 15:29:00 -04:00
|
|
|
@center-view
|
2022-03-31 01:52:20 -04:00
|
|
|
.term/rows LDZ2 INC2 #0002 DIV2 STH2k
|
2022-03-26 15:29:00 -04:00
|
|
|
.cursor/row LDZ2 LTH2 ,&standard JCN
|
|
|
|
POP2r
|
|
|
|
#0000 .buffer/line-offset STZ2
|
|
|
|
;data .buffer/offset STZ2
|
|
|
|
,&done JMP
|
|
|
|
&standard
|
|
|
|
.cursor/row LDZ2 STH2r SUB2
|
|
|
|
DUP2 .buffer/line-offset STZ2
|
|
|
|
;abs-line JSR2 .buffer/offset STZ2
|
|
|
|
&done
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-03-26 15:29:00 -04:00
|
|
|
|
|
|
|
@page-up ( -> )
|
|
|
|
.term/rows LDZ2 #0002 SUB2 STH2k
|
|
|
|
.buffer/line-offset LDZ2 LTH2 ,&move-full JCN
|
|
|
|
POP2r
|
2022-03-06 15:35:14 -05:00
|
|
|
;zero-row JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .cursor/col STZ2
|
2022-03-26 15:29:00 -04:00
|
|
|
,&done JMP
|
|
|
|
&move-full
|
|
|
|
.cursor/row LDZ2 STH2kr SUB2 .cursor/row STZ2
|
|
|
|
.buffer/line-offset LDZ2 STH2r SUB2
|
|
|
|
DUP2 .buffer/line-offset STZ2
|
|
|
|
;abs-line JSR2 .buffer/offset STZ2
|
|
|
|
&done
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
|
|
|
|
2022-02-15 21:58:12 -05:00
|
|
|
|
|
|
|
@page-down
|
|
|
|
;eof-is-visible JSR2 ,&near-eof JCN
|
2022-03-26 15:29:00 -04:00
|
|
|
.term/rows LDZ2 #0002 SUB2 STH2k
|
|
|
|
.buffer/line-offset LDZ2 ADD2
|
|
|
|
DUP2 .buffer/line-offset STZ2
|
|
|
|
;abs-line JSR2 .buffer/offset STZ2
|
|
|
|
.cursor/row LDZ2 STH2r ADD2 .cursor/row STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-02-15 21:58:12 -05:00
|
|
|
&near-eof
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/line-count LDZ2 #0001 SUB2 ;set-abs-row JSR2
|
|
|
|
;cur-len JSR2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-cursor JSR2 ;return JMP2
|
2022-02-15 21:58:12 -05:00
|
|
|
|
2022-03-23 22:55:03 -04:00
|
|
|
@quit
|
|
|
|
#01 .state/quitting STZ
|
|
|
|
.state/modified LDZ ,&is-modified JCN
|
|
|
|
quit!
|
|
|
|
&is-modified
|
|
|
|
;messages/quit-prompt ;messages/null ;do-quit ;start-prompt JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-03-23 22:55:03 -04:00
|
|
|
@do-quit
|
|
|
|
.tmp/data LDZ LIT 'n EQU ;quit-now JCN2
|
|
|
|
.tmp/data LDZ LIT 'y EQU ;save JCN2
|
|
|
|
#00 .state/quitting STZ
|
|
|
|
;move-to-message-line JSR2
|
|
|
|
;messages/unknown-input ;print JSR2
|
|
|
|
;tmp/data ;print JSR2
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@quit-now quit!
|
|
|
|
|
|
|
|
@ignore
|
2022-03-30 01:26:33 -04:00
|
|
|
;draw-cursor JSR2 BRK
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-02-06 17:07:11 -05:00
|
|
|
@insert ( c^ -> )
|
2022-03-23 22:55:03 -04:00
|
|
|
#01 .state/modified STZ
|
2022-02-06 17:07:11 -05:00
|
|
|
;cur-pos JSR2 ;shift-right JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
;cur-col JSR2 INC2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-03-23 22:12:17 -04:00
|
|
|
@insert-prompt ( c^ -> )
|
|
|
|
.tmp/pos LDZ2 STH2k STA ( data[pos] <- c )
|
|
|
|
INC2r #00 STH2kr STA ( data[pos+1] <- 0 )
|
|
|
|
STH2r .tmp/pos STZ2 ( pos <- pos+1 )
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-03-23 22:12:17 -04:00
|
|
|
|
2022-03-03 21:12:26 -05:00
|
|
|
@insert-tab ( -> )
|
2022-03-23 22:55:03 -04:00
|
|
|
#01 .state/modified STZ
|
2022-03-07 22:38:02 -05:00
|
|
|
.config/insert-tabs LDZ ,&use-tabs JCN
|
|
|
|
#0000 .config/tab-width LDZ2 SUB2
|
2022-03-03 21:12:26 -05:00
|
|
|
&loop
|
|
|
|
DUP2 #0000 EQU2 ,&done JCN
|
|
|
|
#20 ;cur-pos JSR2 ;shift-right JSR2
|
|
|
|
INC2 ,&loop JMP
|
|
|
|
&done
|
2022-03-07 22:38:02 -05:00
|
|
|
;cur-col JSR2 .config/tab-width LDZ2 ADD2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-03-03 21:12:26 -05:00
|
|
|
&use-tabs
|
|
|
|
#09 ;insert JMP2
|
|
|
|
|
2022-02-12 02:10:27 -05:00
|
|
|
( TODO: handle last line )
|
2022-02-07 22:25:32 -05:00
|
|
|
@newline ( c^ -> )
|
2022-03-23 22:55:03 -04:00
|
|
|
#01 .state/modified STZ
|
2022-02-07 22:25:32 -05:00
|
|
|
#0a ;cur-pos JSR2 ;shift-right JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .cursor/col STZ2
|
2022-04-01 00:44:07 -04:00
|
|
|
.cursor/row LDZ2 INC2 .cursor/row STZ2
|
2022-03-23 21:46:59 -04:00
|
|
|
.buffer/line-count LDZ2k INC2 ROT STZ2
|
2022-02-15 21:19:44 -05:00
|
|
|
;ensure-visible-cursor JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
( @at-buffer-start ( -> bool^ )
|
|
|
|
;cur-pos JSR2 ;data EQU2 JMP2r )
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
( @at-line-start ( -> bool^ )
|
|
|
|
.cursor/col LDZ2 #0000 EQU2 JMP2r )
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
( @bof-is-visible ( -> bool^ )
|
|
|
|
.buffer/line-offset LDZ2 #0000 EQU2 JMP2r )
|
2022-02-15 22:03:31 -05:00
|
|
|
|
2022-02-15 21:58:12 -05:00
|
|
|
@eof-is-visible ( -> bool^ )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/line-offset LDZ2 .term/rows LDZ2 ADD2 INC2
|
|
|
|
.buffer/line-count LDZ2
|
2022-02-15 21:58:12 -05:00
|
|
|
GTH2 JMP2r
|
|
|
|
|
2022-02-06 17:07:11 -05:00
|
|
|
@backspace ( -> )
|
2022-03-31 01:52:20 -04:00
|
|
|
;cur-pos JSR2 ;data EQU2 ,&skip JCN
|
2022-03-30 01:26:33 -04:00
|
|
|
;go-back JSR2
|
2022-03-25 23:17:34 -04:00
|
|
|
;delete JMP2
|
2022-03-30 01:26:33 -04:00
|
|
|
&skip
|
|
|
|
;redraw-cursor JSR2 ;return JMP2
|
2022-03-25 23:17:34 -04:00
|
|
|
|
2022-03-23 22:12:17 -04:00
|
|
|
@backspace-prompt ( -> )
|
|
|
|
#00 .tmp/pos LDZ2 #0001 SUB2 ( 0 pos-1 )
|
|
|
|
STH2k STA ( data[pos-1] <- 0 )
|
|
|
|
STH2r .tmp/pos STZ2 ( pos <- pos-1 )
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-03-23 22:12:17 -04:00
|
|
|
|
2022-02-07 22:25:32 -05:00
|
|
|
@delete ( -> )
|
2022-03-23 22:55:03 -04:00
|
|
|
#01 .state/modified STZ
|
2022-03-24 23:21:35 -04:00
|
|
|
;last-pos JSR2 ;cur-pos JSR2 LTH2 ,&skip JCN
|
2022-02-13 14:46:50 -05:00
|
|
|
;cur-pos JSR2 LDAk STH ( cur [c] )
|
|
|
|
;shift-left JSR2 ( [c] )
|
2022-02-11 15:39:49 -05:00
|
|
|
STHr #0a NEQ ,¬-newline JCN
|
2022-03-23 21:46:59 -04:00
|
|
|
.buffer/line-count LDZ2k #0001 SUB2 ROT STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
¬-newline ;redraw-all JSR2 ;return JMP2
|
|
|
|
&skip ;redraw-cursor JSR2 ;return JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-08 22:22:08 -05:00
|
|
|
@escape ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
#01 .state/saw-esc STZ BRK
|
2022-02-08 22:22:08 -05:00
|
|
|
|
2022-02-12 02:25:41 -05:00
|
|
|
@goto-end ( -> )
|
2022-03-26 15:29:00 -04:00
|
|
|
.buffer/line-count LDZ2 #0001 SUB2 .cursor/row STZ2
|
|
|
|
.buffer/line-count LDZ2 .term/rows LDZ2 LTH2k ,&use-zero JCN
|
|
|
|
SUB2 #0002 ADD2 ,&continue JMP
|
|
|
|
&use-zero
|
|
|
|
POP2 POP2 #0000
|
2022-02-13 14:46:50 -05:00
|
|
|
&continue
|
2022-03-07 22:38:02 -05:00
|
|
|
DUP2 .buffer/line-offset STZ2
|
|
|
|
;abs-line JSR2 .buffer/offset STZ2
|
|
|
|
;cur-len JSR2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-02-12 02:25:41 -05:00
|
|
|
|
2022-02-08 22:22:08 -05:00
|
|
|
@goto-start ( -> )
|
2022-03-06 15:35:14 -05:00
|
|
|
;zero-row JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
|
|
|
|
2022-02-10 01:40:48 -05:00
|
|
|
@goto-line ( -> )
|
2022-03-24 00:09:55 -04:00
|
|
|
;messages/goto-line ;messages/null ;do-goto-line ;start-prompt JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-03-24 00:09:55 -04:00
|
|
|
|
|
|
|
@parse-decimal-number ( addr* -> n* ok^ )
|
|
|
|
LDAk ,&non-empty JCN
|
|
|
|
#00 JMP2r
|
|
|
|
&non-empty
|
|
|
|
LIT2r 0000
|
|
|
|
&loop
|
|
|
|
LDAk ,&continue JCN
|
|
|
|
POP2 STH2r #01 JMP2r
|
|
|
|
&continue
|
|
|
|
LDAk LIT '0 LTH ,&fail JCN
|
|
|
|
LDAk LIT '9 GTH ,&fail JCN
|
|
|
|
LIT2r 000a MUL2r
|
|
|
|
LDAk LIT '0 SUB #00 SWP STH2 ADD2r
|
|
|
|
INC2 ,&loop JMP
|
|
|
|
&fail
|
|
|
|
POP2r #00 JMP2r
|
|
|
|
|
|
|
|
|
|
|
|
@do-goto-line
|
|
|
|
;tmp/data ;parse-decimal-number JSR2
|
|
|
|
,&ok JCN
|
|
|
|
;move-to-message-line JSR2
|
|
|
|
;messages/unknown-input ;print JSR2
|
|
|
|
;tmp/data ;print JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;return JMP2
|
2022-03-24 00:09:55 -04:00
|
|
|
&ok
|
|
|
|
#0001 SUB2 ( convert 1-indexing to 0-indexing )
|
|
|
|
DUP2 .buffer/line-count LDZ2 LTH2 ,&within JCN
|
|
|
|
POP2 ;goto-end JMP2
|
|
|
|
&within
|
|
|
|
;jump-to-line JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-02-10 01:40:48 -05:00
|
|
|
|
2022-03-31 13:48:08 -04:00
|
|
|
@move-to-coord ( col* row* -> )
|
|
|
|
DUP2 ;line-is-visible JSR2 ;jump-to-coord/short JCN2
|
|
|
|
;jump-to-coord JMP2
|
|
|
|
|
|
|
|
@jump-to-coord ( x* y* -> )
|
|
|
|
.term/rows LDZ2 INC2 #0002 DIV2 LTH2k ( x y rows/2 y<rows/2? ) ,&early JCN
|
|
|
|
OVR2 SWP2 SUB2 ( x y y-rows/2 )
|
|
|
|
.buffer/line-count LDZ2 ( x y y-rows/2 lines )
|
|
|
|
.term/rows LDZ2 SUB2 ( x y y-rows/2 lines-rows )
|
|
|
|
GTH2k ( x y y-rows/2 lines-rows y-rows/2>lines-rows? )
|
|
|
|
,&late JCN ( x y y-rows/2 lines-rows )
|
2022-02-10 01:40:48 -05:00
|
|
|
POP2 ,&finish JMP
|
2022-03-31 13:48:08 -04:00
|
|
|
&early ( x y rows/2 )
|
|
|
|
POP2 #0000 ,&finish JMP ( x y 0000 )
|
|
|
|
&late ( x y y-rows/2 lines-rows )
|
2022-02-14 16:47:36 -05:00
|
|
|
NIP2
|
2022-03-31 13:48:08 -04:00
|
|
|
&finish ( x y o )
|
|
|
|
;redraw-all JSR2
|
|
|
|
SUB2k STH2 DUP2 ( x y o o [y-o] )
|
|
|
|
.buffer/line-offset STZ2 ( x y o [y-o] )
|
|
|
|
;abs-line JSR2 .buffer/offset STZ2 ( x y [y-o] )
|
|
|
|
POP2r
|
|
|
|
&short
|
|
|
|
;redraw-statusbar-and-cursor JSR2
|
|
|
|
.cursor/row STZ2 ( x )
|
|
|
|
.cursor/col STZ2
|
2022-02-10 01:40:48 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-03-31 13:48:08 -04:00
|
|
|
@jump-to-line ( n* -> )
|
|
|
|
#0000 SWP2 ;jump-to-coord JMP2
|
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
@ensure-visible-cursor
|
2022-04-01 12:11:09 -04:00
|
|
|
.cursor/row LDZ2 .buffer/line-offset LDZ2
|
|
|
|
SUB2 .term/rows LDZ2 LTH2 ,&noop JCN
|
2022-02-18 00:34:42 -05:00
|
|
|
;cur-abs-row JSR2 ;jump-to-line JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2
|
2022-02-14 16:47:36 -05:00
|
|
|
&noop JMP2r
|
|
|
|
|
2022-02-13 14:46:50 -05:00
|
|
|
@debug
|
2022-03-25 00:12:09 -04:00
|
|
|
;messages/rel-line-error ;error! JMP2
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-02-15 21:19:44 -05:00
|
|
|
@move-to-message-line ( -> )
|
2022-03-23 22:12:17 -04:00
|
|
|
#0000 .term/rows LDZ2 #0002 ADD2 ;term-move-cursor JMP2
|
2022-02-15 21:19:44 -05:00
|
|
|
|
2022-03-23 21:46:59 -04:00
|
|
|
( when called vector should end in BRK )
|
|
|
|
@start-prompt ( prompt* default* vector* -> )
|
|
|
|
.prompt/active LDZ ,&is-active JCN
|
|
|
|
#01 .prompt/active STZ ( prompt/active <- 1 )
|
|
|
|
.prompt/vector STZ2 ( prompt/vector <- vector )
|
|
|
|
DUP2 ;tmp/data ;str-copy JSR2 ( tmp/data <- default )
|
2022-03-23 22:12:17 -04:00
|
|
|
;str-len JSR2 ;tmp/data ADD2 ( len(default)+data )
|
|
|
|
.tmp/pos STZ2 ( tmp/pos <- len(default)+data )
|
2022-03-23 21:46:59 -04:00
|
|
|
.prompt/string STZ2 ( prompt/string <- prompt )
|
|
|
|
JMP2r
|
|
|
|
&is-active
|
|
|
|
#0000 DIV
|
|
|
|
|
|
|
|
( ends prompt without calling vector )
|
|
|
|
@cancel-prompt ( -> )
|
|
|
|
.prompt/active LDZ ,&is-active JCN
|
|
|
|
#0000 DIV
|
|
|
|
&is-active
|
|
|
|
#00 .prompt/active STZ
|
2022-03-24 23:21:35 -04:00
|
|
|
#00 .state/quitting STZ
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-03-23 21:46:59 -04:00
|
|
|
|
|
|
|
( when called vector should end in BRK )
|
|
|
|
@finish-prompt ( -> )
|
|
|
|
.prompt/active LDZ ,&is-active JCN
|
|
|
|
#0000 DIV
|
|
|
|
&is-active
|
|
|
|
#00 .prompt/active STZ
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2
|
2022-03-23 21:46:59 -04:00
|
|
|
.prompt/vector LDZ2 JMP2
|
|
|
|
|
|
|
|
@save
|
|
|
|
;messages/save-prompt ;filename ;do-save ;start-prompt JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-03-23 21:46:59 -04:00
|
|
|
|
|
|
|
@do-save ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/limit LDZ2 ;data SUB2 STH2 ( [size] )
|
2022-03-23 21:46:59 -04:00
|
|
|
;tmp/data .File/name DEO2
|
|
|
|
STH2kr .File/length DEO2
|
|
|
|
;data .File/write DEO2
|
2022-02-15 21:19:44 -05:00
|
|
|
|
|
|
|
;move-to-message-line JSR2
|
|
|
|
.File/success DEI2 STH2r EQU2 ( ok? ) ,&ok JCN
|
2022-03-24 01:26:06 -04:00
|
|
|
;messages/save-failed ,&finish JMP
|
|
|
|
&ok
|
|
|
|
#00 .state/modified STZ
|
|
|
|
;tmp/data ;filename ;str-copy JSR2
|
|
|
|
;messages/save-ok
|
2022-03-23 22:55:03 -04:00
|
|
|
&finish
|
|
|
|
;print JSR2 ;tmp/data ;print JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2
|
2022-03-23 22:55:03 -04:00
|
|
|
.state/quitting LDZ ;quit-now JCN2
|
2022-03-30 01:26:33 -04:00
|
|
|
;return JMP2
|
2022-02-15 21:19:44 -05:00
|
|
|
|
2022-03-29 00:02:22 -04:00
|
|
|
@search ( -> )
|
|
|
|
;messages/search-prompt ;messages/null ;do-search ;start-prompt JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
2022-03-29 00:02:22 -04:00
|
|
|
|
|
|
|
@do-search ( -> )
|
2022-04-01 12:11:09 -04:00
|
|
|
#0000 .searching/regex STZ2
|
2022-03-31 23:21:49 -04:00
|
|
|
;move-to-next-match JSR2 ,&found JCN
|
|
|
|
;move-to-prev-match JSR2 ,&found JCN
|
|
|
|
;move-to-message-line JSR2 ;messages/no-matches-found ;print JSR2
|
|
|
|
;draw-cursor JSR2 BRK
|
|
|
|
&found #01 .searching/active STZ ;return JMP2
|
|
|
|
|
2022-04-01 12:11:09 -04:00
|
|
|
@regex-search ( -> )
|
2022-03-31 23:21:49 -04:00
|
|
|
;messages/regex-search-prompt ;messages/null ;do-regex-search ;start-prompt JSR2
|
|
|
|
;redraw-prompt-and-cursor JSR2 ;return JMP2
|
|
|
|
|
|
|
|
@do-regex-search ( -> )
|
|
|
|
;tmp/data ;compile .searching/regex STZ2
|
|
|
|
;move-to-next-regex-match JSR2 ,&found JCN
|
|
|
|
;move-to-prev-regex-match JSR2 ,&found JCN
|
|
|
|
;move-to-message-line JSR2 ;messages/no-matches-found ;print JSR2
|
|
|
|
;draw-cursor JSR2 BRK
|
2022-04-01 12:11:09 -04:00
|
|
|
&found #01 .searching/active STZ ;return JMP2
|
2022-03-29 00:02:22 -04:00
|
|
|
|
2022-03-24 01:35:35 -04:00
|
|
|
@toggle-color ( -> )
|
|
|
|
.config/color LDZ2 #3733 EQU2 ,&wrap-around JCN
|
|
|
|
.config/color LDZ2 #0100 ADD2 .config/color STZ2 ,&done JMP
|
|
|
|
&wrap-around #3033 .config/color STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
&done ;redraw-all JSR2 ;return JMP2
|
2022-03-24 01:35:35 -04:00
|
|
|
|
2022-03-25 00:12:09 -04:00
|
|
|
@toggle-tabs ( -> )
|
|
|
|
.config/insert-tabs LDZk #01 EOR SWP STZ
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-statusbar-and-cursor JSR2 ;return JMP2
|
2022-03-25 00:12:09 -04:00
|
|
|
|
2022-03-23 21:46:59 -04:00
|
|
|
( TODO: M-f and M-b for next/previous word )
|
|
|
|
( M-n and M-p for next/previous paragraph )
|
|
|
|
( maybe M-% for search&replace )
|
|
|
|
@on-key-escaped ( -> )
|
|
|
|
#00 .state/saw-esc STZ
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ LIT '< EQU ( M-< ) ;goto-start JCN2
|
|
|
|
.state/key LDZ LIT '> EQU ( M-> ) ;goto-end JCN2
|
|
|
|
.state/key LDZ LIT 'c EQU ( M-c ) ;toggle-color JCN2
|
|
|
|
.state/key LDZ LIT 'g EQU ( M-g ) ;goto-line JCN2
|
2022-04-01 12:11:09 -04:00
|
|
|
.state/key LDZ LIT 's EQU ( M-s ) ;regex-search JCN2
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ LIT 't EQU ( M-t ) ;toggle-tabs JCN2
|
|
|
|
.state/key LDZ LIT 'v EQU ( M-v ) ;page-up JCN2
|
|
|
|
.state/key LDZ LIT '[ EQU ( M-[ ) ;xterm JCN2
|
2022-03-24 01:26:06 -04:00
|
|
|
BRK
|
|
|
|
|
|
|
|
@xterm
|
|
|
|
#01 .state/saw-xterm STZ BRK
|
|
|
|
|
|
|
|
@on-key-vt ( -> )
|
|
|
|
.state/saw-vt LDZk STH #00 SWP STZ
|
2022-03-31 00:27:29 -04:00
|
|
|
.state/key LDZ LIT '~ EQU ,&ok JCN
|
2022-03-24 01:26:06 -04:00
|
|
|
POPr BRK
|
|
|
|
&ok
|
|
|
|
STHr DUP LIT '1 NEQ ,¬-1 JCN
|
|
|
|
( ^[[1~ -> home ) POP ;bol JMP2
|
|
|
|
¬-1 DUP LIT '2 NEQ ,¬-2 JCN
|
|
|
|
( ^[[2~ -> insert ) POP BRK
|
|
|
|
¬-2 DUP LIT '3 NEQ ,¬-3 JCN
|
|
|
|
( ^[[3~ -> delete ) POP ;delete JMP2
|
|
|
|
¬-3 DUP LIT '4 NEQ ,¬-4 JCN
|
|
|
|
( ^[[4~ -> end ) POP ;eol JMP2
|
|
|
|
¬-4 DUP LIT '5 NEQ ,¬-5 JCN
|
|
|
|
( ^[[5~ -> page up ) POP ;page-up JMP2
|
|
|
|
¬-5 DUP LIT '6 NEQ ,¬-6 JCN
|
|
|
|
( ^[[6~ -> page down ) POP ;page-down JMP2
|
|
|
|
¬-6 DUP LIT '7 NEQ ,¬-7 JCN
|
|
|
|
( ^[[7~ -> home ) POP ;bol JMP2
|
|
|
|
¬-7 DUP LIT '8 NEQ ,¬-8 JCN
|
|
|
|
( ^[[8~ -> end ) POP ;eol JMP2
|
|
|
|
¬-8
|
|
|
|
( ??? ) POP BRK
|
|
|
|
|
|
|
|
@on-key-xterm ( -> )
|
|
|
|
#00 .state/saw-xterm STZ
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ LIT 'A EQU ( ^[[A -> up ) ;up JCN2
|
|
|
|
.state/key LDZ LIT 'B EQU ( ^[[B -> down ) ;down JCN2
|
|
|
|
.state/key LDZ LIT 'C EQU ( ^[[C -> right ) ;forward JCN2
|
|
|
|
.state/key LDZ LIT 'D EQU ( ^[[D -> left ) ;back JCN2
|
|
|
|
.state/key LDZ LIT 'F EQU ( ^[[F -> end ) ;eol JCN2
|
|
|
|
.state/key LDZ LIT 'H EQU ( ^[[H -> home ) ;bol JCN2
|
|
|
|
.state/key LDZ LIT '0 LTH ;ignore JCN2
|
|
|
|
.state/key LDZ LIT '8 GTH ;ignore JCN2
|
|
|
|
.state/key LDZ .state/saw-vt STZ ( ^[[1 through ^[[8 )
|
2022-03-23 21:46:59 -04:00
|
|
|
BRK
|
|
|
|
|
2022-03-23 22:55:03 -04:00
|
|
|
@clear-line ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi emit-2 emit-K JMP2r
|
2022-03-23 22:55:03 -04:00
|
|
|
|
|
|
|
@clear-message-line
|
|
|
|
;move-to-message-line JSR2
|
|
|
|
;clear-line JSR2
|
|
|
|
JMP2r
|
|
|
|
|
2022-03-29 00:02:22 -04:00
|
|
|
@cancel-search
|
|
|
|
#00 .searching/active STZ
|
2022-03-31 00:27:29 -04:00
|
|
|
.searching/orig-row LDZ2 ;jump-to-line JSR2
|
|
|
|
.searching/orig-col LDZ2 .cursor/col STZ2
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-03-29 00:02:22 -04:00
|
|
|
|
|
|
|
@finish-search
|
|
|
|
#00 .searching/active STZ
|
2022-03-30 01:26:33 -04:00
|
|
|
;redraw-all JSR2 ;return JMP2
|
2022-03-29 00:02:22 -04:00
|
|
|
|
2022-03-31 13:59:20 -04:00
|
|
|
( TODO: i haven't decided how to solve the problem of )
|
|
|
|
( overlapping matches yet. i don't really want to maintain )
|
|
|
|
( a global list of all matches, which means that currently )
|
|
|
|
( it can change in response to e.g. cursor position when )
|
|
|
|
( matches overlap. )
|
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
@jump-to-next-match ( -> )
|
|
|
|
;move-to-next-match JSR2 POP ;return JMP2
|
|
|
|
|
|
|
|
@jump-to-prev-match ( -> )
|
|
|
|
;move-to-prev-match JSR2 POP ;return JMP2
|
|
|
|
|
|
|
|
@move-to-next-match ( -> ok^ )
|
2022-03-31 00:27:29 -04:00
|
|
|
.buffer/limit LDZ2
|
|
|
|
;cur-pos JSR2 INC2
|
|
|
|
&loop
|
2022-04-01 12:11:09 -04:00
|
|
|
GTH2k #00 EQU ,&fail JCN
|
2022-03-31 00:27:29 -04:00
|
|
|
DUP2 ;matches-at JSR2
|
|
|
|
ORA ,&found JCN
|
|
|
|
INC2 ,&loop JMP
|
|
|
|
&found
|
2022-04-01 12:11:09 -04:00
|
|
|
NIP2 ;jump-to-pos JSR2 #01 JMP2r
|
2022-03-31 00:27:29 -04:00
|
|
|
&fail
|
2022-04-01 12:11:09 -04:00
|
|
|
;redraw-cursor JSR2 POP2 POP2 #00 JMP2r
|
2022-03-31 00:27:29 -04:00
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
@move-to-prev-match ( -> ok^ )
|
2022-03-31 01:52:20 -04:00
|
|
|
;data
|
|
|
|
;cur-pos JSR2 #0001 SUB2
|
|
|
|
&loop
|
2022-04-01 00:44:07 -04:00
|
|
|
GTH2k ,&fail JCN
|
2022-03-31 01:52:20 -04:00
|
|
|
DUP2 ;matches-at JSR2
|
|
|
|
ORA ,&found JCN
|
|
|
|
#0001 SUB2 ,&loop JMP
|
|
|
|
&found
|
2022-04-01 12:11:09 -04:00
|
|
|
NIP2 ;jump-to-pos JSR2 #01 JMP2r
|
2022-03-31 01:52:20 -04:00
|
|
|
&fail
|
2022-04-01 12:11:09 -04:00
|
|
|
;redraw-cursor JSR2 POP2 POP2 #00 JMP2r
|
2022-03-31 23:21:49 -04:00
|
|
|
|
2022-04-01 12:11:09 -04:00
|
|
|
@move-to-next-regex-match ( -> ok^ )
|
2022-03-31 23:21:49 -04:00
|
|
|
.buffer/limit LDZ2
|
|
|
|
;cur-pos JSR2 INC2
|
|
|
|
&loop
|
2022-04-01 12:11:09 -04:00
|
|
|
GTH2k #00 EQU ,&fail JCN
|
2022-03-31 23:21:49 -04:00
|
|
|
( ;search-start ;search-end )
|
|
|
|
( DUP2 ;matches-at JSR2 )
|
|
|
|
DUP2 .searching/regex LDR2 ;rx-search
|
|
|
|
,&found JCN
|
|
|
|
INC2 ( TODO move to next line )
|
|
|
|
,&loop JMP
|
|
|
|
&found
|
2022-03-31 01:52:20 -04:00
|
|
|
POP2 POP2
|
2022-03-31 23:21:49 -04:00
|
|
|
;search-start LDA2
|
|
|
|
;jump-to-pos JSR2 #01 JMP2r
|
|
|
|
&fail
|
2022-04-01 12:11:09 -04:00
|
|
|
POP2 POP2 #00 JMP2r
|
2022-03-31 23:21:49 -04:00
|
|
|
|
2022-04-01 12:11:09 -04:00
|
|
|
@move-to-prev-regex-match ( -> ok^ )
|
2022-03-31 23:21:49 -04:00
|
|
|
#00 JMP2r
|
|
|
|
( ;data
|
|
|
|
;cur-pos JSR2 #0001 SUB2
|
|
|
|
&loop
|
2022-04-01 00:44:07 -04:00
|
|
|
GTH2k ,&fail JCN
|
2022-03-31 23:21:49 -04:00
|
|
|
DUP2 ;matches-at JSR2
|
|
|
|
ORA ,&found JCN
|
|
|
|
#0001 SUB2 ,&loop JMP
|
|
|
|
&found
|
|
|
|
NIP2 ;jump-to-pos JSR2 #01 ,&done JMP
|
|
|
|
&fail
|
|
|
|
POP2 POP2 #00
|
|
|
|
&done
|
2022-04-01 12:11:09 -04:00
|
|
|
JMP2r )
|
2022-03-29 00:02:22 -04:00
|
|
|
|
|
|
|
@on-key-searching
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ #07 EQU ( C-g ) ;cancel-search JCN2
|
|
|
|
.state/key LDZ #0d EQU ( \r ) ;finish-search JCN2
|
2022-03-31 23:21:49 -04:00
|
|
|
.state/key LDZ #12 EQU ( C-r ) ;jump-to-prev-match JCN2
|
|
|
|
.state/key LDZ #13 EQU ( C-s ) ;jump-to-next-match JCN2
|
|
|
|
.state/key LDZ #6e EQU ( n ) ;jump-to-next-match JCN2
|
|
|
|
.state/key LDZ #70 EQU ( p ) ;jump-to-prev-match JCN2
|
2022-03-29 00:02:22 -04:00
|
|
|
;ignore JMP2
|
|
|
|
|
2022-03-23 21:46:59 -04:00
|
|
|
@on-key-prompt
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ #07 EQU ( C-g ) ;cancel-prompt JCN2
|
|
|
|
.state/key LDZ #0d EQU ( \r ) ;finish-prompt JCN2
|
|
|
|
.state/key LDZ #7f EQU ( DEL ) ;backspace-prompt JCN2
|
|
|
|
.state/key LDZ #20 LTH ;ignore JCN2 ( ignore for now )
|
|
|
|
.state/key LDZ #7e GTH ;ignore JCN2 ( ignore for now )
|
|
|
|
.state/key LDZ ( printable ASCII ) ;insert-prompt JMP2
|
2022-03-23 21:46:59 -04:00
|
|
|
BRK
|
|
|
|
|
2022-03-23 22:55:03 -04:00
|
|
|
( TODO: C-h for help )
|
2022-02-09 20:04:12 -05:00
|
|
|
@on-key
|
2022-03-31 00:27:29 -04:00
|
|
|
.Console/read DEI .state/key STZ
|
2022-03-23 22:55:03 -04:00
|
|
|
;clear-message-line JSR2
|
2022-03-29 00:02:22 -04:00
|
|
|
.searching/active LDZ ;on-key-searching JCN2
|
2022-03-23 21:46:59 -04:00
|
|
|
.prompt/active LDZ ;on-key-prompt JCN2
|
2022-03-24 01:26:06 -04:00
|
|
|
.state/saw-vt LDZ ;on-key-vt JCN2
|
|
|
|
.state/saw-xterm LDZ ;on-key-xterm JCN2
|
2022-03-07 22:38:02 -05:00
|
|
|
.state/saw-esc LDZ ;on-key-escaped JCN2
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ #01 EQU ( C-a ) ;bol JCN2
|
|
|
|
.state/key LDZ #02 EQU ( C-b ) ;back JCN2
|
|
|
|
.state/key LDZ #04 EQU ( C-d ) ;delete JCN2
|
|
|
|
.state/key LDZ #05 EQU ( C-e ) ;eol JCN2
|
|
|
|
.state/key LDZ #06 EQU ( C-f ) ;forward JCN2
|
2022-03-31 23:21:49 -04:00
|
|
|
.state/key LDZ #09 EQU ( \t ) ;insert-tab JCN2
|
2022-03-30 23:41:16 -04:00
|
|
|
.state/key LDZ #0c EQU ( C-l ) ;center-view JCN2
|
|
|
|
.state/key LDZ #0d EQU ( \r ) ;newline JCN2
|
|
|
|
.state/key LDZ #0e EQU ( C-n ) ;down JCN2
|
|
|
|
.state/key LDZ #0f EQU ( C-o ) ;save JCN2
|
|
|
|
.state/key LDZ #10 EQU ( C-p ) ;up JCN2
|
|
|
|
.state/key LDZ #13 EQU ( C-s ) ;search JCN2
|
|
|
|
.state/key LDZ #16 EQU ( C-v ) ;page-down JCN2
|
|
|
|
.state/key LDZ #18 EQU ( C-x ) ;quit JCN2
|
|
|
|
.state/key LDZ #1a EQU ( C-z ) ;debug JCN2
|
|
|
|
.state/key LDZ #1b EQU ( ESC ) ;escape JCN2
|
|
|
|
.state/key LDZ #7f EQU ( DEL ) ;backspace JCN2
|
|
|
|
.state/key LDZ #20 LTH ;ignore JCN2 ( ignore for now )
|
|
|
|
.state/key LDZ #7e GTH ;ignore JCN2 ( ignore for now )
|
|
|
|
.state/key LDZ ( printable ASCII ) ;insert JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-15 21:58:12 -05:00
|
|
|
@min2 ( x* y* -> min* )
|
|
|
|
LTH2k JMP SWP2 POP2 JMP2r
|
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@term-move-cursor ( col* row* -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi INC2 ( row+1 ) ;emit-dec2 JSR2
|
|
|
|
emit-; INC2 ( col+1 ) ;emit-dec2 JSR2
|
|
|
|
emit-H JMP2r
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-03-03 21:12:26 -05:00
|
|
|
@term-move-right ( n* -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi ;emit-dec2 JSR2 emit-C JMP2r
|
2022-03-03 21:12:26 -05:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@term-get-cursor-position ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi emit-6 emit-n JMP2r
|
2022-02-09 01:05:11 -05:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@term-erase-all ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi emit-2 emit-J JMP2r
|
2022-02-09 01:05:11 -05:00
|
|
|
|
2022-03-30 01:26:33 -04:00
|
|
|
@redraw-add ( n^ -> )
|
|
|
|
.state/redraw LDZk ROT ORA SWP STZ JMP2r
|
|
|
|
|
|
|
|
@redraw-cursor ( -> ) #01 ;redraw-add JMP2
|
|
|
|
@redraw-statusbar ( -> ) #02 ;redraw-add JMP2
|
|
|
|
@redraw-statusbar-and-cursor ( -> ) #03 ;redraw-add JMP2
|
|
|
|
@redraw-prompt-and-cursor ( -> ) #05 ;redraw-add JMP2
|
|
|
|
@redraw-all ( -> ) #1f ;redraw-add JMP2
|
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@draw-cursor ( -> )
|
2022-03-23 21:46:59 -04:00
|
|
|
.prompt/active LDZ ,&on-prompt JCN
|
2022-04-01 12:11:09 -04:00
|
|
|
( TODO: handle long lines )
|
2022-03-11 00:48:52 -05:00
|
|
|
;cur-w-col JSR2 .term/lmargin LDZ2 ADD2
|
|
|
|
;cur-rel-row JSR2
|
|
|
|
;term-move-cursor JMP2
|
2022-03-23 21:46:59 -04:00
|
|
|
&on-prompt
|
|
|
|
JMP2r
|
2022-02-09 01:05:11 -05:00
|
|
|
|
2022-03-23 22:55:03 -04:00
|
|
|
@get-save-status
|
|
|
|
.state/modified LDZ ,&is-modified JCN
|
|
|
|
;messages/saved JMP2r
|
|
|
|
&is-modified ;messages/unsaved JMP2r
|
|
|
|
|
2022-03-25 00:12:09 -04:00
|
|
|
@get-tab-status
|
|
|
|
.config/insert-tabs LDZ ,&tabs JCN
|
|
|
|
;messages/st-spaces JMP2r
|
|
|
|
&tabs ;messages/st-tabs JMP2r
|
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@draw-statusbar ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .term/rows LDZ2 ;term-move-cursor JSR2
|
2022-03-04 15:30:26 -05:00
|
|
|
;emit-color-reverse JSR2
|
2022-02-09 01:05:11 -05:00
|
|
|
LIT2r 2018
|
2022-03-07 22:38:02 -05:00
|
|
|
.term/cols LDZ2 #0000
|
2022-02-09 01:05:11 -05:00
|
|
|
&loop GTH2k ,&continue JCN ,&done JMP
|
|
|
|
&continue DEOkr INC2 ,&loop JMP
|
|
|
|
&done POP2 POP2 POP2r
|
2022-02-11 15:39:49 -05:00
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .term/rows LDZ2 ;term-move-cursor JSR2
|
2022-03-23 22:55:03 -04:00
|
|
|
;get-save-status JSR2 ;print JSR2
|
2022-02-11 15:39:49 -05:00
|
|
|
;filename ;print JSR2
|
2022-03-25 02:22:28 -04:00
|
|
|
sp
|
|
|
|
emit-[
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/limit LDZ2 ;data SUB2 ;emit-dec2 JSR2
|
2022-02-11 15:39:49 -05:00
|
|
|
;messages/bytes ;print JSR2
|
2022-03-25 02:22:28 -04:00
|
|
|
sp
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/line-count LDZ2 ;emit-dec2 JSR2
|
2022-02-11 15:39:49 -05:00
|
|
|
;messages/lines ;print JSR2
|
2022-03-25 02:22:28 -04:00
|
|
|
sp
|
|
|
|
emit-(
|
2022-03-11 00:06:48 -05:00
|
|
|
;cur-col JSR2 INC2 ;emit-dec2 JSR2
|
2022-03-25 02:22:28 -04:00
|
|
|
emit-,
|
2022-02-12 02:25:41 -05:00
|
|
|
;cur-abs-row JSR2 INC2 ;emit-dec2 JSR2
|
2022-03-25 02:22:28 -04:00
|
|
|
emit-)
|
|
|
|
sp
|
2022-03-25 00:12:09 -04:00
|
|
|
;get-tab-status JSR2 ;print JSR2
|
2022-04-01 12:11:09 -04:00
|
|
|
sp .counter LDZ2 ;emit-dec2 JSR2 ( FIXME )
|
2022-03-04 15:30:26 -05:00
|
|
|
;emit-reset JSR2
|
2022-02-09 01:05:11 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-03-23 21:46:59 -04:00
|
|
|
@draw-prompt ( -> )
|
2022-03-23 22:55:03 -04:00
|
|
|
;clear-message-line JSR2
|
2022-03-23 21:46:59 -04:00
|
|
|
.prompt/active LDZ ,&is-active JCN
|
|
|
|
JMP2r
|
|
|
|
&is-active
|
|
|
|
;emit-color-bold JSR2
|
|
|
|
.prompt/string LDZ2 ;print JSR2
|
|
|
|
;emit-reset JSR2
|
|
|
|
;tmp/data ;print JSR2
|
|
|
|
JMP2r
|
|
|
|
|
2022-03-03 21:12:26 -05:00
|
|
|
@draw-linenum ( n* -> )
|
2022-03-04 15:30:26 -05:00
|
|
|
;emit-reset JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
ansi .config/color LDZ2 emit emit emit-m
|
2022-03-03 21:12:26 -05:00
|
|
|
;emit-dec2-pad JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
ansi emit-0 emit-m JMP2r
|
2022-03-03 21:12:26 -05:00
|
|
|
|
2022-03-29 00:02:22 -04:00
|
|
|
@matches-at ( s* -> limit* )
|
|
|
|
LIT2r :tmp/data
|
|
|
|
&loop
|
|
|
|
LDAkr STHr ,&non-zero JCN ,&done JMP
|
|
|
|
&non-zero
|
|
|
|
LDAk LDAkr STHr NEQ ,&fail JCN
|
|
|
|
INC2 INC2r ,&loop JMP
|
|
|
|
&done
|
|
|
|
POP2r JMP2r
|
|
|
|
&fail
|
|
|
|
POP2r POP2 #0000 JMP2r
|
|
|
|
|
|
|
|
@draw-region ( offset* limit* col* row* -> )
|
|
|
|
OVR2 ( offset limit col row col )
|
|
|
|
.term/cols LDZ2 SWP2 SUB2 STH2 ( offset limit col row [cols-col] )
|
|
|
|
;term-move-cursor JSR2 ( offset limit [cols-col] )
|
|
|
|
OVR2 STH2r ADD2 ( offset limit offset+cols-col )
|
|
|
|
;min2 JSR2 STH2 ( offset [cutoff] )
|
|
|
|
&loop ( i [cutoff] )
|
|
|
|
DUP2 STH2kr LTH2 ,&continue JCN ,&done JMP
|
|
|
|
&continue ( i [cutoff] )
|
|
|
|
LDAk #00 EQU ,&done JCN
|
|
|
|
LDAk #18 DEO INC2 ,&loop JMP
|
|
|
|
&done
|
|
|
|
POP2 POP2r JMP2r
|
|
|
|
|
|
|
|
@screen-limit ( -> sc-limit* )
|
|
|
|
.term/rows LDZ2 .buffer/line-offset LDZ2 ADD2 ( row0+rows )
|
|
|
|
DUP2 .buffer/line-count LDZ2 LTH2 ,¬-end JCN
|
|
|
|
POP2 .buffer/limit LDZ2 JMP2r
|
|
|
|
¬-end
|
|
|
|
;abs-line JMP2
|
|
|
|
|
2022-04-01 12:11:09 -04:00
|
|
|
( TODO: enable drawing of regex matches )
|
|
|
|
( requires a way to anchor our regex on the LHS (e.g. ^) )
|
2022-03-29 00:02:22 -04:00
|
|
|
@draw-matches ( -> )
|
|
|
|
( return if not searching )
|
|
|
|
.searching/active LDZ #00 EQU ,&return JCN ( )
|
|
|
|
;emit-color-reverse JSR2
|
|
|
|
|
2022-03-30 01:26:33 -04:00
|
|
|
.term/lmargin LDZ2 ,&x STR2 #0000 ,&y STR2 ( x <- 0, y <- 0 )
|
2022-03-29 00:02:22 -04:00
|
|
|
|
|
|
|
.buffer/offset LDZ2 DUP2
|
|
|
|
;screen-limit JSR2 SUB2 STH2 ( offset [-count] )
|
|
|
|
|
|
|
|
&loop ( offset [-count] )
|
|
|
|
STH2kr #0000 EQU2 ,&done JCN
|
|
|
|
DUP2 ;matches-at JSR2 ( offset mlim [-count] )
|
|
|
|
DUP2 ORA ,&found JCN
|
|
|
|
POP2 ( offset [-count] )
|
|
|
|
LDAk #0a EQU ,&newline JCN
|
|
|
|
#0001 ,&next JMP ( offset n [-count] )
|
|
|
|
&found ( offset mlim [-count] )
|
|
|
|
STH2k ( offset mlim [mlim -count] )
|
|
|
|
OVR2 SWP2 ,&x LDR2 ,&y LDR2 ( offset offset mlim x y [mlim -count] )
|
|
|
|
;draw-region JSR2 ( offset [mlim -count] ) ( POP2 POP2 POP2 POP2 ( FIXME ) )
|
|
|
|
STH2r ( offset mlim [-count] )
|
|
|
|
OVR2 SUB2 ( offset mlim-offset [-count] )
|
|
|
|
&next ( offset n [-count] )
|
|
|
|
DUP2 ,&x LDR2 ADD2 ,&x STR2 ( offset n [-count )
|
|
|
|
STH2k ( offset n [n -count] )
|
|
|
|
ADD2 ADD2r ( offset+n [n-count] )
|
|
|
|
,&loop JMP
|
|
|
|
&newline ( offset [-count] )
|
2022-03-30 01:26:33 -04:00
|
|
|
.term/lmargin LDZ2 ,&x STR2
|
2022-03-29 00:02:22 -04:00
|
|
|
,&y LDR2 INC2 ,&y STR2
|
|
|
|
INC2 INC2r
|
|
|
|
,&loop JMP
|
|
|
|
&done
|
|
|
|
POP2 POP2r
|
|
|
|
;emit-reset JSR2
|
|
|
|
&return
|
|
|
|
JMP2r
|
|
|
|
[ &x $2 &y $2 ]
|
|
|
|
|
2022-03-03 21:12:26 -05:00
|
|
|
@emit-tab ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
#0000 .config/tab-width LDZ2 SUB2
|
2022-03-03 21:12:26 -05:00
|
|
|
LIT2r 2018
|
|
|
|
&loop ORAk ,&next JCN POP2 POP2r JMP2r
|
|
|
|
&next DEOkr INC2 ,&loop JMP
|
|
|
|
|
2022-03-04 01:47:11 -05:00
|
|
|
@emit-red ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi emit-3 emit-1 emit-m JMP2r
|
2022-03-04 01:47:11 -05:00
|
|
|
|
|
|
|
@emit-reset ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi emit-0 emit-m JMP2r
|
2022-03-04 01:47:11 -05:00
|
|
|
|
|
|
|
@emit-red-dollar ( -> )
|
2022-03-30 01:26:33 -04:00
|
|
|
;emit-red JSR2 emit-$ ;emit-reset JMP2
|
2022-03-04 01:47:11 -05:00
|
|
|
|
2022-03-04 15:30:26 -05:00
|
|
|
@emit-color-reverse ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi .config/color LDZ2 emit emit emit-; emit-7 emit-m JMP2r
|
2022-03-04 15:30:26 -05:00
|
|
|
|
2022-03-23 21:46:59 -04:00
|
|
|
@emit-color-bold ( -> )
|
2022-03-25 02:22:28 -04:00
|
|
|
ansi .config/color LDZ2 emit emit emit-; emit-1 emit-m JMP2r
|
2022-03-23 21:46:59 -04:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@draw-all ( -> )
|
2022-02-09 01:05:11 -05:00
|
|
|
;term-erase-all JSR2
|
2022-02-18 00:20:09 -05:00
|
|
|
#0000 #0000 ;term-move-cursor JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/line-offset LDZ2 STH2 LIT2r 0001 ( [k line-offset] )
|
|
|
|
.buffer/offset LDZ2
|
2022-03-04 15:30:26 -05:00
|
|
|
&bol
|
|
|
|
ADD2kr STH2r ;draw-linenum JSR2
|
2022-03-07 22:38:02 -05:00
|
|
|
.term/lmargin LDZ2 INC2 ,&x STR2
|
2022-03-04 01:47:11 -05:00
|
|
|
&loop ( offset [k line-offset] )
|
2022-03-04 15:30:26 -05:00
|
|
|
LDAk #00 EQU ,&eof JCN
|
|
|
|
LDAk #0a EQU ,&eol JCN
|
2022-03-07 22:38:02 -05:00
|
|
|
,&x LDR2 .term/cols LDZ2
|
2022-03-04 01:47:11 -05:00
|
|
|
LTH2k ,&ok JCN
|
|
|
|
GTH2 ,&skip JCN
|
|
|
|
;emit-red-dollar JSR2 ,&x LDR2 INC2 ,&x STR2
|
2022-03-04 15:30:26 -05:00
|
|
|
&skip INC2
|
2022-03-11 00:06:48 -05:00
|
|
|
,&loop JMP
|
2022-03-04 01:47:11 -05:00
|
|
|
&ok POP2 POP2
|
2022-03-04 15:30:26 -05:00
|
|
|
LDAk #09 EQU ,&do-tab JCN
|
|
|
|
LDAk emit INC2 ,&x LDR2 INC2 ,&x STR2
|
|
|
|
,&loop JMP
|
|
|
|
&eol INC2r
|
2022-03-11 00:06:48 -05:00
|
|
|
STH2kr .term/rows LDZ2 GTH2 ,&done JCN
|
|
|
|
cr nl INC2 ,&bol JMP
|
2022-03-04 15:30:26 -05:00
|
|
|
&do-tab ;emit-tab JSR2 INC2
|
2022-03-07 22:38:02 -05:00
|
|
|
.config/tab-width LDZ2 ,&x LDR2 ADD2 ,&x STR2
|
2022-03-04 15:30:26 -05:00
|
|
|
,&loop JMP
|
2022-03-04 01:47:11 -05:00
|
|
|
[ &x $2 ]
|
2022-02-13 14:46:50 -05:00
|
|
|
&eof
|
2022-03-04 01:47:11 -05:00
|
|
|
;emit-red JSR2
|
2022-02-13 14:46:50 -05:00
|
|
|
&eof-loop
|
2022-03-07 22:38:02 -05:00
|
|
|
STH2kr .term/rows LDZ2 GTH2 ,&done JCN
|
2022-02-13 14:46:50 -05:00
|
|
|
cr nl
|
2022-03-07 22:38:02 -05:00
|
|
|
.term/lmargin LDZ2 ;term-move-right JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
emit-~ INC2r
|
2022-02-13 14:46:50 -05:00
|
|
|
,&eof-loop JMP
|
2022-03-03 21:12:26 -05:00
|
|
|
&done POP2 POP2r POP2r
|
2022-03-04 01:47:11 -05:00
|
|
|
;emit-reset JSR2
|
2022-03-29 00:02:22 -04:00
|
|
|
;draw-matches JSR2
|
2022-02-12 02:10:27 -05:00
|
|
|
;draw-statusbar JSR2
|
2022-03-30 01:26:33 -04:00
|
|
|
;draw-prompt JSR2
|
|
|
|
;draw-cursor JSR2
|
2022-02-06 17:07:11 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-03-30 01:26:33 -04:00
|
|
|
( handler completion code to do necessary drawing and BRK )
|
|
|
|
@return ( -> )
|
2022-03-31 23:21:49 -04:00
|
|
|
.state/redraw LDZ
|
|
|
|
DUP #10 AND ,&draw-all JCN
|
|
|
|
DUP #08 AND ,&do-8 JCN ,&skip-8 JMP &do-8 ;draw-matches JSR2
|
|
|
|
&skip-8 DUP #04 AND ,&do-4 JCN ,&skip-4 JMP &do-4 ;draw-prompt JSR2
|
|
|
|
&skip-4 DUP #02 AND ,&do-2 JCN ,&skip-2 JMP &do-2 ;draw-statusbar JSR2
|
2022-04-01 12:11:09 -04:00
|
|
|
&skip-2 DUP #01 AND ,&do-1 JCN ,&finish JMP &do-1 ;draw-cursor JSR2 ,&finish JMP
|
|
|
|
&draw-all .counter LDZ2k INC2 ROT STZ2 ;draw-all JSR2
|
|
|
|
&finish POP #00 .state/redraw STZ BRK
|
2022-03-30 01:26:33 -04:00
|
|
|
|
2022-02-11 15:39:49 -05:00
|
|
|
@str-copy ( src* dst* -> )
|
|
|
|
STH2 ( src [dst] )
|
|
|
|
&loop LDAk #00 EQU ,&done JCN
|
|
|
|
LDAk STH2kr STA
|
|
|
|
INC2 INC2r ,&loop JMP
|
|
|
|
&done POP2 #00 STH2r STA
|
|
|
|
JMP2r
|
|
|
|
|
2022-03-23 21:46:59 -04:00
|
|
|
@str-len ( s* -> n* )
|
|
|
|
LIT2r 0000
|
|
|
|
&loop LDAk #00 EQU ,&done JCN
|
|
|
|
INC2 INC2r ,&loop JMP
|
|
|
|
&done POP2 STH2r
|
|
|
|
JMP2r
|
|
|
|
|
2022-02-11 15:39:49 -05:00
|
|
|
@print ( s* -> )
|
2022-02-06 17:07:11 -05:00
|
|
|
&loop LDAk #00 EQU ,&eof JCN
|
|
|
|
LDAk #18 DEO INC2 ,&loop JMP
|
|
|
|
&eof POP2 JMP2r
|
|
|
|
|
|
|
|
@cur-len ( -> n* )
|
2022-03-07 12:56:52 -05:00
|
|
|
;cur-line JSR2 ;line-len JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
|
|
|
@line-len ( s* -> n* )
|
|
|
|
#0000 STH2
|
|
|
|
&loop LDAk #00 EQU ,&end JCN
|
|
|
|
LDAk #0a EQU ,&end JCN
|
2022-03-03 21:12:26 -05:00
|
|
|
INC2 INC2r ,&loop JMP
|
2022-02-06 17:07:11 -05:00
|
|
|
&end POP2 STH2r JMP2r
|
|
|
|
|
2022-03-31 13:48:08 -04:00
|
|
|
@line-is-visible ( n* -> bool^ )
|
|
|
|
.buffer/line-offset LDZ2 LTH2k ,&no JCN
|
|
|
|
.term/rows LDZ2 ADD2 LTH2 JMP2r
|
|
|
|
&no POP2 POP2 #00 JMP2r
|
|
|
|
|
2022-03-31 00:27:29 -04:00
|
|
|
@jump-to-pos ( s* -> )
|
2022-03-31 23:21:49 -04:00
|
|
|
;pos-to-row-col JSR2 SWP2 ;move-to-coord JMP2
|
2022-03-31 00:27:29 -04:00
|
|
|
|
|
|
|
@pos-to-row-col ( s* -> row* col* )
|
|
|
|
#0000 ,&row STR2
|
|
|
|
#0000 ,&col STR2
|
|
|
|
;data
|
|
|
|
&loop ( s pos )
|
|
|
|
GTH2k ,&next JCN ,&done JMP
|
|
|
|
&next
|
|
|
|
LDAk #0a EQU ,&newline JCN
|
|
|
|
,&col LDR2 INC2 ,&col STR2
|
|
|
|
INC2 ,&loop JMP
|
|
|
|
&newline
|
|
|
|
#0000 ,&col STR2
|
|
|
|
,&row LDR2 INC2 ,&row STR2
|
|
|
|
INC2 ,&loop JMP
|
|
|
|
&done
|
2022-03-31 01:52:20 -04:00
|
|
|
POP2 POP2
|
2022-03-31 00:27:29 -04:00
|
|
|
,&row LDR2 ,&col LDR2 JMP2r
|
|
|
|
[ &row $2 &col $2 ]
|
|
|
|
|
2022-02-10 01:40:48 -05:00
|
|
|
@abs-line ( y* -> s* )
|
|
|
|
#0000 SWP2 SUB2 STH2 ( [-y] )
|
2022-03-07 22:38:02 -05:00
|
|
|
;data ( addr )
|
2022-02-10 01:40:48 -05:00
|
|
|
&newline ( addr [-y] )
|
|
|
|
STH2kr ORA ,&loop JCN ,&done JMP
|
|
|
|
&loop ( addr [-y] )
|
|
|
|
LDAk #00 EQU ,¬-found JCN ( addr [-y] )
|
|
|
|
LDAk #0a EQU ,&found JCN ( addr [-y] )
|
|
|
|
INC2 ,&loop JMP ( addr+1 [-y] )
|
|
|
|
&found INC2 INC2r ( addr+1 [-y+1] ) ,&newline JMP
|
|
|
|
&done POP2r JMP2r
|
|
|
|
¬-found POP2 POP2r #0000 JMP2r
|
|
|
|
|
2022-02-06 17:07:11 -05:00
|
|
|
( line number relative to the offset, starting at 0 )
|
2022-02-18 00:20:09 -05:00
|
|
|
@rel-line ( y* -> s* )
|
|
|
|
#0000 SWP2 SUB2 STH2 ( [-y] )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/offset LDZ2 ( addr* )
|
2022-02-18 00:20:09 -05:00
|
|
|
STH2kr #0000 EQU2 ,&done JCN ( addr [-y] )
|
2022-02-06 17:07:11 -05:00
|
|
|
&newline ( addr [-y] )
|
2022-02-18 00:20:09 -05:00
|
|
|
STH2kr ORA ,&loop JCN ,&done JMP
|
2022-02-06 17:07:11 -05:00
|
|
|
&loop ( addr [-y] )
|
|
|
|
LDAk #00 EQU ,¬-found JCN ( addr [-y] )
|
|
|
|
LDAk #0a EQU ,&found JCN ( addr [-y] )
|
|
|
|
INC2 ,&loop JMP ( addr+1 [-y] )
|
2022-02-18 00:20:09 -05:00
|
|
|
&found INC2 INC2r ( addr+1 [-y+1] ) ,&newline JMP
|
|
|
|
&done POP2r JMP2r
|
2022-03-25 00:12:09 -04:00
|
|
|
¬-found ;messages/rel-line-error ;error! JMP2
|
2022-02-06 17:07:11 -05:00
|
|
|
|
|
|
|
@cur-line ( -> s* )
|
2022-03-26 15:29:00 -04:00
|
|
|
;cur-rel-row JSR2 .term/rows LDZ2 LTH2 ,&safe JCN
|
|
|
|
.cursor/row LDZ2 ;abs-line JMP2
|
|
|
|
&safe ;cur-rel-row JSR2 ;rel-line JMP2
|
2022-02-14 16:47:36 -05:00
|
|
|
|
2022-02-06 17:07:11 -05:00
|
|
|
@cur-pos ( -> s* )
|
2022-02-18 00:20:09 -05:00
|
|
|
;cur-line JSR2 ;cur-col JSR2 ADD2 JMP2r
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-02-12 02:10:27 -05:00
|
|
|
@cur-abs-row ( -> n* )
|
2022-03-07 22:38:02 -05:00
|
|
|
;cur-rel-row JSR2 .buffer/line-offset LDZ2 ADD2 JMP2r
|
2022-02-12 02:10:27 -05:00
|
|
|
|
2022-02-13 14:46:50 -05:00
|
|
|
@last-abs-row ( -> n* )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/line-count LDZ2 #0001 SUB2 JMP2r
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-02-06 17:07:11 -05:00
|
|
|
@shift-right ( c^ addr* -> )
|
|
|
|
ROT STH ( addr [prev^] )
|
2022-02-14 16:47:36 -05:00
|
|
|
;last-pos JSR2 SWP2 ( last addr [prev^] )
|
2022-02-06 17:07:11 -05:00
|
|
|
&loop LTH2k ,&done JCN ( last addr [prev^] )
|
|
|
|
LDAk STH SWPr ( last addr [prev^ curr^] )
|
|
|
|
DUP2 STHr ( last addr addr prev^ [curr^] )
|
|
|
|
ROT ROT STA ( last addr [curr^] )
|
|
|
|
INC2 ,&loop JMP ( last addr+1 [curr^] )
|
|
|
|
&done NIP2 DUP2 ( addr addr [prev^] )
|
|
|
|
STHr ROT ROT ( addr prev^ addr )
|
|
|
|
STA INC2 ( addr+1 )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/limit STZ2 ( )
|
2022-02-06 17:07:11 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-02-13 14:46:50 -05:00
|
|
|
( TODO: change last/addr order and GTH -> LTH to remove hack )
|
2022-02-06 17:07:11 -05:00
|
|
|
@shift-left ( addr* -> )
|
2022-02-14 16:47:36 -05:00
|
|
|
;last-pos JSR2 SWP2 ( last addr )
|
2022-02-13 14:46:50 -05:00
|
|
|
&loop GTH2k ,&next JCN ( last addr )
|
|
|
|
,&done JMP ( last addr )
|
|
|
|
&next DUP2 INC2 LDAk ( last addr addr+1 c1^ )
|
|
|
|
STH SWP2 STHr ( last addr+1 addr c1^ )
|
|
|
|
ROT ROT ( last addr+1 c1^ addr )
|
|
|
|
STA ,&loop JMP ( last addr+1 )
|
|
|
|
&done POP2 ( last )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/limit STZ2 ( )
|
|
|
|
#00 .buffer/limit LDZ2 STA ( ensure null termination )
|
2022-02-06 17:07:11 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@cur-col ( -> col* )
|
2022-03-07 22:38:02 -05:00
|
|
|
.cursor/col LDZ2 ;cur-len JSR2 ;min2 JMP2
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-03-03 21:12:26 -05:00
|
|
|
@cur-w-col ( -> col* )
|
|
|
|
LIT2r 0000 ( [0] )
|
|
|
|
;cur-line JSR2 DUP2 ;cur-col JSR2 ADD2 SWP2 ( lim s [0] )
|
|
|
|
&loop GTH2k ,&next JCN
|
|
|
|
POP2 POP2 STH2r JMP2r
|
2022-03-07 22:38:02 -05:00
|
|
|
&next LDAk #09 EQU ,&tabs JCN INC2 INC2r ,&loop JMP
|
|
|
|
&tabs INC2 .config/tab-width LDZ2 STH2 ADD2r ,&loop JMP
|
2022-03-03 21:12:26 -05:00
|
|
|
|
2022-03-06 15:35:14 -05:00
|
|
|
@cur-rel-row ( -> row* )
|
2022-03-26 15:29:00 -04:00
|
|
|
.cursor/row LDZ2 .buffer/line-offset LDZ2 SUB2 JMP2r
|
2022-02-06 17:07:11 -05:00
|
|
|
|
2022-03-06 15:35:14 -05:00
|
|
|
@set-abs-row ( n* -> )
|
2022-03-26 15:29:00 -04:00
|
|
|
.cursor/row STZ2 JMP2r
|
2022-03-06 15:35:14 -05:00
|
|
|
|
|
|
|
@zero-row ( -> )
|
2022-03-07 22:38:02 -05:00
|
|
|
;data .buffer/offset STZ2
|
|
|
|
#0000 .buffer/line-offset STZ2
|
|
|
|
#0000 .cursor/row STZ2
|
2022-03-06 15:35:14 -05:00
|
|
|
JMP2r
|
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
( @inc-row ( -> )
|
|
|
|
.cursor/row LDZ2 INC2 .cursor/row STZ2 JMP2r )
|
2022-03-06 15:35:14 -05:00
|
|
|
|
2022-03-31 23:21:49 -04:00
|
|
|
( @dec-row ( -> )
|
|
|
|
.cursor/row LDZ2 #0001 SUB2 .cursor/row STZ2 JMP2r )
|
2022-03-06 15:35:14 -05:00
|
|
|
|
2022-02-18 00:20:09 -05:00
|
|
|
@last-pos ( -> addr* )
|
2022-03-07 22:38:02 -05:00
|
|
|
.buffer/limit LDZ2 #0001 SUB2 JMP2r
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-03-26 15:29:00 -04:00
|
|
|
( @more-than-one-screen ( -> bool^ )
|
|
|
|
.buffer/line-count LDZ2 .term/rows LDZ2 GTH2 JMP2r )
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-03-25 00:12:09 -04:00
|
|
|
( @fits-in-one-screen ( -> bool^ )
|
|
|
|
.buffer/line-count LDZ2 .term/rows LDZ2 INC2 LTH2 JMP2r )
|
2022-02-13 14:46:50 -05:00
|
|
|
|
2022-03-25 02:22:28 -04:00
|
|
|
( @mod-div ( x^ y^ -> x%d x/y )
|
|
|
|
DIVk STHk MUL SUB STHr JMP2r )
|
2022-02-09 01:05:11 -05:00
|
|
|
|
|
|
|
@mod-div2 ( x^ y^ -> x%d x/y )
|
|
|
|
DIV2k STH2k MUL2 SUB2 STH2r JMP2r
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-03-25 02:22:28 -04:00
|
|
|
( @base-10-width ( n* -> w* )
|
2022-03-03 21:12:26 -05:00
|
|
|
LIT2r 0000 ( n [0] )
|
|
|
|
&loop ( n [w] )
|
|
|
|
DUP2 #0000 EQU2 ,&done JCN ( n [w] )
|
|
|
|
#000a DIV2 ( n/10 [w] )
|
|
|
|
INC2r ,&loop JMP ( n/10 [w+1] )
|
|
|
|
&done ( 0 [w] )
|
2022-03-25 02:22:28 -04:00
|
|
|
POP2 STH2r JMP2r )
|
2022-02-11 15:39:49 -05:00
|
|
|
|
2022-02-07 22:25:32 -05:00
|
|
|
@emit-digit ( n^ -> )
|
|
|
|
LIT '0 ADD emit JMP2r
|
|
|
|
|
2022-03-25 02:22:28 -04:00
|
|
|
( @emit-dec ( n^ -> )
|
2022-02-07 22:25:32 -05:00
|
|
|
DUP #63 GTH ,&do3 JCN
|
|
|
|
DUP #09 GTH ,&do2 JCN
|
|
|
|
,&do1 JMP
|
|
|
|
&do3 #64 ;mod-div JSR2 ;emit-digit JSR2
|
|
|
|
&do2 #0a ;mod-div JSR2 ;emit-digit JSR2
|
2022-03-25 02:22:28 -04:00
|
|
|
&do1 ;emit-digit JMP2 )
|
2022-02-07 22:25:32 -05:00
|
|
|
|
2022-02-09 01:05:11 -05:00
|
|
|
@emit-dec2 ( n* -> )
|
|
|
|
DUP2 #270f GTH2 ,&do5 JCN
|
|
|
|
DUP2 #03e7 GTH2 ,&do4 JCN
|
|
|
|
DUP2 #0063 GTH2 ,&do3 JCN
|
|
|
|
DUP2 #0009 GTH2 ,&do2 JCN
|
|
|
|
,&do1 JMP
|
|
|
|
&do5 #2710 ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
2022-02-11 15:39:49 -05:00
|
|
|
&do4 #03e8 ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
2022-02-09 01:05:11 -05:00
|
|
|
&do3 #0064 ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
|
|
|
&do2 #000a ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
2022-03-07 12:56:52 -05:00
|
|
|
&do1 NIP ;emit-digit JMP2
|
2022-02-09 01:05:11 -05:00
|
|
|
|
2022-03-03 21:12:26 -05:00
|
|
|
@emit-dec2-pad ( n* -> )
|
|
|
|
LIT2r 2018 ( preload #20 .Console/write into rst )
|
|
|
|
DUP2 #270f GTH2 ,&do5 JCN DEOkr
|
|
|
|
DUP2 #03e7 GTH2 ,&do4 JCN DEOkr
|
|
|
|
DUP2 #0063 GTH2 ,&do3 JCN DEOkr
|
|
|
|
DUP2 #0009 GTH2 ,&do2 JCN DEOkr
|
|
|
|
,&do1 JMP
|
|
|
|
&do5 #2710 ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
|
|
|
&do4 #03e8 ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
|
|
|
&do3 #0064 ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
|
|
|
&do2 #000a ;mod-div2 JSR2 NIP ;emit-digit JSR2
|
|
|
|
&do1 NIP ;emit-digit JSR2
|
|
|
|
DEOr JMP2r
|
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
( various string constants used as messages for the user )
|
2022-03-23 22:55:03 -04:00
|
|
|
@messages [ &null 00
|
|
|
|
&input-error "input 20 "error: 20 00
|
2022-02-12 02:10:27 -05:00
|
|
|
&bytes 20 "bytes, 00
|
2022-03-23 22:12:17 -04:00
|
|
|
&save-ok "Successfully 20 "saved 20 00
|
|
|
|
&save-failed "Failed 20 "to 20 "save 20 00
|
2022-02-12 02:10:27 -05:00
|
|
|
&lines 20 "lines] 00
|
2022-03-24 00:09:55 -04:00
|
|
|
&goto-line "Go 20 "to 20 "line: 20 00
|
2022-03-23 21:46:59 -04:00
|
|
|
&save-prompt "File 20 "Name 20 "to 20 "Write: 20 00
|
2022-03-29 00:02:22 -04:00
|
|
|
&search-prompt "Text 20 "to 20 "Search 20 "for: 20 00
|
2022-04-01 12:11:09 -04:00
|
|
|
®ex-search-prompt "Regex 20 "to 20 "Search 20 "for: 20 00
|
2022-03-23 22:55:03 -04:00
|
|
|
&quit-prompt "Save 20 "modified 20 "file 20 "(y/n)? 20 00
|
|
|
|
&unknown-input "Unknown 20 "input: 20 00
|
2022-03-31 23:21:49 -04:00
|
|
|
&no-matches-found "No 20 "matches 20 "found 00
|
2022-02-11 19:15:40 -05:00
|
|
|
&saved "-- 20 00
|
2022-03-25 00:12:09 -04:00
|
|
|
&unsaved "** 20 00
|
|
|
|
&term-size-parse-error "error 20 "parsing 20 "term 20 "size 00
|
|
|
|
&rel-line-error "invalid 20 "relative 20 "line 20 "number 00
|
|
|
|
&st-tabs "[t] 00
|
|
|
|
&st-spaces "[s] 00
|
|
|
|
]
|
2022-02-08 22:22:08 -05:00
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
@filename $80 ( path to file being edited )
|
2022-02-10 01:40:48 -05:00
|
|
|
|
2022-03-07 22:38:02 -05:00
|
|
|
@data $f000 ( actual file data to be edited )
|