diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-06 10:25:39 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-06 10:25:39 -0700 |
commit | 3434223916977d98cbd767dc8342b03d607dc2a2 (patch) | |
tree | ab85506e88a2b1609057b7f92f07cd74ae9d9318 | |
parent | 3ad1d42cc9b8d25b22e53cfb4b206b91b1fc3a17 (diff) | |
download | mu-3434223916977d98cbd767dc8342b03d607dc2a2.tar.gz |
1534 - print results in a different color
-rw-r--r-- | 071print.mu | 16 | ||||
-rw-r--r-- | repl.mu | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/071print.mu b/071print.mu index d7edf7ae..db7c97d1 100644 --- a/071print.mu +++ b/071print.mu @@ -420,13 +420,19 @@ recipe print-string [ default-space:address:array:location <- new location:type, 30:literal x:address:screen <- next-ingredient s:address:array:character <- next-ingredient + color:number, color-found?:boolean <- next-ingredient + { + # default color to white + break-if color-found?:boolean + color:number <- copy 7:literal/white + } len:number <- length s:address:array:character/deref i:number <- copy 0:literal { done?:boolean <- greater-or-equal i:number, len:number break-if done?:boolean c:character <- index s:address:array:character/deref, i:number - print-character x:address:screen c:character + print-character x:address:screen, c:character, color:number i:number <- add i:number, 1:literal loop } @@ -437,8 +443,14 @@ recipe print-integer [ default-space:address:array:location <- new location:type, 30:literal x:address:screen <- next-ingredient n:number <- next-ingredient + color:number, color-found?:boolean <- next-ingredient + { + # default color to white + break-if color-found?:boolean + color:number <- copy 7:literal/white + } # todo: other bases besides decimal s:address:array:character <- integer-to-decimal-string n:number - print-string x:address:screen, s:address:array:character + print-string x:address:screen, s:address:array:character, color:number reply x:address:screen/same-as-ingredient:0 ] diff --git a/repl.mu b/repl.mu index 008e79b7..93d4fd72 100644 --- a/repl.mu +++ b/repl.mu @@ -5,7 +5,7 @@ recipe main [ switch-to-display msg:address:array:character <- new [ready! type in an instruction, then hit enter. ctrl-d exits. ] - 0:literal/real-screen <- print-string 0:literal/real-screen, msg:address:array:character + 0:literal/real-screen <- print-string 0:literal/real-screen, msg:address:array:character, 245:literal/grey 0:literal/real-keyboard, 0:literal/real-screen <- color-session 0:literal/real-keyboard, 0:literal/real-screen #? wait-for-key-from-keyboard #? 1 return-to-console |