very basic save support + docs
This commit is contained in:
parent
ad2f91f329
commit
45a3056406
59
femto.tal
59
femto.tal
|
@ -37,13 +37,9 @@
|
||||||
( blue, magenta, cyan, white )
|
( blue, magenta, cyan, white )
|
||||||
|
|
||||||
( TODO: )
|
( TODO: )
|
||||||
( - set up term scrolling at start )
|
|
||||||
( - optimize term drawing )
|
( - optimize term drawing )
|
||||||
( - get long line truncation/scrolling working )
|
( - get long line truncation/scrolling working )
|
||||||
( - unify insertion/overwrite code )
|
|
||||||
( - display cursor coords )
|
|
||||||
( - page up/page down )
|
( - page up/page down )
|
||||||
( - jump to end of buffer )
|
|
||||||
( - line numbers in left column (toggle mode?) )
|
( - line numbers in left column (toggle mode?) )
|
||||||
( - help text )
|
( - help text )
|
||||||
( - save file command -> tmp first )
|
( - save file command -> tmp first )
|
||||||
|
@ -55,6 +51,10 @@
|
||||||
( - tab support? )
|
( - tab support? )
|
||||||
( - windows line-ending support (CRLF) )
|
( - windows line-ending support (CRLF) )
|
||||||
|
|
||||||
|
( FIXME: )
|
||||||
|
( - stop using bytes for row/col/etc. )
|
||||||
|
( - consider storing absolute cursor instead )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|
|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 ]
|
|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 ]
|
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
|
||||||
|
@ -134,7 +134,6 @@
|
||||||
LDAk LIT '0 SUB #00 SWP STH2 ADD2r
|
LDAk LIT '0 SUB #00 SWP STH2 ADD2r
|
||||||
INC2 ,&loop JMP
|
INC2 ,&loop JMP
|
||||||
&parse-col
|
&parse-col
|
||||||
( INC2 STH2r ;term/rows STA2 )
|
|
||||||
INC2 STH2r #0002 SUB2 ;term/rows STA2
|
INC2 STH2r #0002 SUB2 ;term/rows STA2
|
||||||
&loop2
|
&loop2
|
||||||
LDAk LIT 'R EQU ,&done JCN
|
LDAk LIT 'R EQU ,&done JCN
|
||||||
|
@ -181,7 +180,6 @@
|
||||||
;setup-terminal-size JSR2 ( detect terminal dimensions )
|
;setup-terminal-size JSR2 ( detect terminal dimensions )
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
|
||||||
@bol
|
@bol
|
||||||
#00 ;cursor/col STA
|
#00 ;cursor/col STA
|
||||||
;draw-statusbar JSR2
|
;draw-statusbar JSR2
|
||||||
|
@ -214,7 +212,6 @@
|
||||||
;draw-cursor JSR2
|
;draw-cursor JSR2
|
||||||
&skip BRK
|
&skip BRK
|
||||||
|
|
||||||
( TODO: integrate ensure-visible-cursor to move by half-screens )
|
|
||||||
@up
|
@up
|
||||||
;cur-line-num JSR2 #0000 EQU2 ,&done JCN
|
;cur-line-num JSR2 #0000 EQU2 ,&done JCN
|
||||||
;cursor/row LDA #01 LTH ,&screen-up JCN
|
;cursor/row LDA #01 LTH ,&screen-up JCN
|
||||||
|
@ -227,7 +224,6 @@
|
||||||
;draw-all JSR2
|
;draw-all JSR2
|
||||||
&done BRK
|
&done BRK
|
||||||
|
|
||||||
( FIXME: need to handle 'end of buffer' stuff )
|
|
||||||
@down
|
@down
|
||||||
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
;cur-abs-row JSR2 ;last-abs-row JSR2 EQU2 ,&done JCN
|
||||||
;cursor/row LDA INC ;cursor/row STA
|
;cursor/row LDA INC ;cursor/row STA
|
||||||
|
@ -246,19 +242,13 @@
|
||||||
;draw-all JSR2
|
;draw-all JSR2
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
( @overwrite ( c^ -> )
|
|
||||||
;cursor/col LDA pen-col GTH ,&skip JCN ( FIXME )
|
|
||||||
;cur-pos JSR2 STA
|
|
||||||
;cursor/col LDA #01 ADD ;cursor/col STA
|
|
||||||
;draw-all JSR2
|
|
||||||
&skip BRK )
|
|
||||||
|
|
||||||
( TODO: handle last line )
|
( TODO: handle last line )
|
||||||
@newline ( c^ -> )
|
@newline ( c^ -> )
|
||||||
#0a ;cur-pos JSR2 ;shift-right JSR2
|
#0a ;cur-pos JSR2 ;shift-right JSR2
|
||||||
#00 ;cursor/col STA
|
#00 ;cursor/col STA
|
||||||
;cursor/row LDA INC ;cursor/row STA
|
;cursor/row LDA INC ;cursor/row STA
|
||||||
;buffer/line-count LDA2k INC2 SWP2 STA2
|
;buffer/line-count LDA2k INC2 SWP2 STA2
|
||||||
|
;ensure-visible-cursor JSR2
|
||||||
;draw-all JSR2
|
;draw-all JSR2
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@ -268,14 +258,14 @@
|
||||||
@at-line-start ( -> bool^ )
|
@at-line-start ( -> bool^ )
|
||||||
;cursor/col LDA #00 EQU JMP2r
|
;cursor/col LDA #00 EQU JMP2r
|
||||||
|
|
||||||
( TODO: handle first line )
|
|
||||||
@backspace ( -> )
|
@backspace ( -> )
|
||||||
;at-buffer-start JSR2 ,&skip JCN
|
;at-buffer-start JSR2 ,&skip JCN
|
||||||
;at-line-start JSR2 ,&prev-line JCN
|
;at-line-start JSR2 ,&prev-line JCN
|
||||||
;cur-col JSR2 #01 SUB ;cursor/col STA
|
;cur-col JSR2 #01 SUB ;cursor/col STA
|
||||||
,&finish JMP
|
,&finish JMP
|
||||||
&prev-line ( TODO: what if row=0 but offset>0 ? )
|
&prev-line
|
||||||
;cursor/row LDA #01 SUB ;cursor/row STA
|
;cur-line-num JSR2 #0001 SUB2
|
||||||
|
;jump-to-line JSR2 ( TODO: fix weird eof behavior )
|
||||||
;cur-len JSR2 NIP ;cursor/col STA
|
;cur-len JSR2 NIP ;cursor/col STA
|
||||||
;buffer/line-count LDA2k #0001 SUB2 SWP2 STA2
|
;buffer/line-count LDA2k #0001 SUB2 SWP2 STA2
|
||||||
&finish
|
&finish
|
||||||
|
@ -365,6 +355,24 @@
|
||||||
.Console/read DEI LIT 'g EQU ( M-g ) ;goto-line JCN2
|
.Console/read DEI LIT 'g EQU ( M-g ) ;goto-line JCN2
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@move-to-message-line ( -> )
|
||||||
|
#02 height #02 ADD ;term-move-cursor JSR2 JMP2r
|
||||||
|
|
||||||
|
( TODO: filename prmopt )
|
||||||
|
@save ( -> )
|
||||||
|
;buffer/limit LDA2 ;buffer/data SUB2 STH2 ( [size] )
|
||||||
|
;tmp-file-name .File/name DEO2
|
||||||
|
STH2kr .File/length DEO2
|
||||||
|
;buffer/data .File/write DEO2
|
||||||
|
|
||||||
|
;move-to-message-line JSR2
|
||||||
|
.File/success DEI2 STH2r EQU2 ( ok? ) ,&ok JCN
|
||||||
|
;messages/save-failed ,&finish JMP
|
||||||
|
&ok ;messages/save-ok
|
||||||
|
&finish ;print JSR2 BRK
|
||||||
|
|
||||||
|
@tmp-file-name "file.tmp 00
|
||||||
|
|
||||||
( TODO: C-g or C-h for help )
|
( TODO: C-g or C-h for help )
|
||||||
( TODO: C-s for search )
|
( TODO: C-s for search )
|
||||||
( TODO: C-v for page down )
|
( TODO: C-v for page down )
|
||||||
|
@ -380,6 +388,7 @@
|
||||||
.Console/read DEI #0c EQU ( C-l ) ;refresh JCN2
|
.Console/read DEI #0c EQU ( C-l ) ;refresh JCN2
|
||||||
.Console/read DEI #0d EQU ( \r ) ;newline JCN2
|
.Console/read DEI #0d EQU ( \r ) ;newline JCN2
|
||||||
.Console/read DEI #0e EQU ( C-n ) ;down JCN2
|
.Console/read DEI #0e EQU ( C-n ) ;down JCN2
|
||||||
|
.Console/read DEI #0f EQU ( C-o ) ;save JCN2
|
||||||
.Console/read DEI #10 EQU ( C-p ) ;up JCN2
|
.Console/read DEI #10 EQU ( C-p ) ;up JCN2
|
||||||
.Console/read DEI #18 EQU ( C-x ) ;quit JCN2
|
.Console/read DEI #18 EQU ( C-x ) ;quit JCN2
|
||||||
.Console/read DEI #1a EQU ( C-z ) ;debug JCN2
|
.Console/read DEI #1a EQU ( C-z ) ;debug JCN2
|
||||||
|
@ -582,18 +591,6 @@
|
||||||
@fits-in-one-screen ( -> bool^ )
|
@fits-in-one-screen ( -> bool^ )
|
||||||
;buffer/line-count LDA2 ;term/rows LDA2 INC2 LTH2 JMP2r
|
;buffer/line-count LDA2 ;term/rows LDA2 INC2 LTH2 JMP2r
|
||||||
|
|
||||||
( @doc-start ( -> s* ) ;buffer/data JMP2r
|
|
||||||
@doc-limit ( -> s* ) ;buffer/limit LDA2 JMP2r
|
|
||||||
@doc-last ( -> s* ) ;buffer/limit LDA2 #0001 SUB2 JMP2r )
|
|
||||||
|
|
||||||
( @page-start ( -> s* ) ;buffer/offset LDA2 JMP2r
|
|
||||||
@page-limit ( -> s* ) height ;rel-line JSR2 JMP2r
|
|
||||||
@page-last ( -> s* ) height ;rel-line JSR2 #0001 SUB2 JMP2r )
|
|
||||||
|
|
||||||
( @line-start ( -> s* ) ;cursor/row LDA ;rel-line JSR2 JMP2r
|
|
||||||
@line-limit ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 JMP2r
|
|
||||||
@line-last ( -> s* ) ;cursor/row LDA INC ;rel-line JSR2 #0001 SUB2 JMP2r )
|
|
||||||
|
|
||||||
@mod-div ( x^ y^ -> x%d x/y )
|
@mod-div ( x^ y^ -> x%d x/y )
|
||||||
DIVk STHk MUL SUB STHr JMP2r
|
DIVk STHk MUL SUB STHr JMP2r
|
||||||
|
|
||||||
|
@ -632,6 +629,8 @@
|
||||||
|
|
||||||
@messages [ &input-error "input 20 "error 00
|
@messages [ &input-error "input 20 "error 00
|
||||||
&bytes 20 "bytes, 00
|
&bytes 20 "bytes, 00
|
||||||
|
&save-ok "saved 00
|
||||||
|
&save-failed "failed 00
|
||||||
&lines 20 "lines] 00
|
&lines 20 "lines] 00
|
||||||
&saved "-- 20 00
|
&saved "-- 20 00
|
||||||
&unsaved "** 20 00 ]
|
&unsaved "** 20 00 ]
|
||||||
|
|
Loading…
Reference in New Issue