diff options
-rw-r--r-- | edit/004-programming-environment.mu | 62 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 66 | ||||
-rw-r--r-- | edit/009-sandbox-test.mu | 4 | ||||
-rw-r--r-- | edit/010-sandbox-trace.mu | 2 | ||||
-rw-r--r-- | edit/011-errors.mu | 4 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 62 | ||||
-rw-r--r-- | sandbox/005-sandbox.mu | 66 | ||||
-rw-r--r-- | sandbox/009-sandbox-test.mu | 4 | ||||
-rw-r--r-- | sandbox/010-sandbox-trace.mu | 2 | ||||
-rw-r--r-- | sandbox/011-errors.mu | 4 |
10 files changed, 138 insertions, 138 deletions
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 247a4c68..e83aa642 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -539,68 +539,6 @@ def update-cursor screen:address:screen, recipes:address:editor-data, current-sa screen <- move-cursor screen, cursor-row, cursor-column ] -# print a text 's' to 'editor' in 'color' starting at 'row' -# clear rest of last line, move cursor to next line -def 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 - return-unless s - column:number <- copy left - screen <- move-cursor screen, row, column - screen-height:number <- screen-height screen - i:number <- copy 0 - len:number <- length *s - { - +next-character - done?:boolean <- greater-or-equal i, len - break-if done? - done? <- greater-or-equal row, screen-height - break-if done? - c:character <- index *s, i - { - # at right? wrap. - at-right?:boolean <- equal column, right - break-unless at-right? - # print wrap icon - wrap-icon:character <- copy 8617/loop-back-to-left - print screen, wrap-icon, 245/grey - column <- copy left - row <- add row, 1 - screen <- move-cursor screen, row, column - loop +next-character:label # retry i - } - i <- add i, 1 - { - # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline - break-unless newline? - # clear rest of line in this window - { - done?:boolean <- greater-than column, right - break-if done? - space:character <- copy 32/space - print screen, space - column <- add column, 1 - loop - } - row <- add row, 1 - column <- copy left - screen <- move-cursor screen, row, column - loop +next-character:label - } - print screen, c, color - column <- add column, 1 - loop - } - was-at-left?:boolean <- equal column, left - clear-line-until screen, right - { - break-if was-at-left? - row <- add row, 1 - } - move-cursor screen, row, left -] - # like 'render' for texts, but with colorization for comments like in the editor def render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ local-scope diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 0091eb1f..347e7cbe 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -292,7 +292,7 @@ def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:n { break-unless empty-screen? <render-sandbox-response> - row, screen <- render screen, sandbox-response, left, right, 245/grey, row + row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height @@ -353,6 +353,68 @@ def sandbox-menu-columns left:number, right:number -> edit-button-left:number, e copy-button-right:number <- subtract delete-button-left, 1 ] +# print a text 's' to 'editor' in 'color' starting at 'row' +# clear rest of last line, move cursor to next line +def render-text screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ + local-scope + load-ingredients + return-unless s + column:number <- copy left + screen <- move-cursor screen, row, column + screen-height:number <- screen-height screen + i:number <- copy 0 + len:number <- length *s + { + +next-character + done?:boolean <- greater-or-equal i, len + break-if done? + done? <- greater-or-equal row, screen-height + break-if done? + c:character <- index *s, i + { + # at right? wrap. + at-right?:boolean <- equal column, right + break-unless at-right? + # print wrap icon + wrap-icon:character <- copy 8617/loop-back-to-left + print screen, wrap-icon, 245/grey + column <- copy left + row <- add row, 1 + screen <- move-cursor screen, row, column + loop +next-character:label # retry i + } + i <- add i, 1 + { + # newline? move to left rather than 0 + newline?:boolean <- equal c, 10/newline + break-unless newline? + # clear rest of line in this window + { + done?:boolean <- greater-than column, right + break-if done? + space:character <- copy 32/space + print screen, space + column <- add column, 1 + loop + } + row <- add row, 1 + column <- copy left + screen <- move-cursor screen, row, column + loop +next-character:label + } + print screen, c, color + column <- add column, 1 + loop + } + was-at-left?:boolean <- equal column, left + clear-line-until screen, right + { + break-if was-at-left? + row <- add row, 1 + } + move-cursor screen, row, left +] + # assumes programming environment has no sandboxes; restores them from previous session def restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ local-scope @@ -393,7 +455,7 @@ def render-screen screen:address:screen, sandbox-screen:address:screen, left:num load-ingredients return-unless sandbox-screen # print 'screen:' - row <- render screen, [screen:], left, right, 245/grey, row + row <- render-text screen, [screen:], left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left diff --git a/edit/009-sandbox-test.mu b/edit/009-sandbox-test.mu index 16c85c45..05738626 100644 --- a/edit/009-sandbox-test.mu +++ b/edit/009-sandbox-test.mu @@ -191,11 +191,11 @@ after <render-sandbox-response> [ response-is-expected?:boolean <- equal expected-response, sandbox-response { break-if response-is-expected?:boolean - row, screen <- render screen, sandbox-response, left, right, 1/red, row + row, screen <- render-text screen, sandbox-response, left, right, 1/red, row } { break-unless response-is-expected?:boolean - row, screen <- render screen, sandbox-response, left, right, 2/green, row + row, screen <- render-text screen, sandbox-response, left, right, 2/green, row } jump +render-sandbox-end:label } diff --git a/edit/010-sandbox-trace.mu b/edit/010-sandbox-trace.mu index ab21e24c..e7297b75 100644 --- a/edit/010-sandbox-trace.mu +++ b/edit/010-sandbox-trace.mu @@ -247,7 +247,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 screen, sandbox-trace, left, right, 245/grey, row + row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row } <render-sandbox-trace-done> ] diff --git a/edit/011-errors.mu b/edit/011-errors.mu index 688ea5aa..c27ec54f 100644 --- a/edit/011-errors.mu +++ b/edit/011-errors.mu @@ -36,7 +36,7 @@ before <render-recipe-components-end> [ { recipe-errors:address:array:character <- get *env, recipe-errors:offset break-unless recipe-errors - row, screen <- render screen, recipe-errors, left, right, 1/red, row + row, screen <- render-text screen, recipe-errors, left, right, 1/red, row } ] @@ -108,7 +108,7 @@ after <render-sandbox-trace-done> [ sandbox-errors:address:array:character <- get *sandbox, errors:offset break-unless sandbox-errors *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 # no response - row, screen <- render screen, sandbox-errors, left, right, 1/red, row + row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row # don't try to print anything more for this sandbox jump +render-sandbox-end:label } diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index a0b529fc..b2f0ebc0 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -283,68 +283,6 @@ def update-cursor screen:address:screen, current-sandbox:address:editor-data, en screen <- move-cursor screen, cursor-row, cursor-column ] -# print a text 's' to 'editor' in 'color' starting at 'row' -# clear rest of last line, move cursor to next line -def 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 - return-unless s - column:number <- copy left - screen <- move-cursor screen, row, column - screen-height:number <- screen-height screen - i:number <- copy 0 - len:number <- length *s - { - +next-character - done?:boolean <- greater-or-equal i, len - break-if done? - done? <- greater-or-equal row, screen-height - break-if done? - c:character <- index *s, i - { - # at right? wrap. - at-right?:boolean <- equal column, right - break-unless at-right? - # print wrap icon - wrap-icon:character <- copy 8617/loop-back-to-left - print screen, wrap-icon, 245/grey - column <- copy left - row <- add row, 1 - screen <- move-cursor screen, row, column - loop +next-character:label # retry i - } - i <- add i, 1 - { - # newline? move to left rather than 0 - newline?:boolean <- equal c, 10/newline - break-unless newline? - # clear rest of line in this window - { - done?:boolean <- greater-than column, right - break-if done? - space:character <- copy 32/space - print screen, space - column <- add column, 1 - loop - } - row <- add row, 1 - column <- copy left - screen <- move-cursor screen, row, column - loop +next-character:label - } - print screen, c, color - column <- add column, 1 - loop - } - was-at-left?:boolean <- equal column, left - clear-line-until screen, right - { - break-if was-at-left? - row <- add row, 1 - } - move-cursor screen, row, left -] - # like 'render' for texts, but with colorization for comments like in the editor def render-code screen:address:screen, s:address:array:character, left:number, right:number, row:number -> row:number, screen:address:screen [ local-scope diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 93c2e83a..4f1429b5 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -277,7 +277,7 @@ def render-sandboxes screen:address:screen, sandbox:address:sandbox-data, left:n { break-unless empty-screen? <render-sandbox-response> - row, screen <- render screen, sandbox-response, left, right, 245/grey, row + row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height @@ -338,6 +338,68 @@ def sandbox-menu-columns left:number, right:number -> edit-button-left:number, e copy-button-right:number <- subtract delete-button-left, 1 ] +# print a text 's' to 'editor' in 'color' starting at 'row' +# clear rest of last line, move cursor to next line +def render-text screen:address:screen, s:address:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:screen [ + local-scope + load-ingredients + return-unless s + column:number <- copy left + screen <- move-cursor screen, row, column + screen-height:number <- screen-height screen + i:number <- copy 0 + len:number <- length *s + { + +next-character + done?:boolean <- greater-or-equal i, len + break-if done? + done? <- greater-or-equal row, screen-height + break-if done? + c:character <- index *s, i + { + # at right? wrap. + at-right?:boolean <- equal column, right + break-unless at-right? + # print wrap icon + wrap-icon:character <- copy 8617/loop-back-to-left + print screen, wrap-icon, 245/grey + column <- copy left + row <- add row, 1 + screen <- move-cursor screen, row, column + loop +next-character:label # retry i + } + i <- add i, 1 + { + # newline? move to left rather than 0 + newline?:boolean <- equal c, 10/newline + break-unless newline? + # clear rest of line in this window + { + done?:boolean <- greater-than column, right + break-if done? + space:character <- copy 32/space + print screen, space + column <- add column, 1 + loop + } + row <- add row, 1 + column <- copy left + screen <- move-cursor screen, row, column + loop +next-character:label + } + print screen, c, color + column <- add column, 1 + loop + } + was-at-left?:boolean <- equal column, left + clear-line-until screen, right + { + break-if was-at-left? + row <- add row, 1 + } + move-cursor screen, row, left +] + # assumes programming environment has no sandboxes; restores them from previous session def! restore-sandboxes env:address:programming-environment-data -> env:address:programming-environment-data [ local-scope @@ -378,7 +440,7 @@ def render-screen screen:address:screen, sandbox-screen:address:screen, left:num load-ingredients return-unless sandbox-screen # print 'screen:' - row <- render screen, [screen:], left, right, 245/grey, row + row <- render-text screen, [screen:], left, right, 245/grey, row screen <- move-cursor screen, row, left # start printing sandbox-screen column:number <- copy left diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index e8e13d74..6d0ca691 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -188,11 +188,11 @@ after <render-sandbox-response> [ response-is-expected?:boolean <- equal expected-response, sandbox-response { break-if response-is-expected?:boolean - row, screen <- render screen, sandbox-response, left, right, 1/red, row + row, screen <- render-text screen, sandbox-response, left, right, 1/red, row } { break-unless response-is-expected?:boolean - row, screen <- render screen, sandbox-response, left, right, 2/green, row + row, screen <- render-text screen, sandbox-response, left, right, 2/green, row } jump +render-sandbox-end:label } diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index d6693035..a544d9ca 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -238,7 +238,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 screen, sandbox-trace, left, right, 245/grey, row + row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row } <render-sandbox-trace-done> ] diff --git a/sandbox/011-errors.mu b/sandbox/011-errors.mu index fc1e99ed..8b0180be 100644 --- a/sandbox/011-errors.mu +++ b/sandbox/011-errors.mu @@ -116,9 +116,9 @@ after <render-sandbox-trace-done> [ { break-unless env recipe-errors:address:array:character <- get *env, recipe-errors:offset - row, screen <- render screen, recipe-errors, left, right, 1/red, row + row, screen <- render-text screen, recipe-errors, left, right, 1/red, row } - row, screen <- render screen, sandbox-errors, left, right, 1/red, row + row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row # don't try to print anything more for this sandbox jump +render-sandbox-end:label } |