open empty files, error on large files

This commit is contained in:
~d6 2022-04-09 00:05:12 -04:00
parent 81c02526c2
commit e3358fd1d3
1 changed files with 15 additions and 7 deletions

View File

@ -35,7 +35,7 @@
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
( MAX file size is currently #d200, i.e. 532926 bytes )
( MAX file size is currently #d200, i.e. 53760 bytes )
%dbg { #ff .System/debug DEO }
%emit { .Console/write DEO }
@ -190,10 +190,11 @@
( TODO: enable closing/opening files with editor already running )
@open-file ( filename* -> )
.File/name DEO2
#d200 .File/length DEO2
#d201 .File/length DEO2
;data .File/read DEO2
.File/success DEI2 #0000 GTH2 ,&ok JCN
.File/success DEI2 #0000 EQU2 .state/modified STZ
.File/success DEI2 #d201 LTH2 ,&ok JCN
;messages/input-error ;print JSR2
;filename ;print JSR2 nl quit!
@ -1195,9 +1196,6 @@
LIT 's .config/insert-tabs LDZ ADD emit
emit-] sp emit-u emit-:
;undo-stack/pos LDA2 ;undo-stack/data SUB2 #0003 DIV2 ;emit-dec2 JSR2
( sp
;undo-stack/pos LDA2 #0003 SUB2 LDA2k ;emit-dec2 JSR2 sp
INC2 INC2 LDA #00 SWP ;emit-dec2 JSR2 ( ) )
;emit-reset JMP2
@ -1553,7 +1551,7 @@
( various string constants used as messages for the user )
@messages [ &null 00
&input-error "Input 20 "error: 20 00
&input-error "Input 20 "error, 20 "file 20 "too 20 "large: 20 00
&bytes 20 "bytes, 00
&save-ok "Successfully 20 "saved 20 00
&save-failed "Failed 20 "to 20 "save 20 00
@ -1608,6 +1606,16 @@
( path to file being edited )
@filename $80
( stack of data to undo )
( )
( each item in the stack consists of: )
( - 2 bytes: address to jump to )
( - 1 byte: character to insert, or \0 to delete )
( )
( pos points to the next open stack frame. )
( )
( when pos points to data the stack is empty, and )
( when pos points to pos the stack is full. )
@undo-stack [
&data $180 ( 128 steps )
&pos :undo-stack/data