femto: start long lines
This commit is contained in:
parent
408d0267ad
commit
97e7ce5cea
56
femto.tal
56
femto.tal
|
@ -14,9 +14,8 @@
|
||||||
|10 @Console [ &vector $2 &read $5 &type $1 &write $1 &error $1 ]
|
|10 @Console [ &vector $2 &read $5 &type $1 &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 ]
|
||||||
|
|
||||||
( MAX file size is currently #ce80, i.e. 52864 bytes )
|
( MAX file size is currently #d0000, i.e. 53248 bytes )
|
||||||
|
|
||||||
%dbg { #ff .System/debug DEO }
|
|
||||||
%emit { .Console/write DEO }
|
%emit { .Console/write DEO }
|
||||||
%sp { #2018 DEO }
|
%sp { #2018 DEO }
|
||||||
%nl { #0a18 DEO }
|
%nl { #0a18 DEO }
|
||||||
|
@ -36,27 +35,15 @@
|
||||||
%emit-lpar { LIT2 28 18 DEO }
|
%emit-lpar { LIT2 28 18 DEO }
|
||||||
%emit-rpar { LIT2 29 18 DEO }
|
%emit-rpar { LIT2 29 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-; { LIT2 "; 18 DEO }
|
%emit-; { LIT2 "; 18 DEO }
|
||||||
%emit-C { LIT2 "C 18 DEO }
|
%emit-C { LIT2 "C 18 DEO }
|
||||||
%emit-H { LIT2 "H 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-[ { LIT2 "[ 18 DEO }
|
||||||
%emit-] { LIT2 "] 18 DEO }
|
%emit-] { LIT2 "] 18 DEO }
|
||||||
%emit-m { LIT2 "m 18 DEO }
|
|
||||||
%emit-n { LIT2 "n 18 DEO }
|
|
||||||
%emit-~ { LIT2 "~ 18 DEO }
|
%emit-~ { LIT2 "~ 18 DEO }
|
||||||
|
|
||||||
%quit! { #01 .System/halt DEO BRK }
|
%quit! { #01 .System/halt DEO BRK }
|
||||||
%quit-restore! { alternate-buffer-off quit! }
|
%quit-restore! { alternate-buffer-off quit! }
|
||||||
%lmargin { #0006 }
|
|
||||||
|
|
||||||
( zero page )
|
( zero page )
|
||||||
|0000
|
|0000
|
||||||
|
@ -73,9 +60,11 @@
|
||||||
( )
|
( )
|
||||||
( these can be changed at any time without breaking anything else )
|
( these can be changed at any time without breaking anything else )
|
||||||
@config [
|
@config [
|
||||||
|
&lmargin $2 ( size of the left margin )
|
||||||
&tab-width $2 ( how many spaces to display tab chars )
|
&tab-width $2 ( how many spaces to display tab chars )
|
||||||
&tab-adjust $2 ( how many "extra" spaces; tab-width - 1 )
|
&tab-adjust $2 ( how many "extra" spaces; tab-width - 1 )
|
||||||
&insert-tabs $1 ( tab key inserts tabs when true )
|
&insert-tabs $1 ( tab key inserts tabs when true )
|
||||||
|
&show-linenum $1 ( )
|
||||||
&color $2 ( digits of highlight color in reverse order )
|
&color $2 ( digits of highlight color in reverse order )
|
||||||
&red $2 ( digits of color for line/EOF markers in reverse order )
|
&red $2 ( digits of color for line/EOF markers in reverse order )
|
||||||
]
|
]
|
||||||
|
@ -85,7 +74,7 @@
|
||||||
( limit and line-count change when we modify the buffer. )
|
( limit and line-count change when we modify the buffer. )
|
||||||
( offset and line-offset change when we move the view port. )
|
( offset and line-offset change when we move the view port. )
|
||||||
@buffer [
|
@buffer [
|
||||||
&limit $2 ( last byte of actual data (not including \0) + 1 )
|
&limit $2 ( last byte of actual data, not including \0, + 1 )
|
||||||
&line-count $2 ( total number of lines in file )
|
&line-count $2 ( total number of lines in file )
|
||||||
&offset $2 ( first byte of data visible in terminal )
|
&offset $2 ( first byte of data visible in terminal )
|
||||||
&line-offset $2 ( first line of text visible in terminal )
|
&line-offset $2 ( first line of text visible in terminal )
|
||||||
|
@ -95,8 +84,8 @@
|
||||||
( )
|
( )
|
||||||
( when these change we may need to move the view port as well )
|
( when these change we may need to move the view port as well )
|
||||||
@cursor [
|
@cursor [
|
||||||
&col $2 ( current column value 0-n (may exceed lenght of row) )
|
&col $2 ( current column value 0-n, may exceed lenght of row )
|
||||||
&row $2 ( current relative row value, 0-(height-1) )
|
&row $2 ( current relative row value, 0-[height-1] )
|
||||||
]
|
]
|
||||||
|
|
||||||
( tracks overall editor state between events )
|
( tracks overall editor state between events )
|
||||||
|
@ -149,9 +138,11 @@
|
||||||
( init zero page )
|
( init zero page )
|
||||||
#0050 .term/cols STZ2
|
#0050 .term/cols STZ2
|
||||||
#0018 .term/rows STZ2
|
#0018 .term/rows STZ2
|
||||||
|
#0006 .config/lmargin STZ2
|
||||||
#0004 .config/tab-width STZ2
|
#0004 .config/tab-width STZ2
|
||||||
#0003 .config/tab-adjust STZ2
|
#0003 .config/tab-adjust STZ2
|
||||||
#00 .config/insert-tabs STZ
|
#00 .config/insert-tabs STZ
|
||||||
|
#01 .config/show-linenum STZ
|
||||||
#3333 .config/color STZ2
|
#3333 .config/color STZ2
|
||||||
( #3133 .config/red STZ2 )
|
( #3133 .config/red STZ2 )
|
||||||
( #3033 .config/color STZ2 )
|
( #3033 .config/color STZ2 )
|
||||||
|
@ -166,12 +157,14 @@
|
||||||
( import uxn regex library )
|
( import uxn regex library )
|
||||||
~regex.tal
|
~regex.tal
|
||||||
|
|
||||||
|
@lmargin .config/lmargin LDZ2 JMP2r
|
||||||
|
|
||||||
( ERROR HANDLING )
|
( ERROR HANDLING )
|
||||||
|
|
||||||
( using errorq will print the given message before causing )
|
( using errorq will print the given message before causing )
|
||||||
( the interpreter to halt. )
|
( the interpreter to halt. )
|
||||||
@errorq ( msg* -> )
|
@errorq ( msg* -> )
|
||||||
emit-! sp print nl dbg BRK
|
emit-! sp print nl #ff .System/debug DEO BRK
|
||||||
|
|
||||||
( open the given file at editor start up )
|
( open the given file at editor start up )
|
||||||
( )
|
( )
|
||||||
|
@ -180,11 +173,11 @@
|
||||||
( TODO: enable closing/opening files with editor already running )
|
( TODO: enable closing/opening files with editor already running )
|
||||||
@open-file ( filename* -> )
|
@open-file ( filename* -> )
|
||||||
.File/name DEO2
|
.File/name DEO2
|
||||||
#ce81 .File/length DEO2
|
#d001 .File/length DEO2
|
||||||
;data .File/read DEO2
|
;data .File/read DEO2
|
||||||
|
|
||||||
.File/success DEI2 #0000 EQU2 .state/modified STZ
|
.File/success DEI2 #0000 EQU2 .state/modified STZ
|
||||||
.File/success DEI2 #ce81 LTH2 ?&ok
|
.File/success DEI2 #d001 LTH2 ?&ok
|
||||||
crlf
|
crlf
|
||||||
;messages/input-error print
|
;messages/input-error print
|
||||||
;filename print crlf quit!
|
;filename print crlf quit!
|
||||||
|
@ -1126,6 +1119,14 @@
|
||||||
@redraw-matches ( -> ) #08 !redraw-add
|
@redraw-matches ( -> ) #08 !redraw-add
|
||||||
@redraw-all ( -> ) #1f !redraw-add
|
@redraw-all ( -> ) #1f !redraw-add
|
||||||
|
|
||||||
|
( for a normal short line this returns: 0, 0 )
|
||||||
|
( )
|
||||||
|
( for a long line it returns: )
|
||||||
|
( - buffer offset: how far past the start of line to begin drawing )
|
||||||
|
( - cursor offset: how much to subtract from cursor x coordinate )
|
||||||
|
@on-long-line ( -> buf-offset* cursor-offset* )
|
||||||
|
#0000 #0000 JMP2r
|
||||||
|
|
||||||
( draw the current cursor location )
|
( draw the current cursor location )
|
||||||
@draw-cursor ( -> )
|
@draw-cursor ( -> )
|
||||||
.prompt/active LDZ #00 EQU JMP JMP2r
|
.prompt/active LDZ #00 EQU JMP JMP2r
|
||||||
|
@ -1444,7 +1445,7 @@
|
||||||
LDAk ?{ POP2 JMP2r } LDAk #18 DEO INC2 !print
|
LDAk ?{ POP2 JMP2r } LDAk #18 DEO INC2 !print
|
||||||
|
|
||||||
@cur-len ( -> n* )
|
@cur-len ( -> n* )
|
||||||
cur-line !line-len
|
cur-line ( >> )
|
||||||
|
|
||||||
@line-len ( s* -> n* )
|
@line-len ( s* -> n* )
|
||||||
#0000 STH2
|
#0000 STH2
|
||||||
|
@ -1453,6 +1454,17 @@
|
||||||
INC2 INC2r !&loop
|
INC2 INC2r !&loop
|
||||||
&end POP2 STH2r JMP2r
|
&end POP2 STH2r JMP2r
|
||||||
|
|
||||||
|
@cur-w-len ( -> n* )
|
||||||
|
cur-line ( >> )
|
||||||
|
|
||||||
|
@line-w-len ( s* -> n* )
|
||||||
|
LIT2r 0000
|
||||||
|
&loop LDAk DUP #00 EQU ?&end
|
||||||
|
DUP #0a EQU ?&end
|
||||||
|
#09 NEQ ?{ LIT -config/tab-adjust LDZ2r ADD2r }
|
||||||
|
INC2 INC2r !&loop
|
||||||
|
&end POP POP2 STH2r JMP2r
|
||||||
|
|
||||||
@line-is-visible ( n* -> bool^ )
|
@line-is-visible ( n* -> bool^ )
|
||||||
.buffer/line-offset LDZ2 LTH2k ?&no
|
.buffer/line-offset LDZ2 LTH2k ?&no
|
||||||
.term/rows LDZ2 ADD2 LTH2 JMP2r
|
.term/rows LDZ2 ADD2 LTH2 JMP2r
|
||||||
|
@ -1702,6 +1714,6 @@
|
||||||
]
|
]
|
||||||
|
|
||||||
( actual file data to be edited )
|
( actual file data to be edited )
|
||||||
@data $ce80
|
@data $d000
|
||||||
|
|
||||||
( end of femto.tal )
|
( end of femto.tal )
|
||||||
|
|
Loading…
Reference in New Issue