diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-01-26 20:10:43 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-01-26 20:10:43 -0800 |
commit | da31c4245227d6e05080d4e289e34c5360aa933d (patch) | |
tree | b3ab0f6b6efbed609bcc5302074a593bb2fa2230 | |
parent | 7dbd1df7797a08ecc37ffb75163e0b6d84d83080 (diff) | |
download | mu-da31c4245227d6e05080d4e289e34c5360aa933d.tar.gz |
634
-rw-r--r-- | mu.arc | 24 | ||||
-rw-r--r-- | mu.arc.t | 35 |
2 files changed, 53 insertions, 6 deletions
diff --git a/mu.arc b/mu.arc index 4edc7d92..fc8fc9fc 100644 --- a/mu.arc +++ b/mu.arc @@ -1502,7 +1502,7 @@ (~is memory*.addr value.idx) (do1 nil (prn "@addr should contain @(repr value.idx) but contains @(repr memory*.addr)") -;? (recur (+ addr 1) (+ idx 1)) ;? 1 +;? (recur (+ addr 1) (+ idx 1)) ;? 2 ) :else (recur (+ addr 1) (+ idx 1)))))) @@ -2082,15 +2082,24 @@ (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address) (c:character <- maybe-coerce x:tagged-value character:literal) (assert c:character) -;? (print-primitive-to-host line:buffer-address) ;? 1 -;? (print-primitive-to-host (("\n" literal))) ;? 1 -;? (print-primitive-to-host c:character) ;? 1 -;? (print-primitive-to-host (("\n" literal))) ;? 1 +;? (print-primitive-to-host line:buffer-address) ;? 2 +;? (print-primitive-to-host (("\n" literal))) ;? 2 +;? (print-primitive-to-host c:character) ;? 2 +;? (print-primitive-to-host (("\n" literal))) ;? 2 + ; handle backspace { begin (backspace?:boolean <- equal c:character ((#\backspace literal))) (break-unless backspace?:boolean) (len:integer-address <- get-address line:buffer-address/deref length:offset) - (len:integer-address/deref <- subtract len:integer-address/deref 1:literal) + ; but only if we need to + { begin +;? (print-primitive-to-host (("backspace: " literal))) ;? 1 +;? (print-primitive-to-host len:integer-address/deref) ;? 1 +;? (print-primitive-to-host (("\n" literal))) ;? 1 + (zero?:boolean <- lesser-or-equal len:integer-address/deref 0:literal) + (break-if zero?:boolean) + (len:integer-address/deref <- subtract len:integer-address/deref 1:literal) + } (loop 2:blocks) } (line:buffer-address <- append line:buffer-address c:character) @@ -2111,6 +2120,9 @@ (curr:tagged-value <- save-type c:character) ;? ($dump-channel 1093:literal) ;? 1 ;? ($start-tracing) ;? 1 +;? (print-primitive-to-host (("print: " literal))) ;? 1 +;? (print-primitive-to-host c:character) ;? 1 +;? (print-primitive-to-host (("\n" literal))) ;? 1 (buffered-stdin:channel-address/deref <- write buffered-stdin:channel-address curr:tagged-value) ;? ($stop-tracing) ;? 1 ;? ($dump-channel 1093:literal) ;? 1 diff --git a/mu.arc.t b/mu.arc.t index 565a06dc..4409d70e 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -4385,6 +4385,41 @@ " ")) (prn "F - 'buffer-stdin' handles backspace")) +(reset) +(new-trace "buffered-contents-ignore-excess-backspace") +(add-code + '((function main [ + (default-space:space-address <- new space:literal 30:literal) + (s:string-address <- new "a\b\bfoo\nbar") + (k:keyboard-address <- init-keyboard s:string-address) + (stdin:channel-address <- init-channel 1:literal) + (fork send-keys-to-stdin:fn nil:literal/globals nil:literal/limit k:keyboard-address stdin:channel-address) + (buffered-stdin:channel-address <- init-channel 1:literal) + (r:integer/routine <- fork buffer-stdin:fn nil:literal/globals nil:literal/limit stdin:channel-address buffered-stdin:channel-address) + (screen:terminal-address <- init-fake-terminal 20:literal 10:literal) + (5:string-address/raw <- get screen:terminal-address/deref data:offset) + (fork-helper send-prints-to-stdout:fn nil:literal/globals nil:literal/limit screen:terminal-address buffered-stdin:channel-address) + (sleep until-routine-done:literal r:integer/routine) + ]))) +;? (= dump-trace* (obj whitelist '("schedule" "run"))) ;? 1 +(run 'main) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +;? (prn memory*.5) ;? 1 +(when (~memory-contains-array memory*.5 + (+ "foo\n " + " " + " " + " " + " " + " " + " " + " " + " " + " ")) + (prn "F - 'buffer-stdin' ignores backspace when there's nothing to backspace over")) + ) ; section 100 (reset) |