diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-21 10:01:12 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-21 10:04:38 -0800 |
commit | 3f7eed6c600d6fb10ad6ae279f87541af69af9a2 (patch) | |
tree | 5b39a6c193697fd86746873d1252e180edbc43f7 | |
parent | 167d0ca0d62f46598ea7385a11fa64ec935b5269 (diff) | |
download | mu-3f7eed6c600d6fb10ad6ae279f87541af69af9a2.tar.gz |
2467 - rename 'string' to 'text' everywhere
Not entirely happy with this. Maybe we'll find a better name. But at least it's an improvement. One part I *am* happy with is renaming string-replace to replace, string-append to append, etc. Overdue, now that we have static dispatch.
-rw-r--r-- | 051scenario_test.mu | 2 | ||||
-rw-r--r-- | 070text.mu (renamed from 070string.mu) | 155 | ||||
-rw-r--r-- | 076stream.mu | 4 | ||||
-rw-r--r-- | 081print.mu | 10 | ||||
-rw-r--r-- | 091run_interactive.cc | 6 | ||||
-rw-r--r-- | chessboard.mu | 28 | ||||
-rw-r--r-- | edit/001-editor.mu | 4 | ||||
-rw-r--r-- | edit/004-programming-environment.mu | 14 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 16 | ||||
-rw-r--r-- | edit/008-sandbox-test.mu | 6 | ||||
-rw-r--r-- | edit/009-sandbox-trace.mu | 2 | ||||
-rw-r--r-- | edit/010-warnings.mu | 6 | ||||
-rw-r--r-- | sandbox/001-editor.mu | 10 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 14 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 16 | ||||
-rw-r--r-- | sandbox/008-sandbox-test.mu | 6 | ||||
-rw-r--r-- | sandbox/009-sandbox-trace.mu | 2 | ||||
-rw-r--r-- | sandbox/010-warnings.mu | 4 |
18 files changed, 153 insertions, 152 deletions
diff --git a/051scenario_test.mu b/051scenario_test.mu index 3e2e5462..4f86c188 100644 --- a/051scenario_test.mu +++ b/051scenario_test.mu @@ -30,7 +30,7 @@ scenario scenario_with_multiple_comments_in_mu [ ] ] -scenario check_string_in_memory [ +scenario check_text_in_memory [ run [ 1:number <- copy 3 2:character <- copy 97 # 'a' diff --git a/070string.mu b/070text.mu index 91afb08e..923c3636 100644 --- a/070string.mu +++ b/070text.mu @@ -1,19 +1,20 @@ -# Some useful helpers for dealing with strings. +# Some useful helpers for dealing with text (arrays of characters) -recipe string-equal a:address:array:character, b:address:array:character -> result:boolean [ +# todo: rename to 'equal' once we can overload primitives +recipe text-equal a:address:array:character, b:address:array:character -> result:boolean [ local-scope load-ingredients a-len:number <- length *a b-len:number <- length *b # compare lengths { - trace 99, [string-equal], [comparing lengths] + trace 99, [text-equal], [comparing lengths] length-equal?:boolean <- equal a-len, b-len break-if length-equal? reply 0 } # compare each corresponding character - trace 99, [string-equal], [comparing characters] + trace 99, [text-equal], [comparing characters] i:number <- copy 0 { done?:boolean <- greater-or-equal i, a-len @@ -31,72 +32,72 @@ recipe string-equal a:address:array:character, b:address:array:character -> resu reply 1 ] -scenario string-equal-reflexive [ +scenario text-equal-reflexive [ run [ default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] - 3:boolean/raw <- string-equal x, x + 3:boolean/raw <- text-equal x, x ] memory-should-contain [ 3 <- 1 # x == x for all x ] ] -scenario string-equal-identical [ +scenario text-equal-identical [ run [ default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] y:address:array:character <- new [abc] - 3:boolean/raw <- string-equal x, y + 3:boolean/raw <- text-equal x, y ] memory-should-contain [ 3 <- 1 # abc == abc ] ] -scenario string-equal-distinct-lengths [ +scenario text-equal-distinct-lengths [ run [ default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] y:address:array:character <- new [abcd] - 3:boolean/raw <- string-equal x, y + 3:boolean/raw <- text-equal x, y ] memory-should-contain [ 3 <- 0 # abc != abcd ] trace-should-contain [ - string-equal: comparing lengths + text-equal: comparing lengths ] trace-should-not-contain [ - string-equal: comparing characters + text-equal: comparing characters ] ] -scenario string-equal-with-empty [ +scenario text-equal-with-empty [ run [ default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [] y:address:array:character <- new [abcd] - 3:boolean/raw <- string-equal x, y + 3:boolean/raw <- text-equal x, y ] memory-should-contain [ 3 <- 0 # "" != abcd ] ] -scenario string-equal-common-lengths-but-distinct [ +scenario text-equal-common-lengths-but-distinct [ run [ default-space:address:array:location <- new location:type, 30 x:address:array:character <- new [abc] y:address:array:character <- new [abd] - 3:boolean/raw <- string-equal x, y + 3:boolean/raw <- text-equal x, y ] memory-should-contain [ 3 <- 0 # abc != abd ] ] -# A new type to help incrementally construct strings. +# A new type to help incrementally construct texts. container buffer [ length:number data:address:array:character @@ -224,8 +225,8 @@ scenario buffer-append-handles-backspace [ ] ] -# result:address:array:character <- integer-to-decimal-string n:number -recipe integer-to-decimal-string n:number -> result:address:array:character [ +# result:address:array:character <- integer-to-decimal-text n:number +recipe integer-to-decimal-text n:number -> result:address:array:character [ local-scope load-ingredients # is n zero? @@ -258,7 +259,7 @@ recipe integer-to-decimal-string n:number -> result:address:array:character [ break-unless negate-result:boolean tmp <- buffer-append tmp, 45 # '-' } - # reverse buffer into string result + # reverse buffer into text result len:number <- get *tmp, length:offset buf:address:array:character <- get *tmp, data:offset result <- new character:type, len @@ -304,7 +305,7 @@ recipe buffer-to-array in:address:buffer -> result:address:array:character [ scenario integer-to-decimal-digit-zero [ run [ - 1:address:array:character/raw <- integer-to-decimal-string 0 + 1:address:array:character/raw <- integer-to-decimal-text 0 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -314,7 +315,7 @@ scenario integer-to-decimal-digit-zero [ scenario integer-to-decimal-digit-positive [ run [ - 1:address:array:character/raw <- integer-to-decimal-string 234 + 1:address:array:character/raw <- integer-to-decimal-text 234 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -324,7 +325,7 @@ scenario integer-to-decimal-digit-positive [ scenario integer-to-decimal-digit-negative [ run [ - 1:address:array:character/raw <- integer-to-decimal-string -1 + 1:address:array:character/raw <- integer-to-decimal-text -1 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -334,7 +335,7 @@ scenario integer-to-decimal-digit-negative [ ] ] -recipe string-append a:address:array:character, b:address:array:character -> result:address:array:character [ +recipe append a:address:array:character, b:address:array:character -> result:address:array:character [ local-scope load-ingredients # result = new character[a.length + b.length] @@ -373,11 +374,11 @@ recipe string-append a:address:array:character, b:address:array:character -> res } ] -scenario string-append-1 [ +scenario text-append-1 [ run [ 1:address:array:character/raw <- new [hello,] 2:address:array:character/raw <- new [ world!] - 3:address:array:character/raw <- string-append 1:address:array:character/raw, 2:address:array:character/raw + 3:address:array:character/raw <- append 1:address:array:character/raw, 2:address:array:character/raw 4:array:character/raw <- copy *3:address:array:character/raw ] memory-should-contain [ @@ -385,10 +386,10 @@ scenario string-append-1 [ ] ] -scenario replace-character-in-string [ +scenario replace-character-in-text [ run [ 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- string-replace 1:address:array:character/raw, 98/b, 122/z + 1:address:array:character/raw <- replace 1:address:array:character/raw, 98/b, 122/z 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -396,7 +397,7 @@ scenario replace-character-in-string [ ] ] -recipe string-replace s:address:array:character, oldc:character, newc:character -> s:address:array:character [ +recipe replace s:address:array:character, oldc:character, newc:character -> s:address:array:character [ local-scope load-ingredients from:number, _ <- next-ingredient # default to 0 @@ -407,13 +408,13 @@ recipe string-replace s:address:array:character, oldc:character, newc:character dest:address:character <- index-address *s, i *dest <- copy newc i <- add i, 1 - s <- string-replace s, oldc, newc, i + s <- replace s, oldc, newc, i ] scenario replace-character-at-start [ run [ 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- string-replace 1:address:array:character/raw, 97/a, 122/z + 1:address:array:character/raw <- replace 1:address:array:character/raw, 97/a, 122/z 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -424,7 +425,7 @@ scenario replace-character-at-start [ scenario replace-character-at-end [ run [ 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- string-replace 1:address:array:character/raw, 99/c, 122/z + 1:address:array:character/raw <- replace 1:address:array:character/raw, 99/c, 122/z 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -435,7 +436,7 @@ scenario replace-character-at-end [ scenario replace-character-missing [ run [ 1:address:array:character/raw <- new [abc] - 1:address:array:character/raw <- string-replace 1:address:array:character/raw, 100/d, 122/z + 1:address:array:character/raw <- replace 1:address:array:character/raw, 100/d, 122/z 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -446,7 +447,7 @@ scenario replace-character-missing [ scenario replace-all-characters [ run [ 1:address:array:character/raw <- new [banana] - 1:address:array:character/raw <- string-replace 1:address:array:character/raw, 97/a, 122/z + 1:address:array:character/raw <- replace 1:address:array:character/raw, 97/a, 122/z 2:array:character/raw <- copy *1:address:array:character/raw ] memory-should-contain [ @@ -754,7 +755,7 @@ recipe find-next text:address:array:character, pattern:character, idx:number -> reply idx ] -scenario string-find-next [ +scenario text-find-next [ run [ 1:address:array:character <- new [a/b] 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index @@ -764,7 +765,7 @@ scenario string-find-next [ ] ] -scenario string-find-next-empty [ +scenario text-find-next-empty [ run [ 1:address:array:character <- new [] 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index @@ -774,7 +775,7 @@ scenario string-find-next-empty [ ] ] -scenario string-find-next-initial [ +scenario text-find-next-initial [ run [ 1:address:array:character <- new [/abc] 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index @@ -784,7 +785,7 @@ scenario string-find-next-initial [ ] ] -scenario string-find-next-final [ +scenario text-find-next-final [ run [ 1:address:array:character <- new [abc/] 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index @@ -794,7 +795,7 @@ scenario string-find-next-final [ ] ] -scenario string-find-next-missing [ +scenario text-find-next-missing [ run [ 1:address:array:character <- new [abc] 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index @@ -804,7 +805,7 @@ scenario string-find-next-missing [ ] ] -scenario string-find-next-invalid-index [ +scenario text-find-next-invalid-index [ run [ 1:address:array:character <- new [abc] 2:number <- find-next 1:address:array:character, 47/slash, 4/start-index @@ -814,7 +815,7 @@ scenario string-find-next-invalid-index [ ] ] -scenario string-find-next-first [ +scenario text-find-next-first [ run [ 1:address:array:character <- new [ab/c/] 2:number <- find-next 1:address:array:character, 47/slash, 0/start-index @@ -824,7 +825,7 @@ scenario string-find-next-first [ ] ] -scenario string-find-next-second [ +scenario text-find-next-second [ run [ 1:address:array:character <- new [ab/c/] 2:number <- find-next 1:address:array:character, 47/slash, 3/start-index @@ -834,16 +835,16 @@ scenario string-find-next-second [ ] ] -# like find-next, but searches for multiple characters +# search for a pattern of multiple characters # fairly dumb algorithm -recipe find-substring text:address:array:character, pattern:address:array:character, idx:number -> next-idx:number [ +recipe find-next text:address:array:character, pattern:address:array:character, idx:number -> next-index:number [ local-scope load-ingredients first:character <- index *pattern, 0 # repeatedly check for match at current idx len:number <- length *text { - # does some unnecessary work checking for substrings even when there isn't enough of text left + # does some unnecessary work checking even when there isn't enough of text left done?:boolean <- greater-or-equal idx, len break-if done? found?:boolean <- match-at text, pattern, idx @@ -856,62 +857,62 @@ recipe find-substring text:address:array:character, pattern:address:array:charac reply idx ] -scenario find-substring-1 [ +scenario find-next-text-1 [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [bc] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 + 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 1 ] ] -scenario find-substring-2 [ +scenario find-next-text-2 [ run [ 1:address:array:character <- new [abcd] 2:address:array:character <- new [bc] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 1 + 3:number <- find-next 1:address:array:character, 2:address:array:character, 1 ] memory-should-contain [ 3 <- 1 ] ] -scenario find-substring-no-match [ +scenario find-next-no-match [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [bd] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 + 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 3 # not found ] ] -scenario find-substring-suffix-match [ +scenario find-next-suffix-match [ run [ 1:address:array:character <- new [abcd] 2:address:array:character <- new [cd] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 + 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 2 ] ] -scenario find-substring-suffix-match-2 [ +scenario find-next-suffix-match-2 [ run [ 1:address:array:character <- new [abcd] 2:address:array:character <- new [cde] - 3:number <- find-substring 1:address:array:character, 2:address:array:character, 0 + 3:number <- find-next 1:address:array:character, 2:address:array:character, 0 ] memory-should-contain [ 3 <- 4 # not found ] ] -# checks if substring matches at index 'idx' +# checks if pattern matches at index 'idx' recipe match-at text:address:array:character, pattern:address:array:character, idx:number -> result:boolean [ local-scope load-ingredients @@ -943,7 +944,7 @@ recipe match-at text:address:array:character, pattern:address:array:character, i reply 1/found ] -scenario match-at-checks-substring-at-index [ +scenario match-at-checks-pattern-at-index [ run [ 1:address:array:character <- new [abc] 2:address:array:character <- new [ab] @@ -1025,7 +1026,7 @@ scenario match-at-inside-bounds [ 3:boolean <- match-at 1:address:array:character, 2:address:array:character, 1 ] memory-should-contain [ - 3 <- 1 # matches inner substring + 3 <- 1 # match ] ] @@ -1043,7 +1044,7 @@ scenario match-at-inside-bounds-2 [ recipe split s:address:array:character, delim:character -> result:address:array:address:array:character [ local-scope load-ingredients - # empty string? return empty array + # empty text? return empty array len:number <- length *s { empty?:boolean <- equal len, 0 @@ -1074,7 +1075,7 @@ recipe split s:address:array:character, delim:character -> result:address:array: end:number <- find-next s, delim, start # copy start..end into result[curr-result] dest:address:address:array:character <- index-address *result, curr-result - *dest <- string-copy s, start, end + *dest <- text-copy s, start, end # slide over to next slice start <- add end, 1 curr-result <- add curr-result, 1 @@ -1082,7 +1083,7 @@ recipe split s:address:array:character, delim:character -> result:address:array: } ] -scenario string-split-1 [ +scenario text-split-1 [ run [ 1:address:array:character <- new [a/b] 2:address:array:address:array:character <- split 1:address:array:character, 47/slash @@ -1099,7 +1100,7 @@ scenario string-split-1 [ ] ] -scenario string-split-2 [ +scenario text-split-2 [ run [ 1:address:array:character <- new [a/b/c] 2:address:array:address:array:character <- split 1:address:array:character, 47/slash @@ -1119,7 +1120,7 @@ scenario string-split-2 [ ] ] -scenario string-split-missing [ +scenario text-split-missing [ run [ 1:address:array:character <- new [abc] 2:address:array:address:array:character <- split 1:address:array:character, 47/slash @@ -1133,7 +1134,7 @@ scenario string-split-missing [ ] ] -scenario string-split-empty [ +scenario text-split-empty [ run [ 1:address:array:character <- new [] 2:address:array:address:array:character <- split 1:address:array:character, 47/slash @@ -1144,7 +1145,7 @@ scenario string-split-empty [ ] ] -scenario string-split-empty-piece [ +scenario text-split-empty-piece [ run [ 1:address:array:character <- new [a/b//c] 2:address:array:address:array:character <- split 1:address:array:character, 47/slash @@ -1170,7 +1171,7 @@ scenario string-split-empty-piece [ recipe split-first text:address:array:character, delim:character -> x:address:array:character, y:address:array:character [ local-scope load-ingredients - # empty string? return empty strings + # empty text? return empty texts len:number <- length *text { empty?:boolean <- equal len, 0 @@ -1180,12 +1181,12 @@ recipe split-first text:address:array:character, delim:character -> x:address:ar reply } idx:number <- find-next text, delim, 0 - x:address:array:character <- string-copy text, 0, idx + x:address:array:character <- text-copy text, 0, idx idx <- add idx, 1 - y:address:array:character <- string-copy text, idx, len + y:address:array:character <- text-copy text, idx, len ] -scenario string-split-first [ +scenario text-split-first [ run [ 1:address:array:character <- new [a/b] 2:address:array:character, 3:address:array:character <- split-first 1:address:array:character, 47/slash @@ -1198,8 +1199,8 @@ scenario string-split-first [ ] ] -# todo: make this generic -recipe string-copy buf:address:array:character, start:number, end:number -> result:address:array:character [ +# todo: rename to 'copy' once we can overload primitives +recipe text-copy buf:address:array:character, start:number, end:number -> result:address:array:character [ local-scope load-ingredients # if end is out of bounds, trim it @@ -1223,10 +1224,10 @@ recipe string-copy buf:address:array:character, start:number, end:number -> resu } ] -scenario string-copy-copies-substring [ +scenario text-copy-copies-partial-text [ run [ 1:address:array:character <- new [abc] - 2:address:array:character <- string-copy 1:address:array:character, 1, 3 + 2:address:array:character <- text-copy 1:address:array:character, 1, 3 3:array:character <- copy *2:address:array:character ] memory-should-contain [ @@ -1234,10 +1235,10 @@ scenario string-copy-copies-substring [ ] ] -scenario string-copy-out-of-bounds [ +scenario text-copy-out-of-bounds [ run [ 1:address:array:character <- new [abc] - 2:address:array:character <- string-copy 1:address:array:character, 2, 4 + 2:address:array:character <- text-copy 1:address:array:character, 2, 4 3:array:character <- copy *2:address:array:character ] memory-should-contain [ @@ -1245,10 +1246,10 @@ scenario string-copy-out-of-bounds [ ] ] -scenario string-copy-out-of-bounds-2 [ +scenario text-copy-out-of-bounds-2 [ run [ 1:address:array:character <- new [abc] - 2:address:array:character <- string-copy 1:address:array:character, 3, 3 + 2:address:array:character <- text-copy 1:address:array:character, 3, 3 3:array:character <- copy *2:address:array:character ] memory-should-contain [ diff --git a/076stream.mu b/076stream.mu index bb441ade..7306fa6b 100644 --- a/076stream.mu +++ b/076stream.mu @@ -1,4 +1,4 @@ -# new type to help incrementally read strings +# new type to help incrementally read texts (arrays of characters) container stream [ index:number data:address:array:character @@ -27,7 +27,7 @@ recipe read-line in:address:stream -> result:address:array:character, in:address idx:address:number <- get-address *in, index:offset s:address:array:character <- get *in, data:offset next-idx:number <- find-next s, 10/newline, *idx - result <- string-copy s, *idx, next-idx + result <- text-copy s, *idx, next-idx *idx <- add next-idx, 1 # skip newline ] diff --git a/081print.mu b/081print.mu index a0c39e9f..92c977b7 100644 --- a/081print.mu +++ b/081print.mu @@ -592,7 +592,7 @@ recipe show-screen screen:address:screen -> screen:address:screen [ show-display ] -recipe print-string screen:address:screen, s:address:array:character -> screen:address:screen [ +recipe print screen:address:screen, s:address:array:character -> screen:address:screen [ local-scope load-ingredients color:number, color-found?:boolean <- next-ingredient @@ -619,11 +619,11 @@ recipe print-string screen:address:screen, s:address:array:character -> screen:a } ] -scenario print-string-stops-at-right-margin [ +scenario print-text-stops-at-right-margin [ run [ 1:address:screen <- new-fake-screen 3/width, 2/height 2:address:array:character <- new [abcd] - 1:address:screen <- print-string 1:address:screen, 2:address:array:character + 1:address:screen <- print 1:address:screen, 2:address:array:character 3:address:array:screen-cell <- get *1:address:screen, data:offset 4:array:screen-cell <- copy *3:address:array:screen-cell ] @@ -656,6 +656,6 @@ recipe print-integer screen:address:screen, n:number -> screen:address:screen [ bg-color <- copy 0/black } # todo: other bases besides decimal - s:address:array:character <- integer-to-decimal-string n - screen <- print-string screen, s, color, bg-color + s:address:array:character <- integer-to-decimal-text n + screen <- print screen, s, color, bg-color ] diff --git a/091run_interactive.cc b/091run_interactive.cc index 44fe5736..ec9e13d7 100644 --- a/091run_interactive.cc +++ b/091run_interactive.cc @@ -253,7 +253,7 @@ case _CLEANUP_RUN_INTERACTIVE: { break; } -:(scenario "run_interactive_returns_stringified_result") +:(scenario "run_interactive_converts_result_to_text") recipe main [ # try to interactively add 2 and 2 1:address:array:character <- new [add 2, 2] @@ -263,13 +263,13 @@ recipe main [ # first letter in the output should be '4' in unicode +mem: storing 52 in location 11 -:(scenario "run_interactive_returns_string") +:(scenario "run_interactive_returns_text") recipe main [ # try to interactively add 2 and 2 1:address:array:character <- new [ x:address:array:character <- new [a] y:address:array:character <- new [b] - z:address:array:character <- string-append x:address:array:character, y:address:array:character + z:address:array:character <- append x:address:array:character, y:address:array:character ] 2:address:array:character <- run-interactive 1:address:array:character 10:array:character <- copy 2:address:array:character/lookup diff --git a/chessboard.mu b/chessboard.mu index 77ce8adb..015a6853 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -79,21 +79,21 @@ recipe chessboard screen:address:screen, console:address:console -> screen:addre { msg:address:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves. ] - print-string screen, msg + print screen, msg cursor-to-next-line screen print-board screen, board cursor-to-next-line screen msg <- new [Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>. ] - print-string screen, msg + print screen, msg cursor-to-next-line screen msg <- new [Hit 'q' to exit. ] - print-string screen, msg + print screen, msg { cursor-to-next-line screen msg <- new [move: ] - screen <- print-string screen, msg + screen <- print screen, msg m:address:move, quit:boolean, error:boolean <- read-move buffered-stdin, screen break-if quit, +quit:label buffered-stdin <- clear-channel buffered-stdin # cleanup after error. todo: test this? @@ -157,7 +157,7 @@ recipe print-board screen:address:screen, board:address:array:address:array:char rank:number <- add row, 1 print-integer screen, rank s:address:array:character <- new [ | ] - print-string screen, s + print screen, s # print each square in the row col:number <- copy 0 { @@ -176,10 +176,10 @@ recipe print-board screen:address:screen, board:address:array:address:array:char } # print file letters as legend s <- new [ +----------------] - print-string screen, s + print screen, s screen <- cursor-to-next-line screen s <- new [ a b c d e f g h] - screen <- print-string screen, s + screen <- print screen, s screen <- cursor-to-next-line screen ] @@ -293,7 +293,7 @@ recipe read-file stdin:address:channel, screen:address:screen -> file:number, qu newline?:boolean <- equal c, 10/newline break-unless newline? error-message:address:array:character <- new [that's not enough] - print-string screen, error-message + print screen, error-message reply 0/dummy, 0/quit, 1/error } file:number <- subtract c, 97/a @@ -302,7 +302,7 @@ recipe read-file stdin:address:channel, screen:address:screen -> file:number, qu above-min:boolean <- greater-or-equal file, 0 break-if above-min error-message:address:array:character <- new [file too low: ] - print-string screen, error-message + print screen, error-message print-character screen, c cursor-to-next-line screen reply 0/dummy, 0/quit, 1/error @@ -311,7 +311,7 @@ recipe read-file stdin:address:channel, screen:address:screen -> file:number, qu below-max:boolean <- lesser-than file, 8 break-if below-max error-message <- new [file too high: ] - print-string screen, error-message + print screen, error-message print-character screen, c reply 0/dummy, 0/quit, 1/error } @@ -337,7 +337,7 @@ recipe read-rank stdin:address:channel, screen:address:screen -> rank:number, qu newline?:boolean <- equal c, 10 # newline break-unless newline? error-message:address:array:character <- new [that's not enough] - print-string screen, error-message + print screen, error-message reply 0/dummy, 0/quit, 1/error } rank:number <- subtract c, 49/'1' @@ -346,7 +346,7 @@ recipe read-rank stdin:address:channel, screen:address:screen -> rank:number, qu above-min:boolean <- greater-or-equal rank, 0 break-if above-min error-message <- new [rank too low: ] - print-string screen, error-message + print screen, error-message print-character screen, c reply 0/dummy, 0/quit, 1/error } @@ -354,7 +354,7 @@ recipe read-rank stdin:address:channel, screen:address:screen -> rank:number, qu below-max:boolean <- lesser-or-equal rank, 7 break-if below-max error-message <- new [rank too high: ] - print-string screen, error-message + print screen, error-message print-character screen, c reply 0/dummy, 0/quit, 1/error } @@ -371,7 +371,7 @@ recipe expect-from-channel stdin:address:channel, expected:character, screen:add match?:boolean <- equal c, expected break-if match? s:address:array:character <- new [expected character not found] - print-string screen, s + print screen, s } result <- not match? ] diff --git a/edit/001-editor.mu b/edit/001-editor.mu index ae9e5219..f84e388a 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -1,6 +1,6 @@ ## the basic editor data structure, and how it displays text to the screen -# temporary main for this layer: just render the given string at the given +# temporary main for this layer: just render the given text at the given # screen dimensions, then stop recipe! main text:address:array:character [ local-scope @@ -13,7 +13,7 @@ recipe! main text:address:array:character [ close-console ] -scenario editor-initially-prints-string-to-screen [ +scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ 1:address:array:character <- new [abc] diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 0915fb33..51dd2362 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -34,7 +34,7 @@ recipe new-programming-environment screen:address:screen, initial-recipe-content assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start run-button:address:array:character <- new [ run (F4) ] - print-string screen, run-button, 255/white, 161/reddish + print screen, run-button, 255/white, 161/reddish # dotted line down the middle divider:number, _ <- divide-with-remainder width, 2 draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted @@ -381,7 +381,7 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start run-button:address:array:character <- new [ run (F4) ] - print-string screen, run-button, 255/white, 161/reddish + print screen, run-button, 255/white, 161/reddish # dotted line down the middle trace 11, [app], [render divider] divider:number, _ <- divide-with-remainder width, 2 @@ -450,9 +450,9 @@ recipe update-cursor screen:address:screen, recipes:address:editor-data, current screen <- move-cursor screen, cursor-row, cursor-column ] -# print a string 's' to 'editor' in 'color' starting at 'row' +# print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render-string screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ +recipe render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients reply-unless s @@ -510,8 +510,8 @@ recipe render-string screen:address:screen, s:address:array:character, left:numb move-cursor screen, row, left ] -# like 'render-string' but with colorization for comments like in the editor -recipe render-code-string screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ +# like 'render' for texts, but with colorization for comments like in the editor +recipe render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients reply-unless s @@ -528,7 +528,7 @@ recipe render-code-string screen:address:screen, s:address:array:character, left done? <- greater-or-equal row, screen-height break-if done? c:character <- index *s, i - <character-c-received> # only line different from render-string + <character-c-received> # only line different from render { # at right? wrap. at-right?:boolean <- equal column, right diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index d6e8b8a4..bb34de1b 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -194,7 +194,7 @@ recipe update-status screen:address:screen, msg:address:array:character, color:n local-scope load-ingredients screen <- move-cursor screen, 0, 2 - screen <- print-string screen, msg, color, 238/grey/background + screen <- print screen, msg, color, 238/grey/background ] recipe save-sandboxes env:address:programming-environment-data [ @@ -209,12 +209,12 @@ recipe save-sandboxes env:address:programming-environment-data [ { break-unless curr data:address:array:character <- get *curr, data:offset - filename:address:array:character <- integer-to-decimal-string idx + filename:address:array:character <- integer-to-decimal-text idx save filename, data { expected-response:address:array:character <- get *curr, expected-response:offset break-unless expected-response - filename <- string-append filename, suffix + filename <- append filename, suffix save filename, expected-response } idx <- add idx, 1 @@ -258,7 +258,7 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef row <- add row, 1 screen <- move-cursor screen, row, left sandbox-data:address:array:character <- get *sandbox, data:offset - row, screen <- render-code-string screen, sandbox-data, left, right, row + row, screen <- render-code screen, sandbox-data, left, right, row code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order @@ -275,7 +275,7 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef break-unless empty-screen? *response-starting-row <- copy row <render-sandbox-response> - row, screen <- render-string screen, sandbox-response, left, right, 245/grey, row + row, screen <- render screen, sandbox-response, left, right, 245/grey, row } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height @@ -296,7 +296,7 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address idx:number <- copy 0 curr:address:address:sandbox-data <- get-address *env, sandbox:offset { - filename:address:array:character <- integer-to-decimal-string idx + filename:address:array:character <- integer-to-decimal-text idx contents:address:array:character <- restore filename break-unless contents # stop at first error; assuming file didn't exist # create new sandbox for file @@ -305,7 +305,7 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address *data <- copy contents # restore expected output for sandbox if it exists { - filename <- string-append filename, suffix + filename <- append filename, suffix contents <- restore filename break-unless contents expected-response:address:address:array:character <- get-address **curr, expected-response:offset @@ -326,7 +326,7 @@ recipe render-screen screen:address:screen, sandbox-screen:address:screen, left: reply-unless sandbox-screen # print 'screen:' header:address:array:character <- new [screen:] - row <- render-string screen, header, left, right, 245/grey, row + row <- render screen, header, left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu index 2c557c17..6c3c4acd 100644 --- a/edit/008-sandbox-test.mu +++ b/edit/008-sandbox-test.mu @@ -157,14 +157,14 @@ after <render-sandbox-response> [ break-unless sandbox-response expected-response:address:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey - response-is-expected?:boolean <- string-equal expected-response, sandbox-response + response-is-expected?:boolean <- text-equal expected-response, sandbox-response { break-if response-is-expected?:boolean - row, screen <- render-string screen, sandbox-response, left, right, 1/red, row + row, screen <- render screen, sandbox-response, left, right, 1/red, row } { break-unless response-is-expected?:boolean - row, screen <- render-string screen, sandbox-response, left, right, 2/green, row + row, screen <- render screen, sandbox-response, left, right, 2/green, row } jump +render-sandbox-end:label } diff --git a/edit/009-sandbox-trace.mu b/edit/009-sandbox-trace.mu index a67dc999..10e34c9c 100644 --- a/edit/009-sandbox-trace.mu +++ b/edit/009-sandbox-trace.mu @@ -203,7 +203,7 @@ after <render-sandbox-results> [ break-unless display-trace? sandbox-trace:address:array:character <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on - row, screen <- render-string, screen, sandbox-trace, left, right, 245/grey, row + row, screen <- render screen, sandbox-trace, left, right, 245/grey, row } <render-sandbox-trace-done> ] diff --git a/edit/010-warnings.mu b/edit/010-warnings.mu index b84a512c..4a04d73d 100644 --- a/edit/010-warnings.mu +++ b/edit/010-warnings.mu @@ -38,7 +38,7 @@ before <render-recipe-components-end> [ { recipe-warnings:address:array:character <- get *env, recipe-warnings:offset break-unless recipe-warnings - row, screen <- render-string screen, recipe-warnings, left, right, 1/red, row + row, screen <- render screen, recipe-warnings, left, right, 1/red, row } ] @@ -71,7 +71,7 @@ after <render-sandbox-trace-done> [ sandbox-warnings:address:array:character <- get *sandbox, warnings:offset break-unless sandbox-warnings *response-starting-row <- copy 0 # no response - row, screen <- render-string screen, sandbox-warnings, left, right, 1/red, row + row, screen <- render screen, sandbox-warnings, left, right, 1/red, row # don't try to print anything more for this sandbox jump +render-sandbox-end:label } @@ -232,7 +232,7 @@ scenario run-shows-unbalanced-bracket-warnings [ recipe foo « x <- copy 0 ] - string-replace 1:address:array:character, 171/«, 91 # '[' + replace 1:address:array:character, 171/«, 91 # '[' 2:address:array:character <- new [foo] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character assume-console [ diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index c74e6ac4..f84e388a 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/001-editor.mu @@ -1,6 +1,6 @@ ## the basic editor data structure, and how it displays text to the screen -# temporary main for this layer: just render the given string at the given +# temporary main for this layer: just render the given text at the given # screen dimensions, then stop recipe! main text:address:array:character [ local-scope @@ -13,7 +13,7 @@ recipe! main text:address:array:character [ close-console ] -scenario editor-initially-prints-string-to-screen [ +scenario editor-initially-prints-text-to-screen [ assume-screen 10/width, 5/height run [ 1:address:array:character <- new [abc] @@ -47,7 +47,7 @@ container editor-data [ # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -recipe new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data [ +recipe new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data, screen:address:screen [ local-scope load-ingredients # no clipping of bounds @@ -224,13 +224,13 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited screen:address:screen, column:number, right:number [ +recipe clear-line-delimited screen:address:screen, column:number, right:number -> screen:address:screen [ local-scope load-ingredients { done?:boolean <- greater-than column, right break-if done? - print-character screen, 32/space + screen <- print-character screen, 32/space column <- add column, 1 loop } diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 353502fe..c9cb020a 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -32,7 +32,7 @@ recipe new-programming-environment screen:address:screen, initial-sandbox-conten assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start run-button:address:array:character <- new [ run (F4) ] - print-string screen, run-button, 255/white, 161/reddish + print screen, run-button, 255/white, 161/reddish # sandbox editor current-sandbox:address:address:editor-data <- get-address *result, current-sandbox:offset *current-sandbox <- new-editor initial-sandbox-contents, screen, 0, width/right @@ -165,7 +165,7 @@ recipe render-all screen:address:screen, env:address:programming-environment-dat assert button-on-screen?, [screen too narrow for menu] screen <- move-cursor screen, 0/row, button-start run-button:address:array:character <- new [ run (F4) ] - print-string screen, run-button, 255/white, 161/reddish + print screen, run-button, 255/white, 161/reddish # screen <- render-sandbox-side screen, env <render-components-end> @@ -200,9 +200,9 @@ recipe update-cursor screen:address:screen, current-sandbox:address:editor-data screen <- move-cursor screen, cursor-row, cursor-column ] -# print a string 's' to 'editor' in 'color' starting at 'row' +# print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render-string screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ +recipe render screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients reply-unless s @@ -260,8 +260,8 @@ recipe render-string screen:address:screen, s:address:array:character, left:numb move-cursor screen, row, left ] -# like 'render-string' but with colorization for comments like in the editor -recipe render-code-string screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ +# like 'render' for texts, but with colorization for comments like in the editor +recipe render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ local-scope load-ingredients reply-unless s @@ -278,7 +278,7 @@ recipe render-code-string screen:address:screen, s:address:array:character, left done? <- greater-or-equal row, screen-height break-if done? c:character <- index *s, i - <character-c-received> # only line different from render-string + <character-c-received> # only line different from render { # at right? wrap. at-right?:boolean <- equal column, right diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 63d86fb6..0ebd079e 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -177,7 +177,7 @@ recipe update-status screen:address:screen, msg:address:array:character, color:n local-scope load-ingredients screen <- move-cursor screen, 0, 2 - screen <- print-string screen, msg, color, 238/grey/background + screen <- print screen, msg, color, 238/grey/background ] recipe save-sandboxes env:address:programming-environment-data [ @@ -192,12 +192,12 @@ recipe save-sandboxes env:address:programming-environment-data [ { break-unless curr data:address:array:character <- get *curr, data:offset - filename:address:array:character <- integer-to-decimal-string idx + filename:address:array:character <- integer-to-decimal-text idx save filename, data { expected-response:address:array:character <- get *curr, expected-response:offset break-unless expected-response - filename <- string-append filename, suffix + filename <- append filename, suffix save filename, expected-response } idx <- add idx, 1 @@ -242,7 +242,7 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef row <- add row, 1 screen <- move-cursor screen, row, left sandbox-data:address:array:character <- get *sandbox, data:offset - row, screen <- render-code-string screen, sandbox-data, left, right, row + row, screen <- render-code screen, sandbox-data, left, right, row code-ending-row:address:number <- get-address *sandbox, code-ending-row-on-screen:offset *code-ending-row <- copy row # render sandbox warnings, screen or response, in that order @@ -259,7 +259,7 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef break-unless empty-screen? *response-starting-row <- copy row <render-sandbox-response> - row, screen <- render-string screen, sandbox-response, left, right, 245/grey, row + row, screen <- render screen, sandbox-response, left, right, 245/grey, row } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height @@ -280,7 +280,7 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address idx:number <- copy 0 curr:address:address:sandbox-data <- get-address *env, sandbox:offset { - filename:address:array:character <- integer-to-decimal-string idx + filename:address:array:character <- integer-to-decimal-text idx contents:address:array:character <- restore filename break-unless contents # stop at first error; assuming file didn't exist # create new sandbox for file @@ -289,7 +289,7 @@ recipe restore-sandboxes env:address:programming-environment-data -> env:address *data <- copy contents # restore expected output for sandbox if it exists { - filename <- string-append filename, suffix + filename <- append filename, suffix contents <- restore filename break-unless contents expected-response:address:address:array:character <- get-address **curr, expected-response:offset @@ -310,7 +310,7 @@ recipe render-screen screen:address:screen, sandbox-screen:address:screen, left: reply-unless sandbox-screen # print 'screen:' header:address:array:character <- new [screen:] - row <- render-string screen, header, left, right, 245/grey, row + row <- render screen, header, left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left diff --git a/sandbox/008-sandbox-test.mu b/sandbox/008-sandbox-test.mu index a73064df..ce896017 100644 --- a/sandbox/008-sandbox-test.mu +++ b/sandbox/008-sandbox-test.mu @@ -78,14 +78,14 @@ after <render-sandbox-response> [ break-unless sandbox-response expected-response:address:array:character <- get *sandbox, expected-response:offset break-unless expected-response # fall-through to print in grey - response-is-expected?:boolean <- string-equal expected-response, sandbox-response + response-is-expected?:boolean <- text-equal expected-response, sandbox-response { break-if response-is-expected?:boolean - row, screen <- render-string screen, sandbox-response, left, right, 1/red, row + row, screen <- render screen, sandbox-response, left, right, 1/red, row } { break-unless response-is-expected?:boolean - row, screen <- render-string screen, sandbox-response, left, right, 2/green, row + row, screen <- render screen, sandbox-response, left, right, 2/green, row } jump +render-sandbox-end:label } diff --git a/sandbox/009-sandbox-trace.mu b/sandbox/009-sandbox-trace.mu index 1829e3a4..2a4cc55e 100644 --- a/sandbox/009-sandbox-trace.mu +++ b/sandbox/009-sandbox-trace.mu @@ -195,7 +195,7 @@ after <render-sandbox-results> [ break-unless display-trace? sandbox-trace:address:array:character <- get *sandbox, trace:offset break-unless sandbox-trace # nothing to print; move on - row, screen <- render-string, screen, sandbox-trace, left, right, 245/grey, row + row, screen <- render screen, sandbox-trace, left, right, 245/grey, row } <render-sandbox-trace-done> ] diff --git a/sandbox/010-warnings.mu b/sandbox/010-warnings.mu index c04e4690..5bfb9d7d 100644 --- a/sandbox/010-warnings.mu +++ b/sandbox/010-warnings.mu @@ -66,9 +66,9 @@ after <render-sandbox-trace-done> [ { break-unless env recipe-warnings:address:array:character <- get *env, recipe-warnings:offset - row, screen <- render-string screen, recipe-warnings, left, right, 1/red, row + row, screen <- render screen, recipe-warnings, left, right, 1/red, row } - row, screen <- render-string screen, sandbox-warnings, left, right, 1/red, row + row, screen <- render screen, sandbox-warnings, left, right, 1/red, row # don't try to print anything more for this sandbox jump +render-sandbox-end:label } |