simple nano highlighting for unxtal
This commit is contained in:
parent
3fc2c9f16a
commit
8860f63e7a
48
femto.tal
48
femto.tal
|
@ -49,7 +49,6 @@
|
|||
( - search&replace )
|
||||
( - tab support? )
|
||||
( - windows line-ending support (CRLF) )
|
||||
|
||||
( FIXME: )
|
||||
( - stop using bytes for row/col/etc. )
|
||||
( - consider storing absolute cursor instead )
|
||||
|
@ -470,9 +469,9 @@
|
|||
|
||||
@draw-statusbar ( -> )
|
||||
#0000 ;term/rows LDA2 ;term-move-cursor JSR2
|
||||
ansi ;config/color LDA2 emit emit
|
||||
LIT2 '7 '; emit emit
|
||||
LIT 'm emit ( esc [ 33 ; 7 m )
|
||||
;emit-color-reverse JSR2
|
||||
( ansi ;config/color LDA2 emit emit
|
||||
LIT2 '7 '; emit emit LIT 'm emit )
|
||||
LIT2r 2018
|
||||
;term/cols LDA2 #0000
|
||||
&loop GTH2k ,&continue JCN ,&done JMP
|
||||
|
@ -496,10 +495,12 @@
|
|||
;cur-abs-row JSR2 INC2 ;emit-dec2 JSR2
|
||||
LIT ') emit
|
||||
|
||||
ansi LIT '0 emit LIT 'm emit
|
||||
;emit-reset JSR2
|
||||
( ansi LIT '0 emit LIT 'm emit )
|
||||
JMP2r
|
||||
|
||||
@draw-linenum ( n* -> )
|
||||
;emit-reset JSR2
|
||||
ansi ;config/color LDA2 emit emit LIT 'm emit
|
||||
;emit-dec2-pad JSR2
|
||||
ansi LIT2 'm '0 emit emit JMP2r
|
||||
|
@ -519,31 +520,40 @@
|
|||
@emit-red-dollar ( -> )
|
||||
;emit-red JSR2 LIT '$ emit ;emit-reset JMP2
|
||||
|
||||
@emit-color-reverse ( -> )
|
||||
ansi ;config/color LDA2 emit emit LIT2 '7 '; emit emit LIT 'm emit JMP2r
|
||||
|
||||
@draw-all ( -> )
|
||||
;term-erase-all JSR2
|
||||
#0000 #0000 ;term-move-cursor JSR2
|
||||
;buffer/line-offset LDA2 STH2 LIT2r 0001 ( [k line-offset] )
|
||||
ADD2kr STH2r ;draw-linenum JSR2
|
||||
;buffer/offset LDA2
|
||||
;term/lmargin LDA2 INC2 ,&x STR2
|
||||
&bol
|
||||
ADD2kr STH2r ;draw-linenum JSR2
|
||||
;term/lmargin LDA2 INC2 ,&x STR2
|
||||
( TODO: use this for cursor-line highlighting and long line support )
|
||||
( STH2kr ;cursor/row LDA2 INC2 NEQ2 ,&loop JCN
|
||||
;emit-color-reverse JSR2 )
|
||||
&loop ( offset [k line-offset] )
|
||||
LDAk #00 EQU ,&eof JCN
|
||||
LDAk #0a EQU ,&eol JCN
|
||||
,&x LDR2 ;term/cols LDA2
|
||||
LDAk #00 EQU ,&eof JCN
|
||||
LDAk #0a EQU ,&eol JCN
|
||||
,&x LDR2 ;term/cols LDA2
|
||||
LTH2k ,&ok JCN
|
||||
GTH2 ,&skip JCN
|
||||
;emit-red-dollar JSR2 ,&x LDR2 INC2 ,&x STR2
|
||||
&skip INC2 ,&loop JMP
|
||||
&skip INC2
|
||||
,&loop JMP
|
||||
&ok POP2 POP2
|
||||
LDAk #09 EQU ,&do-tab JCN
|
||||
LDAk emit INC2 ,&x LDR2 INC2 ,&x STR2 ,&loop JMP
|
||||
&do-tab ;emit-tab JSR2 INC2 ;config/tab-width LDA2 ,&x LDR2 ADD2 ,&x STR2 ,&loop JMP
|
||||
LDAk #09 EQU ,&do-tab JCN
|
||||
LDAk emit INC2 ,&x LDR2 INC2 ,&x STR2
|
||||
,&loop JMP
|
||||
&eol INC2r
|
||||
STH2kr ;term/rows LDA2 GTH2 ,&done JCN
|
||||
cr nl INC2 ,&bol JMP
|
||||
&do-tab ;emit-tab JSR2 INC2
|
||||
;config/tab-width LDA2 ,&x LDR2 ADD2 ,&x STR2
|
||||
,&loop JMP
|
||||
[ &x $2 ]
|
||||
&eol INC2r STH2kr ;term/rows LDA2 GTH2 ,&done JCN
|
||||
cr nl INC2
|
||||
ADD2kr STH2r ;draw-linenum JSR2
|
||||
;term/lmargin LDA2 INC2 ,&x STR2
|
||||
,&loop JMP
|
||||
&eof
|
||||
;emit-red JSR2
|
||||
&eof-loop
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# basic syntax for the uxntal assembly language
|
||||
#
|
||||
# mostly sticks to ANSI colors with a few exceptions
|
||||
#
|
||||
# comments are known to not handle nesting correctly.
|
||||
# it's not possible to express nested comments using
|
||||
# just start and end regexes.
|
||||
|
||||
# use this syntax for .tal files
|
||||
syntax tal ".*\.tal"
|
||||
|
||||
# characters to insert when comments requested
|
||||
comment "( | )"
|
||||
|
||||
# raw values
|
||||
color pink "\"[^ ]+"
|
||||
color pink "'[^ ]"
|
||||
color pink "\<[0-9a-f]{2}{1,2}\>"
|
||||
|
||||
# literals
|
||||
color bold,green "#[0-9a-f]{2}{1,2}\>"
|
||||
|
||||
# absolute addresses
|
||||
color bold,yellow "(;&?|\.)\S+"
|
||||
color bold,orange ",&?\S+"
|
||||
color bold,orange "/\S+"
|
||||
|
||||
# relative pads
|
||||
color yellow "\$[0-9a-f]{1,4}\>"
|
||||
|
||||
# instructions
|
||||
color bold,cyan "\<(BRK|LIT|INC|POP|DUP|NIP|SWP|OVR|ROT|EQU|NEQ|GTH|LTH|JMP|JCN|JSR|STH|LDZ|STZ|LDR|STR|LDA|STA|DEI|DEO|ADD|SUB|MUL|DIV|AND|ORA|EOR|SFT)2?k?r?\>"
|
||||
|
||||
# label definitions
|
||||
color bold,blue "(^|\s)(@|&)\S+"
|
||||
|
||||
# macros
|
||||
color bold,magenta "%\S+"
|
||||
|
||||
# absolute pads
|
||||
color yellow "\|[0-9a-f]{2}{1,2}\>"
|
||||
|
||||
# comments
|
||||
color red start="\(\s" end="\s\)"
|
Loading…
Reference in New Issue