~rabbits/left

1cc56f9a2c0bdbb01cc67a85d67df1c36f9ff30f — Devine Lu Linvega 2 months ago cec6a2c
Fixed issue with open-binary
1 files changed, 30 insertions(+), 28 deletions(-)

M src/left.tal
M src/left.tal => src/left.tal +30 -28
@@ 144,7 144,7 @@
@on-console-arg ( -> )
	.Console/read DEI .filepath skey ?{ BRK }
	;on-console .Console/vector DEO2
	file-open-reset untrap BRK
	file-open untrap BRK

@on-button-trap ( -> )
	<clear-filepath>


@@ 156,7 156,7 @@
	BRK

	&open ( c -> )
	file-open-reset
	file-open
	&escape ( c -> )
	POP untrap BRK



@@ 368,14 368,15 @@
(
@|editing )

@put-byte ( byte -- )
	DUP #04 SFT put-byte/h
@<put-byte> ( byte -- )
	DUP #04 SFT <put-byte>/h
	&h ( byte -- )
	#0f AND DUP #09 GTH #27 MUL ADD #30 ADD
	( >> )

@put-char ( char -- )
@<put-char> ( char -- )
	get-eof DUP2 #fff0 GTH2 ?{
		STA
		#0001 SUB2 STA
		.textarea/length LDZ2k INC2 ROT STZ2
		JMP2r }
	POP2 POP JMP2r


@@ 997,10 998,10 @@
		#0001 SUB2 LDAk [ LIT "/ ] NEQ ?{
			NIP2
			( null ) [ LITr 00 ] STH2
			INC2r STAr !file-open-reset }
			INC2r STAr !file-open }
		NEQ2k ?&>w
	&skip ( -- )
	POP2 [ LIT2 ". 00 ] SWP2 STA2 !file-open-reset
	POP2 [ LIT2 ". 00 ] SWP2 STA2 !file-open

@go-selection ( -- )
	get-from LDA2 [ LIT2 ".. ] EQU2 ?go-directory


@@ 1019,7 1020,7 @@

	&e ( cap buffer )
	#00 STHr STZ
	POP2 POP2 !file-open-reset
	POP2 POP2 !file-open

(
@|document )


@@ 1039,17 1040,16 @@
	#01 <draw-filepath>
	update-nav !reqdraw-textarea

@file-open-reset ( -- )
	reset-each/reset-scroll
	( >> )

@file-open ( -- )
	#0000 <set-scroll-y>
	#0094 <scroll-to-x>
	;text <select-a>
	<reset-search>
	( >> )

@file-reopen ( -- )
	file-is-bin? ?file-open-binary
	;text <sclr>
	;filepath file-is-bin? ?file-open-binary
	;filepath .File/name DEO2
	#fff0 ;text SUB2 .File/length DEO2
	;text .File/read DEO2


@@ 1065,12 1065,14 @@
	#0001 .File/length DEO2
	#0000
	&s ( -- )
	;&b feof? ?&eof
	[ LIT &b $1 ] put-byte INC2
	( | format )
	DUP #01 AND ?&s
	DUP #0f AND #00 NEQ #16 MUL #0a ADD put-char !&s
	&eof POP2 #0000 <set-scroll-y>
	;&b feof? ?{
		[ LIT &b $1 ] <put-byte>
		INC2
		( | format )
		DUP #01 AND ?&s
		DUP #0f AND #00 NEQ #16 MUL #0a ADD <put-char> !&s }
	POP2
	( | continue )
	[ LIT2 01 -textarea/highlight ] STZ
	select-reset #01 <draw-filepath>
	#0a <draw-state> !reqdraw-textarea


@@ 1143,15 1145,15 @@

	&tal-ext ".tal $1

@file-is-bin? ( -- bool )
	;filepath .File/name DEO2
@file-is-bin? ( path* -- bool )
	.File/name DEO2
	#0001 .File/length DEO2
	&s ( -- )
	;&b feof? ?&eof
	[ LIT &b $1 ] ?&s
	#01 JMP2r
	!&s
	&eof #00 JMP2r
	;&b feof? ?{
		[ LIT &b $1 ] ?&s
		#01 JMP2r
		!&s }
	#00 JMP2r

@feof? ( buf* -- eof )
	.File/read DEO2


@@ 1172,7 1174,7 @@
	JMP2r

@edit-paste ( -- )
	;snarf-txt !file-inject
	;snarf-txt file-is-bin? ;snarf-txt !file-inject

@edit-inject ( -- )
	;search !file-inject