~rabbits/left

094542c6d7772a37ce4edfc7eb5867d40db94440 — neauoire a month ago 9517003
Optimized syntax highlight color
1 files changed, 28 insertions(+), 53 deletions(-)

M src/main.tal
M src/main.tal => src/main.tal +28 -53
@@ 118,7 118,6 @@
	( init body ) ;document/body ;select-addr JSR2

	#01 .textarea/highlight STZ
	#01 .textarea/font STZ
	
	#21 ;draw-filepath JSR2
	#0000 .Screen/width DEI2 #0018 #01 ;line-hor JSR2


@@ 447,7 446,7 @@ BRK
	( count char width )
	DUP2 #0a ;find-next-char JSR2
	&loop
		( get character ) OVR2 ;syntax-highlight JSR2 LDA TOS
		( get character ) OVR2 ;scan-font JSR2 LDA TOS
		( get width ) ;draw-uf2/font LDA2 ++ LDA 
		( incr ) STH2r ROT TOS ++ STH2
		LTH2kr STHr ,&end JCN


@@ 589,7 588,7 @@ RTN
	DUP2 #0001 -- #0a ;find-prev-char JSR2 SWP2
	&loop
		EQU2k ,&end JCN
		( get character ) OVR2 ;syntax-highlight JSR2 LDA TOS
		( get character ) OVR2 ;scan-font JSR2 LDA TOS
		( get width ) ;draw-uf2/font LDA2 ++ LDA 
		( incr ) STH2r ROT TOS ++ STH2
		INCR2


@@ 782,43 781,34 @@ RTN
@draw-textarea ( -- )
	
	.textarea/x0 LDZ2 .textarea/y0 LDZ2 
		.scroll/addr LDZ2 #21 ;draw-uf2-multiline JSR2
		.scroll/addr LDZ2 ;draw-uf2-multiline JSR2

RTN

@syntax-highlight ( addr )
	
	.textarea/highlight LDZ #01 JCN [ RTN ]
@scan-font ( addr* )
		
	LDAk IS-SPACER #01 JCN [ RTN ]

	( look ahead )
	DUP2 #0001 ++ LDA #28 ( left-paren ) ! ,&no-paren-open JCN
		#01 ,&comment STR
		;font-data-regular ;set-font JSR2
		RTN
	.textarea/font LDZ ,&fixed-width JCN
	DUP2 #0001 ++ LDA ( left-paren ) #28 ! ,&no-paren-open JCN
		#01 ,&commented STR
		,&default JMP
		&no-paren-open
	( look behind )
	DUP2 #0001 -- LDA #29 ( right-paren ) ! ,&no-paren-close JCN
		#00 ,&comment STR
	DUP2 #0001 -- LDA ( right-paren ) #29 ! ,&no-paren-close JCN
		#00 ,&commented STR
		,&default JMP
		&no-paren-close
	,&comment LDR ,&end JCN
	( special )
	DUP2 #0001 ++ LDA #40 > ,&no-special JCN
		DUP2 #0001 ++ LDA IS-LABEL #00 = ,&no-label JCN
			&no-label
		;font-data-bold ;set-font JSR2
		RTN
		&no-special
	( reset )
	;font-data-regular ;set-font JSR2
	,&commented LDR ,&end JCN
	DUP2 #0001 ++ LDA #40 < ,&bold JCN
	DUP2 #0001 ++ LDA IS-LABEL ,&bold JCN
	&default
		;font-data-regular ;draw-uf2/font STA2 RTN
	&bold
		;font-data-bold ;draw-uf2/font STA2 RTN
	&fixed-width
		;font-data-fixed ;draw-uf2/font STA2 RTN
	&end
	RTN
	&comment $1

RTN

@scan-font ( addr* )

		RTN
	&commented $1

RTN



@@ 827,9 817,7 @@ RTN
	DUP2 .selection/from LDZ2 == ,&selected JCN
	DUP2 .selection/to LDZ2 == ,&default JCN
	DUP2 .selection/from LDZ2 >> STH DUP2 .selection/to LDZ2 << STHr #0101 == ,&selected JCN

	LDAk IS-SPACER #01 JCN [ RTN ]

	DUP2 #0001 ++ LDA ( left-paren ) #28 ! ,&no-paren-open JCN
		#01 ,&commented STR
		#23 ;draw-uf2-multiline/color STA RTN


@@ 838,11 826,8 @@ RTN
		#00 ,&commented STR
		,&default JMP
		&no-paren-close

	,&commented LDR ,&end JCN

	DUP2 #0001 ++ LDA IS-LABEL ,&label JCN

	&default
		#21 ;draw-uf2-multiline/color STA RTN
	&selected


@@ 855,23 840,14 @@ RTN

RTN

@set-font ( addr* -- )

	.textarea/font LDZ ,&no-fixed JCN
		POP2 ;font-data-fixed 
		&no-fixed
	;draw-uf2/font STA2

RTN

@clear-uf2-multiline ( x* y* text* color -- )
	 
	;font-data-regular ;draw-uf2/font STA2
	SWP2 .Screen/y DEO2
	SWP2 .scroll/x LDZ2 -- DUP2 .Screen/x DEO2 SWP2
	( look behind ) #0001 -- ;syntax-highlight JSR2 #0001 ++
	( look behind ) #0001 -- ;scan-font JSR2 #0001 ++
	&while
		;syntax-highlight JSR2
		;scan-font JSR2
		( do not overdraw )
		.Screen/x DEI2 .textarea/x1 LDZ2 GTS2 ,&outside JCN
			LDAk #20 ;draw-uf2/sprite JSR2


@@ 889,16 865,15 @@ RTN

RTN

@draw-uf2-multiline ( x* y* text* color -- )
@draw-uf2-multiline ( x* y* text* -- )
	
	;&color STA
	;font-data-regular ;draw-uf2/font STA2
	SWP2 .Screen/y DEO2
	SWP2 .scroll/x LDZ2 -- DUP2 .Screen/x DEO2 SWP2
	( look behind ) #0001 -- ;syntax-highlight JSR2 #0001 ++
	( look behind ) #0001 -- ;scan-font JSR2 #0001 ++
	&while
		;scan-color JSR2
		;syntax-highlight JSR2
		;scan-font JSR2
		( do not overdraw )
		.Screen/x DEI2 .textarea/x1 LDZ2 GTS2 ,&outside JCN
			LDAk ,&color LDR ;draw-uf2/sprite JSR2