diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-03-14 11:21:22 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-03-14 11:21:22 -0700 |
commit | fadb576efca5586fc67bdc3f69fc32e86fc3bb01 (patch) | |
tree | 16c664ee22094b5916cbf55b2c09afc5a1ac800e /sandbox | |
parent | 7b38bc8ece46b92855c6363fde53d59011d9f0a4 (diff) | |
download | mu-fadb576efca5586fc67bdc3f69fc32e86fc3bb01.tar.gz |
3796
Standardize the order of some common blocks in `render`, `render-text` and `render-code`. This is preparation for trying to reorganize them to reduce duplicate code.
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/005-sandbox.mu | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index 528ca5ce..badd0d46 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -365,19 +365,6 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num break-if done? c:char <- index *s, i { - # at right? wrap. - at-right?:bool <- equal column, right - break-unless at-right? - # print wrap icon - wrap-icon:char <- 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 # retry i - } - i <- add i, 1 - { # newline? move to left rather than 0 newline?:bool <- equal c, 10/newline break-unless newline? @@ -393,8 +380,23 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num row <- add row, 1 column <- copy left screen <- move-cursor screen, row, column + i <- add i, 1 + loop +next-character + } + { + # at right? wrap. + at-right?:bool <- equal column, right + break-unless at-right? + # print wrap icon + wrap-icon:char <- 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 + # don't increment i loop +next-character } + i <- add i, 1 print screen, c, color column <- add column, 1 loop @@ -428,19 +430,6 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num c:char <- index *s, i <character-c-received> # only line different from 'render-text' { - # at right? wrap. - at-right?:bool <- equal column, right - break-unless at-right? - # print wrap icon - wrap-icon:char <- 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 # retry i - } - i <- add i, 1 - { # newline? move to left rather than 0 newline?:bool <- equal c, 10/newline break-unless newline? @@ -456,8 +445,23 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num row <- add row, 1 column <- copy left screen <- move-cursor screen, row, column + i <- add i, 1 + loop +next-character + } + { + # at right? wrap. + at-right?:bool <- equal column, right + break-unless at-right? + # print wrap icon + wrap-icon:char <- 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 + # don't increment i loop +next-character } + i <- add i, 1 print screen, c, color column <- add column, 1 loop |