remove CRLF support, optimizations
This commit is contained in:
parent
8229c0db14
commit
873419689e
77
femto.tal
77
femto.tal
|
@ -37,6 +37,7 @@
|
||||||
( blue, magenta, cyan, white )
|
( blue, magenta, cyan, white )
|
||||||
|
|
||||||
( TODO: )
|
( TODO: )
|
||||||
|
( - dollar ($) and caret (^) regex bug )
|
||||||
( - optimize term drawing )
|
( - optimize term drawing )
|
||||||
( - get long line truncation/scrolling working )
|
( - get long line truncation/scrolling working )
|
||||||
( - allow line numbers to be toggled off )
|
( - allow line numbers to be toggled off )
|
||||||
|
@ -44,9 +45,7 @@
|
||||||
( - open file command? )
|
( - open file command? )
|
||||||
( - close file command? )
|
( - close file command? )
|
||||||
( - move by word/paragraph )
|
( - move by word/paragraph )
|
||||||
( - search )
|
|
||||||
( - search&replace )
|
( - search&replace )
|
||||||
( - windows line-ending support (CRLF) )
|
|
||||||
|
|
||||||
|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 ]
|
||||||
|
@ -105,7 +104,6 @@
|
||||||
&tab-width $2 ( how many spaces to display tab chars )
|
&tab-width $2 ( how many spaces to display tab chars )
|
||||||
&insert-tabs $1 ( tab key inserts tabs when true )
|
&insert-tabs $1 ( tab key inserts tabs when true )
|
||||||
&color $2 ( digits of highlight color in reverse order )
|
&color $2 ( digits of highlight color in reverse order )
|
||||||
&line-endings $1 ( 00 = unix, 01 = windows, 80 = mixed )
|
|
||||||
]
|
]
|
||||||
|
|
||||||
( tracks information related to the buffer's view of data )
|
( tracks information related to the buffer's view of data )
|
||||||
|
@ -272,8 +270,7 @@
|
||||||
@count-c ( c^ -> n* )
|
@count-c ( c^ -> n* )
|
||||||
#0000 ,&count STR2
|
#0000 ,&count STR2
|
||||||
STH ;data
|
STH ;data
|
||||||
&loop ( DUP2 .buffer/limit LDZ2 EQU2 ,&done JCN )
|
&loop LDAk #00 EQU ,&done JCN
|
||||||
LDAk #00 EQU ,&done JCN
|
|
||||||
LDAk STHkr NEQ ,&next JCN
|
LDAk STHkr NEQ ,&next JCN
|
||||||
,&count LDR2 INC2 ,&count STR2
|
,&count LDR2 INC2 ,&count STR2
|
||||||
&next INC2 ,&loop JMP
|
&next INC2 ,&loop JMP
|
||||||
|
@ -286,26 +283,7 @@
|
||||||
@setup-linecount ( -> )
|
@setup-linecount ( -> )
|
||||||
#0a ;count-c JSR2 INC2 .buffer/line-count STZ2
|
#0a ;count-c JSR2 INC2 .buffer/line-count STZ2
|
||||||
#09 ;count-c JSR2 #0000 GTH2 .config/insert-tabs STZ
|
#09 ;count-c JSR2 #0000 GTH2 .config/insert-tabs STZ
|
||||||
#0d ;count-c JSR2 DUP2 INC2 .buffer/line-count LDZ2 EQU2 STH
|
JMP2r
|
||||||
#0000 NEQ2 STHkr #00 EQU AND #80 MUL
|
|
||||||
STHr ADD DUP .config/line-endings STZ
|
|
||||||
;strip-cr JCN2 JMP2r
|
|
||||||
|
|
||||||
( strip our carriage returns \r )
|
|
||||||
( )
|
|
||||||
( a few imporant notes: )
|
|
||||||
( 1. we need "re-add" these \r bytes when displaying the buffer size )
|
|
||||||
( 2. we need to "zero out" all the trailing bytes )
|
|
||||||
@strip-cr ( -> )
|
|
||||||
;data LIT2r :data ( readpos [writepos] )
|
|
||||||
&loop LDAk #00 EQU ,&done JCN
|
|
||||||
LDAk #0d NEQ ,&next JCN INC2 ,&loop JMP
|
|
||||||
&next LDAk STH2kr STA
|
|
||||||
INC2 INC2r ,&loop JMP
|
|
||||||
&done STH2kr .buffer/limit STZ2
|
|
||||||
&fill DUP2 STH2kr EQU2 ,&exit JCN
|
|
||||||
#00 STH2kr STA INC2r ,&fill JMP
|
|
||||||
&exit POP2 POP2r JMP2r
|
|
||||||
|
|
||||||
( reads filename from the program's argv )
|
( reads filename from the program's argv )
|
||||||
( )
|
( )
|
||||||
|
@ -804,14 +782,6 @@
|
||||||
.config/insert-tabs LDZk #00 EQU SWP STZ
|
.config/insert-tabs LDZk #00 EQU SWP STZ
|
||||||
;redraw-statusbar-and-cursor JSR2 ;return JMP2
|
;redraw-statusbar-and-cursor JSR2 ;return JMP2
|
||||||
|
|
||||||
( toggle whether to use literal tab characters )
|
|
||||||
( )
|
|
||||||
( when opening a file, this defaults to 01 if existing tab )
|
|
||||||
( characters are found, and 00 otherwise. )
|
|
||||||
@toggle-line-endings ( -> )
|
|
||||||
.config/line-endings LDZk #00 EQU SWP STZ
|
|
||||||
;redraw-statusbar-and-cursor JSR2 ;return JMP2
|
|
||||||
|
|
||||||
( interpret user input as an escaped sequence )
|
( interpret user input as an escaped sequence )
|
||||||
( )
|
( )
|
||||||
( called by on-key with state/saw-esc is true )
|
( called by on-key with state/saw-esc is true )
|
||||||
|
@ -825,7 +795,6 @@
|
||||||
.state/key LDZ LIT '> EQU ( M-> ) ;goto-end 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 'c EQU ( M-c ) ;toggle-color JCN2
|
||||||
.state/key LDZ LIT 'g EQU ( M-g ) ;goto-line JCN2
|
.state/key LDZ LIT 'g EQU ( M-g ) ;goto-line JCN2
|
||||||
.state/key LDZ LIT 'l EQU ( M-l ) ;toggle-line-endings JCN2
|
|
||||||
.state/key LDZ LIT 's EQU ( M-s ) ;regex-search JCN2
|
.state/key LDZ LIT 's EQU ( M-s ) ;regex-search JCN2
|
||||||
.state/key LDZ LIT 't EQU ( M-t ) ;toggle-tabs JCN2
|
.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 'v EQU ( M-v ) ;page-up JCN2
|
||||||
|
@ -1178,21 +1147,10 @@
|
||||||
&next LDAk #09 EQU ,&tabs JCN INC2 INC2r ,&loop JMP
|
&next LDAk #09 EQU ,&tabs JCN INC2 INC2r ,&loop JMP
|
||||||
&tabs INC2 .config/tab-width LDZ2 STH2 ADD2r ,&loop JMP
|
&tabs INC2 .config/tab-width LDZ2 STH2 ADD2r ,&loop JMP
|
||||||
|
|
||||||
( display ** if the buffer has unsaved changes, -- otherwise )
|
|
||||||
@get-save-status
|
|
||||||
;messages/unsaved ;messages/saved
|
|
||||||
.state/modified LDZ JMP SWP2 POP2 JMP2r
|
|
||||||
|
|
||||||
( move the terminal cursor to the statusbar line )
|
( move the terminal cursor to the statusbar line )
|
||||||
@move-to-statusbar ( -> )
|
@move-to-statusbar ( -> )
|
||||||
#0000 .term/rows LDZ2 ;term-move-cursor JMP2
|
#0000 .term/rows LDZ2 ;term-move-cursor JMP2
|
||||||
|
|
||||||
@buffer-size
|
|
||||||
.buffer/limit LDZ2 ;data SUB2
|
|
||||||
.config/line-endings LDZ #00 EQU ,&done JCN
|
|
||||||
.buffer/line-count LDZ2 #0001 SUB2 ADD2
|
|
||||||
&done JMP2r
|
|
||||||
|
|
||||||
( draw the full statusbar )
|
( draw the full statusbar )
|
||||||
@draw-statusbar ( -> )
|
@draw-statusbar ( -> )
|
||||||
;move-to-statusbar JSR2
|
;move-to-statusbar JSR2
|
||||||
|
@ -1203,11 +1161,13 @@
|
||||||
&done POP2 POP2 POP2r ( )
|
&done POP2 POP2 POP2r ( )
|
||||||
|
|
||||||
;move-to-statusbar JSR2
|
;move-to-statusbar JSR2
|
||||||
;get-save-status JSR2 ;print JSR2
|
|
||||||
|
( display ** if the buffer has unsaved changes, -- otherwise )
|
||||||
|
#2d .state/modified LDZ #00 NEQ #03 MUL SUB DUP emit emit sp
|
||||||
|
|
||||||
;filename ;print JSR2
|
;filename ;print JSR2
|
||||||
sp emit-[
|
sp emit-[
|
||||||
( .buffer/limit LDZ2 ;data SUB2 ;emit-dec2 JSR2 )
|
.buffer/limit LDZ2 ;data SUB2 ;emit-dec2 JSR2
|
||||||
;buffer-size JSR2 ;emit-dec2 JSR2
|
|
||||||
;messages/bytes ;print JSR2
|
;messages/bytes ;print JSR2
|
||||||
sp
|
sp
|
||||||
.buffer/line-count LDZ2 ;emit-dec2 JSR2
|
.buffer/line-count LDZ2 ;emit-dec2 JSR2
|
||||||
|
@ -1218,8 +1178,6 @@
|
||||||
.cursor/row LDZ2 INC2 ;emit-dec2 JSR2
|
.cursor/row LDZ2 INC2 ;emit-dec2 JSR2
|
||||||
emit-) sp emit-[
|
emit-) sp emit-[
|
||||||
LIT 's .config/insert-tabs LDZ ADD emit
|
LIT 's .config/insert-tabs LDZ ADD emit
|
||||||
emit-:
|
|
||||||
LIT 'u .config/line-endings LDZ #00 NEQ #02 MUL ADD emit ( "u" or "w" )
|
|
||||||
emit-]
|
emit-]
|
||||||
;emit-reset JMP2
|
;emit-reset JMP2
|
||||||
|
|
||||||
|
@ -1250,6 +1208,7 @@
|
||||||
&fail POP2 #0000
|
&fail POP2 #0000
|
||||||
&done POP2r JMP2r
|
&done POP2r JMP2r
|
||||||
|
|
||||||
|
( TODO: this doesn't handle tabs correctly )
|
||||||
@draw-region ( offset* limit* col* row* -> )
|
@draw-region ( offset* limit* col* row* -> )
|
||||||
OVR2 ( offset limit col row col )
|
OVR2 ( offset limit col row col )
|
||||||
.term/cols LDZ2 SWP2 SUB2 STH2 ( offset limit col row [cols-col] )
|
.term/cols LDZ2 SWP2 SUB2 STH2 ( offset limit col row [cols-col] )
|
||||||
|
@ -1481,17 +1440,17 @@
|
||||||
@abs-line ( y* -> s* )
|
@abs-line ( y* -> s* )
|
||||||
;data SWP2 ;line-to-pos JMP2
|
;data SWP2 ;line-to-pos JMP2
|
||||||
|
|
||||||
( find string pointer for absolute y coordinate )
|
|
||||||
@rel-line ( y* -> s* )
|
|
||||||
.buffer/offset LDZ2 SWP2 ;line-to-pos JMP2
|
|
||||||
|
|
||||||
( return a pointer to the current line )
|
( return a pointer to the current line )
|
||||||
@cur-line ( -> s* )
|
@cur-line ( -> s* )
|
||||||
.cursor/row LDZ2 .buffer/line-offset LDZ2 SUB2k
|
.cursor/row LDZ2 .buffer/line-offset LDZ2 LTH2k ,&early JCN
|
||||||
.term/rows LDZ2 LTH2 ,&ok JCN
|
( if cursor/row is later than line-offset )
|
||||||
|
( we can save some time by starting at )
|
||||||
|
( buffer/offset instead of the beginning )
|
||||||
|
SUB2 .buffer/offset LDZ2 SWP2 ;line-to-pos JMP2
|
||||||
|
&early
|
||||||
|
( if cursor/row is earlier than line-offset )
|
||||||
|
( we need to use the absolute y coordinate )
|
||||||
POP2 ;abs-line JMP2
|
POP2 ;abs-line JMP2
|
||||||
&ok
|
|
||||||
SUB2 ;rel-line JMP2
|
|
||||||
|
|
||||||
( return a pointer to the current cursor position )
|
( return a pointer to the current cursor position )
|
||||||
@cur-pos ( -> s* )
|
@cur-pos ( -> s* )
|
||||||
|
@ -1583,8 +1542,6 @@
|
||||||
&quit-prompt "Save 20 "modified 20 "file 20 "(y/n)? 20 00
|
&quit-prompt "Save 20 "modified 20 "file 20 "(y/n)? 20 00
|
||||||
&unknown-input "Unknown 20 "input: 20 00
|
&unknown-input "Unknown 20 "input: 20 00
|
||||||
&no-matches-found "No 20 "matches 20 "found: 20 00
|
&no-matches-found "No 20 "matches 20 "found: 20 00
|
||||||
&saved "-- 20 00
|
|
||||||
&unsaved "** 20 00
|
|
||||||
&term-size-parse-error "error 20 "parsing 20 "term 20 "size 00
|
&term-size-parse-error "error 20 "parsing 20 "term 20 "size 00
|
||||||
&rel-line-error "invalid 20 "relative 20 "line 20 "number 00
|
&rel-line-error "invalid 20 "relative 20 "line 20 "number 00
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue