~rabbits/left

ba979086bbbe40b74d36b1d83bdea9eba73ff9d6 — neauoire 2 months ago fcd62a6
Improved find
1 files changed, 35 insertions(+), 11 deletions(-)

M src/main.tal
M src/main.tal => src/main.tal +35 -11
@@ 3,6 3,7 @@
	mouse1 - select
	mouse2 - find
	alt+mouse2 - find from top
	ctrl+mouse2 - cut and find
	backspace/delete - erase
	escape - deselect
	arrow - move


@@ 39,6 40,7 @@
%RESET-STATE { #00 .state/changed STZ ;draw-state JSR2 }
%RELEASE-MOUSE { #00 .Mouse/state DEO }
%RESET-SELECTION { .selection/from LDZ2 ;select-addr JSR2 }
%ERASE-SELECTION { .selection/from LDZ2 SELECTION-LENGTH STH2k ++ EOF STH2r ;shiftl JSR2 }

%EOF { ;document/body ;document/length LDA2 ++ }
%SPACE-AVAILABLE { #fff0 ;document/length LDA2 ;document/body ++ -- }


@@ 194,8 196,7 @@ BRK
		&continue
	DUP ( ctrl+a ) #61 ! ,&no-selectall JCN
		;clear-textarea JSR2
		;document/body .selection/from STZ2
		EOF .selection/to STZ2
		;document/body EOF ;select-range JSR2
		;draw-textarea JSR2
		POP BRK
		&no-selectall


@@ 366,7 367,7 @@ RTN

	&erase-multiple ( -- )
		;clear-textarea JSR2
		.selection/from LDZ2 SELECTION-LENGTH STH2k ++ EOF STH2r ;shiftl JSR2
		ERASE-SELECTION
		.selection/from LDZ2 #0001 ++ .selection/to STZ2
		;draw-textarea JSR2
		;draw-widget/memory JSR2


@@ 412,7 413,15 @@ BRK
			.Controller/button DEI #02 ! ,&no-alt-find JCN 
				POP2 ;document/body
				&no-alt-find
			;find JSR2
			;find JSR2 
			DUP2 #0000 == ,&no-result JCN
				.Controller/button DEI #01 ! ,&no-ctrl-find JCN 
					;cut-snarf JSR2
					SELECTION-LENGTH --
					&no-ctrl-find
				DUP2 DUP2 SELECTION-LENGTH ++ ;select-range JSR2
				&no-result
			POP2
			RELEASE-MOUSE
			POP2 POP BRK
			&no-down-alt


@@ 579,6 588,22 @@ RTN

RTN	

@select-range ( from* to* -- )
	
	;clear-textarea JSR2
	&no-clear
	SWP2 ;clamp-addr JSR2 .selection/from STZ2 
	( min )
	.selection/from LDZ2 #0001 ++ GTH2k ,&no-min JCN
		SWP2
		&no-min
	POP2
	DUP2 ;clamp-addr JSR2 .selection/to STZ2 
	,follow-selection JSR
	;draw-textarea JSR2

RTN

@follow-selection ( addr* -- )
	
	( get line at addr* )


@@ 631,19 656,16 @@ RTN

RTN

@find ( from* -- )
@find ( from* -- addr* )
		
	SELECTION-LENGTH STH2
	&while
		DUP2 STH2kr ,&compare JSR #00 = ,&no-found JCN
			DUP2 .selection/from STZ2
			DUP2 STH2kr ++ 
			;select-until-addr JSR2
			POP2 POP2r RTN
			POP2r RTN
			&no-found
		#0001 ++
		LDAk ,&while JCN
	POP2 POP2r
	POP2 POP2r #0000
	RTN
	&compare ( addr* length* -- flag )
		SWP2 STH2


@@ 860,6 882,7 @@ RTN
@clear-uf2-multiline ( x* y* text* -- )
	 
	;font-data-regular ;draw-uf2/font STA2
	#00 ;scan-font/commented STA
	SWP2 .Screen/y DEO2
	SWP2 .scroll/x LDZ2 -- DUP2 .Screen/x DEO2 SWP2
	&while


@@ 884,6 907,7 @@ RTN
@draw-uf2-multiline ( x* y* text* -- )
	
	;font-data-regular ;draw-uf2/font STA2
	#00 ;scan-font/commented STA
	#21 ,&color STR
	SWP2 .Screen/y DEO2
	SWP2 .scroll/x LDZ2 -- DUP2 .Screen/x DEO2 SWP2


@@ 1072,7 1096,7 @@ RTN

	;clear-textarea JSR2
	,copy-snarf JSR
	.selection/from LDZ2 SELECTION-LENGTH STH2k ++ EOF STH2r ;shiftl JSR2
	ERASE-SELECTION
	RESET-SELECTION
	;draw-textarea JSR2