From 298f8065857630e414d84e4ee785a6d17e5f99bb Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 5 Jul 2016 01:08:00 -0700 Subject: 3102 --- html/edit/002-typing.mu.html | 81 ++++++--- html/edit/004-programming-environment.mu.html | 185 ++++++++++--------- html/edit/005-sandbox.mu.html | 246 ++++++++++++++++++++++++-- html/edit/006-sandbox-copy.mu.html | 3 +- html/edit/007-sandbox-delete.mu.html | 10 +- html/edit/008-sandbox-edit.mu.html | 6 +- html/edit/009-sandbox-test.mu.html | 6 +- html/edit/010-sandbox-trace.mu.html | 46 ++++- html/edit/011-errors.mu.html | 4 +- 9 files changed, 450 insertions(+), 137 deletions(-) (limited to 'html/edit') diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 7375cd90..69e1b614 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -726,12 +726,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color after <insert-character-special-case> [ # if the line wraps at the cursor, move cursor to start of next row { - # if we're at the column just before the wrap indicator - wrap-column:number <- subtract right, 1 + # if either: + # a) we're at the end of the line and at the column of the wrap indicator, or + # b) we're not at end of line and just before the column of the wrap indicator + wrap-column:number <- copy right + before-wrap-column:number <- subtract wrap-column, 1 at-wrap?:boolean <- greater-or-equal cursor-column, wrap-column - break-unless at-wrap? - cursor-column <- subtract cursor-column, wrap-column - cursor-column <- add cursor-column, left + just-before-wrap?:boolean <- greater-or-equal cursor-column, before-wrap-column + next:address:duplex-list:character <- next before-cursor + # at end of line? next == 0 || next.value == 10/newline + at-end-of-line?:boolean <- equal next, 0 + { + break-if at-end-of-line? + next-character:character <- get *next, value:offset + at-end-of-line? <- equal next-character, 10/newline + } + # break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?)) + move-cursor-to-next-line?:boolean <- copy 0/false + { + break-if at-end-of-line? + move-cursor-to-next-line? <- copy just-before-wrap? + # if we're moving the cursor because it's in the middle of a wrapping + # line, adjust it to left-most column + potential-new-cursor-column:number <- copy left + } + { + break-unless at-end-of-line? + move-cursor-to-next-line? <- copy at-wrap? + # if we're moving the cursor because it's at the end of a wrapping line, + # adjust it to one past the left-most column to make room for the + # newly-inserted wrap-indicator + potential-new-cursor-column:number <- add left, 1/make-room-for-wrap-indicator + } + break-unless move-cursor-to-next-line? + cursor-column <- copy potential-new-cursor-column *editor <- put *editor, cursor-column:offset, cursor-column cursor-row <- add cursor-row, 1 *editor <- put *editor, cursor-row:offset, cursor-row @@ -746,12 +774,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color } ] -scenario editor-wraps-cursor-after-inserting-characters [ +scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ assume-screen 10/width, 5/height 1:address:array:character <- new [abcde] 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right assume-console [ - left-click 1, 4 # line is full; no wrap icon yet + left-click 1, 3 # right before the wrap icon type [f] ] run [ @@ -761,40 +789,43 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] screen-should-contain [ . . - .abcd↩ . - .fe . + .abcf↩ . + .de . .┈┈┈┈┈ . . . ] memory-should-contain [ 3 <- 2 # cursor row - 4 <- 1 # cursor column + 4 <- 0 # cursor column ] ] -scenario editor-wraps-cursor-after-inserting-characters-2 [ +scenario editor-wraps-cursor-after-inserting-characters-at-end-of-line [ + local-scope assume-screen 10/width, 5/height - 1:address:array:character <- new [abcde] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right + # create an editor containing two lines + contents:address:array:character <- new [abc +xyz] + 1:address:editor-data/raw <- new-editor contents, screen, 0/left, 5/right + screen-should-contain [ + . . + .abc . + .xyz . + . . + ] assume-console [ - left-click 1, 3 # right before the wrap icon - type [f] + left-click 1, 4 # at end of first line + type [de] # trigger wrap ] run [ - editor-event-loop screen:address:screen, console:address:console, 2:address:editor-data - 3:number <- get *2:address:editor-data, cursor-row:offset - 4:number <- get *2:address:editor-data, cursor-column:offset + editor-event-loop screen:address:screen, console:address:console, 1:address:editor-data/raw ] screen-should-contain [ . . - .abcf↩ . - .de . + .abcd↩ . + .e . + .xyz . .┈┈┈┈┈ . - . . - ] - memory-should-contain [ - 3 <- 2 # cursor row - 4 <- 0 # cursor column ] ] diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 6ae14e6c..a640fa59 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -21,6 +21,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.CommentedCode { color: #6c6c6c; } .muControl { color: #c0a020; } --> @@ -45,7 +46,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color initial-sandbox:address:array:character <- new [] hide-screen 0/screen env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox - render-all 0/screen, env + render-all 0/screen, env, render event-loop 0/screen, 0/console, env # never gets here ] @@ -146,7 +147,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { break-if more-events? env, screen <- resize screen, env - screen <- render-all screen, env + screen <- render-all screen, env, render-without-moving-cursor render-all-on-no-more-events? <- copy 0/false # full render done } loop +next-event:label @@ -171,14 +172,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { break-unless render-all-on-no-more-events? # no more events, and we have to force render - screen <- render-all screen, env + screen <- render-all screen, env, render render-all-on-no-more-events? <- copy 0/false jump +finish-event:label } # no more events, no force render { break-unless render? - screen <- render-recipes screen, env + screen <- render-recipes screen, env, render jump +finish-event:label } } @@ -199,14 +200,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { break-unless render-all-on-no-more-events? # no more events, and we have to force render - screen <- render-all screen, env + screen <- render-all screen, env, render render-all-on-no-more-events? <- copy 0/false jump +finish-event:label } # no more events, no force render { break-unless render? - screen <- render-sandbox-side screen, env + screen <- render-sandbox-side screen, env, render jump +finish-event:label } } @@ -243,6 +244,90 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *current-sandbox <- put *current-sandbox, cursor-column:offset, left ] +# Variant of 'render' that updates cursor-row and cursor-column based on +# before-cursor (rather than the other way around). If before-cursor moves +# off-screen, it resets cursor-row and cursor-column. +def render-without-moving-cursor screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ + local-scope + load-ingredients + return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + left:number <- get *editor, left:offset + screen-height:number <- screen-height screen + right:number <- get *editor, right:offset + curr:address:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev + curr <- next curr + +render-loop-initialization + color:number <- copy 7/white + row:number <- copy 1/top + column:number <- copy left + # save before-cursor + old-before-cursor:address:duplex-list:character <- get *editor, before-cursor:offset + # initialze cursor-row/cursor-column/before-cursor to the top of the screen + # by default + *editor <- put *editor, cursor-row:offset, row + *editor <- put *editor, cursor-column:offset, column + top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset + *editor <- put *editor, before-cursor:offset, top-of-screen + screen <- move-cursor screen, row, column + { + +next-character + break-unless curr + off-screen?:boolean <- greater-or-equal row, screen-height + break-if off-screen? + # if we find old-before-cursor still on the new resized screen, update + # editor-data.cursor-row and editor-data.cursor-column based on + # old-before-cursor + { + at-cursor?:boolean <- equal old-before-cursor, prev + break-unless at-cursor? + *editor <- put *editor, cursor-row:offset, row + *editor <- put *editor, cursor-column:offset, column + *editor <- put *editor, before-cursor:offset, old-before-cursor + } + c:character <- get *curr, value:offset + <character-c-received> + { + # newline? move to left rather than 0 + newline?:boolean <- equal c, 10/newline + break-unless newline? + # clear rest of line in this window + clear-line-until screen, right + # skip to next line + row <- add row, 1 + column <- copy left + screen <- move-cursor screen, row, column + curr <- next curr + prev <- next prev + loop +next-character:label + } + { + # at right? wrap. even if there's only one more letter left; we need + # room for clicking on the cursor after it. + 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 + # don't increment curr + loop +next-character:label + } + print screen, c, color + curr <- next curr + prev <- next prev + column <- add column, 1 + loop + } + # save first character off-screen + *editor <- put *editor, bottom-of-screen:offset, curr + *editor <- put *editor, bottom:offset, row + return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 +] + + scenario point-at-multiple-editors [ trace-until 100/app # trace too long assume-screen 30/width, 5/height @@ -276,7 +361,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [abc] 2:address:array:character <- new [def] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # type one letter in each of them assume-console [ left-click 1, 1 @@ -321,7 +406,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [abc] 2:address:array:character <- new [def] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render ] # divider isn't messed up screen-should-contain [ @@ -339,7 +424,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [abc] 2:address:array:character <- new [def] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # initialize programming environment and highlight cursor assume-console [] run [ @@ -373,14 +458,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] scenario backspace-in-sandbox-editor-joins-lines [ - trace-until 100/app # trace too long +#? trace-until 100/app # trace too long assume-screen 30/width, 5/height # initialize sandbox side with two lines 1:address:array:character <- new [] 2:address:array:character <- new [abc def] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render screen-should-contain [ . run (F4) . . ┊abc . @@ -407,7 +492,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -def render-all screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ +def render-all screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients trace 10, [app], [render all] @@ -427,8 +512,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color height:number <- screen-height screen draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted # - screen <- render-recipes screen, env - screen <- render-sandbox-side screen, env + screen <- render-recipes screen, env, render-editor + screen <- render-sandbox-side screen, env, render-editor <render-components-end> # recipes:address:editor-data <- get *env, recipes:offset @@ -439,7 +524,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color show-screen screen ] -def render-recipes screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ +def render-recipes screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render recipes] @@ -447,7 +532,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # render recipes left:number <- get *recipes, left:offset right:number <- get *recipes, right:offset - row:number, column:number, screen <- render screen, recipes + row:number, column:number, screen <- call render-editor, screen, recipes clear-line-until screen, right row <- add row, 1 <render-recipe-components-end> @@ -458,13 +543,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] # replaced in a later layer -def render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ +def render-sandbox-side screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients current-sandbox:address:editor-data <- get *env, current-sandbox:offset left:number <- get *current-sandbox, left:offset right:number <- get *current-sandbox, right:offset - row:number, column:number, screen, current-sandbox <- render screen, current-sandbox + row:number, column:number, screen, current-sandbox <- call render-editor, screen, current-sandbox clear-line-until screen, right row <- add row, 1 # draw solid line after code (you'll see why in later layers) @@ -490,68 +575,6 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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 @@ -621,7 +644,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { redraw-screen?:boolean <- equal c, 12/ctrl-l break-unless redraw-screen? - screen <- render-all screen, env:address:programming-environment-data + screen <- render-all screen, env:address:programming-environment-data, render sync-screen screen loop +next-event:label } diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index e3523d27..a4aa964c 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -50,7 +50,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color hide-screen 0/screen env:address:programming-environment-data <- new-programming-environment 0/screen, initial-recipe, initial-sandbox env <- restore-sandboxes env - render-all 0/screen, env + render-all 0/screen, env, render event-loop 0/screen, 0/console, env # never gets here ] @@ -167,7 +167,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color screen <- update-status screen, [running... ], 245/grey error?:boolean, env, screen <- run-sandboxes env, screen # F4 might update warnings and results on both sides - screen <- render-all screen, env + screen <- render-all screen, env, render { break-if error? screen <- update-status screen, [ ], 245/grey @@ -269,7 +269,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color } ] -def! render-sandbox-side screen:address:screen, env:address:programming-environment-data -> screen:address:screen, env:address:programming-environment-data [ +def! render-sandbox-side screen:address:screen, env:address:programming-environment-data, {render-editor: (recipe (address screen) (address editor-data) -> number number (address screen) (address editor-data))} -> screen:address:screen, env:address:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render sandbox side] @@ -282,7 +282,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { render-current-sandbox?:boolean <- equal render-from, -1 break-unless render-current-sandbox? - row, column, screen, current-sandbox <- render screen, current-sandbox + row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox clear-screen-from screen, row, column, left, right row <- add row, 1 } @@ -327,7 +327,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { 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 @@ -388,6 +388,68 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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 @@ -428,7 +490,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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 @@ -611,6 +673,160 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] +# keep the bottom of recipes from scrolling off the screen + +scenario scrolling-down-past-bottom-of-recipe-editor [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [] + render-all screen, env, render + assume-console [ + press enter + press down-arrow + ] + event-loop screen, console:address:console, env + # no scroll + screen-should-contain [ + . run (F4) . + . ┊ . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . + . ┊ . + ] +] + +scenario cursor-down-in-recipe-editor [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [] + render-all screen, env, render + assume-console [ + press enter + press up-arrow + press down-arrow # while cursor isn't at bottom + ] + event-loop screen, console:address:console, env + cursor:character <- copy 9251/␣ + print screen:address:screen, cursor + # cursor moves back to bottom + screen-should-contain [ + . run (F4) . + . ┊ . + .␣ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . + . ┊ . + ] +] + +# we'll not use the recipe-editor's 'bottom' element directly, because later +# layers will add other stuff to the left side below the editor (error messages) + +container programming-environment-data [ + recipe-bottom:number +] + +after <render-recipe-components-end> [ + *env <- put *env, recipe-bottom:offset, row +] + +after <global-keypress> [ + { + break-if sandbox-in-focus? + down-arrow?:boolean <- equal k, 65516/down-arrow + break-unless down-arrow? + recipe-editor:address:editor-data <- get *env, recipes:offset + recipe-cursor-row:number <- get *recipe-editor, cursor-row:offset + recipe-editor-bottom:number <- get *recipe-editor, bottom:offset + at-bottom-of-editor?:boolean <- greater-or-equal recipe-cursor-row, recipe-editor-bottom + break-unless at-bottom-of-editor? + more-to-scroll?:boolean <- more-to-scroll? env, screen + break-if more-to-scroll? + loop +next-event:label + } + { + break-if sandbox-in-focus? + page-down?:boolean <- equal k, 65518/page-down + break-unless page-down? + more-to-scroll?:boolean <- more-to-scroll? env, screen + break-if more-to-scroll? + loop +next-event:label + } +] + +after <global-type> [ + { + break-if sandbox-in-focus? + page-down?:boolean <- equal k, 6/ctrl-f + break-unless page-down? + more-to-scroll?:boolean <- more-to-scroll? env, screen + break-if more-to-scroll? + loop +next-event:label + } +] + +def more-to-scroll? env:address:programming-environment-data, screen:address:screen -> result:boolean [ + local-scope + load-ingredients + recipe-bottom:number <- get *env, recipe-bottom:offset + height:number <- screen-height screen + result <- greater-or-equal recipe-bottom, height +] + +scenario scrolling-down-past-bottom-of-recipe-editor-2 [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [] + render-all screen, env, render + assume-console [ + # add a line + press enter + # cursor back to top line + press up-arrow + # try to scroll + press page-down # or ctrl-f + ] + event-loop screen, console:address:console, env + # no scroll, and cursor remains at top line + screen-should-contain [ + . run (F4) . + . ┊ . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ . + . ┊ . + ] +] + +scenario scrolling-down-past-bottom-of-recipe-editor-3 [ + local-scope + trace-until 100/app + assume-screen 100/width, 10/height + env:address:programming-environment-data <- new-programming-environment screen:address:screen, [], [ab +cd] + render-all screen, env, render + assume-console [ + # add a line + press enter + # switch to sandbox + press ctrl-n + # move cursor + press down-arrow + ] + event-loop screen, console:address:console, env + cursor:character <- copy 9251/␣ + print screen:address:screen, cursor + # no scroll on recipe side, cursor moves on sandbox side + screen-should-contain [ + . run (F4) . + . ┊ab . + . ┊␣d . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] +] + # scrolling through sandboxes scenario scrolling-down-past-bottom-of-sandbox-editor [ @@ -620,7 +836,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [add 2, 2] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render assume-console [ # create a sandbox press F4 @@ -690,7 +906,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color *env <- put *env, render-from:offset, render-from } hide-screen screen - screen <- render-sandbox-side screen, env + screen <- render-sandbox-side screen, env, render show-screen screen jump +finish-event:label } @@ -721,7 +937,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color render-from <- subtract render-from, 1 *env <- put *env, render-from:offset, render-from hide-screen screen - screen <- render-sandbox-side screen, env + screen <- render-sandbox-side screen, env, render show-screen screen jump +finish-event:label } @@ -755,14 +971,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # create a sandbox 2:address:array:character <- new [add 2, 2] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render assume-console [ press F4 ] event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data # hit 'down' in recipe editor assume-console [ - press down-arrow + press page-down ] run [ event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data @@ -772,8 +988,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color # cursor moves down on recipe side screen-should-contain [ . run (F4) . - . ┊ . - .␣ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .␣ ┊ . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊0 edit copy delete . . ┊add 2, 2 . ] @@ -786,7 +1002,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes assume-console [ press ctrl-n @@ -938,7 +1154,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create a sandbox assume-console [ press ctrl-n diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index c201b609..ccf5d361 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -167,7 +167,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color copy?, env <- try-copy-sandbox click-row, env break-unless copy? hide-screen screen - screen <- render-sandbox-side screen, env + screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen loop +next-event:label @@ -215,6 +215,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color load-ingredients curr-sandbox:address:sandbox-data <- get *env, sandbox:offset { + break-unless curr-sandbox start:number <- get *curr-sandbox, starting-row-on-screen:offset found?:boolean <- equal click-row, start return-if found?, curr-sandbox diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 137a7887..f9f26d6f 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -106,7 +106,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color delete?, env <- try-delete-sandbox click-row, env break-unless delete? hide-screen screen - screen <- render-sandbox-side screen, env + screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen loop +next-event:label @@ -188,7 +188,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -234,7 +234,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -280,7 +280,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -328,7 +328,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes assume-console [ press ctrl-n diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 80712819..e79738c5 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -162,7 +162,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color edit?, env <- try-edit-sandbox click-row, env break-unless edit? hide-screen screen - screen <- render-sandbox-side screen, env + screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen loop +next-event:label @@ -258,7 +258,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes and scroll to second assume-console [ press ctrl-n @@ -306,7 +306,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:address:array:character <- new [] 2:address:array:character <- new [] 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character - render-all screen, 3:address:programming-environment-data + render-all screen, 3:address:programming-environment-data, render # create 2 sandboxes assume-console [ press ctrl-n diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 5d7e782a..eeb61f7f 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -165,7 +165,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sandbox <- toggle-expected-response sandbox save-sandboxes env hide-screen screen - screen <- render-sandbox-side screen, env, 1/clear + screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env # no change in cursor show-screen screen @@ -226,11 +226,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 282d2463..b791d18b 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -156,6 +156,48 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] +scenario clicking-on-app-trace-does-nothing [ + trace-until 100/app # trace too long + assume-screen 100/width, 10/height + 1:address:array:character <- new [] + # create and expand the trace + 2:address:array:character <- new [stash 123456789] + assume-console [ + press F4 + left-click 4, 51 + ] + 3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + screen-should-contain [ + . run (F4) . + . ┊ . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊0 edit copy delete . + . ┊stash 123456789 . + . ┊123456789 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] + # click on the stash under the edit-button region (or any of the other buttons, really) + assume-console [ + left-click 5, 57 + ] + run [ + event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data + ] + # no change; doesn't die + screen-should-contain [ + . run (F4) . + . ┊ . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊0 edit copy delete . + . ┊stash 123456789 . + . ┊123456789 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] +] + container sandbox-data [ trace:address:array:character display-trace?:boolean @@ -194,7 +236,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color x <- not x *sandbox <- put *sandbox, display-trace?:offset, x hide-screen screen - screen <- render-sandbox-side screen, env, 1/clear + screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env # no change in cursor show-screen screen @@ -240,7 +282,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 9689ea9f..6bf5c452 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -71,7 +71,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color { 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 } ] @@ -143,7 +143,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 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 } -- cgit 1.4.1-2-gfad0