basic prompt editing works now

This commit is contained in:
~d6 2022-03-23 22:12:17 -04:00
parent af7c3993fc
commit ca71bcfad2
1 changed files with 25 additions and 5 deletions

View File

@ -325,6 +325,14 @@
;draw-all JSR2 ;draw-all JSR2
BRK BRK
@insert-prompt ( c^ -> )
.tmp/pos LDZ2 STH2k STA ( data[pos] <- c )
INC2r #00 STH2kr STA ( data[pos+1] <- 0 )
STH2r .tmp/pos STZ2 ( pos <- pos+1 )
;draw-prompt JSR2
;draw-cursor JSR2
BRK
@insert-tab ( -> ) @insert-tab ( -> )
.config/insert-tabs LDZ ,&use-tabs JCN .config/insert-tabs LDZ ,&use-tabs JCN
#0000 .config/tab-width LDZ2 SUB2 #0000 .config/tab-width LDZ2 SUB2
@ -377,6 +385,14 @@
;draw-all JSR2 ;draw-all JSR2
&skip BRK &skip BRK
@backspace-prompt ( -> )
#00 .tmp/pos LDZ2 #0001 SUB2 ( 0 pos-1 )
STH2k STA ( data[pos-1] <- 0 )
STH2r .tmp/pos STZ2 ( pos <- pos-1 )
;draw-prompt JSR2
;draw-cursor JSR2
BRK
@delete ( -> ) @delete ( -> )
;last-pos JSR2 #0001 SUB2 ( lst-1 ) ;last-pos JSR2 #0001 SUB2 ( lst-1 )
;cur-pos JSR2 LTH2 ,&skip JCN ;cur-pos JSR2 LTH2 ,&skip JCN
@ -447,7 +463,7 @@
;rel-line-error ;error! JMP2 ;rel-line-error ;error! JMP2
@move-to-message-line ( -> ) @move-to-message-line ( -> )
#0002 .term/rows LDZ2 #0002 ADD2 ;term-move-cursor JMP2 #0000 .term/rows LDZ2 #0002 ADD2 ;term-move-cursor JMP2
( TODO: need to create draw-prompt and call it from draw-all ) ( TODO: need to create draw-prompt and call it from draw-all )
@ -457,8 +473,8 @@
#01 .prompt/active STZ ( prompt/active <- 1 ) #01 .prompt/active STZ ( prompt/active <- 1 )
.prompt/vector STZ2 ( prompt/vector <- vector ) .prompt/vector STZ2 ( prompt/vector <- vector )
DUP2 ;tmp/data ;str-copy JSR2 ( tmp/data <- default ) DUP2 ;tmp/data ;str-copy JSR2 ( tmp/data <- default )
;tmp/data ;str-len JSR2 ADD2 ( data+len(default) ) ;str-len JSR2 ;tmp/data ADD2 ( len(default)+data )
.tmp/pos STZ2 ( tmp/pos <- data+len(default) ) .tmp/pos STZ2 ( tmp/pos <- len(default)+data )
.prompt/string STZ2 ( prompt/string <- prompt ) .prompt/string STZ2 ( prompt/string <- prompt )
JMP2r JMP2r
&is-active &is-active
@ -518,6 +534,10 @@
@on-key-prompt @on-key-prompt
.Console/read DEI #07 EQU ( C-g ) ;cancel-prompt JCN2 .Console/read DEI #07 EQU ( C-g ) ;cancel-prompt JCN2
.Console/read DEI #0d EQU ( \r ) ;finish-prompt JCN2 .Console/read DEI #0d EQU ( \r ) ;finish-prompt JCN2
.Console/read DEI #7f EQU ( DEL ) ;backspace-prompt JCN2
.Console/read DEI #20 LTH ;ignore JCN2 ( ignore for now )
.Console/read DEI #7e GTH ;ignore JCN2 ( ignore for now )
.Console/read DEI ( printable ASCII ) ;insert-prompt JMP2
BRK BRK
( TODO: C-g or C-h for help ) ( TODO: C-g or C-h for help )
@ -911,8 +931,8 @@
( various string constants used as messages for the user ) ( various string constants used as messages for the user )
@messages [ &input-error "input 20 "error: 20 00 @messages [ &input-error "input 20 "error: 20 00
&bytes 20 "bytes, 00 &bytes 20 "bytes, 00
&save-ok "saved 20 00 &save-ok "Successfully 20 "saved 20 00
&save-failed "failed 20 "to 20 "save 00 &save-failed "Failed 20 "to 20 "save 20 00
&lines 20 "lines] 00 &lines 20 "lines] 00
&save-prompt "File 20 "Name 20 "to 20 "Write: 20 00 &save-prompt "File 20 "Name 20 "to 20 "Write: 20 00
&saved "-- 20 00 &saved "-- 20 00