From e3358fd1d3f12f7af6eadb39e668889c5a7e7565 Mon Sep 17 00:00:00 2001 From: d6 Date: Sat, 9 Apr 2022 00:05:12 -0400 Subject: [PATCH] open empty files, error on large files --- femto.tal | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/femto.tal b/femto.tal index 52e41bd..f995dc6 100644 --- a/femto.tal +++ b/femto.tal @@ -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