about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-27 21:48:02 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-27 21:50:10 -0800
commit1224ed4c875d2b3ead1b564c1a03940cca5027d4 (patch)
tree81e0009af3000c0dda5d45bd2026746906705acf
parent1af628effea8c4f1f29ba22949c7af9e46dc2745 (diff)
downloadmu-1224ed4c875d2b3ead1b564c1a03940cca5027d4.tar.gz
645
-rw-r--r--color-repl.mu9
1 files changed, 7 insertions, 2 deletions
diff --git a/color-repl.mu b/color-repl.mu
index d95d48d9..1979ac4f 100644
--- a/color-repl.mu
+++ b/color-repl.mu
@@ -1,9 +1,14 @@
 ; a simple line editor for reading lisp s-expressions
+; colors strings and comments. nested parens get different colors.
+;
+; needs to do its own raw keyboard/screen management since we need to decide
+; how to color each key right as it is printed
+; lots of logic devoted to handling backspace correctly
 
 (function read-sexp [
   (default-space:space-address <- new space:literal 30:literal)
   (result:buffer-address <- init-buffer 30:literal)
-  (open-parens:integer <- copy 0:literal)
+  (open-parens:integer <- copy 0:literal)  ; for balancing parens and tracking nesting depth
   ; test: 34<enter>
   { begin
     next-key
@@ -60,7 +65,7 @@
       (close-paren?:boolean <- equal c:character ((#\) literal)))
       (break-unless close-paren?:boolean)
       (open-parens:integer <- subtract open-parens:integer 1:literal)
-      (_ color-code:integer <- divide-with-remainder open-parens:integer 3:literal)
+      (_ color-code:integer <- divide-with-remainder open-parens:integer 3:literal)  ; 3 distinct colors for parens
       (color-code:integer <- add color-code:integer 1:literal)
       ($print-key-to-host c:character color-code:integer)
       (jump next-key:offset)
/buffered-stdin.mu?h=hlt&id=4f686be1ebb6713933298531531fbef0898c6b2b'>^
4ca73eb6 ^
7d2c2d55 ^


4ca73eb6 ^



3a0be565 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28