~rabbits/left

1e5c083349fcc8c1a242b140c563556ae0064762 — neauoire a month ago e81e1ff
Minor optimizations
1 files changed, 29 insertions(+), 44 deletions(-)

M src/main.tal
M src/main.tal => src/main.tal +29 -44
@@ 123,7 123,6 @@
	#00 .textarea/highlight STZ
	#0000 ;scroll-to JSR2
	;document/body ;select-addr JSR2
	;redraw JSR2

	( theme support )
	;load-theme JSR2


@@ 238,9 237,8 @@ BRK
		&no-name
	DUP ( ctrl+o ) #6f ! ,&no-open JCN
		;clear-textarea JSR2
		#0000 ;set-scroll JSR2
		;load-file JSR2
		;document/body ;select-addr/no-clear JSR2 
		.selection/from LDZ2 ;select-addr/no-clear JSR2 
		POP BRK 
		&no-open
	DUP ( ctrl+s ) #73 ! ,&no-save JCN


@@ 397,16 395,20 @@ BRK
		&no-scroll
	POP

	.Mouse/x DEI2 .Mouse/y DEI2 .textarea ;within-rect JSR2
		;on-mouse-textarea JCN2
	.Mouse/x DEI2 .Mouse/y DEI2 .scrollbar ;within-rect JSR2
		;on-mouse-scrollbar JCN2
	.Mouse/y DEI2 #0018 << ,&skip JCN
		.Mouse/x DEI2
		DUP2 .Screen/width DEI2 #0008 -- >> ;on-mouse-scrollbar JCN2
		DUP2 #0010 >> ;on-mouse-textarea JCN2
		POP
		&skip

	( release-record ) #00 DUP .Mouse/state DEO .cursor/last STZ
	
BRK

@on-mouse-textarea ( -> )
@on-mouse-textarea ( x* -> )

	POP2

	.Mouse/state DEI DUP .cursor/last LDZ 
		DUP2 #1000 !! ,&no-down-alt JCN


@@ 488,8 490,9 @@ BRK

RTN

@on-mouse-scrollbar ( -> )
@on-mouse-scrollbar ( x* -> )

	POP2
	( skip unclick ) .Mouse/state DEI #01 JCN [ BRK ]

	.Mouse/y DEI2 .scrollbar/y0 LDZ2 #0008 ++ << ,&up JCN


@@ 1015,29 1018,28 @@ RTN
@draw-scrollbar ( -- )
	
	.scrollbar/x0 LDZ2 .Screen/x DEO2
	#0030 .Screen/y DEO2
	;scrollbar-icns/bg .Screen/addr DEO2

	( fill )
	#0018 .Screen/height DEI2 #0008 --
	#0020 .Screen/height DEI2 #0008 --
	&loop
		( draw ) #23 .Screen/color DEO
		( incr ) SWP2 #0008 ++ SWP2
		OVR2 .Screen/y DEO2
		SWP2 
			DUP2 .Screen/y DEO2
			#23 .Screen/color DEO
		#0008 ++ SWP2
		LTH2k ,&loop JCN
	POP2 POP2
 
	( position )
	.scroll/y LDZ2 .textarea/lines LDZ2 // .scrollbar/y0 LDZ2 ++ #0008 ++ .Screen/y DEO2
	;scrollbar-icns/fg .Screen/addr DEO2
	( count pages ) ;get-lines JSR2 .textarea/lines LDZ2 //
	( maximum scrollbar ) .scrollbar/y1 LDZ2 .scrollbar/y0 LDZ2 -- #0016 --
	( scrollbar height ) SWP2 --
	( draw scrollbar )
	#0000 SWP2
	;get-lines JSR2 .textarea/lines LDZ2 //
	.scrollbar/y1 LDZ2 .scrollbar/y0 LDZ2 -- #0016 --
	SWP2 --

	.scroll/y LDZ2 .textarea/lines LDZ2 // .scrollbar/y0 LDZ2 ++ #0008 ++ SWP2 OVR2 ++
	&stretch
		OVR2 .Screen/y DEO2
		#21 .Screen/color DEO
		.Screen/y DEI2 #0001 ++ .Screen/y DEO2
		INCR2 LTH2k ,&stretch JCN
	POP2 POP2



@@ 1113,13 1115,16 @@ RTN
		#fffa LDA2 .System/r DEO2
		#fffc LDA2 .System/g DEO2
		#fffe LDA2 .System/b DEO2
		;redraw JSR2
		&ignore
	;redraw JSR2

RTN

( snarf )

@snarf-txt
	".snarf $1

@cut-snarf ( -- )
	
	SELECTION-LENGTH #0001 >> ,&continue JCN


@@ 1140,7 1145,7 @@ RTN
		POP2r RTN
		&continue

	;snarfpath-txt .File/name DEO2 
	;snarf-txt .File/name DEO2 
	STH2r .File/length DEO2 
	.selection/from LDZ2 .File/save DEO2



@@ 1151,7 1156,7 @@ RTN
	;clear-textarea JSR2
	( erase selection ) .selection/from LDZ2 SELECTION-LENGTH DUP2 #0001 == TOS -- STH2k ++ EOF STH2r ;shiftl JSR2
	( push right ) .selection/from LDZ2 EOF SPACE-AVAILABLE STH2k ;shiftr JSR2
	;snarfpath-txt .File/name DEO2 
	;snarf-txt .File/name DEO2 
	STH2kr .File/length DEO2 
	.selection/from LDZ2 .File/load DEO2 
	( pull left ) .selection/from LDZ2 STH2kr ++ EOF STH2r .File/success DEI2 -- ;shiftl JSR2


@@ 1184,26 1189,6 @@ RTN

RTN

@within-rect ( x* y* rect -- flag )
	
	STH
	( y < rect.y1 ) DUP2 STHkr #02 + LDZ2 << ,&skip JCN
	( y > rect.y2 ) DUP2 STHkr #06 + LDZ2 >> ,&skip JCN
	SWP2
	( x < rect.x1 ) DUP2 STHkr LDZ2 << ,&skip JCN
	( x > rect.x2 ) DUP2 STHkr #04 + LDZ2 >> ,&skip JCN
	POP2 POP2 POPr
	#01 
RTN
	&skip
	POP2 POP2 POPr
	#00

RTN

@snarfpath-txt
	".snarf $1

@untitled-txt  
	"untitled.txt $1