~rabbits/left

11b75cc50ae5c5a932dda251abb93ac1110f7cc0 — neauoire 2 months ago 094542c
Optimized find
2 files changed, 65 insertions(+), 44 deletions(-)

M src/assets.tal
M src/main.tal
M src/assets.tal => src/assets.tal +1 -0
@@ 902,4 902,5 @@

@document
	&padding $1
	&length $2
	&body $0

M src/main.tal => src/main.tal +64 -44
@@ 40,6 40,9 @@
%RELEASE-MOUSE { #00 .Mouse/state DEO }
%RESET-SELECTION { .selection/from LDZ2 ;select-addr JSR2 }

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

%IS-SPACER   { #21 < } ( char -- flag )
%IS-LABEL    { STHk #40 = STHr #26 = #0000 !! } ( char -- flag )
%NOT-LINEBREAK { STHk #0d = STHr #0a = #0000 == } ( char -- flag )


@@ 194,50 197,63 @@ BRK
		;document/body .selection/from STZ2
		;get-eof JSR2 #0001 -- .selection/to STZ2
		;draw-textarea JSR2
		POP BRK
		&no-selectall
	DUP ( ctrl+h ) #68 ! ,&no-toggle-highlight JCN
		;clear-textarea JSR2
		.textarea/highlight TOGGLE
		;draw-textarea JSR2
		POP BRK
		&no-toggle-highlight
	DUP ( ctrl+f ) #66 ! ,&no-toggle-fixedwidth JCN
		;clear-textarea JSR2
		.textarea/font TOGGLE
		;draw-textarea JSR2
		POP BRK
		&no-toggle-fixedwidth
	( copy/paste/cut )
	DUP ( ctrl+c ) #63 ! ,&no-copy JCN
		;copy-snarf JSR2 
		;draw-widget/memory JSR2 POP BRK 
		;draw-widget/memory JSR2 
		POP BRK 
		&no-copy
	DUP ( ctrl+v ) #76 ! ,&no-paste JCN
		;paste-snarf JSR2 
		;draw-widget/memory JSR2 POP BRK 
		;draw-widget/memory JSR2 
		POP BRK 
		&no-paste
	DUP ( ctrl+x ) #78 ! ,&no-cut JCN
		;cut-snarf JSR2 
		;draw-widget/memory JSR2 POP BRK 
		;draw-widget/memory JSR2 
		POP BRK 
		&no-cut
	( document )
	DUP ( ctrl+r ) #72 ! ,&no-name JCN
		.state/trap TOGGLE
		#00 .state/blink STZ 
		#23 ;draw-filepath JSR2 
		POP BRK 
		&no-name
	DUP ( ctrl+o ) #6f ! ,&no-open JCN
		;clear-textarea JSR2
		#0000 ;set-scroll JSR2
		;load-file JSR2
		;document/body ;select-addr JSR2 POP BRK &no-open
	DUP ( ctrl+r ) #72 ! ,&no-name JCN
		.state/trap TOGGLE
		#00 .state/blink STZ 
		#23 ;draw-filepath JSR2 POP BRK &no-name
		;document/body ;select-addr/no-clear JSR2 
		POP BRK 
		&no-open
	DUP ( ctrl+s ) #73 ! ,&no-save JCN
		;save-file JSR2 
		;draw-state JSR2 POP BRK  &no-save
		;draw-state JSR2 
		POP BRK 
		&no-save
	DUP ( ctrl+n ) #6e ! ,&no-make JCN
		#20 ;draw-filepath JSR2
		;clear-textarea JSR2
		;untitled-txt ;new-file JSR2
		#0000 ;set-scroll JSR2
		;document/body ;select-addr JSR2
		#21 ;draw-filepath JSR2 POP BRK &no-make
		;untitled-txt ;new-file JSR2
		;document/body ;select-addr/no-clear JSR2
		#21 ;draw-filepath JSR2 
		&no-make
	POP 

BRK


@@ 251,6 267,7 @@ BRK
	,arrow-to-addr JSR
	;select-addr JSR2 
	( remove button ) POP 
	;draw-widget/selection JSR2
	BRK

	&shift


@@ 259,6 276,7 @@ BRK
	,arrow-to-addr JSR
	;select-until-addr JSR2 
	( remove button ) POP 
	;draw-widget/size JSR2

BRK



@@ 315,37 333,36 @@ RTN
	DUP #1b = ,&escape JCN
		
	&insert ( key -- )
		SPACE-AVAILABLE #0000 >> ,&no-clamp-to JCN 
			POP BRK
			&no-clamp-to
		;clear-textarea JSR2
		SELECTION-LENGTH #0001 -- ;shift-left JSR2
		#0001 ;shift-right JSR2
		.selection/from LDZ2 STA
		.selection/from LDZ2 #0001 ++ DUP2 
			.selection/from STZ2 #0001 ++ DUP2
			.selection/to STZ2
		;follow-selection JSR2
		;draw-textarea JSR2
		.selection/from LDZ2 STH2k STA
		STH2r #0001 ++ ;select-addr/no-clear JSR2
		;draw-widget/memory JSR2
	BRK

	&escape ( key -- )
		POP
		RESET-SELECTION
	BRK

	&erase ( key -- )
		POP 
		SELECTION-LENGTH #0001 >> ,&erase-multiple JCN
		.selection/from LDZ2 ;document/body !! ,&no-clamp JCN
		.selection/from LDZ2 ;document/body !! ,&no-clamp-from JCN
			BRK
			&no-clamp
			&no-clamp-from
		;clear-textarea JSR2
		.selection/from LDZ2 #0001 -- DUP2 .selection/from STZ2 
		.selection/from LDZ2 #0001 -- DUP2 STH2k .selection/from STZ2 
			#0001 ++ .selection/to STZ2
		#0001 ;shift-left JSR2
		;draw-textarea JSR2
		STH2r ;select-addr/no-clear JSR2
		;draw-widget/memory JSR2
	BRK

	&escape ( key -- )
		POP
		RESET-SELECTION
	BRK

	&erase-multiple ( -- )
		;clear-textarea JSR2
		SELECTION-LENGTH ;shift-left JSR2


@@ 394,7 411,7 @@ BRK
			.Controller/button DEI #02 ! ,&no-alt-find JCN 
				POP2 #0000 
				&no-alt-find
			;get-eof JSR2 ;find JSR2
			;find JSR2
			RELEASE-MOUSE
			POP2 POP BRK
			&no-down-alt


@@ 523,12 540,12 @@ RTN
@select-addr ( addr* -- )
	
	;clear-textarea JSR2
	&no-clear
	;clamp-addr JSR2 
		DUP2 .selection/from STZ2 
		DUP2 #0001 ++ .selection/to STZ2
	,follow-selection JSR
	;draw-textarea JSR2
	;draw-widget/selection JSR2

RTN	



@@ 599,18 616,19 @@ RTN

RTN

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


@@ 651,7 669,7 @@ RTN
RTN

@clamp-addr ( addr* -- addr* )
	

	;document/body GTH2k ,&no-clamp-start JCN
		SWP2  
		&no-clamp-start


@@ 695,7 713,8 @@ RTN
		( value ) OVR2 LDAk ROT ROT STH2kr -- STA
		INCR2 LTH2k ,&loop JCN
	POP2 POP2
	POP2r
	( update )
	;document/length LDA2 STH2r -- ;document/length STA2

RTN



@@ 707,7 726,8 @@ RTN
		( value ) OVR2 LDAk ROT ROT STH2kr ++ STA
		DECR2 GTH2k ,&loop JCN
	POP2 POP2
	POP2r
	( update )
	;document/length LDA2 STH2r ++ ;document/length STA2

RTN



@@ 742,7 762,7 @@ RTN
		,&init JSR SELECTION-LENGTH #22 ;draw-short JSR2
		RTN
	&memory
		,&init JSR ;document/body #21 ;draw-short JSR2 
		,&init JSR SPACE-AVAILABLE #21 ;draw-short JSR2 
		RTN
	&init
		#fff0 .Screen/addr DEO2


@@ 997,6 1017,7 @@ RTN
	
	;clear-file JSR2
	#0000 ;document/body STA2
	#0000 ;document/length STA2
	( rename )
	STH2
	#00 #0c


@@ 1019,6 1040,7 @@ RTN
	;document/body .File/load DEO2
	RESET-STATE
	( null ) #00 ;document/body .File/success DEI2 ++ STA
	.File/success DEI2 ;document/length STA2

RTN



@@ 1073,10 1095,8 @@ RTN
	;clear-textarea JSR2
	( move beyond to end of file )
	;snarfpath-txt .File/name DEO2 
	( get space available ) 
	#ffff ;get-eof JSR2 -- 
	( allow for maximum space )
	STH2k #0001 -- .File/length DEO2 
	SPACE-AVAILABLE STH2k .File/length DEO2 

	( push to end of memory, eof to from )
	;get-eof JSR2 DUP2 .selection/from LDZ2 #0001 --