diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-06-25 01:08:53 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-06-25 01:08:53 -0700 |
commit | afdda1ea04ff623f68a129ecbbe9e6a25476fade (patch) | |
tree | d5441fdb45b19539f938e8f4aa8691a7cbf6ddbe /edit | |
parent | 4ec5d8513c7c8651a08308047d2b9d765e32a042 (diff) | |
download | mu-afdda1ea04ff623f68a129ecbbe9e6a25476fade.tar.gz |
3067
Diffstat (limited to 'edit')
-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 |
5 files changed, 69 insertions, 69 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 } |