From fdfe34ded306526bd87568e50ac9a6e03c9c0594 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 26 Dec 2016 21:23:55 -0800 Subject: 3715 Fix cross-links in html for the edit/ app. I originally thought I'd need to provide a commandline flag like --rel-path or something. But we need to support different relative paths in a single html file. So the solution instead is appropriately engineering the tags file. --- html/edit/001-editor.mu.html | 116 ++--- html/edit/002-typing.mu.html | 260 +++++----- html/edit/003-shortcuts.mu.html | 718 +++++++++++++------------- html/edit/004-programming-environment.mu.html | 214 ++++---- html/edit/005-sandbox.mu.html | 370 ++++++------- html/edit/006-sandbox-copy.mu.html | 62 +-- html/edit/007-sandbox-delete.mu.html | 80 +-- html/edit/008-sandbox-edit.mu.html | 84 +-- html/edit/009-sandbox-test.mu.html | 36 +- html/edit/010-sandbox-trace.mu.html | 42 +- html/edit/011-errors.mu.html | 94 ++-- html/edit/012-editor-undo.mu.html | 448 ++++++++-------- 12 files changed, 1262 insertions(+), 1262 deletions(-) (limited to 'html') diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index 3d19d408..e9523e13 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -65,19 +65,19 @@ if ('onhashchange' in window) { 6 local-scope 7 load-ingredients 8 open-console - 9 hide-screen 0/screen - 10 new-editor text, 0/left, 5/right - 11 show-screen 0/screen - 12 wait-for-event 0/console + 9 hide-screen 0/screen + 10 new-editor text, 0/left, 5/right + 11 show-screen 0/screen + 12 wait-for-event 0/console 13 close-console 14 ] 15 16 scenario editor-renders-text-to-screen [ 17 local-scope 18 assume-screen 10/width, 5/height - 19 e:&:editor <- new-editor [abc], 0/left, 10/right + 19 e:&:editor <- new-editor [abc], 0/left, 10/right 20 run [ - 21 render screen, e + 21 render screen, e 22 ] 23 screen-should-contain [ 24 # top line of screen reserved for menu @@ -107,7 +107,7 @@ if ('onhashchange' in window) { 48 49 # creates a new editor widget 50 # right is exclusive - 51 def new-editor s:text, left:num, right:num -> result:&:editor [ + 51 def new-editor s:text, left:num, right:num -> result:&:editor [ 52 local-scope 53 load-ingredients 54 # no clipping of bounds @@ -124,11 +124,11 @@ if ('onhashchange' in window) { 65 *result <- put *result, data:offset, init 66 *result <- put *result, top-of-screen:offset, init 67 *result <- put *result, before-cursor:offset, init - 68 result <- insert-text result, s + 68 result <- insert-text result, s 69 <editor-initialization> 70 ] 71 - 72 def insert-text editor:&:editor, text:text -> editor:&:editor [ + 72 def insert-text editor:&:editor, text:text -> editor:&:editor [ 73 local-scope 74 load-ingredients 75 # early exit if text is empty @@ -144,7 +144,7 @@ if ('onhashchange' in window) { 85 c:char <- index *text, idx 86 insert c, curr 87 # next iter - 88 curr <- next curr + 88 curr <- next curr 89 idx <- add idx, 1 90 loop 91 } @@ -154,7 +154,7 @@ if ('onhashchange' in window) { 95 local-scope 96 assume-screen 5/width, 3/height 97 run [ - 98 e:&:editor <- new-editor 0/data, 2/left, 5/right + 98 e:&:editor <- new-editor 0/data, 2/left, 5/right 99 2:editor/raw <- copy *e 100 ] 101 memory-should-contain [ @@ -178,17 +178,17 @@ if ('onhashchange' in window) { 119 # Assumes cursor should be at coordinates (cursor-row, cursor-column) and 120 # updates before-cursor to match. Might also move coordinates if they're 121 # outside text. -122 def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ +122 def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ 123 local-scope 124 load-ingredients 125 return-unless editor, 1/top, 0/left 126 left:num <- get *editor, left:offset -127 screen-height:num <- screen-height screen +127 screen-height:num <- screen-height screen 128 right:num <- get *editor, right:offset 129 # traversing editor 130 curr:&:duplex-list:char <- get *editor, top-of-screen:offset -131 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev -132 curr <- next curr +131 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev +132 curr <- next curr 133 # traversing screen 134 +render-loop-initialization 135 color:num <- copy 7/white @@ -197,11 +197,11 @@ if ('onhashchange' in window) { 138 cursor-row:num <- get *editor, cursor-row:offset 139 cursor-column:num <- get *editor, cursor-column:offset 140 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -141 screen <- move-cursor screen, row, column +141 screen <- move-cursor screen, row, column 142 { 143 +next-character 144 break-unless curr -145 off-screen?:bool <- greater-or-equal row, screen-height +145 off-screen?:bool <- greater-or-equal row, screen-height 146 break-if off-screen? 147 # update editor.before-cursor 148 # Doing so at the start of each iteration ensures it stays one step behind @@ -211,7 +211,7 @@ if ('onhashchange' in window) { 152 break-unless at-cursor-row? 153 at-cursor?:bool <- equal column, cursor-column 154 break-unless at-cursor? -155 before-cursor <- copy prev +155 before-cursor <- copy prev 156 } 157 c:char <- get *curr, value:offset 158 <character-c-received> @@ -226,16 +226,16 @@ if ('onhashchange' in window) { 167 left-of-cursor?:bool <- lesser-than column, cursor-column 168 break-unless left-of-cursor? 169 cursor-column <- copy column -170 before-cursor <- prev curr +170 before-cursor <- prev curr 171 } 172 # clear rest of line in this window -173 clear-line-until screen, right +173 clear-line-until screen, right 174 # skip to next line 175 row <- add row, 1 176 column <- copy left -177 screen <- move-cursor screen, row, column -178 curr <- next curr -179 prev <- next prev +177 screen <- move-cursor screen, row, column +178 curr <- next curr +179 prev <- next prev 180 loop +next-character 181 } 182 { @@ -245,16 +245,16 @@ if ('onhashchange' in window) { 186 break-unless at-right? 187 # print wrap icon 188 wrap-icon:char <- copy 8617/loop-back-to-left -189 print screen, wrap-icon, 245/grey +189 print screen, wrap-icon, 245/grey 190 column <- copy left 191 row <- add row, 1 -192 screen <- move-cursor screen, row, column +192 screen <- move-cursor screen, row, column 193 # don't increment curr 194 loop +next-character 195 } -196 print screen, c, color -197 curr <- next curr -198 prev <- next prev +196 print screen, c, color +197 curr <- next curr +198 prev <- next prev 199 column <- add column, 1 200 loop 201 } @@ -270,7 +270,7 @@ if ('onhashchange' in window) { 211 break-unless before-cursor? 212 cursor-row <- copy row 213 cursor-column <- copy column -214 before-cursor <- copy prev +214 before-cursor <- copy prev 215 } 216 *editor <- put *editor, bottom:offset, row 217 *editor <- put *editor, cursor-row:offset, cursor-row @@ -279,32 +279,32 @@ if ('onhashchange' in window) { 220 return row, column 221 ] 222 -223 def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ +223 def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ 224 local-scope 225 load-ingredients 226 # if it's the real screen, use the optimized primitive 227 { -228 break-if screen +228 break-if screen 229 clear-display-from row, column, left, right 230 return 231 } 232 # if not, go the slower route -233 screen <- move-cursor screen, row, column -234 clear-line-until screen, right -235 clear-rest-of-screen screen, row, left, right +233 screen <- move-cursor screen, row, column +234 clear-line-until screen, right +235 clear-rest-of-screen screen, row, left, right 236 ] 237 -238 def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ +238 def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ 239 local-scope 240 load-ingredients 241 row <- add row, 1 -242 screen <- move-cursor screen, row, left -243 screen-height:num <- screen-height screen +242 screen <- move-cursor screen, row, left +243 screen-height:num <- screen-height screen 244 { -245 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height +245 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height 246 break-if at-bottom-of-screen? -247 screen <- move-cursor screen, row, left -248 clear-line-until screen, right +247 screen <- move-cursor screen, row, left +248 clear-line-until screen, right 249 row <- add row, 1 250 loop 251 } @@ -315,9 +315,9 @@ if ('onhashchange' in window) { 256 assume-screen 5/width, 5/height 257 s:text <- new [abc 258 def] -259 e:&:editor <- new-editor s, 0/left, 5/right +259 e:&:editor <- new-editor s, 0/left, 5/right 260 run [ -261 render screen, e +261 render screen, e 262 ] 263 screen-should-contain [ 264 . . @@ -330,9 +330,9 @@ if ('onhashchange' in window) { 271 scenario editor-handles-offsets [ 272 local-scope 273 assume-screen 5/width, 5/height -274 e:&:editor <- new-editor [abc], 1/left, 5/right +274 e:&:editor <- new-editor [abc], 1/left, 5/right 275 run [ -276 render screen, e +276 render screen, e 277 ] 278 screen-should-contain [ 279 . . @@ -346,9 +346,9 @@ if ('onhashchange' in window) { 287 assume-screen 5/width, 5/height 288 s:text <- new [abc 289 def] -290 e:&:editor <- new-editor s, 1/left, 5/right +290 e:&:editor <- new-editor s, 1/left, 5/right 291 run [ -292 render screen, e +292 render screen, e 293 ] 294 screen-should-contain [ 295 . . @@ -361,9 +361,9 @@ if ('onhashchange' in window) { 302 scenario editor-wraps-long-lines [ 303 local-scope 304 assume-screen 5/width, 5/height -305 e:&:editor <- new-editor [abc def], 0/left, 5/right +305 e:&:editor <- new-editor [abc def], 0/left, 5/right 306 run [ -307 render screen, e +307 render screen, e 308 ] 309 screen-should-contain [ 310 . . @@ -382,9 +382,9 @@ if ('onhashchange' in window) { 323 scenario editor-wraps-barely-long-lines [ 324 local-scope 325 assume-screen 5/width, 5/height -326 e:&:editor <- new-editor [abcde], 0/left, 5/right +326 e:&:editor <- new-editor [abcde], 0/left, 5/right 327 run [ -328 render screen, e +328 render screen, e 329 ] 330 # still wrap, even though the line would fit. We need room to click on the 331 # end of the line @@ -405,9 +405,9 @@ if ('onhashchange' in window) { 346 scenario editor-with-empty-text [ 347 local-scope 348 assume-screen 5/width, 5/height -349 e:&:editor <- new-editor [], 0/left, 5/right +349 e:&:editor <- new-editor [], 0/left, 5/right 350 run [ -351 render screen, e +351 render screen, e 352 3:num/raw <- get *e, cursor-row:offset 353 4:num/raw <- get *e, cursor-column:offset 354 ] @@ -430,9 +430,9 @@ if ('onhashchange' in window) { 371 s:text <- new [abc 372 # de 373 f] -374 e:&:editor <- new-editor s, 0/left, 5/right +374 e:&:editor <- new-editor s, 0/left, 5/right 375 run [ -376 render screen, e +376 render screen, e 377 ] 378 screen-should-contain [ 379 . . @@ -458,11 +458,11 @@ if ('onhashchange' in window) { 399 ] 400 401 after <character-c-received> [ -402 color <- get-color color, c +402 color <- get-color color, c 403 ] 404 405 # so far the previous color is all the information we need; that may change -406 def get-color color:num, c:char -> color:num [ +406 def get-color color:num, c:char -> color:num [ 407 local-scope 408 load-ingredients 409 color-is-white?:bool <- equal color, 7/white @@ -513,9 +513,9 @@ if ('onhashchange' in window) { 454 s:text <- new [abc 455 d <- e 456 f] -457 e:&:editor <- new-editor s, 0/left, 8/right +457 e:&:editor <- new-editor s, 0/left, 8/right 458 run [ -459 render screen, e +459 render screen, e 460 ] 461 screen-should-contain [ 462 . . diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index e6d55bfc..26f60cb4 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -65,12 +65,12 @@ if ('onhashchange' in window) { 6 local-scope 7 load-ingredients 8 open-console - 9 editor:&:editor <- new-editor text, 5/left, 45/right - 10 editor-event-loop 0/screen, 0/console, editor + 9 editor:&:editor <- new-editor text, 5/left, 45/right + 10 editor-event-loop 0/screen, 0/console, editor 11 close-console 12 ] 13 - 14 def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> screen:&:screen, console:&:console, editor:&:editor [ + 14 def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> screen:&:screen, console:&:console, editor:&:editor [ 15 local-scope 16 load-ingredients 17 { @@ -78,25 +78,25 @@ if ('onhashchange' in window) { 19 +next-event 20 cursor-row:num <- get *editor, cursor-row:offset 21 cursor-column:num <- get *editor, cursor-column:offset - 22 screen <- move-cursor screen, cursor-row, cursor-column - 23 e:event, found?:bool, quit?:bool, console <- read-event console + 22 screen <- move-cursor screen, cursor-row, cursor-column + 23 e:event, found?:bool, quit?:bool, console <- read-event console 24 loop-unless found? 25 break-if quit? # only in tests 26 trace 10, [app], [next-event] 27 # 'touch' event - 28 t:touch-event, is-touch?:bool <- maybe-convert e, touch:variant + 28 t:touch-event, is-touch?:bool <- maybe-convert e, touch:variant 29 { 30 break-unless is-touch? - 31 move-cursor-in-editor screen, editor, t + 31 move-cursor-in-editor screen, editor, t 32 loop +next-event 33 } 34 # keyboard events 35 { 36 break-if is-touch? - 37 go-render?:bool <- handle-keyboard-event screen, editor, e + 37 go-render?:bool <- handle-keyboard-event screen, editor, e 38 { 39 break-unless go-render? - 40 screen <- editor-render screen, editor + 40 screen <- editor-render screen, editor 41 } 42 } 43 loop @@ -104,7 +104,7 @@ if ('onhashchange' in window) { 45 ] 46 47 # process click, return if it was on current editor - 48 def move-cursor-in-editor screen:&:screen, editor:&:editor, t:touch-event -> in-focus?:bool, editor:&:editor [ + 48 def move-cursor-in-editor screen:&:screen, editor:&:editor, t:touch-event -> in-focus?:bool, editor:&:editor [ 49 local-scope 50 load-ingredients 51 return-unless editor, 0/false @@ -119,7 +119,7 @@ if ('onhashchange' in window) { 60 return-if too-far-right?, 0/false 61 # position cursor 62 <move-cursor-begin> - 63 editor <- snap-cursor screen, editor, click-row, click-column + 63 editor <- snap-cursor screen, editor, click-row, click-column 64 undo-coalesce-tag:num <- copy 0/never 65 <move-cursor-end> 66 # gain focus @@ -129,17 +129,17 @@ if ('onhashchange' in window) { 70 # Variant of 'render' that only moves the cursor (coordinates and 71 # before-cursor). If it's past the end of a line, it 'slides' it left. If it's 72 # past the last line it positions at end of last line. - 73 def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column:num -> editor:&:editor [ + 73 def snap-cursor screen:&:screen, editor:&:editor, target-row:num, target-column:num -> editor:&:editor [ 74 local-scope 75 load-ingredients 76 return-unless editor 77 left:num <- get *editor, left:offset 78 right:num <- get *editor, right:offset - 79 screen-height:num <- screen-height screen + 79 screen-height:num <- screen-height screen 80 # count newlines until screen row 81 curr:&:duplex-list:char <- get *editor, top-of-screen:offset - 82 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev - 83 curr <- next curr + 82 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev + 83 curr <- next curr 84 row:num <- copy 1/top 85 column:num <- copy left 86 *editor <- put *editor, cursor-row:offset, target-row @@ -150,7 +150,7 @@ if ('onhashchange' in window) { 91 { 92 +next-character 93 break-unless curr - 94 off-screen?:bool <- greater-or-equal row, screen-height + 94 off-screen?:bool <- greater-or-equal row, screen-height 95 break-if off-screen? 96 # update editor.before-cursor 97 # Doing so at the start of each iteration ensures it stays one step behind @@ -160,7 +160,7 @@ if ('onhashchange' in window) { 101 break-unless at-cursor-row? 102 at-cursor?:bool <- equal column, cursor-column 103 break-unless at-cursor? - 104 before-cursor <- copy prev + 104 before-cursor <- copy prev 105 *editor <- put *editor, before-cursor:offset, before-cursor 106 } 107 c:char <- get *curr, value:offset @@ -176,14 +176,14 @@ if ('onhashchange' in window) { 117 break-unless left-of-cursor? 118 cursor-column <- copy column 119 *editor <- put *editor, cursor-column:offset, cursor-column - 120 before-cursor <- copy prev + 120 before-cursor <- copy prev 121 *editor <- put *editor, before-cursor:offset, before-cursor 122 } 123 # skip to next line 124 row <- add row, 1 125 column <- copy left - 126 curr <- next curr - 127 prev <- next prev + 126 curr <- next curr + 127 prev <- next prev 128 loop +next-character 129 } 130 { @@ -196,8 +196,8 @@ if ('onhashchange' in window) { 137 # don't increment curr/prev 138 loop +next-character 139 } - 140 curr <- next curr - 141 prev <- next prev + 140 curr <- next curr + 141 prev <- next prev 142 column <- add column, 1 143 loop 144 } @@ -213,19 +213,19 @@ if ('onhashchange' in window) { 154 *editor <- put *editor, cursor-row:offset, cursor-row 155 cursor-column <- copy column 156 *editor <- put *editor, cursor-column:offset, cursor-column - 157 before-cursor <- copy prev + 157 before-cursor <- copy prev 158 *editor <- put *editor, before-cursor:offset, before-cursor 159 } 160 ] 161 162 # Process an event 'e' and try to minimally update the screen. 163 # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. - 164 def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> go-render?:bool, screen:&:screen, editor:&:editor [ + 164 def handle-keyboard-event screen:&:screen, editor:&:editor, e:event -> go-render?:bool, screen:&:screen, editor:&:editor [ 165 local-scope 166 load-ingredients 167 return-unless editor, 0/don't-render - 168 screen-width:num <- screen-width screen - 169 screen-height:num <- screen-height screen + 168 screen-width:num <- screen-width screen + 169 screen-height:num <- screen-height screen 170 left:num <- get *editor, left:offset 171 right:num <- get *editor, right:offset 172 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset @@ -245,24 +245,24 @@ if ('onhashchange' in window) { 186 return-unless regular-character?, 0/don't-render 187 # otherwise type it in 188 <insert-character-begin> - 189 go-render? <- insert-at-cursor editor, c, screen + 189 go-render? <- insert-at-cursor editor, c, screen 190 <insert-character-end> 191 return 192 } 193 # special key to modify the text or move the cursor - 194 k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant + 194 k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant 195 assert is-keycode?, [event was of unknown type; neither keyboard nor mouse] 196 # handlers for each special key will go here 197 <handle-special-key> 198 return 1/go-render 199 ] 200 - 201 def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool, editor:&:editor, screen:&:screen [ + 201 def insert-at-cursor editor:&:editor, c:char, screen:&:screen -> go-render?:bool, editor:&:editor, screen:&:screen [ 202 local-scope 203 load-ingredients 204 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 205 insert c, before-cursor - 206 before-cursor <- next before-cursor + 206 before-cursor <- next before-cursor 207 *editor <- put *editor, before-cursor:offset, before-cursor 208 cursor-row:num <- get *editor, cursor-row:offset 209 cursor-column:num <- get *editor, cursor-column:offset @@ -270,34 +270,34 @@ if ('onhashchange' in window) { 211 right:num <- get *editor, right:offset 212 save-row:num <- copy cursor-row 213 save-column:num <- copy cursor-column - 214 screen-width:num <- screen-width screen - 215 screen-height:num <- screen-height screen + 214 screen-width:num <- screen-width screen + 215 screen-height:num <- screen-height screen 216 # occasionally we'll need to mess with the cursor 217 <insert-character-special-case> 218 # but mostly we'll just move the cursor right 219 cursor-column <- add cursor-column, 1 220 *editor <- put *editor, cursor-column:offset, cursor-column - 221 next:&:duplex-list:char <- next before-cursor + 221 next:&:duplex-list:char <- next before-cursor 222 { 223 # at end of all text? no need to scroll? just print the character and leave - 224 at-end?:bool <- equal next, 0/null + 224 at-end?:bool <- equal next, 0/null 225 break-unless at-end? - 226 bottom:num <- subtract screen-height, 1 + 226 bottom:num <- subtract screen-height, 1 227 at-bottom?:bool <- equal save-row, bottom 228 at-right?:bool <- equal save-column, right 229 overflow?:bool <- and at-bottom?, at-right? 230 break-if overflow? - 231 move-cursor screen, save-row, save-column - 232 print screen, c + 231 move-cursor screen, save-row, save-column + 232 print screen, c 233 return 0/don't-render 234 } 235 { 236 # not at right margin? print the character and rest of line - 237 break-unless next - 238 at-right?:bool <- greater-or-equal cursor-column, screen-width + 237 break-unless next + 238 at-right?:bool <- greater-or-equal cursor-column, screen-width 239 break-if at-right? 240 curr:&:duplex-list:char <- copy before-cursor - 241 move-cursor screen, save-row, save-column + 241 move-cursor screen, save-row, save-column 242 curr-column:num <- copy save-column 243 { 244 # hit right margin? give up and let caller render @@ -308,9 +308,9 @@ if ('onhashchange' in window) { 249 currc:char <- get *curr, value:offset 250 at-newline?:bool <- equal currc, 10/newline 251 break-if at-newline? - 252 print screen, currc + 252 print screen, currc 253 curr-column <- add curr-column, 1 - 254 curr <- next curr + 254 curr <- next curr 255 loop 256 } 257 return 0/don't-render @@ -319,27 +319,27 @@ if ('onhashchange' in window) { 260 ] 261 262 # helper for tests - 263 def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:editor [ + 263 def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:editor [ 264 local-scope 265 load-ingredients 266 left:num <- get *editor, left:offset 267 right:num <- get *editor, right:offset - 268 row:num, column:num <- render screen, editor - 269 clear-line-until screen, right + 268 row:num, column:num <- render screen, editor + 269 clear-line-until screen, right 270 row <- add row, 1 - 271 draw-horizontal screen, row, left, right, 9480/horizontal-dotted + 271 draw-horizontal screen, row, left, right, 9480/horizontal-dotted 272 row <- add row, 1 - 273 clear-screen-from screen, row, left, left, right + 273 clear-screen-from screen, row, left, left, right 274 ] 275 276 scenario editor-handles-empty-event-queue [ 277 local-scope 278 assume-screen 10/width, 5/height - 279 e:&:editor <- new-editor [abc], 0/left, 10/right - 280 editor-render screen, e + 279 e:&:editor <- new-editor [abc], 0/left, 10/right + 280 editor-render screen, e 281 assume-console [] 282 run [ - 283 editor-event-loop screen, console, e + 283 editor-event-loop screen, console, e 284 ] 285 screen-should-contain [ 286 . . @@ -352,14 +352,14 @@ if ('onhashchange' in window) { 293 scenario editor-handles-mouse-clicks [ 294 local-scope 295 assume-screen 10/width, 5/height - 296 e:&:editor <- new-editor [abc], 0/left, 10/right - 297 editor-render screen, e + 296 e:&:editor <- new-editor [abc], 0/left, 10/right + 297 editor-render screen, e 298 $clear-trace 299 assume-console [ 300 left-click 1, 1 # on the 'b' 301 ] 302 run [ - 303 editor-event-loop screen, console, e + 303 editor-event-loop screen, console, e 304 3:num/raw <- get *e, cursor-row:offset 305 4:num/raw <- get *e, cursor-column:offset 306 ] @@ -379,13 +379,13 @@ if ('onhashchange' in window) { 320 scenario editor-handles-mouse-clicks-outside-text [ 321 local-scope 322 assume-screen 10/width, 5/height - 323 e:&:editor <- new-editor [abc], 0/left, 10/right + 323 e:&:editor <- new-editor [abc], 0/left, 10/right 324 $clear-trace 325 assume-console [ 326 left-click 1, 7 # last line, to the right of text 327 ] 328 run [ - 329 editor-event-loop screen, console, e + 329 editor-event-loop screen, console, e 330 3:num/raw <- get *e, cursor-row:offset 331 4:num/raw <- get *e, cursor-column:offset 332 ] @@ -401,13 +401,13 @@ if ('onhashchange' in window) { 342 assume-screen 10/width, 5/height 343 s:text <- new [abc 344 def] - 345 e:&:editor <- new-editor s, 0/left, 10/right + 345 e:&:editor <- new-editor s, 0/left, 10/right 346 $clear-trace 347 assume-console [ 348 left-click 1, 7 # interior line, to the right of text 349 ] 350 run [ - 351 editor-event-loop screen, console, e + 351 editor-event-loop screen, console, e 352 3:num/raw <- get *e, cursor-row:offset 353 4:num/raw <- get *e, cursor-column:offset 354 ] @@ -423,13 +423,13 @@ if ('onhashchange' in window) { 364 assume-screen 10/width, 5/height 365 s:text <- new [abc 366 def] - 367 e:&:editor <- new-editor s, 0/left, 10/right + 367 e:&:editor <- new-editor s, 0/left, 10/right 368 $clear-trace 369 assume-console [ 370 left-click 3, 7 # below text 371 ] 372 run [ - 373 editor-event-loop screen, console, e + 373 editor-event-loop screen, console, e 374 3:num/raw <- get *e, cursor-row:offset 375 4:num/raw <- get *e, cursor-column:offset 376 ] @@ -444,15 +444,15 @@ if ('onhashchange' in window) { 385 local-scope 386 assume-screen 10/width, 5/height 387 # editor occupies only left half of screen - 388 e:&:editor <- new-editor [abc], 0/left, 5/right - 389 editor-render screen, e + 388 e:&:editor <- new-editor [abc], 0/left, 5/right + 389 editor-render screen, e 390 $clear-trace 391 assume-console [ 392 # click on right half of screen 393 left-click 3, 8 394 ] 395 run [ - 396 editor-event-loop screen, console, e + 396 editor-event-loop screen, console, e 397 3:num/raw <- get *e, cursor-row:offset 398 4:num/raw <- get *e, cursor-column:offset 399 ] @@ -472,15 +472,15 @@ if ('onhashchange' in window) { 413 scenario editor-handles-mouse-clicks-in-menu-area [ 414 local-scope 415 assume-screen 10/width, 5/height - 416 e:&:editor <- new-editor [abc], 0/left, 5/right - 417 editor-render screen, e + 416 e:&:editor <- new-editor [abc], 0/left, 5/right + 417 editor-render screen, e 418 $clear-trace 419 assume-console [ 420 # click on first, 'menu' row 421 left-click 0, 3 422 ] 423 run [ - 424 editor-event-loop screen, console, e + 424 editor-event-loop screen, console, e 425 3:num/raw <- get *e, cursor-row:offset 426 4:num/raw <- get *e, cursor-column:offset 427 ] @@ -494,14 +494,14 @@ if ('onhashchange' in window) { 435 scenario editor-inserts-characters-into-empty-editor [ 436 local-scope 437 assume-screen 10/width, 5/height - 438 e:&:editor <- new-editor [], 0/left, 5/right - 439 editor-render screen, e + 438 e:&:editor <- new-editor [], 0/left, 5/right + 439 editor-render screen, e 440 $clear-trace 441 assume-console [ 442 type [abc] 443 ] 444 run [ - 445 editor-event-loop screen, console, e + 445 editor-event-loop screen, console, e 446 ] 447 screen-should-contain [ 448 . . @@ -515,8 +515,8 @@ if ('onhashchange' in window) { 456 scenario editor-inserts-characters-at-cursor [ 457 local-scope 458 assume-screen 10/width, 5/height - 459 e:&:editor <- new-editor [abc], 0/left, 10/right - 460 editor-render screen, e + 459 e:&:editor <- new-editor [abc], 0/left, 10/right + 460 editor-render screen, e 461 $clear-trace 462 # type two letters at different places 463 assume-console [ @@ -525,7 +525,7 @@ if ('onhashchange' in window) { 466 type [d] 467 ] 468 run [ - 469 editor-event-loop screen, console, e + 469 editor-event-loop screen, console, e 470 ] 471 screen-should-contain [ 472 . . @@ -539,15 +539,15 @@ if ('onhashchange' in window) { 480 scenario editor-inserts-characters-at-cursor-2 [ 481 local-scope 482 assume-screen 10/width, 5/height - 483 e:&:editor <- new-editor [abc], 0/left, 10/right - 484 editor-render screen, e + 483 e:&:editor <- new-editor [abc], 0/left, 10/right + 484 editor-render screen, e 485 $clear-trace 486 assume-console [ 487 left-click 1, 5 # right of last line 488 type [d] 489 ] 490 run [ - 491 editor-event-loop screen, console, e + 491 editor-event-loop screen, console, e 492 ] 493 screen-should-contain [ 494 . . @@ -563,15 +563,15 @@ if ('onhashchange' in window) { 504 assume-screen 10/width, 5/height 505 s:text <- new [abc 506 d] - 507 e:&:editor <- new-editor s, 0/left, 10/right - 508 editor-render screen, e + 507 e:&:editor <- new-editor s, 0/left, 10/right + 508 editor-render screen, e 509 $clear-trace 510 assume-console [ 511 left-click 1, 5 # right of non-last line 512 type [e] 513 ] 514 run [ - 515 editor-event-loop screen, console, e + 515 editor-event-loop screen, console, e 516 ] 517 screen-should-contain [ 518 . . @@ -586,15 +586,15 @@ if ('onhashchange' in window) { 527 scenario editor-inserts-characters-at-cursor-3 [ 528 local-scope 529 assume-screen 10/width, 5/height - 530 e:&:editor <- new-editor [abc], 0/left, 10/right - 531 editor-render screen, e + 530 e:&:editor <- new-editor [abc], 0/left, 10/right + 531 editor-render screen, e 532 $clear-trace 533 assume-console [ 534 left-click 3, 5 # below all text 535 type [d] 536 ] 537 run [ - 538 editor-event-loop screen, console, e + 538 editor-event-loop screen, console, e 539 ] 540 screen-should-contain [ 541 . . @@ -610,15 +610,15 @@ if ('onhashchange' in window) { 551 assume-screen 10/width, 5/height 552 s:text <- new [abc 553 d] - 554 e:&:editor <- new-editor s, 0/left, 10/right - 555 editor-render screen, e + 554 e:&:editor <- new-editor s, 0/left, 10/right + 555 editor-render screen, e 556 $clear-trace 557 assume-console [ 558 left-click 3, 5 # below all text 559 type [e] 560 ] 561 run [ - 562 editor-event-loop screen, console, e + 562 editor-event-loop screen, console, e 563 ] 564 screen-should-contain [ 565 . . @@ -635,15 +635,15 @@ if ('onhashchange' in window) { 576 assume-screen 10/width, 5/height 577 s:text <- new [abc 578 d] - 579 e:&:editor <- new-editor s, 0/left, 10/right - 580 editor-render screen, e + 579 e:&:editor <- new-editor s, 0/left, 10/right + 580 editor-render screen, e 581 $clear-trace 582 assume-console [ 583 left-click 3, 5 # below all text 584 type [ef] 585 ] 586 run [ - 587 editor-event-loop screen, console, e + 587 editor-event-loop screen, console, e 588 ] 589 screen-should-contain [ 590 . . @@ -658,13 +658,13 @@ if ('onhashchange' in window) { 599 scenario editor-moves-cursor-after-inserting-characters [ 600 local-scope 601 assume-screen 10/width, 5/height - 602 e:&:editor <- new-editor [ab], 0/left, 5/right - 603 editor-render screen, e + 602 e:&:editor <- new-editor [ab], 0/left, 5/right + 603 editor-render screen, e 604 assume-console [ 605 type [01] 606 ] 607 run [ - 608 editor-event-loop screen, console, e + 608 editor-event-loop screen, console, e 609 ] 610 screen-should-contain [ 611 . . @@ -679,14 +679,14 @@ if ('onhashchange' in window) { 620 scenario editor-wraps-line-on-insert [ 621 local-scope 622 assume-screen 5/width, 5/height - 623 e:&:editor <- new-editor [abc], 0/left, 5/right - 624 editor-render screen, e + 623 e:&:editor <- new-editor [abc], 0/left, 5/right + 624 editor-render screen, e 625 # type a letter 626 assume-console [ 627 type [e] 628 ] 629 run [ - 630 editor-event-loop screen, console, e + 630 editor-event-loop screen, console, e 631 ] 632 # no wrap yet 633 screen-should-contain [ @@ -701,7 +701,7 @@ if ('onhashchange' in window) { 642 type [f] 643 ] 644 run [ - 645 editor-event-loop screen, console, e + 645 editor-event-loop screen, console, e 646 ] 647 # now wrap 648 screen-should-contain [ @@ -719,15 +719,15 @@ if ('onhashchange' in window) { 660 assume-screen 10/width, 5/height 661 s:text <- new [abcdefg 662 defg] - 663 e:&:editor <- new-editor s, 0/left, 5/right - 664 editor-render screen, e + 663 e:&:editor <- new-editor s, 0/left, 5/right + 664 editor-render screen, e 665 # type more text at the start 666 assume-console [ 667 left-click 3, 0 668 type [abc] 669 ] 670 run [ - 671 editor-event-loop screen, console, e + 671 editor-event-loop screen, console, e 672 3:num/raw <- get *e, cursor-row:offset 673 4:num/raw <- get *e, cursor-column:offset 674 ] @@ -756,9 +756,9 @@ if ('onhashchange' in window) { 697 before-wrap-column:num <- subtract wrap-column, 1 698 at-wrap?:bool <- greater-or-equal cursor-column, wrap-column 699 just-before-wrap?:bool <- greater-or-equal cursor-column, before-wrap-column - 700 next:&:duplex-list:char <- next before-cursor + 700 next:&:duplex-list:char <- next before-cursor 701 # at end of line? next == 0 || next.value == 10/newline - 702 at-end-of-line?:bool <- equal next, 0 + 702 at-end-of-line?:bool <- equal next, 0 703 { 704 break-if at-end-of-line? 705 next-character:char <- get *next, value:offset @@ -788,7 +788,7 @@ if ('onhashchange' in window) { 729 *editor <- put *editor, cursor-row:offset, cursor-row 730 # if we're out of the screen, scroll down 731 { - 732 below-screen?:bool <- greater-or-equal cursor-row, screen-height + 732 below-screen?:bool <- greater-or-equal cursor-row, screen-height 733 break-unless below-screen? 734 <scroll-down> 735 } @@ -799,13 +799,13 @@ if ('onhashchange' in window) { 740 scenario editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ 741 local-scope 742 assume-screen 10/width, 5/height - 743 e:&:editor <- new-editor [abcde], 0/left, 5/right + 743 e:&:editor <- new-editor [abcde], 0/left, 5/right 744 assume-console [ 745 left-click 1, 3 # right before the wrap icon 746 type [f] 747 ] 748 run [ - 749 editor-event-loop screen, console, e + 749 editor-event-loop screen, console, e 750 3:num/raw <- get *e, cursor-row:offset 751 4:num/raw <- get *e, cursor-column:offset 752 ] @@ -828,8 +828,8 @@ if ('onhashchange' in window) { 769 # create an editor containing two lines 770 s:text <- new [abc 771 xyz] - 772 e:&:editor <- new-editor s, 0/left, 5/right - 773 editor-render screen, e + 772 e:&:editor <- new-editor s, 0/left, 5/right + 773 editor-render screen, e 774 screen-should-contain [ 775 . . 776 .abc . @@ -842,7 +842,7 @@ if ('onhashchange' in window) { 783 type [de] # trigger wrap 784 ] 785 run [ - 786 editor-event-loop screen, console, e + 786 editor-event-loop screen, console, e 787 ] 788 screen-should-contain [ 789 . . @@ -856,13 +856,13 @@ if ('onhashchange' in window) { 797 scenario editor-wraps-cursor-to-left-margin [ 798 local-scope 799 assume-screen 10/width, 5/height - 800 e:&:editor <- new-editor [abcde], 2/left, 7/right + 800 e:&:editor <- new-editor [abcde], 2/left, 7/right 801 assume-console [ 802 left-click 1, 5 # line is full; no wrap icon yet 803 type [01] 804 ] 805 run [ - 806 editor-event-loop screen, console, e + 806 editor-event-loop screen, console, e 807 3:num/raw <- get *e, cursor-row:offset 808 4:num/raw <- get *e, cursor-column:offset 809 ] @@ -892,13 +892,13 @@ if ('onhashchange' in window) { 833 scenario editor-moves-cursor-down-after-inserting-newline [ 834 local-scope 835 assume-screen 10/width, 5/height - 836 e:&:editor <- new-editor [abc], 0/left, 10/right + 836 e:&:editor <- new-editor [abc], 0/left, 10/right 837 assume-console [ 838 type [0 839 1] 840 ] 841 run [ - 842 editor-event-loop screen, console, e + 842 editor-event-loop screen, console, e 843 ] 844 screen-should-contain [ 845 . . @@ -914,13 +914,13 @@ if ('onhashchange' in window) { 855 newline?:bool <- equal c, 10/newline 856 break-unless newline? 857 <insert-enter-begin> - 858 insert-new-line-and-indent editor, screen + 858 insert-new-line-and-indent editor, screen 859 <insert-enter-end> 860 return 1/go-render 861 } 862 ] 863 - 864 def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen [ + 864 def insert-new-line-and-indent editor:&:editor, screen:&:screen -> editor:&:editor, screen:&:screen [ 865 local-scope 866 load-ingredients 867 cursor-row:num <- get *editor, cursor-row:offset @@ -928,10 +928,10 @@ if ('onhashchange' in window) { 869 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 870 left:num <- get *editor, left:offset 871 right:num <- get *editor, right:offset - 872 screen-height:num <- screen-height screen + 872 screen-height:num <- screen-height screen 873 # insert newline 874 insert 10/newline, before-cursor - 875 before-cursor <- next before-cursor + 875 before-cursor <- next before-cursor 876 *editor <- put *editor, before-cursor:offset, before-cursor 877 cursor-row <- add cursor-row, 1 878 *editor <- put *editor, cursor-row:offset, cursor-row @@ -939,7 +939,7 @@ if ('onhashchange' in window) { 880 *editor <- put *editor, cursor-column:offset, cursor-column 881 # maybe scroll 882 { - 883 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal, never greater + 883 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal, never greater 884 break-unless below-screen? 885 <scroll-down> 886 cursor-row <- subtract cursor-row, 1 # bring back into screen range @@ -949,13 +949,13 @@ if ('onhashchange' in window) { 890 indent?:bool <- get *editor, indent?:offset 891 return-unless indent? 892 d:&:duplex-list:char <- get *editor, data:offset - 893 end-of-previous-line:&:duplex-list:char <- prev before-cursor - 894 indent:num <- line-indent end-of-previous-line, d + 893 end-of-previous-line:&:duplex-list:char <- prev before-cursor + 894 indent:num <- line-indent end-of-previous-line, d 895 i:num <- copy 0 896 { 897 indent-done?:bool <- greater-or-equal i, indent 898 break-if indent-done? - 899 insert-at-cursor editor, 32/space, screen + 899 insert-at-cursor editor, 32/space, screen 900 i <- add i, 1 901 loop 902 } @@ -963,7 +963,7 @@ if ('onhashchange' in window) { 904 905 # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts 906 # the number of spaces at the start of the line containing 'curr'. - 907 def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ + 907 def line-indent curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ 908 local-scope 909 load-ingredients 910 result:num <- copy 0 @@ -971,7 +971,7 @@ if ('onhashchange' in window) { 912 at-start?:bool <- equal curr, start 913 return-if at-start? 914 { - 915 curr <- prev curr + 915 curr <- prev curr 916 break-unless curr 917 at-start?:bool <- equal curr, start 918 break-if at-start? @@ -996,13 +996,13 @@ if ('onhashchange' in window) { 937 scenario editor-moves-cursor-down-after-inserting-newline-2 [ 938 local-scope 939 assume-screen 10/width, 5/height - 940 e:&:editor <- new-editor [abc], 1/left, 10/right + 940 e:&:editor <- new-editor [abc], 1/left, 10/right 941 assume-console [ 942 type [0 943 1] 944 ] 945 run [ - 946 editor-event-loop screen, console, e + 946 editor-event-loop screen, console, e 947 ] 948 screen-should-contain [ 949 . . @@ -1016,8 +1016,8 @@ if ('onhashchange' in window) { 957 scenario editor-clears-previous-line-completely-after-inserting-newline [ 958 local-scope 959 assume-screen 10/width, 5/height - 960 e:&:editor <- new-editor [abcde], 0/left, 5/right - 961 editor-render screen, e + 960 e:&:editor <- new-editor [abcde], 0/left, 5/right + 961 editor-render screen, e 962 screen-should-contain [ 963 . . 964 .abcd↩ . @@ -1029,7 +1029,7 @@ if ('onhashchange' in window) { 970 press enter 971 ] 972 run [ - 973 editor-event-loop screen, console, e + 973 editor-event-loop screen, console, e 974 ] 975 # line should be fully cleared 976 screen-should-contain [ @@ -1047,7 +1047,7 @@ if ('onhashchange' in window) { 988 s:text <- new [ab 989 cd 990 ef] - 991 e:&:editor <- new-editor s, 0/left, 10/right + 991 e:&:editor <- new-editor s, 0/left, 10/right 992 # position cursor after 'cd' and hit 'newline' 993 assume-console [ 994 left-click 2, 8 @@ -1055,7 +1055,7 @@ if ('onhashchange' in window) { 996 ] 997 ] 998 run [ - 999 editor-event-loop screen, console, e + 999 editor-event-loop screen, console, e 1000 3:num/raw <- get *e, cursor-row:offset 1001 4:num/raw <- get *e, cursor-column:offset 1002 ] @@ -1072,7 +1072,7 @@ if ('onhashchange' in window) { 1013 s:text <- new [ab 1014 cd 1015 ef] -1016 e:&:editor <- new-editor s, 0/left, 10/right +1016 e:&:editor <- new-editor s, 0/left, 10/right 1017 # position cursor after 'cd' and hit 'newline' surrounded by paste markers 1018 assume-console [ 1019 left-click 2, 8 @@ -1081,7 +1081,7 @@ if ('onhashchange' in window) { 1022 press 65506 # end paste 1023 ] 1024 run [ -1025 editor-event-loop screen, console, e +1025 editor-event-loop screen, console, e 1026 3:num/raw <- get *e, cursor-row:offset 1027 4:num/raw <- get *e, cursor-column:offset 1028 ] @@ -1112,7 +1112,7 @@ if ('onhashchange' in window) { 1053 1054 ## helpers 1055 -1056 def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [ +1056 def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [ 1057 local-scope 1058 load-ingredients 1059 style:char, style-found?:bool <- next-ingredient @@ -1131,11 +1131,11 @@ if ('onhashchange' in window) { 1072 break-if bg-color-found? 1073 bg-color <- copy 0/black 1074 } -1075 screen <- move-cursor screen, row, x +1075 screen <- move-cursor screen, row, x 1076 { 1077 continue?:bool <- lesser-or-equal x, right # right is inclusive, to match editor semantics 1078 break-unless continue? -1079 print screen, style, color, bg-color +1079 print screen, style, color, bg-color 1080 x <- add x, 1 1081 loop 1082 } diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 1a19ad63..3cbade2a 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -68,12 +68,12 @@ if ('onhashchange' in window) { 10 # just one character in final line 11 s:text <- new [ab 12 cd] - 13 e:&:editor <- new-editor s, 0/left, 5/right + 13 e:&:editor <- new-editor s, 0/left, 5/right 14 assume-console [ 15 press tab 16 ] 17 run [ - 18 editor-event-loop screen, console, e + 18 editor-event-loop screen, console, e 19 ] 20 screen-should-contain [ 21 . . @@ -87,8 +87,8 @@ if ('onhashchange' in window) { 29 tab?:bool <- equal c, 9/tab 30 break-unless tab? 31 <insert-character-begin> - 32 insert-at-cursor editor, 32/space, screen - 33 insert-at-cursor editor, 32/space, screen + 32 insert-at-cursor editor, 32/space, screen + 33 insert-at-cursor editor, 32/space, screen 34 <insert-character-end> 35 return 1/go-render 36 } @@ -99,15 +99,15 @@ if ('onhashchange' in window) { 41 scenario editor-handles-backspace-key [ 42 local-scope 43 assume-screen 10/width, 5/height - 44 e:&:editor <- new-editor [abc], 0/left, 10/right - 45 editor-render screen, e + 44 e:&:editor <- new-editor [abc], 0/left, 10/right + 45 editor-render screen, e 46 $clear-trace 47 assume-console [ 48 left-click 1, 1 49 press backspace 50 ] 51 run [ - 52 editor-event-loop screen, console, e + 52 editor-event-loop screen, console, e 53 4:num/raw <- get *e, cursor-row:offset 54 5:num/raw <- get *e, cursor-column:offset 55 ] @@ -129,7 +129,7 @@ if ('onhashchange' in window) { 71 delete-previous-character?:bool <- equal c, 8/backspace 72 break-unless delete-previous-character? 73 <backspace-character-begin> - 74 go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen + 74 go-render?:bool, backspaced-cell:&:duplex-list:char <- delete-before-cursor editor, screen 75 <backspace-character-end> 76 return 77 } @@ -138,23 +138,23 @@ if ('onhashchange' in window) { 80 # return values: 81 # go-render? - whether caller needs to update the screen 82 # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. - 83 def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ + 83 def delete-before-cursor editor:&:editor, screen:&:screen -> go-render?:bool, backspaced-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ 84 local-scope 85 load-ingredients 86 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 87 data:&:duplex-list:char <- get *editor, data:offset 88 # if at start of text (before-cursor at § sentinel), return - 89 prev:&:duplex-list:char <- prev before-cursor - 90 return-unless prev, 0/no-more-render, 0/nothing-deleted + 89 prev:&:duplex-list:char <- prev before-cursor + 90 return-unless prev, 0/no-more-render, 0/nothing-deleted 91 trace 10, [app], [delete-before-cursor] 92 original-row:num <- get *editor, cursor-row:offset - 93 scroll?:bool <- move-cursor-coordinates-left editor + 93 scroll?:bool <- move-cursor-coordinates-left editor 94 backspaced-cell:&:duplex-list:char <- copy before-cursor 95 data <- remove before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/before-cursor - 96 before-cursor <- copy prev + 96 before-cursor <- copy prev 97 *editor <- put *editor, before-cursor:offset, before-cursor 98 return-if scroll?, 1/go-render - 99 screen-width:num <- screen-width screen + 99 screen-width:num <- screen-width screen 100 cursor-row:num <- get *editor, cursor-row:offset 101 cursor-column:num <- get *editor, cursor-column:offset 102 # did we just backspace over a newline? @@ -162,8 +162,8 @@ if ('onhashchange' in window) { 104 return-unless same-row?, 1/go-render 105 left:num <- get *editor, left:offset 106 right:num <- get *editor, right:offset - 107 curr:&:duplex-list:char <- next before-cursor - 108 screen <- move-cursor screen, cursor-row, cursor-column + 107 curr:&:duplex-list:char <- next before-cursor + 108 screen <- move-cursor screen, cursor-row, cursor-column 109 curr-column:num <- copy cursor-column 110 { 111 # hit right margin? give up and let caller render @@ -174,18 +174,18 @@ if ('onhashchange' in window) { 116 currc:char <- get *curr, value:offset 117 at-newline?:bool <- equal currc, 10/newline 118 break-if at-newline? - 119 screen <- print screen, currc + 119 screen <- print screen, currc 120 curr-column <- add curr-column, 1 - 121 curr <- next curr + 121 curr <- next curr 122 loop 123 } 124 # we're guaranteed not to be at the right margin 125 space:char <- copy 32/space - 126 screen <- print screen, space + 126 screen <- print screen, space 127 go-render? <- copy 0/false 128 ] 129 - 130 def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:editor [ + 130 def move-cursor-coordinates-left editor:&:editor -> go-render?:bool, editor:&:editor [ 131 local-scope 132 load-ingredients 133 go-render?:bool <- copy 0/false @@ -222,7 +222,7 @@ if ('onhashchange' in window) { 164 # compute length of previous line 165 trace 10, [app], [switching to previous line] 166 d:&:duplex-list:char <- get *editor, data:offset - 167 end-of-line:num <- previous-line-length before-cursor, d + 167 end-of-line:num <- previous-line-length before-cursor, d 168 right:num <- get *editor, right:offset 169 width:num <- subtract right, left 170 wrap?:bool <- greater-than end-of-line, width @@ -248,7 +248,7 @@ if ('onhashchange' in window) { 190 191 # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts 192 # the length of the previous line before the 'curr' pointer. - 193 def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ + 193 def previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char -> result:num [ 194 local-scope 195 load-ingredients 196 result:num <- copy 0 @@ -256,7 +256,7 @@ if ('onhashchange' in window) { 198 at-start?:bool <- equal curr, start 199 return-if at-start? 200 { - 201 curr <- prev curr + 201 curr <- prev curr 202 break-unless curr 203 at-start?:bool <- equal curr, start 204 break-if at-start? @@ -274,13 +274,13 @@ if ('onhashchange' in window) { 216 # just one character in final line 217 s:text <- new [ab 218 cd] - 219 e:&:editor <- new-editor s, 0/left, 10/right + 219 e:&:editor <- new-editor s, 0/left, 10/right 220 assume-console [ 221 left-click 2, 0 # cursor at only character in final line 222 press backspace 223 ] 224 run [ - 225 editor-event-loop screen, console, e + 225 editor-event-loop screen, console, e 226 4:num/raw <- get *e, cursor-row:offset 227 5:num/raw <- get *e, cursor-column:offset 228 ] @@ -302,8 +302,8 @@ if ('onhashchange' in window) { 244 # initialize editor with two long-ish but non-wrapping lines 245 s:text <- new [abc def 246 ghi jkl] - 247 e:&:editor <- new-editor s, 0/left, 10/right - 248 editor-render screen, e + 247 e:&:editor <- new-editor s, 0/left, 10/right + 248 editor-render screen, e 249 $clear-trace 250 # position the cursor at the start of the second and hit backspace 251 assume-console [ @@ -311,7 +311,7 @@ if ('onhashchange' in window) { 253 press backspace 254 ] 255 run [ - 256 editor-event-loop screen, console, e + 256 editor-event-loop screen, console, e 257 ] 258 # resulting single line should wrap correctly 259 screen-should-contain [ @@ -327,8 +327,8 @@ if ('onhashchange' in window) { 269 local-scope 270 assume-screen 10/width, 5/height 271 # initialize editor in part of the screen with a long line - 272 e:&:editor <- new-editor [abc def ghij], 0/left, 8/right - 273 editor-render screen, e + 272 e:&:editor <- new-editor [abc def ghij], 0/left, 8/right + 273 editor-render screen, e 274 # confirm that it wraps 275 screen-should-contain [ 276 . . @@ -343,7 +343,7 @@ if ('onhashchange' in window) { 285 press backspace 286 ] 287 run [ - 288 editor-event-loop screen, console, e + 288 editor-event-loop screen, console, e 289 ] 290 # resulting single line should wrap correctly and not overflow its bounds 291 screen-should-contain [ @@ -360,14 +360,14 @@ if ('onhashchange' in window) { 302 scenario editor-handles-delete-key [ 303 local-scope 304 assume-screen 10/width, 5/height - 305 e:&:editor <- new-editor [abc], 0/left, 10/right - 306 editor-render screen, e + 305 e:&:editor <- new-editor [abc], 0/left, 10/right + 306 editor-render screen, e 307 $clear-trace 308 assume-console [ 309 press delete 310 ] 311 run [ - 312 editor-event-loop screen, console, e + 312 editor-event-loop screen, console, e 313 ] 314 screen-should-contain [ 315 . . @@ -381,7 +381,7 @@ if ('onhashchange' in window) { 323 press delete 324 ] 325 run [ - 326 editor-event-loop screen, console, e + 326 editor-event-loop screen, console, e 327 ] 328 screen-should-contain [ 329 . . @@ -397,47 +397,47 @@ if ('onhashchange' in window) { 339 delete-next-character?:bool <- equal k, 65522/delete 340 break-unless delete-next-character? 341 <delete-character-begin> - 342 go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen + 342 go-render?:bool, deleted-cell:&:duplex-list:char <- delete-at-cursor editor, screen 343 <delete-character-end> 344 return 345 } 346 ] 347 - 348 def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ + 348 def delete-at-cursor editor:&:editor, screen:&:screen -> go-render?:bool, deleted-cell:&:duplex-list:char, editor:&:editor, screen:&:screen [ 349 local-scope 350 load-ingredients 351 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 352 data:&:duplex-list:char <- get *editor, data:offset - 353 deleted-cell:&:duplex-list:char <- next before-cursor + 353 deleted-cell:&:duplex-list:char <- next before-cursor 354 return-unless deleted-cell, 0/don't-render 355 currc:char <- get *deleted-cell, value:offset 356 data <- remove deleted-cell, data 357 deleted-newline?:bool <- equal currc, 10/newline 358 return-if deleted-newline?, 1/go-render 359 # wasn't a newline? render rest of line - 360 curr:&:duplex-list:char <- next before-cursor # refresh after remove above + 360 curr:&:duplex-list:char <- next before-cursor # refresh after remove above 361 cursor-row:num <- get *editor, cursor-row:offset 362 cursor-column:num <- get *editor, cursor-column:offset - 363 screen <- move-cursor screen, cursor-row, cursor-column + 363 screen <- move-cursor screen, cursor-row, cursor-column 364 curr-column:num <- copy cursor-column - 365 screen-width:num <- screen-width screen + 365 screen-width:num <- screen-width screen 366 { 367 # hit right margin? give up and let caller render - 368 at-right?:bool <- greater-or-equal curr-column, screen-width + 368 at-right?:bool <- greater-or-equal curr-column, screen-width 369 return-if at-right?, 1/go-render 370 break-unless curr 371 # newline? done. 372 currc:char <- get *curr, value:offset 373 at-newline?:bool <- equal currc, 10/newline 374 break-if at-newline? - 375 screen <- print screen, currc + 375 screen <- print screen, currc 376 curr-column <- add curr-column, 1 - 377 curr <- next curr + 377 curr <- next curr 378 loop 379 } 380 # we're guaranteed not to be at the right margin 381 space:char <- copy 32/space - 382 screen <- print screen, space + 382 screen <- print screen, space 383 go-render? <- copy 0/false 384 ] 385 @@ -446,15 +446,15 @@ if ('onhashchange' in window) { 388 scenario editor-moves-cursor-right-with-key [ 389 local-scope 390 assume-screen 10/width, 5/height - 391 e:&:editor <- new-editor [abc], 0/left, 10/right - 392 editor-render screen, e + 391 e:&:editor <- new-editor [abc], 0/left, 10/right + 392 editor-render screen, e 393 $clear-trace 394 assume-console [ 395 press right-arrow 396 type [0] 397 ] 398 run [ - 399 editor-event-loop screen, console, e + 399 editor-event-loop screen, console, e 400 ] 401 screen-should-contain [ 402 . . @@ -470,21 +470,21 @@ if ('onhashchange' in window) { 412 move-to-next-character?:bool <- equal k, 65514/right-arrow 413 break-unless move-to-next-character? 414 # if not at end of text - 415 next-cursor:&:duplex-list:char <- next before-cursor + 415 next-cursor:&:duplex-list:char <- next before-cursor 416 break-unless next-cursor 417 # scan to next character 418 <move-cursor-begin> 419 before-cursor <- copy next-cursor 420 *editor <- put *editor, before-cursor:offset, before-cursor - 421 go-render?:bool <- move-cursor-coordinates-right editor, screen-height - 422 screen <- move-cursor screen, cursor-row, cursor-column + 421 go-render?:bool <- move-cursor-coordinates-right editor, screen-height + 422 screen <- move-cursor screen, cursor-row, cursor-column 423 undo-coalesce-tag:num <- copy 2/right-arrow 424 <move-cursor-end> 425 return 426 } 427 ] 428 - 429 def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ + 429 def move-cursor-coordinates-right editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 430 local-scope 431 load-ingredients 432 before-cursor:&:duplex-list:char <- get *editor before-cursor:offset @@ -501,7 +501,7 @@ if ('onhashchange' in window) { 443 *editor <- put *editor, cursor-row:offset, cursor-row 444 cursor-column <- copy left 445 *editor <- put *editor, cursor-column:offset, cursor-column - 446 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal + 446 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal 447 return-unless below-screen?, 0/don't-render 448 <scroll-down> 449 cursor-row <- subtract cursor-row, 1 # bring back into screen range @@ -515,8 +515,8 @@ if ('onhashchange' in window) { 457 at-wrap?:bool <- equal cursor-column, wrap-column 458 break-unless at-wrap? 459 # and if next character isn't newline - 460 next:&:duplex-list:char <- next before-cursor - 461 break-unless next + 460 next:&:duplex-list:char <- next before-cursor + 461 break-unless next 462 next-character:char <- get *next, value:offset 463 newline?:bool <- equal next-character, 10/newline 464 break-if newline? @@ -524,7 +524,7 @@ if ('onhashchange' in window) { 466 *editor <- put *editor, cursor-row:offset, cursor-row 467 cursor-column <- copy left 468 *editor <- put *editor, cursor-column:offset, cursor-column - 469 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal + 469 below-screen?:bool <- greater-or-equal cursor-row, screen-height # must be equal 470 return-unless below-screen?, 0/no-more-render 471 <scroll-down> 472 cursor-row <- subtract cursor-row, 1 # bring back into screen range @@ -542,8 +542,8 @@ if ('onhashchange' in window) { 484 assume-screen 10/width, 5/height 485 s:text <- new [abc 486 d] - 487 e:&:editor <- new-editor s, 0/left, 10/right - 488 editor-render screen, e + 487 e:&:editor <- new-editor s, 0/left, 10/right + 488 editor-render screen, e 489 $clear-trace 490 # type right-arrow a few times to get to start of second line 491 assume-console [ @@ -553,7 +553,7 @@ if ('onhashchange' in window) { 495 press right-arrow # next line 496 ] 497 run [ - 498 editor-event-loop screen, console, e + 498 editor-event-loop screen, console, e 499 ] 500 check-trace-count-for-label 0, [print-character] 501 # type something and ensure it goes where it should @@ -561,7 +561,7 @@ if ('onhashchange' in window) { 503 type [0] 504 ] 505 run [ - 506 editor-event-loop screen, console, e + 506 editor-event-loop screen, console, e 507 ] 508 screen-should-contain [ 509 . . @@ -578,8 +578,8 @@ if ('onhashchange' in window) { 520 assume-screen 10/width, 5/height 521 s:text <- new [abc 522 d] - 523 e:&:editor <- new-editor s, 1/left, 10/right - 524 editor-render screen, e + 523 e:&:editor <- new-editor s, 1/left, 10/right + 524 editor-render screen, e 525 assume-console [ 526 press right-arrow 527 press right-arrow @@ -588,7 +588,7 @@ if ('onhashchange' in window) { 530 type [0] 531 ] 532 run [ - 533 editor-event-loop screen, console, e + 533 editor-event-loop screen, console, e 534 ] 535 screen-should-contain [ 536 . . @@ -602,15 +602,15 @@ if ('onhashchange' in window) { 544 scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ 545 local-scope 546 assume-screen 10/width, 5/height - 547 e:&:editor <- new-editor [abcdef], 0/left, 5/right - 548 editor-render screen, e + 547 e:&:editor <- new-editor [abcdef], 0/left, 5/right + 548 editor-render screen, e 549 $clear-trace 550 assume-console [ 551 left-click 1, 3 552 press right-arrow 553 ] 554 run [ - 555 editor-event-loop screen, console, e + 555 editor-event-loop screen, console, e 556 3:num/raw <- get *e, cursor-row:offset 557 4:num/raw <- get *e, cursor-column:offset 558 ] @@ -632,8 +632,8 @@ if ('onhashchange' in window) { 574 local-scope 575 assume-screen 10/width, 5/height 576 # line just barely wrapping - 577 e:&:editor <- new-editor [abcde], 0/left, 5/right - 578 editor-render screen, e + 577 e:&:editor <- new-editor [abcde], 0/left, 5/right + 578 editor-render screen, e 579 $clear-trace 580 # position cursor at last character before wrap and hit right-arrow 581 assume-console [ @@ -641,7 +641,7 @@ if ('onhashchange' in window) { 583 press right-arrow 584 ] 585 run [ - 586 editor-event-loop screen, console, e + 586 editor-event-loop screen, console, e 587 3:num/raw <- get *e, cursor-row:offset 588 4:num/raw <- get *e, cursor-column:offset 589 ] @@ -654,7 +654,7 @@ if ('onhashchange' in window) { 596 press right-arrow 597 ] 598 run [ - 599 editor-event-loop screen, console, e + 599 editor-event-loop screen, console, e 600 3:num/raw <- get *e, cursor-row:offset 601 4:num/raw <- get *e, cursor-column:offset 602 ] @@ -668,15 +668,15 @@ if ('onhashchange' in window) { 610 scenario editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ 611 local-scope 612 assume-screen 10/width, 5/height - 613 e:&:editor <- new-editor [abcdef], 1/left, 6/right - 614 editor-render screen, e + 613 e:&:editor <- new-editor [abcdef], 1/left, 6/right + 614 editor-render screen, e 615 $clear-trace 616 assume-console [ 617 left-click 1, 4 618 press right-arrow 619 ] 620 run [ - 621 editor-event-loop screen, console, e + 621 editor-event-loop screen, console, e 622 3:num/raw <- get *e, cursor-row:offset 623 4:num/raw <- get *e, cursor-column:offset 624 ] @@ -699,8 +699,8 @@ if ('onhashchange' in window) { 641 assume-screen 10/width, 5/height 642 s:text <- new [abc 643 d] - 644 e:&:editor <- new-editor s, 0/left, 10/right - 645 editor-render screen, e + 644 e:&:editor <- new-editor s, 0/left, 10/right + 645 editor-render screen, e 646 $clear-trace 647 # move to end of line, press right-arrow, type a character 648 assume-console [ @@ -709,7 +709,7 @@ if ('onhashchange' in window) { 651 type [0] 652 ] 653 run [ - 654 editor-event-loop screen, console, e + 654 editor-event-loop screen, console, e 655 ] 656 # new character should be in next line 657 screen-should-contain [ @@ -729,8 +729,8 @@ if ('onhashchange' in window) { 671 scenario editor-moves-cursor-left-with-key [ 672 local-scope 673 assume-screen 10/width, 5/height - 674 e:&:editor <- new-editor [abc], 0/left, 10/right - 675 editor-render screen, e + 674 e:&:editor <- new-editor [abc], 0/left, 10/right + 675 editor-render screen, e 676 $clear-trace 677 assume-console [ 678 left-click 1, 2 @@ -738,7 +738,7 @@ if ('onhashchange' in window) { 680 type [0] 681 ] 682 run [ - 683 editor-event-loop screen, console, e + 683 editor-event-loop screen, console, e 684 ] 685 screen-should-contain [ 686 . . @@ -755,11 +755,11 @@ if ('onhashchange' in window) { 697 break-unless move-to-previous-character? 698 trace 10, [app], [left arrow] 699 # if not at start of text (before-cursor at § sentinel) - 700 prev:&:duplex-list:char <- prev before-cursor - 701 return-unless prev, 0/don't-render + 700 prev:&:duplex-list:char <- prev before-cursor + 701 return-unless prev, 0/don't-render 702 <move-cursor-begin> - 703 go-render? <- move-cursor-coordinates-left editor - 704 before-cursor <- copy prev + 703 go-render? <- move-cursor-coordinates-left editor + 704 before-cursor <- copy prev 705 *editor <- put *editor, before-cursor:offset, before-cursor 706 undo-coalesce-tag:num <- copy 1/left-arrow 707 <move-cursor-end> @@ -773,8 +773,8 @@ if ('onhashchange' in window) { 715 # initialize editor with two lines 716 s:text <- new [abc 717 d] - 718 e:&:editor <- new-editor s, 0/left, 10/right - 719 editor-render screen, e + 718 e:&:editor <- new-editor s, 0/left, 10/right + 719 editor-render screen, e 720 $clear-trace 721 # position cursor at start of second line (so there's no previous newline) 722 assume-console [ @@ -782,7 +782,7 @@ if ('onhashchange' in window) { 724 press left-arrow 725 ] 726 run [ - 727 editor-event-loop screen, console, e + 727 editor-event-loop screen, console, e 728 3:num/raw <- get *e, cursor-row:offset 729 4:num/raw <- get *e, cursor-column:offset 730 ] @@ -800,8 +800,8 @@ if ('onhashchange' in window) { 742 s:text <- new [abc 743 def 744 g] - 745 e:&:editor <- new-editor s:text, 0/left, 10/right - 746 editor-render screen, e + 745 e:&:editor <- new-editor s:text, 0/left, 10/right + 746 editor-render screen, e 747 $clear-trace 748 # position cursor further down (so there's a newline before the character at 749 # the cursor) @@ -811,7 +811,7 @@ if ('onhashchange' in window) { 753 type [0] 754 ] 755 run [ - 756 editor-event-loop screen, console, e + 756 editor-event-loop screen, console, e 757 ] 758 screen-should-contain [ 759 . . @@ -829,8 +829,8 @@ if ('onhashchange' in window) { 771 s:text <- new [abc 772 def 773 g] - 774 e:&:editor <- new-editor s, 0/left, 10/right - 775 editor-render screen, e + 774 e:&:editor <- new-editor s, 0/left, 10/right + 775 editor-render screen, e 776 $clear-trace 777 # position cursor at start of text, press left-arrow, then type a character 778 assume-console [ @@ -839,7 +839,7 @@ if ('onhashchange' in window) { 781 type [0] 782 ] 783 run [ - 784 editor-event-loop screen, console, e + 784 editor-event-loop screen, console, e 785 ] 786 # left-arrow should have had no effect 787 screen-should-contain [ @@ -859,8 +859,8 @@ if ('onhashchange' in window) { 801 s:text <- new [abc 802 803 d] - 804 e:&:editor <- new-editor s, 0/left, 10/right - 805 editor-render screen, e:&:editor + 804 e:&:editor <- new-editor s, 0/left, 10/right + 805 editor-render screen, e:&:editor 806 $clear-trace 807 # position cursor right after empty line 808 assume-console [ @@ -869,7 +869,7 @@ if ('onhashchange' in window) { 811 type [0] 812 ] 813 run [ - 814 editor-event-loop screen, console, e + 814 editor-event-loop screen, console, e 815 ] 816 screen-should-contain [ 817 . . @@ -885,8 +885,8 @@ if ('onhashchange' in window) { 827 local-scope 828 assume-screen 10/width, 5/height 829 # initialize editor with a wrapping line - 830 e:&:editor <- new-editor [abcdef], 0/left, 5/right - 831 editor-render screen, e + 830 e:&:editor <- new-editor [abcdef], 0/left, 5/right + 831 editor-render screen, e 832 $clear-trace 833 screen-should-contain [ 834 . . @@ -901,7 +901,7 @@ if ('onhashchange' in window) { 843 press left-arrow 844 ] 845 run [ - 846 editor-event-loop screen, console, e + 846 editor-event-loop screen, console, e 847 3:num/raw <- get *e, cursor-row:offset 848 4:num/raw <- get *e, cursor-column:offset 849 ] @@ -918,8 +918,8 @@ if ('onhashchange' in window) { 860 # initialize editor with a wrapping line followed by a second line 861 s:text <- new [abcdef 862 g] - 863 e:&:editor <- new-editor s, 0/left, 5/right - 864 editor-render screen, e + 863 e:&:editor <- new-editor s, 0/left, 5/right + 864 editor-render screen, e 865 $clear-trace 866 screen-should-contain [ 867 . . @@ -934,7 +934,7 @@ if ('onhashchange' in window) { 876 press left-arrow 877 ] 878 run [ - 879 editor-event-loop screen, console, e + 879 editor-event-loop screen, console, e 880 3:num/raw <- get *e, cursor-row:offset 881 4:num/raw <- get *e, cursor-column:offset 882 ] @@ -951,8 +951,8 @@ if ('onhashchange' in window) { 893 # initialize editor with a line on the verge of wrapping, followed by a second line 894 s:text <- new [abcd 895 e] - 896 e:&:editor <- new-editor s, 0/left, 5/right - 897 editor-render screen, e + 896 e:&:editor <- new-editor s, 0/left, 5/right + 897 editor-render screen, e 898 $clear-trace 899 screen-should-contain [ 900 . . @@ -967,7 +967,7 @@ if ('onhashchange' in window) { 909 press left-arrow 910 ] 911 run [ - 912 editor-event-loop screen, console, e + 912 editor-event-loop screen, console, e 913 3:num/raw <- get *e, cursor-row:offset 914 4:num/raw <- get *e, cursor-column:offset 915 ] @@ -987,15 +987,15 @@ if ('onhashchange' in window) { 929 assume-screen 10/width, 5/height 930 s:text <- new [abc 931 def] - 932 e:&:editor <- new-editor s, 0/left, 10/right - 933 editor-render screen, e + 932 e:&:editor <- new-editor s, 0/left, 10/right + 933 editor-render screen, e 934 $clear-trace 935 assume-console [ 936 left-click 2, 1 937 press up-arrow 938 ] 939 run [ - 940 editor-event-loop screen, console, e + 940 editor-event-loop screen, console, e 941 3:num/raw <- get *e, cursor-row:offset 942 4:num/raw <- get *e, cursor-column:offset 943 ] @@ -1008,7 +1008,7 @@ if ('onhashchange' in window) { 950 type [0] 951 ] 952 run [ - 953 editor-event-loop screen, console, e + 953 editor-event-loop screen, console, e 954 ] 955 screen-should-contain [ 956 . . @@ -1024,14 +1024,14 @@ if ('onhashchange' in window) { 966 move-to-previous-line?:bool <- equal k, 65517/up-arrow 967 break-unless move-to-previous-line? 968 <move-cursor-begin> - 969 go-render? <- move-to-previous-line editor + 969 go-render? <- move-to-previous-line editor 970 undo-coalesce-tag:num <- copy 3/up-arrow 971 <move-cursor-end> 972 return 973 } 974 ] 975 - 976 def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [ + 976 def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [ 977 local-scope 978 load-ingredients 979 go-render?:bool <- copy 0/false @@ -1053,13 +1053,13 @@ if ('onhashchange' in window) { 995 c2:char <- get *curr, value:offset 996 at-newline?:bool <- equal c2, 10/newline 997 break-if at-newline? - 998 curr:&:duplex-list:char <- before-previous-line curr, editor + 998 curr:&:duplex-list:char <- before-previous-line curr, editor 999 no-motion?:bool <- equal curr, old 1000 return-if no-motion? 1001 } 1002 { 1003 old <- copy curr -1004 curr <- before-previous-line curr, editor +1004 curr <- before-previous-line curr, editor 1005 no-motion?:bool <- equal curr, old 1006 return-if no-motion? 1007 } @@ -1074,7 +1074,7 @@ if ('onhashchange' in window) { 1016 { 1017 done?:bool <- greater-or-equal cursor-column, target-column 1018 break-if done? -1019 curr:&:duplex-list:char <- next before-cursor +1019 curr:&:duplex-list:char <- next before-cursor 1020 break-unless curr 1021 currc:char <- get *curr, value:offset 1022 at-newline?:bool <- equal currc, 10/newline @@ -1101,15 +1101,15 @@ if ('onhashchange' in window) { 1043 assume-screen 10/width, 5/height 1044 s:text <- new [ab 1045 def] -1046 e:&:editor <- new-editor s, 0/left, 10/right -1047 editor-render screen, e +1046 e:&:editor <- new-editor s, 0/left, 10/right +1047 editor-render screen, e 1048 $clear-trace 1049 assume-console [ 1050 left-click 2, 3 1051 press up-arrow 1052 ] 1053 run [ -1054 editor-event-loop screen, console, e +1054 editor-event-loop screen, console, e 1055 3:num/raw <- get *e, cursor-row:offset 1056 4:num/raw <- get *e, cursor-column:offset 1057 ] @@ -1122,7 +1122,7 @@ if ('onhashchange' in window) { 1064 type [0] 1065 ] 1066 run [ -1067 editor-event-loop screen, console, e +1067 editor-event-loop screen, console, e 1068 ] 1069 screen-should-contain [ 1070 . . @@ -1138,15 +1138,15 @@ if ('onhashchange' in window) { 1080 assume-screen 10/width, 5/height 1081 s:text <- new [ 1082 def] -1083 e:&:editor <- new-editor s, 0/left, 10/right -1084 editor-render screen, e +1083 e:&:editor <- new-editor s, 0/left, 10/right +1084 editor-render screen, e 1085 $clear-trace 1086 assume-console [ 1087 left-click 2, 3 1088 press up-arrow 1089 ] 1090 run [ -1091 editor-event-loop screen, console, e +1091 editor-event-loop screen, console, e 1092 3:num/raw <- get *e, cursor-row:offset 1093 4:num/raw <- get *e, cursor-column:offset 1094 ] @@ -1159,7 +1159,7 @@ if ('onhashchange' in window) { 1101 type [0] 1102 ] 1103 run [ -1104 editor-event-loop screen, console, e +1104 editor-event-loop screen, console, e 1105 ] 1106 screen-should-contain [ 1107 . . @@ -1177,8 +1177,8 @@ if ('onhashchange' in window) { 1119 s:text <- new [abc 1120 def 1121 ghi] -1122 e:&:editor <- new-editor s, 0/left, 10/right -1123 editor-render screen, e +1122 e:&:editor <- new-editor s, 0/left, 10/right +1123 editor-render screen, e 1124 $clear-trace 1125 # click on the third line and hit up-arrow, so you end up just after a newline 1126 assume-console [ @@ -1186,7 +1186,7 @@ if ('onhashchange' in window) { 1128 press up-arrow 1129 ] 1130 run [ -1131 editor-event-loop screen, console, e +1131 editor-event-loop screen, console, e 1132 3:num/raw <- get *e, cursor-row:offset 1133 4:num/raw <- get *e, cursor-column:offset 1134 ] @@ -1199,7 +1199,7 @@ if ('onhashchange' in window) { 1141 type [0] 1142 ] 1143 run [ -1144 editor-event-loop screen, console, e +1144 editor-event-loop screen, console, e 1145 ] 1146 screen-should-contain [ 1147 . . @@ -1217,15 +1217,15 @@ if ('onhashchange' in window) { 1159 assume-screen 10/width, 5/height 1160 s:text <- new [abc 1161 def] -1162 e:&:editor <- new-editor s, 0/left, 10/right -1163 editor-render screen, e +1162 e:&:editor <- new-editor s, 0/left, 10/right +1163 editor-render screen, e 1164 $clear-trace 1165 # cursor starts out at (1, 0) 1166 assume-console [ 1167 press down-arrow 1168 ] 1169 run [ -1170 editor-event-loop screen, console, e +1170 editor-event-loop screen, console, e 1171 3:num/raw <- get *e, cursor-row:offset 1172 4:num/raw <- get *e, cursor-column:offset 1173 ] @@ -1239,7 +1239,7 @@ if ('onhashchange' in window) { 1181 type [0] 1182 ] 1183 run [ -1184 editor-event-loop screen, console, e +1184 editor-event-loop screen, console, e 1185 ] 1186 screen-should-contain [ 1187 . . @@ -1255,14 +1255,14 @@ if ('onhashchange' in window) { 1197 move-to-next-line?:bool <- equal k, 65516/down-arrow 1198 break-unless move-to-next-line? 1199 <move-cursor-begin> -1200 go-render? <- move-to-next-line editor, screen-height +1200 go-render? <- move-to-next-line editor, screen-height 1201 undo-coalesce-tag:num <- copy 4/down-arrow 1202 <move-cursor-end> 1203 return 1204 } 1205 ] 1206 -1207 def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ +1207 def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, editor:&:editor [ 1208 local-scope 1209 load-ingredients 1210 cursor-row:num <- get *editor, cursor-row:offset @@ -1270,14 +1270,14 @@ if ('onhashchange' in window) { 1212 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1213 left:num <- get *editor, left:offset 1214 right:num <- get *editor, right:offset -1215 last-line:num <- subtract screen-height, 1 +1215 last-line:num <- subtract screen-height, 1 1216 already-at-bottom?:bool <- greater-or-equal cursor-row, last-line 1217 { 1218 # if cursor not at bottom, move it 1219 break-if already-at-bottom? 1220 # scan to start of next line, then to right column or until end of line 1221 max:num <- subtract right, left -1222 next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max +1222 next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max 1223 { 1224 # already at end of buffer? try to scroll up (so we can see more 1225 # warnings or sandboxes below) @@ -1297,7 +1297,7 @@ if ('onhashchange' in window) { 1239 { 1240 done?:bool <- greater-or-equal cursor-column, target-column 1241 break-if done? -1242 curr:&:duplex-list:char <- next before-cursor +1242 curr:&:duplex-list:char <- next before-cursor 1243 break-unless curr 1244 currc:char <- get *curr, value:offset 1245 at-newline?:bool <- equal currc, 10/newline @@ -1321,15 +1321,15 @@ if ('onhashchange' in window) { 1263 assume-screen 10/width, 5/height 1264 s:text <- new [abc 1265 de] -1266 e:&:editor <- new-editor s, 0/left, 10/right -1267 editor-render screen, e +1266 e:&:editor <- new-editor s, 0/left, 10/right +1267 editor-render screen, e 1268 $clear-trace 1269 assume-console [ 1270 left-click 1, 3 1271 press down-arrow 1272 ] 1273 run [ -1274 editor-event-loop screen, console, e +1274 editor-event-loop screen, console, e 1275 3:num/raw <- get *e, cursor-row:offset 1276 4:num/raw <- get *e, cursor-column:offset 1277 ] @@ -1342,7 +1342,7 @@ if ('onhashchange' in window) { 1284 type [0] 1285 ] 1286 run [ -1287 editor-event-loop screen, console, e +1287 editor-event-loop screen, console, e 1288 ] 1289 screen-should-contain [ 1290 . . @@ -1360,8 +1360,8 @@ if ('onhashchange' in window) { 1302 assume-screen 10/width, 5/height 1303 s:text <- new [123 1304 456] -1305 e:&:editor <- new-editor s, 0/left, 10/right -1306 editor-render screen, e +1305 e:&:editor <- new-editor s, 0/left, 10/right +1306 editor-render screen, e 1307 $clear-trace 1308 # start on second line, press ctrl-a 1309 assume-console [ @@ -1369,7 +1369,7 @@ if ('onhashchange' in window) { 1311 press ctrl-a 1312 ] 1313 run [ -1314 editor-event-loop screen, console, e +1314 editor-event-loop screen, console, e 1315 4:num/raw <- get *e, cursor-row:offset 1316 5:num/raw <- get *e, cursor-column:offset 1317 ] @@ -1386,7 +1386,7 @@ if ('onhashchange' in window) { 1328 move-to-start-of-line?:bool <- equal c, 1/ctrl-a 1329 break-unless move-to-start-of-line? 1330 <move-cursor-begin> -1331 move-to-start-of-line editor +1331 move-to-start-of-line editor 1332 undo-coalesce-tag:num <- copy 0/never 1333 <move-cursor-end> 1334 return 0/don't-render @@ -1398,14 +1398,14 @@ if ('onhashchange' in window) { 1340 move-to-start-of-line?:bool <- equal k, 65521/home 1341 break-unless move-to-start-of-line? 1342 <move-cursor-begin> -1343 move-to-start-of-line editor +1343 move-to-start-of-line editor 1344 undo-coalesce-tag:num <- copy 0/never 1345 <move-cursor-end> 1346 return 0/don't-render 1347 } 1348 ] 1349 -1350 def move-to-start-of-line editor:&:editor -> editor:&:editor [ +1350 def move-to-start-of-line editor:&:editor -> editor:&:editor [ 1351 local-scope 1352 load-ingredients 1353 # update cursor column @@ -1419,10 +1419,10 @@ if ('onhashchange' in window) { 1361 { 1362 at-start-of-text?:bool <- equal before-cursor, init 1363 break-if at-start-of-text? -1364 prev:char <- get *before-cursor, value:offset -1365 at-start-of-line?:bool <- equal prev, 10/newline +1364 prev:char <- get *before-cursor, value:offset +1365 at-start-of-line?:bool <- equal prev, 10/newline 1366 break-if at-start-of-line? -1367 before-cursor <- prev before-cursor +1367 before-cursor <- prev before-cursor 1368 *editor <- put *editor, before-cursor:offset, before-cursor 1369 assert before-cursor, [move-to-start-of-line tried to move before start of text] 1370 loop @@ -1434,8 +1434,8 @@ if ('onhashchange' in window) { 1376 assume-screen 10/width, 5/height 1377 s:text <- new [123 1378 456] -1379 e:&:editor <- new-editor s, 0/left, 10/right -1380 editor-render screen, e +1379 e:&:editor <- new-editor s, 0/left, 10/right +1380 editor-render screen, e 1381 $clear-trace 1382 # start on first line (no newline before), press ctrl-a 1383 assume-console [ @@ -1443,7 +1443,7 @@ if ('onhashchange' in window) { 1385 press ctrl-a 1386 ] 1387 run [ -1388 editor-event-loop screen, console, e +1388 editor-event-loop screen, console, e 1389 4:num/raw <- get *e, cursor-row:offset 1390 5:num/raw <- get *e, cursor-column:offset 1391 ] @@ -1460,7 +1460,7 @@ if ('onhashchange' in window) { 1402 assume-screen 10/width, 5/height 1403 s:text <- new [123 1404 456] -1405 e:&:editor <- new-editor s, 0/left, 10/right +1405 e:&:editor <- new-editor s, 0/left, 10/right 1406 $clear-trace 1407 # start on second line, press 'home' 1408 assume-console [ @@ -1468,7 +1468,7 @@ if ('onhashchange' in window) { 1410 press home 1411 ] 1412 run [ -1413 editor-event-loop screen, console, e +1413 editor-event-loop screen, console, e 1414 3:num/raw <- get *e, cursor-row:offset 1415 4:num/raw <- get *e, cursor-column:offset 1416 ] @@ -1485,8 +1485,8 @@ if ('onhashchange' in window) { 1427 assume-screen 10/width, 5/height 1428 s:text <- new [123 1429 456] -1430 e:&:editor <- new-editor s, 0/left, 10/right -1431 editor-render screen, e +1430 e:&:editor <- new-editor s, 0/left, 10/right +1431 editor-render screen, e 1432 $clear-trace 1433 # start on first line (no newline before), press 'home' 1434 assume-console [ @@ -1494,7 +1494,7 @@ if ('onhashchange' in window) { 1436 press home 1437 ] 1438 run [ -1439 editor-event-loop screen, console, e +1439 editor-event-loop screen, console, e 1440 3:num/raw <- get *e, cursor-row:offset 1441 4:num/raw <- get *e, cursor-column:offset 1442 ] @@ -1513,8 +1513,8 @@ if ('onhashchange' in window) { 1455 assume-screen 10/width, 5/height 1456 s:text <- new [123 1457 456] -1458 e:&:editor <- new-editor s, 0/left, 10/right -1459 editor-render screen, e +1458 e:&:editor <- new-editor s, 0/left, 10/right +1459 editor-render screen, e 1460 $clear-trace 1461 # start on first line, press ctrl-e 1462 assume-console [ @@ -1522,7 +1522,7 @@ if ('onhashchange' in window) { 1464 press ctrl-e 1465 ] 1466 run [ -1467 editor-event-loop screen, console, e +1467 editor-event-loop screen, console, e 1468 4:num/raw <- get *e, cursor-row:offset 1469 5:num/raw <- get *e, cursor-column:offset 1470 ] @@ -1537,7 +1537,7 @@ if ('onhashchange' in window) { 1479 type [z] 1480 ] 1481 run [ -1482 editor-event-loop screen, console, e +1482 editor-event-loop screen, console, e 1483 4:num/raw <- get *e, cursor-row:offset 1484 5:num/raw <- get *e, cursor-column:offset 1485 ] @@ -1560,7 +1560,7 @@ if ('onhashchange' in window) { 1502 move-to-end-of-line?:bool <- equal c, 5/ctrl-e 1503 break-unless move-to-end-of-line? 1504 <move-cursor-begin> -1505 move-to-end-of-line editor +1505 move-to-end-of-line editor 1506 undo-coalesce-tag:num <- copy 0/never 1507 <move-cursor-end> 1508 return 0/don't-render @@ -1572,26 +1572,26 @@ if ('onhashchange' in window) { 1514 move-to-end-of-line?:bool <- equal k, 65520/end 1515 break-unless move-to-end-of-line? 1516 <move-cursor-begin> -1517 move-to-end-of-line editor +1517 move-to-end-of-line editor 1518 undo-coalesce-tag:num <- copy 0/never 1519 <move-cursor-end> 1520 return 0/don't-render 1521 } 1522 ] 1523 -1524 def move-to-end-of-line editor:&:editor -> editor:&:editor [ +1524 def move-to-end-of-line editor:&:editor -> editor:&:editor [ 1525 local-scope 1526 load-ingredients 1527 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1528 cursor-column:num <- get *editor, cursor-column:offset 1529 # while not at start of line, move 1530 { -1531 next:&:duplex-list:char <- next before-cursor -1532 break-unless next # end of text +1531 next:&:duplex-list:char <- next before-cursor +1532 break-unless next # end of text 1533 nextc:char <- get *next, value:offset 1534 at-end-of-line?:bool <- equal nextc, 10/newline 1535 break-if at-end-of-line? -1536 before-cursor <- copy next +1536 before-cursor <- copy next 1537 *editor <- put *editor, before-cursor:offset, before-cursor 1538 cursor-column <- add cursor-column, 1 1539 *editor <- put *editor, cursor-column:offset, cursor-column @@ -1604,8 +1604,8 @@ if ('onhashchange' in window) { 1546 assume-screen 10/width, 5/height 1547 s:text <- new [123 1548 456] -1549 e:&:editor <- new-editor s, 0/left, 10/right -1550 editor-render screen, e +1549 e:&:editor <- new-editor s, 0/left, 10/right +1550 editor-render screen, e 1551 $clear-trace 1552 # start on second line (no newline after), press ctrl-e 1553 assume-console [ @@ -1613,7 +1613,7 @@ if ('onhashchange' in window) { 1555 press ctrl-e 1556 ] 1557 run [ -1558 editor-event-loop screen, console, e +1558 editor-event-loop screen, console, e 1559 4:num/raw <- get *e, cursor-row:offset 1560 5:num/raw <- get *e, cursor-column:offset 1561 ] @@ -1630,8 +1630,8 @@ if ('onhashchange' in window) { 1572 assume-screen 10/width, 5/height 1573 s:text <- new [123 1574 456] -1575 e:&:editor <- new-editor s, 0/left, 10/right -1576 editor-render screen, e +1575 e:&:editor <- new-editor s, 0/left, 10/right +1576 editor-render screen, e 1577 $clear-trace 1578 # start on first line, press 'end' 1579 assume-console [ @@ -1639,7 +1639,7 @@ if ('onhashchange' in window) { 1581 press end 1582 ] 1583 run [ -1584 editor-event-loop screen, console, e +1584 editor-event-loop screen, console, e 1585 3:num/raw <- get *e, cursor-row:offset 1586 4:num/raw <- get *e, cursor-column:offset 1587 ] @@ -1656,8 +1656,8 @@ if ('onhashchange' in window) { 1598 assume-screen 10/width, 5/height 1599 s:text <- new [123 1600 456] -1601 e:&:editor <- new-editor s, 0/left, 10/right -1602 editor-render screen, e +1601 e:&:editor <- new-editor s, 0/left, 10/right +1602 editor-render screen, e 1603 $clear-trace 1604 # start on second line (no newline after), press 'end' 1605 assume-console [ @@ -1665,7 +1665,7 @@ if ('onhashchange' in window) { 1607 press end 1608 ] 1609 run [ -1610 editor-event-loop screen, console, e +1610 editor-event-loop screen, console, e 1611 3:num/raw <- get *e, cursor-row:offset 1612 4:num/raw <- get *e, cursor-column:offset 1613 ] @@ -1684,14 +1684,14 @@ if ('onhashchange' in window) { 1626 assume-screen 10/width, 5/height 1627 s:text <- new [123 1628 456] -1629 e:&:editor <- new-editor s, 0/left, 10/right +1629 e:&:editor <- new-editor s, 0/left, 10/right 1630 # start on second line, press ctrl-u 1631 assume-console [ 1632 left-click 2, 2 1633 press ctrl-u 1634 ] 1635 run [ -1636 editor-event-loop screen, console, e +1636 editor-event-loop screen, console, e 1637 ] 1638 # cursor deletes to start of line 1639 screen-should-contain [ @@ -1708,33 +1708,33 @@ if ('onhashchange' in window) { 1650 delete-to-start-of-line?:bool <- equal c, 21/ctrl-u 1651 break-unless delete-to-start-of-line? 1652 <delete-to-start-of-line-begin> -1653 deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor +1653 deleted-cells:&:duplex-list:char <- delete-to-start-of-line editor 1654 <delete-to-start-of-line-end> 1655 return 1/go-render 1656 } 1657 ] 1658 -1659 def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ +1659 def delete-to-start-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ 1660 local-scope 1661 load-ingredients 1662 # compute range to delete 1663 init:&:duplex-list:char <- get *editor, data:offset 1664 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 1665 start:&:duplex-list:char <- copy before-cursor -1666 end:&:duplex-list:char <- next before-cursor +1666 end:&:duplex-list:char <- next before-cursor 1667 { 1668 at-start-of-text?:bool <- equal start, init 1669 break-if at-start-of-text? 1670 curr:char <- get *start, value:offset 1671 at-start-of-line?:bool <- equal curr, 10/newline 1672 break-if at-start-of-line? -1673 start <- prev start +1673 start <- prev start 1674 assert start, [delete-to-start-of-line tried to move before start of text] 1675 loop 1676 } 1677 # snip it out -1678 result:&:duplex-list:char <- next start -1679 remove-between start, end +1678 result:&:duplex-list:char <- next start +1679 remove-between start, end 1680 # adjust cursor 1681 before-cursor <- copy start 1682 *editor <- put *editor, before-cursor:offset, before-cursor @@ -1747,14 +1747,14 @@ if ('onhashchange' in window) { 1689 assume-screen 10/width, 5/height 1690 s:text <- new [123 1691 456] -1692 e:&:editor <- new-editor s, 0/left, 10/right +1692 e:&:editor <- new-editor s, 0/left, 10/right 1693 # start on first line (no newline before), press ctrl-u 1694 assume-console [ 1695 left-click 1, 2 1696 press ctrl-u 1697 ] 1698 run [ -1699 editor-event-loop screen, console, e +1699 editor-event-loop screen, console, e 1700 ] 1701 # cursor deletes to start of line 1702 screen-should-contain [ @@ -1771,14 +1771,14 @@ if ('onhashchange' in window) { 1713 assume-screen 10/width, 5/height 1714 s:text <- new [123 1715 456] -1716 e:&:editor <- new-editor s, 0/left, 10/right +1716 e:&:editor <- new-editor s, 0/left, 10/right 1717 # start past end of line, press ctrl-u 1718 assume-console [ 1719 left-click 1, 3 1720 press ctrl-u 1721 ] 1722 run [ -1723 editor-event-loop screen, console, e +1723 editor-event-loop screen, console, e 1724 ] 1725 # cursor deletes to start of line 1726 screen-should-contain [ @@ -1795,14 +1795,14 @@ if ('onhashchange' in window) { 1737 assume-screen 10/width, 5/height 1738 s:text <- new [123 1739 456] -1740 e:&:editor <- new-editor s, 0/left, 10/right +1740 e:&:editor <- new-editor s, 0/left, 10/right 1741 # start past end of final line, press ctrl-u 1742 assume-console [ 1743 left-click 2, 3 1744 press ctrl-u 1745 ] 1746 run [ -1747 editor-event-loop screen, console, e +1747 editor-event-loop screen, console, e 1748 ] 1749 # cursor deletes to start of line 1750 screen-should-contain [ @@ -1821,14 +1821,14 @@ if ('onhashchange' in window) { 1763 assume-screen 10/width, 5/height 1764 s:text <- new [123 1765 456] -1766 e:&:editor <- new-editor s, 0/left, 10/right +1766 e:&:editor <- new-editor s, 0/left, 10/right 1767 # start on first line, press ctrl-k 1768 assume-console [ 1769 left-click 1, 1 1770 press ctrl-k 1771 ] 1772 run [ -1773 editor-event-loop screen, console, e +1773 editor-event-loop screen, console, e 1774 ] 1775 # cursor deletes to end of line 1776 screen-should-contain [ @@ -1845,30 +1845,30 @@ if ('onhashchange' in window) { 1787 delete-to-end-of-line?:bool <- equal c, 11/ctrl-k 1788 break-unless delete-to-end-of-line? 1789 <delete-to-end-of-line-begin> -1790 deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor +1790 deleted-cells:&:duplex-list:char <- delete-to-end-of-line editor 1791 <delete-to-end-of-line-end> 1792 return 1/go-render 1793 } 1794 ] 1795 -1796 def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ +1796 def delete-to-end-of-line editor:&:editor -> result:&:duplex-list:char, editor:&:editor [ 1797 local-scope 1798 load-ingredients 1799 # compute range to delete 1800 start:&:duplex-list:char <- get *editor, before-cursor:offset -1801 end:&:duplex-list:char <- next start +1801 end:&:duplex-list:char <- next start 1802 { 1803 at-end-of-text?:bool <- equal end, 0/null 1804 break-if at-end-of-text? 1805 curr:char <- get *end, value:offset 1806 at-end-of-line?:bool <- equal curr, 10/newline 1807 break-if at-end-of-line? -1808 end <- next end +1808 end <- next end 1809 loop 1810 } 1811 # snip it out -1812 result <- next start -1813 remove-between start, end +1812 result <- next start +1813 remove-between start, end 1814 ] 1815 1816 scenario editor-deletes-to-end-of-line-with-ctrl-k-2 [ @@ -1876,14 +1876,14 @@ if ('onhashchange' in window) { 1818 assume-screen 10/width, 5/height 1819 s:text <- new [123 1820 456] -1821 e:&:editor <- new-editor s, 0/left, 10/right +1821 e:&:editor <- new-editor s, 0/left, 10/right 1822 # start on second line (no newline after), press ctrl-k 1823 assume-console [ 1824 left-click 2, 1 1825 press ctrl-k 1826 ] 1827 run [ -1828 editor-event-loop screen, console, e +1828 editor-event-loop screen, console, e 1829 ] 1830 # cursor deletes to end of line 1831 screen-should-contain [ @@ -1900,14 +1900,14 @@ if ('onhashchange' in window) { 1842 assume-screen 10/width, 5/height 1843 s:text <- new [123 1844 456] -1845 e:&:editor <- new-editor s, 0/left, 10/right +1845 e:&:editor <- new-editor s, 0/left, 10/right 1846 # start at end of line 1847 assume-console [ 1848 left-click 1, 2 1849 press ctrl-k 1850 ] 1851 run [ -1852 editor-event-loop screen, console, e +1852 editor-event-loop screen, console, e 1853 ] 1854 # cursor deletes just last character 1855 screen-should-contain [ @@ -1924,14 +1924,14 @@ if ('onhashchange' in window) { 1866 assume-screen 10/width, 5/height 1867 s:text <- new [123 1868 456] -1869 e:&:editor <- new-editor s, 0/left, 10/right +1869 e:&:editor <- new-editor s, 0/left, 10/right 1870 # start past end of line 1871 assume-console [ 1872 left-click 1, 3 1873 press ctrl-k 1874 ] 1875 run [ -1876 editor-event-loop screen, console, e +1876 editor-event-loop screen, console, e 1877 ] 1878 # cursor deletes nothing 1879 screen-should-contain [ @@ -1948,14 +1948,14 @@ if ('onhashchange' in window) { 1890 assume-screen 10/width, 5/height 1891 s:text <- new [123 1892 456] -1893 e:&:editor <- new-editor s, 0/left, 10/right +1893 e:&:editor <- new-editor s, 0/left, 10/right 1894 # start at end of text 1895 assume-console [ 1896 left-click 2, 2 1897 press ctrl-k 1898 ] 1899 run [ -1900 editor-event-loop screen, console, e +1900 editor-event-loop screen, console, e 1901 ] 1902 # cursor deletes just the final character 1903 screen-should-contain [ @@ -1972,14 +1972,14 @@ if ('onhashchange' in window) { 1914 assume-screen 10/width, 5/height 1915 s:text <- new [123 1916 456] -1917 e:&:editor <- new-editor s, 0/left, 10/right +1917 e:&:editor <- new-editor s, 0/left, 10/right 1918 # start past end of text 1919 assume-console [ 1920 left-click 2, 3 1921 press ctrl-k 1922 ] 1923 run [ -1924 editor-event-loop screen, console, e +1924 editor-event-loop screen, console, e 1925 ] 1926 # cursor deletes nothing 1927 screen-should-contain [ @@ -2002,8 +2002,8 @@ if ('onhashchange' in window) { 1944 b 1945 c 1946 d] -1947 e:&:editor <- new-editor s, 0/left, 10/right -1948 editor-render screen, e +1947 e:&:editor <- new-editor s, 0/left, 10/right +1948 editor-render screen, e 1949 screen-should-contain [ 1950 . . 1951 .a . @@ -2016,7 +2016,7 @@ if ('onhashchange' in window) { 1958 press down-arrow 1959 ] 1960 run [ -1961 editor-event-loop screen, console, e +1961 editor-event-loop screen, console, e 1962 ] 1963 # screen slides by one line 1964 screen-should-contain [ @@ -2034,7 +2034,7 @@ if ('onhashchange' in window) { 1976 right:num <- get *editor, right:offset 1977 max:num <- subtract right, left 1978 old-top:&:duplex-list:char <- copy top-of-screen -1979 top-of-screen <- before-start-of-next-line top-of-screen, max +1979 top-of-screen <- before-start-of-next-line top-of-screen, max 1980 *editor <- put *editor, top-of-screen:offset, top-of-screen 1981 no-movement?:bool <- equal old-top, top-of-screen 1982 return-if no-movement?, 0/don't-render @@ -2043,7 +2043,7 @@ if ('onhashchange' in window) { 1985 # takes a pointer into the doubly-linked list, scans ahead at most 'max' 1986 # positions until the next newline 1987 # beware: never return null pointer. -1988 def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ +1988 def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:duplex-list:char [ 1989 local-scope 1990 load-ingredients 1991 count:num <- copy 0 @@ -2053,7 +2053,7 @@ if ('onhashchange' in window) { 1995 c:char <- get *curr, value:offset 1996 at-newline?:bool <- equal c, 10/newline 1997 break-unless at-newline? -1998 curr <- next curr +1998 curr <- next curr 1999 count <- add count, 1 2000 } 2001 { @@ -2063,7 +2063,7 @@ if ('onhashchange' in window) { 2005 c:char <- get *curr, value:offset 2006 at-newline?:bool <- equal c, 10/newline 2007 break-if at-newline? -2008 curr <- next curr +2008 curr <- next curr 2009 count <- add count, 1 2010 loop 2011 } @@ -2081,8 +2081,8 @@ if ('onhashchange' in window) { 2023 g 2024 h 2025 i] -2026 e:&:editor <- new-editor s, 0/left, 5/right -2027 editor-render screen, e +2026 e:&:editor <- new-editor s, 0/left, 5/right +2027 editor-render screen, e 2028 screen-should-contain [ 2029 . . 2030 .abcd↩ . @@ -2095,7 +2095,7 @@ if ('onhashchange' in window) { 2037 press down-arrow 2038 ] 2039 run [ -2040 editor-event-loop screen, console, e +2040 editor-event-loop screen, console, e 2041 ] 2042 # screen shows partial wrapped line 2043 screen-should-contain [ @@ -2115,14 +2115,14 @@ if ('onhashchange' in window) { 2057 k 2058 l 2059 m] -2060 e:&:editor <- new-editor s, 0/left, 5/right +2060 e:&:editor <- new-editor s, 0/left, 5/right 2061 # position cursor at last line, then try to move further down 2062 assume-console [ 2063 left-click 3, 0 2064 press down-arrow 2065 ] 2066 run [ -2067 editor-event-loop screen, console, e +2067 editor-event-loop screen, console, e 2068 ] 2069 # screen shows partial wrapped line containing a wrap icon 2070 screen-should-contain [ @@ -2136,7 +2136,7 @@ if ('onhashchange' in window) { 2078 press down-arrow 2079 ] 2080 run [ -2081 editor-event-loop screen, console, e +2081 editor-event-loop screen, console, e 2082 ] 2083 # screen shows partial wrapped line 2084 screen-should-contain [ @@ -2155,14 +2155,14 @@ if ('onhashchange' in window) { 2097 s:text <- new [a 2098 b 2099 cdef] -2100 e:&:editor <- new-editor s, 0/left, 5/right +2100 e:&:editor <- new-editor s, 0/left, 5/right 2101 # position cursor at end, type a character 2102 assume-console [ 2103 left-click 3, 4 2104 type [g] 2105 ] 2106 run [ -2107 editor-event-loop screen, console, e +2107 editor-event-loop screen, console, e 2108 3:num/raw <- get *e, cursor-row:offset 2109 4:num/raw <- get *e, cursor-column:offset 2110 ] @@ -2186,14 +2186,14 @@ if ('onhashchange' in window) { 2128 s:text <- new [a 2129 b 2130 c] -2131 e:&:editor <- new-editor s, 0/left, 5/right +2131 e:&:editor <- new-editor s, 0/left, 5/right 2132 assume-console [ 2133 left-click 3, 4 2134 type [ 2135 ] 2136 ] 2137 run [ -2138 editor-event-loop screen, console, e +2138 editor-event-loop screen, console, e 2139 3:num/raw <- get *e, cursor-row:offset 2140 4:num/raw <- get *e, cursor-column:offset 2141 ] @@ -2218,14 +2218,14 @@ if ('onhashchange' in window) { 2160 s:text <- new [a 2161 b 2162 cdefgh] -2163 e:&:editor <- new-editor s, 0/left, 5/right +2163 e:&:editor <- new-editor s, 0/left, 5/right 2164 # position cursor at end of screen and try to move right 2165 assume-console [ 2166 left-click 3, 3 2167 press right-arrow 2168 ] 2169 run [ -2170 editor-event-loop screen, console, e +2170 editor-event-loop screen, console, e 2171 3:num/raw <- get *e, cursor-row:offset 2172 4:num/raw <- get *e, cursor-column:offset 2173 ] @@ -2251,14 +2251,14 @@ if ('onhashchange' in window) { 2193 b 2194 c 2195 d] -2196 e:&:editor <- new-editor s, 0/left, 5/right +2196 e:&:editor <- new-editor s, 0/left, 5/right 2197 # position cursor at end of screen and try to move right 2198 assume-console [ 2199 left-click 3, 3 2200 press right-arrow 2201 ] 2202 run [ -2203 editor-event-loop screen, console, e +2203 editor-event-loop screen, console, e 2204 3:num/raw <- get *e, cursor-row:offset 2205 4:num/raw <- get *e, cursor-column:offset 2206 ] @@ -2280,8 +2280,8 @@ if ('onhashchange' in window) { 2222 assume-screen 10/width, 5/height 2223 s:text <- new [abc 2224 de] -2225 e:&:editor <- new-editor s, 0/left, 10/right -2226 editor-render screen, e +2225 e:&:editor <- new-editor s, 0/left, 10/right +2226 editor-render screen, e 2227 $clear-trace 2228 # try to move down past end of text 2229 assume-console [ @@ -2289,7 +2289,7 @@ if ('onhashchange' in window) { 2231 press down-arrow 2232 ] 2233 run [ -2234 editor-event-loop screen, console, e +2234 editor-event-loop screen, console, e 2235 3:num/raw <- get *e, cursor-row:offset 2236 4:num/raw <- get *e, cursor-column:offset 2237 ] @@ -2302,7 +2302,7 @@ if ('onhashchange' in window) { 2244 type [0] 2245 ] 2246 run [ -2247 editor-event-loop screen, console, e +2247 editor-event-loop screen, console, e 2248 ] 2249 screen-should-contain [ 2250 . . @@ -2317,7 +2317,7 @@ if ('onhashchange' in window) { 2259 press down-arrow 2260 ] 2261 run [ -2262 editor-event-loop screen, console, e +2262 editor-event-loop screen, console, e 2263 3:num/raw <- get *e, cursor-row:offset 2264 4:num/raw <- get *e, cursor-column:offset 2265 ] @@ -2331,7 +2331,7 @@ if ('onhashchange' in window) { 2273 type [1] 2274 ] 2275 run [ -2276 editor-event-loop screen, console, e +2276 editor-event-loop screen, console, e 2277 ] 2278 screen-should-contain [ 2279 . . @@ -2353,16 +2353,16 @@ if ('onhashchange' in window) { 2295 e 2296 f 2297 g] -2298 e:&:editor <- new-editor s, 0/left, 5/right -2299 editor-render screen, e +2298 e:&:editor <- new-editor s, 0/left, 5/right +2299 editor-render screen, e 2300 # scroll down one page and one line 2301 assume-console [ -2302 press page-down +2302 press page-down 2303 left-click 3, 0 2304 press down-arrow 2305 ] 2306 run [ -2307 editor-event-loop screen, console, e +2307 editor-event-loop screen, console, e 2308 ] 2309 # screen scrolls down 3 lines 2310 screen-should-contain [ @@ -2384,8 +2384,8 @@ if ('onhashchange' in window) { 2326 b 2327 c 2328 d] -2329 e:&:editor <- new-editor s, 0/left, 10/right -2330 editor-render screen, e +2329 e:&:editor <- new-editor s, 0/left, 10/right +2330 editor-render screen, e 2331 screen-should-contain [ 2332 . . 2333 .a . @@ -2394,11 +2394,11 @@ if ('onhashchange' in window) { 2336 ] 2337 # position cursor at top of second page, then try to move up 2338 assume-console [ -2339 press page-down +2339 press page-down 2340 press up-arrow 2341 ] 2342 run [ -2343 editor-event-loop screen, console, e +2343 editor-event-loop screen, console, e 2344 ] 2345 # screen slides by one line 2346 screen-should-contain [ @@ -2413,7 +2413,7 @@ if ('onhashchange' in window) { 2355 trace 10, [app], [scroll up] 2356 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2357 old-top:&:duplex-list:char <- copy top-of-screen -2358 top-of-screen <- before-previous-line top-of-screen, editor +2358 top-of-screen <- before-previous-line top-of-screen, editor 2359 *editor <- put *editor, top-of-screen:offset, top-of-screen 2360 no-movement?:bool <- equal old-top, top-of-screen 2361 return-if no-movement?, 0/don't-render @@ -2422,7 +2422,7 @@ if ('onhashchange' in window) { 2364 # takes a pointer into the doubly-linked list, scans back to before start of 2365 # previous *wrapped* line 2366 # beware: never return null pointer -2367 def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ +2367 def before-previous-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [ 2368 local-scope 2369 load-ingredients 2370 curr:&:duplex-list:char <- copy in @@ -2434,13 +2434,13 @@ if ('onhashchange' in window) { 2376 right:num <- get *editor, right:offset 2377 max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon 2378 sentinel:&:duplex-list:char <- get *editor, data:offset -2379 len:num <- previous-line-length curr, sentinel +2379 len:num <- previous-line-length curr, sentinel 2380 { 2381 break-if len 2382 # empty line; just skip this newline -2383 prev:&:duplex-list:char <- prev curr -2384 return-unless prev, curr -2385 return prev +2383 prev:&:duplex-list:char <- prev curr +2384 return-unless prev, curr +2385 return prev 2386 } 2387 _, max:num <- divide-with-remainder len, max-line-length 2388 # remainder 0 => scan one width-worth @@ -2454,9 +2454,9 @@ if ('onhashchange' in window) { 2396 { 2397 done?:bool <- greater-or-equal count, max 2398 break-if done? -2399 prev:&:duplex-list:char <- prev curr -2400 break-unless prev -2401 curr <- copy prev +2399 prev:&:duplex-list:char <- prev curr +2400 break-unless prev +2401 curr <- copy prev 2402 count <- add count, 1 2403 loop 2404 } @@ -2473,8 +2473,8 @@ if ('onhashchange' in window) { 2415 g 2416 h 2417 i] -2418 e:&:editor <- new-editor s, 0/left, 5/right -2419 editor-render screen, e +2418 e:&:editor <- new-editor s, 0/left, 5/right +2419 editor-render screen, e 2420 screen-should-contain [ 2421 . . 2422 .abcd↩ . @@ -2483,10 +2483,10 @@ if ('onhashchange' in window) { 2425 ] 2426 # position cursor at top of second page, just below wrapped line 2427 assume-console [ -2428 press page-down +2428 press page-down 2429 ] 2430 run [ -2431 editor-event-loop screen, console, e +2431 editor-event-loop screen, console, e 2432 ] 2433 screen-should-contain [ 2434 . . @@ -2499,7 +2499,7 @@ if ('onhashchange' in window) { 2441 press up-arrow 2442 ] 2443 run [ -2444 editor-event-loop screen, console, e +2444 editor-event-loop screen, console, e 2445 ] 2446 # screen shows partial wrapped line 2447 screen-should-contain [ @@ -2519,14 +2519,14 @@ if ('onhashchange' in window) { 2461 k 2462 l 2463 m] -2464 e:&:editor <- new-editor s, 0/left, 5/right -2465 editor-render screen, e +2464 e:&:editor <- new-editor s, 0/left, 5/right +2465 editor-render screen, e 2466 # position cursor at top of second page 2467 assume-console [ -2468 press page-down +2468 press page-down 2469 ] 2470 run [ -2471 editor-event-loop screen, console, e +2471 editor-event-loop screen, console, e 2472 ] 2473 screen-should-contain [ 2474 . . @@ -2540,7 +2540,7 @@ if ('onhashchange' in window) { 2482 press up-arrow 2483 ] 2484 run [ -2485 editor-event-loop screen, console, e +2485 editor-event-loop screen, console, e 2486 ] 2487 # screen shows partial wrapped line 2488 screen-should-contain [ @@ -2555,7 +2555,7 @@ if ('onhashchange' in window) { 2497 press up-arrow 2498 ] 2499 run [ -2500 editor-event-loop screen, console, e +2500 editor-event-loop screen, console, e 2501 ] 2502 # screen shows partial wrapped line 2503 screen-should-contain [ @@ -2570,7 +2570,7 @@ if ('onhashchange' in window) { 2512 press up-arrow 2513 ] 2514 run [ -2515 editor-event-loop screen, console, e +2515 editor-event-loop screen, console, e 2516 ] 2517 # screen shows partial wrapped line 2518 screen-should-contain [ @@ -2594,8 +2594,8 @@ if ('onhashchange' in window) { 2536 g 2537 h 2538 i] -2539 e:&:editor <- new-editor s, 0/left, 6/right -2540 editor-render screen, e +2539 e:&:editor <- new-editor s, 0/left, 6/right +2540 editor-render screen, e 2541 screen-should-contain [ 2542 . . 2543 .abcde↩ . @@ -2604,10 +2604,10 @@ if ('onhashchange' in window) { 2546 ] 2547 # position cursor at top of second page, just below wrapped line 2548 assume-console [ -2549 press page-down +2549 press page-down 2550 ] 2551 run [ -2552 editor-event-loop screen, console, e +2552 editor-event-loop screen, console, e 2553 ] 2554 screen-should-contain [ 2555 . . @@ -2620,7 +2620,7 @@ if ('onhashchange' in window) { 2562 press up-arrow 2563 ] 2564 run [ -2565 editor-event-loop screen, console, e +2565 editor-event-loop screen, console, e 2566 ] 2567 # screen shows partial wrapped line 2568 screen-should-contain [ @@ -2642,13 +2642,13 @@ if ('onhashchange' in window) { 2584 c 2585 d 2586 e] -2587 e:&:editor <- new-editor s, 0/left, 6/right -2588 editor-render screen, e +2587 e:&:editor <- new-editor s, 0/left, 6/right +2588 editor-render screen, e 2589 assume-console [ -2590 press page-down +2590 press page-down 2591 ] 2592 run [ -2593 editor-event-loop screen, console, e +2593 editor-event-loop screen, console, e 2594 ] 2595 screen-should-contain [ 2596 . . @@ -2657,10 +2657,10 @@ if ('onhashchange' in window) { 2599 .d . 2600 ] 2601 assume-console [ -2602 press page-down +2602 press page-down 2603 ] 2604 run [ -2605 editor-event-loop screen, console, e +2605 editor-event-loop screen, console, e 2606 ] 2607 screen-should-contain [ 2608 . . @@ -2669,10 +2669,10 @@ if ('onhashchange' in window) { 2611 .╌╌╌╌╌╌ . 2612 ] 2613 assume-console [ -2614 press page-up +2614 press page-up 2615 ] 2616 run [ -2617 editor-event-loop screen, console, e +2617 editor-event-loop screen, console, e 2618 ] 2619 screen-should-contain [ 2620 . . @@ -2692,14 +2692,14 @@ if ('onhashchange' in window) { 2634 c 2635 d 2636 e] -2637 e:&:editor <- new-editor s, 0/left, 5/right -2638 editor-render screen, e +2637 e:&:editor <- new-editor s, 0/left, 5/right +2638 editor-render screen, e 2639 # position cursor at top of second page 2640 assume-console [ -2641 press page-down +2641 press page-down 2642 ] 2643 run [ -2644 editor-event-loop screen, console, e +2644 editor-event-loop screen, console, e 2645 ] 2646 screen-should-contain [ 2647 . . @@ -2712,7 +2712,7 @@ if ('onhashchange' in window) { 2654 press left-arrow 2655 ] 2656 run [ -2657 editor-event-loop screen, console, e +2657 editor-event-loop screen, console, e 2658 3:num/raw <- get *e, cursor-row:offset 2659 4:num/raw <- get *e, cursor-column:offset 2660 ] @@ -2738,8 +2738,8 @@ if ('onhashchange' in window) { 2680 b 2681 c 2682 d] -2683 e:&:editor <- new-editor s, 0/left, 10/right -2684 editor-render screen, e +2683 e:&:editor <- new-editor s, 0/left, 10/right +2684 editor-render screen, e 2685 screen-should-contain [ 2686 . . 2687 .a . @@ -2749,12 +2749,12 @@ if ('onhashchange' in window) { 2691 # position cursor at top of second page, then try to move up to start of 2692 # text 2693 assume-console [ -2694 press page-down +2694 press page-down 2695 press up-arrow 2696 press up-arrow 2697 ] 2698 run [ -2699 editor-event-loop screen, console, e +2699 editor-event-loop screen, console, e 2700 ] 2701 # screen slides by one line 2702 screen-should-contain [ @@ -2768,7 +2768,7 @@ if ('onhashchange' in window) { 2710 press up-arrow 2711 ] 2712 run [ -2713 editor-event-loop screen, console, e +2713 editor-event-loop screen, console, e 2714 ] 2715 # screen remains unchanged 2716 screen-should-contain [ @@ -2788,8 +2788,8 @@ if ('onhashchange' in window) { 2730 b 2731 c 2732 d] -2733 e:&:editor <- new-editor s, 0/left, 10/right -2734 editor-render screen, e +2733 e:&:editor <- new-editor s, 0/left, 10/right +2734 editor-render screen, e 2735 screen-should-contain [ 2736 . . 2737 .a . @@ -2798,10 +2798,10 @@ if ('onhashchange' in window) { 2740 ] 2741 # scroll down 2742 assume-console [ -2743 press page-down +2743 press page-down 2744 ] 2745 run [ -2746 editor-event-loop screen, console, e +2746 editor-event-loop screen, console, e 2747 ] 2748 # screen shows next page 2749 screen-should-contain [ @@ -2818,7 +2818,7 @@ if ('onhashchange' in window) { 2760 break-unless page-down? 2761 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2762 <move-cursor-begin> -2763 page-down editor +2763 page-down editor 2764 undo-coalesce-tag:num <- copy 0/never 2765 <move-cursor-end> 2766 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset @@ -2833,7 +2833,7 @@ if ('onhashchange' in window) { 2775 break-unless page-down? 2776 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2777 <move-cursor-begin> -2778 page-down editor +2778 page-down editor 2779 undo-coalesce-tag:num <- copy 0/never 2780 <move-cursor-end> 2781 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset @@ -2844,7 +2844,7 @@ if ('onhashchange' in window) { 2786 2787 # page-down skips entire wrapped lines, so it can't scroll past lines 2788 # taking up the entire screen -2789 def page-down editor:&:editor -> editor:&:editor [ +2789 def page-down editor:&:editor -> editor:&:editor [ 2790 local-scope 2791 load-ingredients 2792 # if editor contents don't overflow screen, do nothing @@ -2852,18 +2852,18 @@ if ('onhashchange' in window) { 2794 return-unless bottom-of-screen 2795 # if not, position cursor at final character 2796 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -2797 before-cursor:&:duplex-list:char <- prev bottom-of-screen +2797 before-cursor:&:duplex-list:char <- prev bottom-of-screen 2798 *editor <- put *editor, before-cursor:offset, before-cursor 2799 # keep one line in common with previous page 2800 { -2801 last:char <- get *before-cursor, value:offset -2802 newline?:bool <- equal last, 10/newline +2801 last:char <- get *before-cursor, value:offset +2802 newline?:bool <- equal last, 10/newline 2803 break-unless newline?:bool -2804 before-cursor <- prev before-cursor +2804 before-cursor <- prev before-cursor 2805 *editor <- put *editor, before-cursor:offset, before-cursor 2806 } 2807 # move cursor and top-of-screen to start of that line -2808 move-to-start-of-line editor +2808 move-to-start-of-line editor 2809 before-cursor <- get *editor, before-cursor:offset 2810 *editor <- put *editor, top-of-screen:offset, before-cursor 2811 ] @@ -2873,8 +2873,8 @@ if ('onhashchange' in window) { 2815 assume-screen 10/width, 4/height 2816 s:text <- new [a 2817 b] -2818 e:&:editor <- new-editor s, 0/left, 10/right -2819 editor-render screen, e +2818 e:&:editor <- new-editor s, 0/left, 10/right +2819 editor-render screen, e 2820 screen-should-contain [ 2821 . . 2822 .a . @@ -2883,10 +2883,10 @@ if ('onhashchange' in window) { 2825 ] 2826 # scroll down 2827 assume-console [ -2828 press page-down +2828 press page-down 2829 ] 2830 run [ -2831 editor-event-loop screen, console, e +2831 editor-event-loop screen, console, e 2832 ] 2833 # screen remains unmodified 2834 screen-should-contain [ @@ -2906,8 +2906,8 @@ if ('onhashchange' in window) { 2848 b 2849 cdefgh] 2850 # editor screen triggers wrap of last line -2851 e:&:editor <- new-editor s, 0/left, 4/right -2852 editor-render screen, e +2851 e:&:editor <- new-editor s, 0/left, 4/right +2852 editor-render screen, e 2853 # some part of last line is not displayed 2854 screen-should-contain [ 2855 . . @@ -2917,10 +2917,10 @@ if ('onhashchange' in window) { 2859 ] 2860 # scroll down 2861 assume-console [ -2862 press page-down +2862 press page-down 2863 ] 2864 run [ -2865 editor-event-loop screen, console, e +2865 editor-event-loop screen, console, e 2866 ] 2867 # screen shows entire wrapped line 2868 screen-should-contain [ @@ -2939,8 +2939,8 @@ if ('onhashchange' in window) { 2881 # and still has something left over 2882 s:text <- new [a 2883 bcdefgh] -2884 e:&:editor <- new-editor s, 0/left, 4/right -2885 editor-render screen, e +2884 e:&:editor <- new-editor s, 0/left, 4/right +2885 editor-render screen, e 2886 # some part of last line is not displayed 2887 screen-should-contain [ 2888 . . @@ -2950,10 +2950,10 @@ if ('onhashchange' in window) { 2892 ] 2893 # scroll down 2894 assume-console [ -2895 press page-down +2895 press page-down 2896 ] 2897 run [ -2898 editor-event-loop screen, console, e +2898 editor-event-loop screen, console, e 2899 ] 2900 # screen shows entire wrapped line 2901 screen-should-contain [ @@ -2973,8 +2973,8 @@ if ('onhashchange' in window) { 2915 b 2916 c 2917 d] -2918 e:&:editor <- new-editor s, 0/left, 10/right -2919 editor-render screen, e +2918 e:&:editor <- new-editor s, 0/left, 10/right +2919 editor-render screen, e 2920 screen-should-contain [ 2921 . . 2922 .a . @@ -2983,10 +2983,10 @@ if ('onhashchange' in window) { 2925 ] 2926 # scroll down 2927 assume-console [ -2928 press page-down +2928 press page-down 2929 ] 2930 run [ -2931 editor-event-loop screen, console, e +2931 editor-event-loop screen, console, e 2932 ] 2933 # screen shows next page 2934 screen-should-contain [ @@ -2997,10 +2997,10 @@ if ('onhashchange' in window) { 2939 ] 2940 # scroll back up 2941 assume-console [ -2942 press page-up +2942 press page-up 2943 ] 2944 run [ -2945 editor-event-loop screen, console, e +2945 editor-event-loop screen, console, e 2946 ] 2947 # screen shows original page again 2948 screen-should-contain [ @@ -3017,7 +3017,7 @@ if ('onhashchange' in window) { 2959 break-unless page-up? 2960 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2961 <move-cursor-begin> -2962 editor <- page-up editor, screen-height +2962 editor <- page-up editor, screen-height 2963 undo-coalesce-tag:num <- copy 0/never 2964 <move-cursor-end> 2965 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset @@ -3032,7 +3032,7 @@ if ('onhashchange' in window) { 2974 break-unless page-up? 2975 old-top:&:duplex-list:char <- get *editor, top-of-screen:offset 2976 <move-cursor-begin> -2977 editor <- page-up editor, screen-height +2977 editor <- page-up editor, screen-height 2978 undo-coalesce-tag:num <- copy 0/never 2979 <move-cursor-end> 2980 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset @@ -3042,18 +3042,18 @@ if ('onhashchange' in window) { 2984 } 2985 ] 2986 -2987 def page-up editor:&:editor, screen-height:num -> editor:&:editor [ +2987 def page-up editor:&:editor, screen-height:num -> editor:&:editor [ 2988 local-scope 2989 load-ingredients -2990 max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line +2990 max:num <- subtract screen-height, 1/menu-bar, 1/overlapping-line 2991 count:num <- copy 0 2992 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 2993 { 2994 done?:bool <- greater-or-equal count, max 2995 break-if done? -2996 prev:&:duplex-list:char <- before-previous-line top-of-screen, editor -2997 break-unless prev -2998 top-of-screen <- copy prev +2996 prev:&:duplex-list:char <- before-previous-line top-of-screen, editor +2997 break-unless prev +2998 top-of-screen <- copy prev 2999 *editor <- put *editor, top-of-screen:offset, top-of-screen 3000 count <- add count, 1 3001 loop @@ -3073,8 +3073,8 @@ if ('onhashchange' in window) { 3015 f 3016 g 3017 h] -3018 e:&:editor <- new-editor s, 0/left, 10/right -3019 editor-render screen, e +3018 e:&:editor <- new-editor s, 0/left, 10/right +3019 editor-render screen, e 3020 screen-should-contain [ 3021 . . 3022 .a . @@ -3083,11 +3083,11 @@ if ('onhashchange' in window) { 3025 ] 3026 # scroll down two pages 3027 assume-console [ -3028 press page-down -3029 press page-down +3028 press page-down +3029 press page-down 3030 ] 3031 run [ -3032 editor-event-loop screen, console, e +3032 editor-event-loop screen, console, e 3033 ] 3034 # screen shows third page 3035 screen-should-contain [ @@ -3098,10 +3098,10 @@ if ('onhashchange' in window) { 3040 ] 3041 # scroll up 3042 assume-console [ -3043 press page-up +3043 press page-up 3044 ] 3045 run [ -3046 editor-event-loop screen, console, e +3046 editor-event-loop screen, console, e 3047 ] 3048 # screen shows second page 3049 screen-should-contain [ @@ -3112,10 +3112,10 @@ if ('onhashchange' in window) { 3054 ] 3055 # scroll up again 3056 assume-console [ -3057 press page-up +3057 press page-up 3058 ] 3059 run [ -3060 editor-event-loop screen, console, e +3060 editor-event-loop screen, console, e 3061 ] 3062 # screen shows original page again 3063 screen-should-contain [ @@ -3142,8 +3142,8 @@ if ('onhashchange' in window) { 3084 n 3085 o] 3086 # editor screen triggers wrap of last line -3087 e:&:editor <- new-editor s, 0/left, 4/right -3088 editor-render screen, e +3087 e:&:editor <- new-editor s, 0/left, 4/right +3088 editor-render screen, e 3089 # some part of last line is not displayed 3090 screen-should-contain [ 3091 . . @@ -3155,12 +3155,12 @@ if ('onhashchange' in window) { 3097 ] 3098 # scroll down a page and a line 3099 assume-console [ -3100 press page-down +3100 press page-down 3101 left-click 5, 0 3102 press down-arrow 3103 ] 3104 run [ -3105 editor-event-loop screen, console, e +3105 editor-event-loop screen, console, e 3106 ] 3107 # screen shows entire wrapped line 3108 screen-should-contain [ @@ -3173,10 +3173,10 @@ if ('onhashchange' in window) { 3115 ] 3116 # now scroll up one page 3117 assume-console [ -3118 press page-up +3118 press page-up 3119 ] 3120 run [ -3121 editor-event-loop screen, console, e +3121 editor-event-loop screen, console, e 3122 ] 3123 # screen resets 3124 screen-should-contain [ @@ -3197,8 +3197,8 @@ if ('onhashchange' in window) { 3139 # and still has something left over 3140 s:text <- new [a 3141 bcdefgh] -3142 e:&:editor <- new-editor s, 0/left, 4/right -3143 editor-render screen, e +3142 e:&:editor <- new-editor s, 0/left, 4/right +3143 editor-render screen, e 3144 # some part of last line is not displayed 3145 screen-should-contain [ 3146 . . @@ -3208,10 +3208,10 @@ if ('onhashchange' in window) { 3150 ] 3151 # scroll down 3152 assume-console [ -3153 press page-down +3153 press page-down 3154 ] 3155 run [ -3156 editor-event-loop screen, console, e +3156 editor-event-loop screen, console, e 3157 ] 3158 # screen shows entire wrapped line 3159 screen-should-contain [ @@ -3222,10 +3222,10 @@ if ('onhashchange' in window) { 3164 ] 3165 # scroll back up 3166 assume-console [ -3167 press page-up +3167 press page-up 3168 ] 3169 run [ -3170 editor-event-loop screen, console, e +3170 editor-event-loop screen, console, e 3171 ] 3172 # screen resets 3173 screen-should-contain [ @@ -3249,8 +3249,8 @@ if ('onhashchange' in window) { 3191 gxx 3192 hxx 3193 ] -3194 e:&:editor <- new-editor s, 0/left, 4/right -3195 editor-render screen, e +3194 e:&:editor <- new-editor s, 0/left, 4/right +3195 editor-render screen, e 3196 screen-should-contain [ 3197 . . 3198 .axx . @@ -3258,10 +3258,10 @@ if ('onhashchange' in window) { 3200 .cxx . 3201 ] 3202 assume-console [ -3203 press page-down +3203 press page-down 3204 ] 3205 run [ -3206 editor-event-loop screen, console, e +3206 editor-event-loop screen, console, e 3207 ] 3208 screen-should-contain [ 3209 . . @@ -3270,10 +3270,10 @@ if ('onhashchange' in window) { 3212 .exx . 3213 ] 3214 assume-console [ -3215 press page-down +3215 press page-down 3216 ] 3217 run [ -3218 editor-event-loop screen, console, e +3218 editor-event-loop screen, console, e 3219 ] 3220 screen-should-contain [ 3221 . . @@ -3283,10 +3283,10 @@ if ('onhashchange' in window) { 3225 ] 3226 # scroll back up past empty line 3227 assume-console [ -3228 press page-up +3228 press page-up 3229 ] 3230 run [ -3231 editor-event-loop screen, console, e +3231 editor-event-loop screen, console, e 3232 ] 3233 screen-should-contain [ 3234 . . @@ -3309,8 +3309,8 @@ if ('onhashchange' in window) { 3251 fxy 3252 gxy 3253 ] -3254 e:&:editor <- new-editor s, 0/left, 4/right -3255 editor-render screen, e +3254 e:&:editor <- new-editor s, 0/left, 4/right +3255 editor-render screen, e 3256 screen-should-contain [ 3257 . . 3258 .axy . @@ -3318,10 +3318,10 @@ if ('onhashchange' in window) { 3260 .cxy . 3261 ] 3262 assume-console [ -3263 press page-down +3263 press page-down 3264 ] 3265 run [ -3266 editor-event-loop screen, console, e +3266 editor-event-loop screen, console, e 3267 ] 3268 screen-should-contain [ 3269 . . @@ -3330,10 +3330,10 @@ if ('onhashchange' in window) { 3272 .dxy . 3273 ] 3274 assume-console [ -3275 press page-down +3275 press page-down 3276 ] 3277 run [ -3278 editor-event-loop screen, console, e +3278 editor-event-loop screen, console, e 3279 ] 3280 screen-should-contain [ 3281 . . @@ -3343,10 +3343,10 @@ if ('onhashchange' in window) { 3285 ] 3286 # scroll back up past empty line 3287 assume-console [ -3288 press page-up +3288 press page-up 3289 ] 3290 run [ -3291 editor-event-loop screen, console, e +3291 editor-event-loop screen, console, e 3292 ] 3293 screen-should-contain [ 3294 . . diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 9b8841fe..04ef7e45 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -65,9 +65,9 @@ if ('onhashchange' in window) { 6 def! main [ 7 local-scope 8 open-console - 9 env:&:environment <- new-programming-environment 0/filesystem, 0/screen - 10 render-all 0/screen, env, render - 11 event-loop 0/screen, 0/console, env, 0/filesystem + 9 env:&:environment <- new-programming-environment 0/filesystem, 0/screen + 10 render-all 0/screen, env, render + 11 event-loop 0/screen, 0/console, env, 0/filesystem 12 # never gets here 13 ] 14 @@ -77,25 +77,25 @@ if ('onhashchange' in window) { 18 sandbox-in-focus?:bool # false => cursor in recipes; true => cursor in current-sandbox 19 ] 20 - 21 def new-programming-environment resources:&:resources, screen:&:screen, test-sandbox-editor-contents:text -> result:&:environment [ + 21 def new-programming-environment resources:&:resources, screen:&:screen, test-sandbox-editor-contents:text -> result:&:environment [ 22 local-scope 23 load-ingredients - 24 width:num <- screen-width screen + 24 width:num <- screen-width screen 25 result <- new environment:type 26 # recipe editor on the left - 27 initial-recipe-contents:text <- slurp resources, [lesson/recipes.mu] # ignore errors + 27 initial-recipe-contents:text <- slurp resources, [lesson/recipes.mu] # ignore errors 28 divider:num, _ <- divide-with-remainder width, 2 - 29 recipes:&:editor <- new-editor initial-recipe-contents, 0/left, divider/right + 29 recipes:&:editor <- new-editor initial-recipe-contents, 0/left, divider/right 30 # sandbox editor on the right 31 sandbox-left:num <- add divider, 1 - 32 current-sandbox:&:editor <- new-editor test-sandbox-editor-contents, sandbox-left, width/right + 32 current-sandbox:&:editor <- new-editor test-sandbox-editor-contents, sandbox-left, width/right 33 *result <- put *result, recipes:offset, recipes 34 *result <- put *result, current-sandbox:offset, current-sandbox 35 *result <- put *result, sandbox-in-focus?:offset, 0/false 36 <programming-environment-initialization> 37 ] 38 - 39 def event-loop screen:&:screen, console:&:console, env:&:environment, resources:&:resources -> screen:&:screen, console:&:console, env:&:environment, resources:&:resources [ + 39 def event-loop screen:&:screen, console:&:console, env:&:environment, resources:&:resources -> screen:&:screen, console:&:console, env:&:environment, resources:&:resources [ 40 local-scope 41 load-ingredients 42 recipes:&:editor <- get *env, recipes:offset @@ -108,25 +108,25 @@ if ('onhashchange' in window) { 49 { 50 # looping over each (keyboard or touch) event as it occurs 51 +next-event - 52 e:event, found?:bool, quit?:bool, console <- read-event console + 52 e:event, found?:bool, quit?:bool, console <- read-event console 53 loop-unless found? 54 break-if quit? # only in tests 55 trace 10, [app], [next-event] 56 <handle-event> 57 # check for global events that will trigger regardless of which editor has focus 58 { - 59 k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant + 59 k:num, is-keycode?:bool <- maybe-convert e:event, keycode:variant 60 break-unless is-keycode? 61 <global-keypress> 62 } 63 { - 64 c:char, is-unicode?:bool <- maybe-convert e:event, text:variant + 64 c:char, is-unicode?:bool <- maybe-convert e:event, text:variant 65 break-unless is-unicode? 66 <global-type> 67 } 68 # 'touch' event - send to both sides, see what picks it up 69 { - 70 t:touch-event, is-touch?:bool <- maybe-convert e:event, touch:variant + 70 t:touch-event, is-touch?:bool <- maybe-convert e:event, touch:variant 71 break-unless is-touch? 72 # ignore all but 'left-click' events for now 73 # todo: test this @@ -138,41 +138,41 @@ if ('onhashchange' in window) { 79 # later exceptions for non-editor touches will go here 80 <global-touch> 81 # send to both editors - 82 _ <- move-cursor-in-editor screen, recipes, t - 83 sandbox-in-focus?:bool <- move-cursor-in-editor screen, current-sandbox, t + 82 _ <- move-cursor-in-editor screen, recipes, t + 83 sandbox-in-focus?:bool <- move-cursor-in-editor screen, current-sandbox, t 84 *env <- put *env, sandbox-in-focus?:offset, sandbox-in-focus? - 85 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + 85 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 86 loop +next-event 87 } 88 # 'resize' event - redraw editor 89 # todo: test this after supporting resize in assume-console 90 { - 91 r:resize-event, is-resize?:bool <- maybe-convert e:event, resize:variant + 91 r:resize-event, is-resize?:bool <- maybe-convert e:event, resize:variant 92 break-unless is-resize? 93 # if more events, we're still resizing; wait until we stop - 94 more-events?:bool <- has-more-events? console + 94 more-events?:bool <- has-more-events? console 95 { 96 break-unless more-events? 97 render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event 98 } 99 { 100 break-if more-events? -101 env, screen <- resize screen, env -102 screen <- render-all screen, env, render-without-moving-cursor +101 env, screen <- resize screen, env +102 screen <- render-all screen, env, render-without-moving-cursor 103 render-all-on-no-more-events? <- copy 0/false # full render done 104 } 105 loop +next-event 106 } 107 # if it's not global and not a touch event, send to appropriate editor 108 { -109 hide-screen screen +109 hide-screen screen 110 sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset 111 { 112 break-if sandbox-in-focus? -113 render?:bool <- handle-keyboard-event screen, recipes, e:event +113 render?:bool <- handle-keyboard-event screen, recipes, e:event 114 # refresh screen only if no more events 115 # if there are more events to process, wait for them to clear up, then make sure you render-all afterward. -116 more-events?:bool <- has-more-events? console +116 more-events?:bool <- has-more-events? console 117 { 118 break-unless more-events? 119 render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event @@ -183,24 +183,24 @@ if ('onhashchange' in window) { 124 { 125 break-unless render-all-on-no-more-events? 126 # no more events, and we have to force render -127 screen <- render-all screen, env, render +127 screen <- render-all screen, env, render 128 render-all-on-no-more-events? <- copy 0/false 129 jump +finish-event 130 } 131 # no more events, no force render 132 { 133 break-unless render? -134 screen <- render-recipes screen, env, render +134 screen <- render-recipes screen, env, render 135 jump +finish-event 136 } 137 } 138 } 139 { 140 break-unless sandbox-in-focus? -141 render?:bool <- handle-keyboard-event screen, current-sandbox, e:event +141 render?:bool <- handle-keyboard-event screen, current-sandbox, e:event 142 # refresh screen only if no more events 143 # if there are more events to process, wait for them to clear up, then make sure you render-all afterward. -144 more-events?:bool <- has-more-events? console +144 more-events?:bool <- has-more-events? console 145 { 146 break-unless more-events? 147 render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event @@ -211,31 +211,31 @@ if ('onhashchange' in window) { 152 { 153 break-unless render-all-on-no-more-events? 154 # no more events, and we have to force render -155 screen <- render-all screen, env, render +155 screen <- render-all screen, env, render 156 render-all-on-no-more-events? <- copy 0/false 157 jump +finish-event 158 } 159 # no more events, no force render 160 { 161 break-unless render? -162 screen <- render-sandbox-side screen, env, render +162 screen <- render-sandbox-side screen, env, render 163 jump +finish-event 164 } 165 } 166 } 167 +finish-event -168 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env -169 show-screen screen +168 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +169 show-screen screen 170 } 171 loop 172 } 173 ] 174 -175 def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:screen [ +175 def resize screen:&:screen, env:&:environment -> env:&:environment, screen:&:screen [ 176 local-scope 177 load-ingredients -178 clear-screen screen # update screen dimensions -179 width:num <- screen-width screen +178 clear-screen screen # update screen dimensions +179 width:num <- screen-width screen 180 divider:num, _ <- divide-with-remainder width, 2 181 # update recipe editor 182 recipes:&:editor <- get *env, recipes:offset @@ -258,16 +258,16 @@ if ('onhashchange' in window) { 199 # Variant of 'render' that updates cursor-row and cursor-column based on 200 # before-cursor (rather than the other way around). If before-cursor moves 201 # off-screen, it resets cursor-row and cursor-column. -202 def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ +202 def render-without-moving-cursor screen:&:screen, editor:&:editor -> last-row:num, last-column:num, screen:&:screen, editor:&:editor [ 203 local-scope 204 load-ingredients 205 return-unless editor, 1/top, 0/left 206 left:num <- get *editor, left:offset -207 screen-height:num <- screen-height screen +207 screen-height:num <- screen-height screen 208 right:num <- get *editor, right:offset 209 curr:&:duplex-list:char <- get *editor, top-of-screen:offset -210 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev -211 curr <- next curr +210 prev:&:duplex-list:char <- copy curr # just in case curr becomes null and we can't compute prev +211 curr <- next curr 212 +render-loop-initialization 213 color:num <- copy 7/white 214 row:num <- copy 1/top @@ -280,17 +280,17 @@ if ('onhashchange' in window) { 221 *editor <- put *editor, cursor-column:offset, column 222 top-of-screen:&:duplex-list:char <- get *editor, top-of-screen:offset 223 *editor <- put *editor, before-cursor:offset, top-of-screen -224 screen <- move-cursor screen, row, column +224 screen <- move-cursor screen, row, column 225 { 226 +next-character 227 break-unless curr -228 off-screen?:bool <- greater-or-equal row, screen-height +228 off-screen?:bool <- greater-or-equal row, screen-height 229 break-if off-screen? 230 # if we find old-before-cursor still on the new resized screen, update 231 # editor.cursor-row and editor.cursor-column based on 232 # old-before-cursor 233 { -234 at-cursor?:bool <- equal old-before-cursor, prev +234 at-cursor?:bool <- equal old-before-cursor, prev 235 break-unless at-cursor? 236 *editor <- put *editor, cursor-row:offset, row 237 *editor <- put *editor, cursor-column:offset, column @@ -303,13 +303,13 @@ if ('onhashchange' in window) { 244 newline?:bool <- equal c, 10/newline 245 break-unless newline? 246 # clear rest of line in this window -247 clear-line-until screen, right +247 clear-line-until screen, right 248 # skip to next line 249 row <- add row, 1 250 column <- copy left -251 screen <- move-cursor screen, row, column -252 curr <- next curr -253 prev <- next prev +251 screen <- move-cursor screen, row, column +252 curr <- next curr +253 prev <- next prev 254 loop +next-character 255 } 256 { @@ -319,16 +319,16 @@ if ('onhashchange' in window) { 260 break-unless at-right? 261 # print wrap icon 262 wrap-icon:char <- copy 8617/loop-back-to-left -263 print screen, wrap-icon, 245/grey +263 print screen, wrap-icon, 245/grey 264 column <- copy left 265 row <- add row, 1 -266 screen <- move-cursor screen, row, column +266 screen <- move-cursor screen, row, column 267 # don't increment curr 268 loop +next-character 269 } -270 print screen, c, color -271 curr <- next curr -272 prev <- next prev +270 print screen, c, color +271 curr <- next curr +272 prev <- next prev 273 column <- add column, 1 274 loop 275 } @@ -348,7 +348,7 @@ if ('onhashchange' in window) { 289 |abc| 290 ] 291 ] -292 env:&:environment <- new-programming-environment resources, screen, [def] # contents of sandbox editor +292 env:&:environment <- new-programming-environment resources, screen, [def] # contents of sandbox editor 293 # focus on both sides 294 assume-console [ 295 left-click 1, 1 @@ -356,7 +356,7 @@ if ('onhashchange' in window) { 297 ] 298 # check cursor column in each 299 run [ -300 event-loop screen, console, env, resources +300 event-loop screen, console, env, resources 301 recipes:&:editor <- get *env, recipes:offset 302 5:num/raw <- get *recipes, cursor-column:offset 303 sandbox:&:editor <- get *env, current-sandbox:offset @@ -378,8 +378,8 @@ if ('onhashchange' in window) { 319 |abc| 320 ] 321 ] -322 env:&:environment <- new-programming-environment resources, screen, [def] # contents of sandbox -323 render-all screen, env, render +322 env:&:environment <- new-programming-environment resources, screen, [def] # contents of sandbox +323 render-all screen, env, render 324 # type one letter in each of them 325 assume-console [ 326 left-click 1, 1 @@ -388,7 +388,7 @@ if ('onhashchange' in window) { 329 type [1] 330 ] 331 run [ -332 event-loop screen, console, env, resources +332 event-loop screen, console, env, resources 333 recipes:&:editor <- get *env, recipes:offset 334 5:num/raw <- get *recipes, cursor-column:offset 335 sandbox:&:editor <- get *env, current-sandbox:offset @@ -408,7 +408,7 @@ if ('onhashchange' in window) { 349 # show the cursor at the right window 350 run [ 351 cursor:char <- copy 9251/␣ -352 print screen, cursor +352 print screen, cursor 353 ] 354 screen-should-contain [ 355 . run (F4) . @@ -428,14 +428,14 @@ if ('onhashchange' in window) { 369 |abc| 370 ] 371 ] -372 env:&:environment <- new-programming-environment resources, screen, [def] -373 render-all screen, env, render +372 env:&:environment <- new-programming-environment resources, screen, [def] +373 render-all screen, env, render 374 # initialize programming environment and highlight cursor 375 assume-console [] 376 run [ -377 event-loop screen, console, env, resources +377 event-loop screen, console, env, resources 378 cursor:char <- copy 9251/␣ -379 print screen, cursor +379 print screen, cursor 380 ] 381 # is cursor at the right place? 382 screen-should-contain [ @@ -450,9 +450,9 @@ if ('onhashchange' in window) { 391 type [z] 392 ] 393 run [ -394 event-loop screen, console, env, resources +394 event-loop screen, console, env, resources 395 cursor:char <- copy 9251/␣ -396 print screen, cursor +396 print screen, cursor 397 ] 398 # cursor should still be right 399 screen-should-contain [ @@ -473,8 +473,8 @@ if ('onhashchange' in window) { 414 # initialize sandbox side with two lines 415 test-sandbox-editor-contents:text <- new [abc 416 def] -417 env:&:environment <- new-programming-environment resources, screen, test-sandbox-editor-contents -418 render-all screen, env, render +417 env:&:environment <- new-programming-environment resources, screen, test-sandbox-editor-contents +418 render-all screen, env, render 419 screen-should-contain [ 420 . run (F4) . 421 . ╎abc . @@ -488,9 +488,9 @@ if ('onhashchange' in window) { 429 press backspace 430 ] 431 run [ -432 event-loop screen, console, env, resources +432 event-loop screen, console, env, resources 433 cursor:char <- copy 9251/␣ -434 print screen, cursor +434 print screen, cursor 435 ] 436 # cursor moves to end of old line 437 screen-should-contain [ @@ -501,39 +501,39 @@ if ('onhashchange' in window) { 442 ] 443 ] 444 -445 def render-all screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ +445 def render-all screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ 446 local-scope 447 load-ingredients 448 trace 10, [app], [render all] -449 hide-screen screen +449 hide-screen screen 450 # top menu 451 trace 11, [app], [render top menu] -452 width:num <- screen-width screen -453 draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey +452 width:num <- screen-width screen +453 draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey 454 button-start:num <- subtract width, 20 455 button-on-screen?:bool <- greater-or-equal button-start, 0 456 assert button-on-screen?, [screen too narrow for menu] -457 screen <- move-cursor screen, 0/row, button-start -458 print screen, [ run (F4) ], 255/white, 161/reddish +457 screen <- move-cursor screen, 0/row, button-start +458 print screen, [ run (F4) ], 255/white, 161/reddish 459 # dotted line down the middle 460 trace 11, [app], [render divider] 461 divider:num, _ <- divide-with-remainder width, 2 -462 height:num <- screen-height screen -463 draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted +462 height:num <- screen-height screen +463 draw-vertical screen, divider, 1/top, height, 9482/vertical-dotted 464 # -465 screen <- render-recipes screen, env, render-editor -466 screen <- render-sandbox-side screen, env, render-editor +465 screen <- render-recipes screen, env, render-editor +466 screen <- render-sandbox-side screen, env, render-editor 467 <render-components-end> 468 # 469 recipes:&:editor <- get *env, recipes:offset 470 current-sandbox:&:editor <- get *env, current-sandbox:offset 471 sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset -472 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +472 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 473 # -474 show-screen screen +474 show-screen screen 475 ] 476 -477 def render-recipes screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ +477 def render-recipes screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ 478 local-scope 479 load-ingredients 480 trace 11, [app], [render recipes] @@ -541,33 +541,33 @@ if ('onhashchange' in window) { 482 # render recipes 483 left:num <- get *recipes, left:offset 484 right:num <- get *recipes, right:offset -485 row:num, column:num, screen <- call render-editor, screen, recipes -486 clear-line-until screen, right +485 row:num, column:num, screen <- call render-editor, screen, recipes +486 clear-line-until screen, right 487 row <- add row, 1 488 <render-recipe-components-end> 489 # draw dotted line after recipes -490 draw-horizontal screen, row, left, right, 9480/horizontal-dotted +490 draw-horizontal screen, row, left, right, 9480/horizontal-dotted 491 row <- add row, 1 -492 clear-screen-from screen, row, left, left, right +492 clear-screen-from screen, row, left, left, right 493 ] 494 495 # replaced in a later layer -496 def render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ +496 def render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ 497 local-scope 498 load-ingredients 499 current-sandbox:&:editor <- get *env, current-sandbox:offset 500 left:num <- get *current-sandbox, left:offset 501 right:num <- get *current-sandbox, right:offset -502 row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox -503 clear-line-until screen, right +502 row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox +503 clear-line-until screen, right 504 row <- add row, 1 505 # draw solid line after code (you'll see why in later layers) -506 draw-horizontal screen, row, left, right +506 draw-horizontal screen, row, left, right 507 row <- add row, 1 -508 clear-screen-from screen, row, left, left, right +508 clear-screen-from screen, row, left, left, right 509 ] 510 -511 def update-cursor screen:&:screen, recipes:&:editor, current-sandbox:&:editor, sandbox-in-focus?:bool, env:&:environment -> screen:&:screen [ +511 def update-cursor screen:&:screen, recipes:&:editor, current-sandbox:&:editor, sandbox-in-focus?:bool, env:&:environment -> screen:&:screen [ 512 local-scope 513 load-ingredients 514 <update-cursor-special-cases> @@ -581,25 +581,25 @@ if ('onhashchange' in window) { 522 cursor-row:num <- get *current-sandbox, cursor-row:offset 523 cursor-column:num <- get *current-sandbox, cursor-column:offset 524 } -525 screen <- move-cursor screen, cursor-row, cursor-column +525 screen <- move-cursor screen, cursor-row, cursor-column 526 ] 527 528 # like 'render' for texts, but with colorization for comments like in the editor -529 def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [ +529 def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num, screen:&:screen [ 530 local-scope 531 load-ingredients 532 return-unless s 533 color:num <- copy 7/white 534 column:num <- copy left -535 screen <- move-cursor screen, row, column -536 screen-height:num <- screen-height screen +535 screen <- move-cursor screen, row, column +536 screen-height:num <- screen-height screen 537 i:num <- copy 0 538 len:num <- length *s 539 { 540 +next-character 541 done?:bool <- greater-or-equal i, len 542 break-if done? -543 done? <- greater-or-equal row, screen-height +543 done? <- greater-or-equal row, screen-height 544 break-if done? 545 c:char <- index *s, i 546 <character-c-received> # only line different from render @@ -609,10 +609,10 @@ if ('onhashchange' in window) { 550 break-unless at-right? 551 # print wrap icon 552 wrap-icon:char <- copy 8617/loop-back-to-left -553 print screen, wrap-icon, 245/grey +553 print screen, wrap-icon, 245/grey 554 column <- copy left 555 row <- add row, 1 -556 screen <- move-cursor screen, row, column +556 screen <- move-cursor screen, row, column 557 loop +next-character # retry i 558 } 559 i <- add i, 1 @@ -625,26 +625,26 @@ if ('onhashchange' in window) { 566 done?:bool <- greater-than column, right 567 break-if done? 568 space:char <- copy 32/space -569 print screen, space +569 print screen, space 570 column <- add column, 1 571 loop 572 } 573 row <- add row, 1 574 column <- copy left -575 screen <- move-cursor screen, row, column +575 screen <- move-cursor screen, row, column 576 loop +next-character 577 } -578 print screen, c, color +578 print screen, c, color 579 column <- add column, 1 580 loop 581 } 582 was-at-left?:bool <- equal column, left -583 clear-line-until screen, right +583 clear-line-until screen, right 584 { 585 break-if was-at-left? 586 row <- add row, 1 587 } -588 move-cursor screen, row, left +588 move-cursor screen, row, left 589 ] 590 591 # ctrl-l - redraw screen (just in case it printed junk somehow) @@ -653,8 +653,8 @@ if ('onhashchange' in window) { 594 { 595 redraw-screen?:bool <- equal c, 12/ctrl-l 596 break-unless redraw-screen? -597 screen <- render-all screen, env:&:environment, render -598 sync-screen screen +597 screen <- render-all screen, env:&:environment, render +598 sync-screen screen 599 loop +next-event 600 } 601 ] @@ -669,14 +669,14 @@ if ('onhashchange' in window) { 610 sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset 611 sandbox-in-focus? <- not sandbox-in-focus? 612 *env <- put *env, sandbox-in-focus?:offset, sandbox-in-focus? -613 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +613 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 614 loop +next-event 615 } 616 ] 617 618 ## helpers 619 -620 def draw-vertical screen:&:screen, col:num, y:num, bottom:num -> screen:&:screen [ +620 def draw-vertical screen:&:screen, col:num, y:num, bottom:num -> screen:&:screen [ 621 local-scope 622 load-ingredients 623 style:char, style-found?:bool <- next-ingredient @@ -693,8 +693,8 @@ if ('onhashchange' in window) { 634 { 635 continue?:bool <- lesser-than y, bottom 636 break-unless continue? -637 screen <- move-cursor screen, y, col -638 print screen, style, color +637 screen <- move-cursor screen, y, col +638 print screen, style, color 639 y <- add y, 1 640 loop 641 } diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 5c5b4f00..624f0322 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -69,10 +69,10 @@ if ('onhashchange' in window) { 10 def! main [ 11 local-scope 12 open-console - 13 env:&:environment <- new-programming-environment 0/filesystem, 0/screen - 14 env <- restore-sandboxes env - 15 render-all 0/screen, env, render - 16 event-loop 0/screen, 0/console, env, 0/filesystem + 13 env:&:environment <- new-programming-environment 0/filesystem, 0/screen + 14 env <- restore-sandboxes env + 15 render-all 0/screen, env, render + 16 event-loop 0/screen, 0/console, env, 0/filesystem 17 # never gets here 18 ] 19 @@ -93,7 +93,7 @@ if ('onhashchange' in window) { 34 # constraint: will be 0 for sandboxes at positions before env.render-from 35 starting-row-on-screen:num 36 code-ending-row-on-screen:num # past end of code - 37 screen:&:screen # prints in the sandbox go here + 37 screen:&:screen # prints in the sandbox go here 38 next-sandbox:&:sandbox 39 ] 40 @@ -105,13 +105,13 @@ if ('onhashchange' in window) { 46 assume-resources [ 47 ] 48 # sandbox editor contains an instruction without storing outputs - 49 env:&:environment <- new-programming-environment resources, screen, [divide-with-remainder 11, 3] + 49 env:&:environment <- new-programming-environment resources, screen, [divide-with-remainder 11, 3] 50 # run the code in the editors 51 assume-console [ 52 press F4 53 ] 54 run [ - 55 event-loop screen, console, env, resources + 55 event-loop screen, console, env, resources 56 ] 57 # check that screen prints the results 58 screen-should-contain [ @@ -161,7 +161,7 @@ if ('onhashchange' in window) { 102 press F4 103 ] 104 run [ - 105 event-loop screen, console, env, resources + 105 event-loop screen, console, env, resources 106 ] 107 # check that screen prints both sandboxes 108 screen-should-contain [ @@ -186,29 +186,29 @@ if ('onhashchange' in window) { 127 { 128 do-run?:bool <- equal k, 65532/F4 129 break-unless do-run? - 130 screen <- update-status screen, [running... ], 245/grey - 131 error?:bool <- run-sandboxes env, resources, screen + 130 screen <- update-status screen, [running... ], 245/grey + 131 error?:bool <- run-sandboxes env, resources, screen 132 # F4 might update warnings and results on both sides - 133 screen <- render-all screen, env, render + 133 screen <- render-all screen, env, render 134 { 135 break-if error? - 136 screen <- update-status screen, [ ], 245/grey + 136 screen <- update-status screen, [ ], 245/grey 137 } - 138 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + 138 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 139 loop +next-event 140 } 141 ] 142 - 143 def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ + 143 def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ 144 local-scope 145 load-ingredients - 146 errors-found?:bool <- update-recipes env, resources, screen + 146 errors-found?:bool <- update-recipes env, resources, screen 147 return-if errors-found? 148 # check contents of right editor (sandbox) 149 <run-sandboxes-begin> 150 current-sandbox:&:editor <- get *env, current-sandbox:offset 151 { - 152 sandbox-contents:text <- editor-contents current-sandbox + 152 sandbox-contents:text <- editor-contents current-sandbox 153 break-unless sandbox-contents 154 # if contents exist, first save them 155 # run them and turn them into a new sandbox @@ -228,7 +228,7 @@ if ('onhashchange' in window) { 169 *current-sandbox <- put *current-sandbox, top-of-screen:offset, init 170 } 171 # save all sandboxes before running, just in case we die when running - 172 save-sandboxes env, resources + 172 save-sandboxes env, resources 173 # run all sandboxes 174 curr:&:sandbox <- get *env, sandbox:offset 175 idx:num <- copy 0 @@ -244,12 +244,12 @@ if ('onhashchange' in window) { 185 186 # load code from disk 187 # replaced in a later layer (whereupon errors-found? will actually be set) - 188 def update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ + 188 def update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ 189 local-scope 190 load-ingredients 191 recipes:&:editor <- get *env, recipes:offset - 192 in:text <- editor-contents recipes - 193 resources <- dump resources, [lesson/recipes.mu], in + 192 in:text <- editor-contents recipes + 193 resources <- dump resources, [lesson/recipes.mu], in 194 reload in 195 errors-found? <- copy 0/false 196 ] @@ -259,19 +259,19 @@ if ('onhashchange' in window) { 200 local-scope 201 load-ingredients 202 data:text <- get *sandbox, data:offset - 203 response:text, _, fake-screen:&:screen <- run-sandboxed data + 203 response:text, _, fake-screen:&:screen <- run-sandboxed data 204 *sandbox <- put *sandbox, response:offset, response - 205 *sandbox <- put *sandbox, screen:offset, fake-screen + 205 *sandbox <- put *sandbox, screen:offset, fake-screen 206 ] 207 - 208 def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [ + 208 def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [ 209 local-scope 210 load-ingredients - 211 screen <- move-cursor screen, 0, 2 - 212 screen <- print screen, msg, color, 238/grey/background + 211 screen <- move-cursor screen, 0, 2 + 212 screen <- print screen, msg, color, 238/grey/background 213 ] 214 - 215 def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [ + 215 def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [ 216 local-scope 217 load-ingredients 218 current-sandbox:&:editor <- get *env, current-sandbox:offset @@ -283,7 +283,7 @@ if ('onhashchange' in window) { 224 break-unless curr 225 data:text <- get *curr, data:offset 226 filename:text <- append [lesson/], idx - 227 resources <- dump resources, filename, data + 227 resources <- dump resources, filename, data 228 <end-save-sandbox> 229 idx <- add idx, 1 230 curr <- get *curr, next-sandbox:offset @@ -291,7 +291,7 @@ if ('onhashchange' in window) { 232 } 233 ] 234 - 235 def! render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ + 235 def! render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (recipe (address screen) (address editor) -> number number (address screen) (address editor))} -> screen:&:screen, env:&:environment [ 236 local-scope 237 load-ingredients 238 trace 11, [app], [render sandbox side] @@ -304,58 +304,58 @@ if ('onhashchange' in window) { 245 { 246 render-current-sandbox?:bool <- equal render-from, -1 247 break-unless render-current-sandbox? - 248 row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox - 249 clear-screen-from screen, row, column, left, right + 248 row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox + 249 clear-screen-from screen, row, column, left, right 250 row <- add row, 1 251 } 252 # render sandboxes - 253 draw-horizontal screen, row, left, right + 253 draw-horizontal screen, row, left, right 254 sandbox:&:sandbox <- get *env, sandbox:offset - 255 row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from - 256 clear-rest-of-screen screen, row, left, right + 255 row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from + 256 clear-rest-of-screen screen, row, left, right 257 ] 258 - 259 def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ + 259 def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ 260 local-scope 261 load-ingredients 262 return-unless sandbox - 263 screen-height:num <- screen-height screen - 264 at-bottom?:bool <- greater-or-equal row, screen-height + 263 screen-height:num <- screen-height screen + 264 at-bottom?:bool <- greater-or-equal row, screen-height 265 return-if at-bottom?:bool 266 hidden?:bool <- lesser-than idx, render-from 267 { 268 break-if hidden? 269 # render sandbox menu 270 row <- add row, 1 - 271 screen <- move-cursor screen, row, left - 272 screen <- render-sandbox-menu screen, idx, left, right + 271 screen <- move-cursor screen, row, left + 272 screen <- render-sandbox-menu screen, idx, left, right 273 # save menu row so we can detect clicks to it later 274 *sandbox <- put *sandbox, starting-row-on-screen:offset, row 275 # render sandbox contents 276 row <- add row, 1 - 277 screen <- move-cursor screen, row, left + 277 screen <- move-cursor screen, row, left 278 sandbox-data:text <- get *sandbox, data:offset - 279 row, screen <- render-code screen, sandbox-data, left, right, row + 279 row, screen <- render-code screen, sandbox-data, left, right, row 280 *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row 281 # render sandbox warnings, screen or response, in that order 282 sandbox-response:text <- get *sandbox, response:offset 283 <render-sandbox-results> 284 { - 285 sandbox-screen:&:screen <- get *sandbox, screen:offset - 286 empty-screen?:bool <- fake-screen-is-empty? sandbox-screen + 285 sandbox-screen:&:screen <- get *sandbox, screen:offset + 286 empty-screen?:bool <- fake-screen-is-empty? sandbox-screen 287 break-if empty-screen? - 288 row, screen <- render-screen screen, sandbox-screen, left, right, row + 288 row, screen <- render-screen screen, sandbox-screen, left, right, row 289 } 290 { 291 break-unless empty-screen? 292 <render-sandbox-response> - 293 row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row + 293 row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row 294 } 295 +render-sandbox-end - 296 at-bottom?:bool <- greater-or-equal row, screen-height + 296 at-bottom?:bool <- greater-or-equal row, screen-height 297 return-if at-bottom? 298 # draw solid line after sandbox - 299 draw-horizontal screen, row, left, right + 299 draw-horizontal screen, row, left, right 300 } 301 # if hidden, reset row attributes 302 { @@ -367,35 +367,35 @@ if ('onhashchange' in window) { 308 # draw next sandbox 309 next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset 310 next-idx:num <- add idx, 1 - 311 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx + 311 row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx 312 ] 313 - 314 def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [ + 314 def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num -> screen:&:screen [ 315 local-scope 316 load-ingredients - 317 move-cursor-to-column screen, left - 318 edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right - 319 print screen, sandbox-index, 232/dark-grey, 245/grey + 317 move-cursor-to-column screen, left + 318 edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <- sandbox-menu-columns left, right + 319 print screen, sandbox-index, 232/dark-grey, 245/grey 320 start-buttons:num <- subtract edit-button-left, 1 - 321 clear-line-until screen, start-buttons, 245/grey - 322 print screen, [edit], 232/black, 94/background-orange - 323 clear-line-until screen, edit-button-right, 94/background-orange - 324 _, col:num <- cursor-position screen + 321 clear-line-until screen, start-buttons, 245/grey + 322 print screen, [edit], 232/black, 94/background-orange + 323 clear-line-until screen, edit-button-right, 94/background-orange + 324 _, col:num <- cursor-position screen 325 at-start-of-copy-button?:bool <- equal col, copy-button-left 326 assert at-start-of-copy-button?, [aaa] - 327 print screen, [copy], 232/black, 58/background-green - 328 clear-line-until screen, copy-button-right, 58/background-green - 329 _, col:num <- cursor-position screen + 327 print screen, [copy], 232/black, 58/background-green + 328 clear-line-until screen, copy-button-right, 58/background-green + 329 _, col:num <- cursor-position screen 330 at-start-of-delete-button?:bool <- equal col, delete-button-left 331 assert at-start-of-delete-button?, [bbb] - 332 print screen, [delete], 232/black, 52/background-red - 333 clear-line-until screen, right, 52/background-red + 332 print screen, [delete], 232/black, 52/background-red + 333 clear-line-until screen, right, 52/background-red 334 ] 335 336 # divide up the menu bar for a sandbox into 3 segments, for edit/copy/delete buttons 337 # delete-button-right == right 338 # all left/right pairs are inclusive - 339 def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [ + 339 def sandbox-menu-columns left:num, right:num -> edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [ 340 local-scope 341 load-ingredients 342 start-buttons:num <- add left, 4/space-for-sandbox-index @@ -412,20 +412,20 @@ if ('onhashchange' in window) { 353 354 # print a text 's' to 'editor' in 'color' starting at 'row' 355 # clear rest of last line, move cursor to next line - 356 def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [ + 356 def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num -> row:num, screen:&:screen [ 357 local-scope 358 load-ingredients 359 return-unless s 360 column:num <- copy left - 361 screen <- move-cursor screen, row, column - 362 screen-height:num <- screen-height screen + 361 screen <- move-cursor screen, row, column + 362 screen-height:num <- screen-height screen 363 i:num <- copy 0 364 len:num <- length *s 365 { 366 +next-character 367 done?:bool <- greater-or-equal i, len 368 break-if done? - 369 done? <- greater-or-equal row, screen-height + 369 done? <- greater-or-equal row, screen-height 370 break-if done? 371 c:char <- index *s, i 372 { @@ -434,10 +434,10 @@ if ('onhashchange' in window) { 375 break-unless at-right? 376 # print wrap icon 377 wrap-icon:char <- copy 8617/loop-back-to-left - 378 print screen, wrap-icon, 245/grey + 378 print screen, wrap-icon, 245/grey 379 column <- copy left 380 row <- add row, 1 - 381 screen <- move-cursor screen, row, column + 381 screen <- move-cursor screen, row, column 382 loop +next-character # retry i 383 } 384 i <- add i, 1 @@ -450,39 +450,39 @@ if ('onhashchange' in window) { 391 done?:bool <- greater-than column, right 392 break-if done? 393 space:char <- copy 32/space - 394 print screen, space + 394 print screen, space 395 column <- add column, 1 396 loop 397 } 398 row <- add row, 1 399 column <- copy left - 400 screen <- move-cursor screen, row, column + 400 screen <- move-cursor screen, row, column 401 loop +next-character 402 } - 403 print screen, c, color + 403 print screen, c, color 404 column <- add column, 1 405 loop 406 } 407 was-at-left?:bool <- equal column, left - 408 clear-line-until screen, right + 408 clear-line-until screen, right 409 { 410 break-if was-at-left? 411 row <- add row, 1 412 } - 413 move-cursor screen, row, left + 413 move-cursor screen, row, left 414 ] 415 416 # assumes programming environment has no sandboxes; restores them from previous session - 417 def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [ + 417 def restore-sandboxes env:&:environment, resources:&:resources -> env:&:environment [ 418 local-scope 419 load-ingredients 420 # read all scenarios, pushing them to end of a list of scenarios 421 idx:num <- copy 0 422 curr:&:sandbox <- copy 0 - 423 prev:&:sandbox <- copy 0 + 423 prev:&:sandbox <- copy 0 424 { 425 filename:text <- append [lesson/], idx - 426 contents:text <- slurp resources, filename + 426 contents:text <- slurp resources, filename 427 break-unless contents # stop at first error; assuming file didn't exist 428 # todo: handle empty sandbox 429 # create new sandbox for file @@ -498,7 +498,7 @@ if ('onhashchange' in window) { 439 *prev <- put *prev, next-sandbox:offset, curr 440 } 441 idx <- add idx, 1 - 442 prev <- copy curr + 442 prev <- copy curr 443 loop 444 } 445 # update sandbox count @@ -507,42 +507,42 @@ if ('onhashchange' in window) { 448 449 # print the fake sandbox screen to 'screen' with appropriate delimiters 450 # leave cursor at start of next line - 451 def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [ + 451 def render-screen screen:&:screen, sandbox-screen:&:screen, left:num, right:num, row:num -> row:num, screen:&:screen [ 452 local-scope 453 load-ingredients 454 return-unless sandbox-screen 455 # print 'screen:' - 456 row <- render-text screen, [screen:], left, right, 245/grey, row - 457 screen <- move-cursor screen, row, left + 456 row <- render-text screen, [screen:], left, right, 245/grey, row + 457 screen <- move-cursor screen, row, left 458 # start printing sandbox-screen 459 column:num <- copy left - 460 s-width:num <- screen-width sandbox-screen - 461 s-height:num <- screen-height sandbox-screen - 462 buf:&:@:screen-cell <- get *sandbox-screen, data:offset + 460 s-width:num <- screen-width sandbox-screen + 461 s-height:num <- screen-height sandbox-screen + 462 buf:&:@:screen-cell <- get *sandbox-screen, data:offset 463 stop-printing:num <- add left, s-width, 3 464 max-column:num <- min stop-printing, right 465 i:num <- copy 0 466 len:num <- length *buf - 467 screen-height:num <- screen-height screen + 467 screen-height:num <- screen-height screen 468 { 469 done?:bool <- greater-or-equal i, len 470 break-if done? - 471 done? <- greater-or-equal row, screen-height + 471 done? <- greater-or-equal row, screen-height 472 break-if done? 473 column <- copy left - 474 screen <- move-cursor screen, row, column + 474 screen <- move-cursor screen, row, column 475 # initial leader for each row: two spaces and a '.' 476 space:char <- copy 32/space - 477 print screen, space, 245/grey - 478 print screen, space, 245/grey + 477 print screen, space, 245/grey + 478 print screen, space, 245/grey 479 full-stop:char <- copy 46/period - 480 print screen, full-stop, 245/grey + 480 print screen, full-stop, 245/grey 481 column <- add left, 3 482 { 483 # print row 484 row-done?:bool <- greater-or-equal column, max-column 485 break-if row-done? - 486 curr:screen-cell <- index *buf, i + 486 curr:screen-cell <- index *buf, i 487 c:char <- get curr, contents:offset 488 color:num <- get curr, color:offset 489 { @@ -551,19 +551,19 @@ if ('onhashchange' in window) { 492 break-unless white? 493 color <- copy 245/grey 494 } - 495 print screen, c, color + 495 print screen, c, color 496 column <- add column, 1 497 i <- add i, 1 498 loop 499 } 500 # print final '.' - 501 print screen, full-stop, 245/grey + 501 print screen, full-stop, 245/grey 502 column <- add column, 1 503 { 504 # clear rest of current line 505 line-done?:bool <- greater-than column, right 506 break-if line-done? - 507 print screen, space + 507 print screen, space 508 column <- add column, 1 509 loop 510 } @@ -588,12 +588,12 @@ if ('onhashchange' in window) { 529 ] 530 ] 531 # sandbox editor contains an instruction without storing outputs - 532 env:&:environment <- new-programming-environment resources, screen, [foo] # contents of sandbox editor + 532 env:&:environment <- new-programming-environment resources, screen, [foo] # contents of sandbox editor 533 # run the code in the editors 534 assume-console [ 535 press F4 536 ] - 537 event-loop screen, console, env, resources + 537 event-loop screen, console, env, resources 538 screen-should-contain [ 539 . run (F4) . 540 . ╎ . @@ -614,7 +614,7 @@ if ('onhashchange' in window) { 555 press F4 556 ] 557 run [ - 558 event-loop screen, console, env, resources + 558 event-loop screen, console, env, resources 559 ] 560 # check that screen updates the result on the right 561 screen-should-contain [ @@ -639,13 +639,13 @@ if ('onhashchange' in window) { 580 assume-resources [ 581 ] 582 # sandbox editor contains an instruction - 583 env:&:environment <- new-programming-environment resources, screen, [print-integer screen, 4] # contents of sandbox editor + 583 env:&:environment <- new-programming-environment resources, screen, [print-integer screen, 4] # contents of sandbox editor 584 # run the code in the editor 585 assume-console [ 586 press F4 587 ] 588 run [ - 589 event-loop screen, console, env, resources + 589 event-loop screen, console, env, resources 590 ] 591 # check that it prints a little toy screen 592 screen-should-contain [ @@ -653,7 +653,7 @@ if ('onhashchange' in window) { 594 . ╎ . 595 .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. 596 . ╎0 edit copy delete . - 597 . ╎print-integer screen, 4 . + 597 . ╎print-integer screen, 4 . 598 . ╎screen: . 599 . ╎ .4 . . 600 . ╎ . . . @@ -665,36 +665,36 @@ if ('onhashchange' in window) { 606 ] 607 ] 608 - 609 def editor-contents editor:&:editor -> result:text [ + 609 def editor-contents editor:&:editor -> result:text [ 610 local-scope 611 load-ingredients - 612 buf:&:buffer <- new-buffer 80 + 612 buf:&:buffer <- new-buffer 80 613 curr:&:duplex-list:char <- get *editor, data:offset 614 # skip § sentinel 615 assert curr, [editor without data is illegal; must have at least a sentinel] - 616 curr <- next curr + 616 curr <- next curr 617 return-unless curr, 0 618 { 619 break-unless curr 620 c:char <- get *curr, value:offset 621 buf <- append buf, c - 622 curr <- next curr + 622 curr <- next curr 623 loop 624 } - 625 result <- buffer-to-array buf + 625 result <- buffer-to-array buf 626 ] 627 628 scenario editor-provides-edited-contents [ 629 local-scope 630 assume-screen 10/width, 5/height - 631 e:&:editor <- new-editor [abc], 0/left, 10/right + 631 e:&:editor <- new-editor [abc], 0/left, 10/right 632 assume-console [ 633 left-click 1, 2 634 type [def] 635 ] 636 run [ - 637 editor-event-loop screen, console, e - 638 s:text <- editor-contents e + 637 editor-event-loop screen, console, e + 638 s:text <- editor-contents e 639 1:@:char/raw <- copy *s 640 ] 641 memory-should-contain [ @@ -710,13 +710,13 @@ if ('onhashchange' in window) { 651 assume-screen 100/width, 10/height 652 assume-resources [ 653 ] - 654 env:&:environment <- new-programming-environment resources, screen, [] - 655 render-all screen, env, render + 654 env:&:environment <- new-programming-environment resources, screen, [] + 655 render-all screen, env, render 656 assume-console [ 657 press enter 658 press down-arrow 659 ] - 660 event-loop screen, console, env, resources + 660 event-loop screen, console, env, resources 661 # no scroll 662 screen-should-contain [ 663 . run (F4) . @@ -733,16 +733,16 @@ if ('onhashchange' in window) { 674 assume-screen 100/width, 10/height 675 assume-resources [ 676 ] - 677 env:&:environment <- new-programming-environment resources, screen, [] - 678 render-all screen, env, render + 677 env:&:environment <- new-programming-environment resources, screen, [] + 678 render-all screen, env, render 679 assume-console [ 680 press enter 681 press up-arrow 682 press down-arrow # while cursor isn't at bottom 683 ] - 684 event-loop screen, console, env, resources + 684 event-loop screen, console, env, resources 685 cursor:char <- copy 9251/␣ - 686 print screen, cursor + 686 print screen, cursor 687 # cursor moves back to bottom 688 screen-should-contain [ 689 . run (F4) . @@ -774,16 +774,16 @@ if ('onhashchange' in window) { 715 recipe-editor-bottom:num <- get *recipe-editor, bottom:offset 716 at-bottom-of-editor?:bool <- greater-or-equal recipe-cursor-row, recipe-editor-bottom 717 break-unless at-bottom-of-editor? - 718 more-to-scroll?:bool <- more-to-scroll? env, screen - 719 break-if more-to-scroll? + 718 more-to-scroll?:bool <- more-to-scroll? env, screen + 719 break-if more-to-scroll? 720 loop +next-event 721 } 722 { 723 break-if sandbox-in-focus? 724 page-down?:bool <- equal k, 65518/page-down 725 break-unless page-down? - 726 more-to-scroll?:bool <- more-to-scroll? env, screen - 727 break-if more-to-scroll? + 726 more-to-scroll?:bool <- more-to-scroll? env, screen + 727 break-if more-to-scroll? 728 loop +next-event 729 } 730 ] @@ -793,17 +793,17 @@ if ('onhashchange' in window) { 734 break-if sandbox-in-focus? 735 page-down?:bool <- equal k, 6/ctrl-f 736 break-unless page-down? - 737 more-to-scroll?:bool <- more-to-scroll? env, screen - 738 break-if more-to-scroll? + 737 more-to-scroll?:bool <- more-to-scroll? env, screen + 738 break-if more-to-scroll? 739 loop +next-event 740 } 741 ] 742 - 743 def more-to-scroll? env:&:environment, screen:&:screen -> result:bool [ + 743 def more-to-scroll? env:&:environment, screen:&:screen -> result:bool [ 744 local-scope 745 load-ingredients 746 recipe-bottom:num <- get *env, recipe-bottom:offset - 747 height:num <- screen-height screen + 747 height:num <- screen-height screen 748 result <- greater-or-equal recipe-bottom, height 749 ] 750 @@ -813,17 +813,17 @@ if ('onhashchange' in window) { 754 assume-screen 100/width, 10/height 755 assume-resources [ 756 ] - 757 env:&:environment <- new-programming-environment resources, screen, [] - 758 render-all screen, env, render + 757 env:&:environment <- new-programming-environment resources, screen, [] + 758 render-all screen, env, render 759 assume-console [ 760 # add a line 761 press enter 762 # cursor back to top line 763 press up-arrow 764 # try to scroll - 765 press page-down # or ctrl-f + 765 press page-down # or ctrl-f 766 ] - 767 event-loop screen, console, env, resources + 767 event-loop screen, console, env, resources 768 # no scroll, and cursor remains at top line 769 screen-should-contain [ 770 . run (F4) . @@ -840,9 +840,9 @@ if ('onhashchange' in window) { 781 assume-screen 100/width, 10/height 782 assume-resources [ 783 ] - 784 env:&:environment <- new-programming-environment resources, screen, [ab + 784 env:&:environment <- new-programming-environment resources, screen, [ab 785 cd] - 786 render-all screen, env, render + 786 render-all screen, env, render 787 assume-console [ 788 # add a line 789 press enter @@ -851,9 +851,9 @@ if ('onhashchange' in window) { 792 # move cursor 793 press down-arrow 794 ] - 795 event-loop screen, console, env, resources + 795 event-loop screen, console, env, resources 796 cursor:char <- copy 9251/␣ - 797 print screen, cursor + 797 print screen, cursor 798 # no scroll on recipe side, cursor moves on sandbox side 799 screen-should-contain [ 800 . run (F4) . @@ -873,13 +873,13 @@ if ('onhashchange' in window) { 814 # initialize 815 assume-resources [ 816 ] - 817 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] - 818 render-all screen, env, render + 817 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] + 818 render-all screen, env, render 819 assume-console [ 820 # create a sandbox 821 press F4 822 ] - 823 event-loop screen, console, env, resources + 823 event-loop screen, console, env, resources 824 screen-should-contain [ 825 . run (F4) . 826 . ╎ . @@ -890,12 +890,12 @@ if ('onhashchange' in window) { 831 # switch to sandbox window and hit 'page-down' 832 assume-console [ 833 press ctrl-n - 834 press page-down + 834 press page-down 835 ] 836 run [ - 837 event-loop screen, console, env, resources + 837 event-loop screen, console, env, resources 838 cursor:char <- copy 9251/␣ - 839 print screen, cursor + 839 print screen, cursor 840 ] 841 # sandbox editor hidden; first sandbox displayed 842 # cursor moves to first sandbox @@ -908,12 +908,12 @@ if ('onhashchange' in window) { 849 ] 850 # hit 'page-up' 851 assume-console [ - 852 press page-up + 852 press page-up 853 ] 854 run [ - 855 event-loop screen, console, env, resources + 855 event-loop screen, console, env, resources 856 cursor:char <- copy 9251/␣ - 857 print screen, cursor + 857 print screen, cursor 858 ] 859 # sandbox editor displays again, cursor is in editor 860 screen-should-contain [ @@ -943,9 +943,9 @@ if ('onhashchange' in window) { 884 render-from <- add render-from, 1 885 *env <- put *env, render-from:offset, render-from 886 } - 887 hide-screen screen - 888 screen <- render-sandbox-side screen, env, render - 889 show-screen screen + 887 hide-screen screen + 888 screen <- render-sandbox-side screen, env, render + 889 show-screen screen 890 jump +finish-event 891 } 892 ] @@ -958,7 +958,7 @@ if ('onhashchange' in window) { 899 scrolling?:bool <- greater-or-equal render-from, 0 900 break-unless scrolling? 901 cursor-column:num <- get *current-sandbox, left:offset - 902 screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 + 902 screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 903 return 904 } 905 ] @@ -974,27 +974,27 @@ if ('onhashchange' in window) { 915 break-if at-beginning? 916 render-from <- subtract render-from, 1 917 *env <- put *env, render-from:offset, render-from - 918 hide-screen screen - 919 screen <- render-sandbox-side screen, env, render - 920 show-screen screen + 918 hide-screen screen + 919 screen <- render-sandbox-side screen, env, render + 920 show-screen screen 921 jump +finish-event 922 } 923 ] 924 925 # sandbox belonging to 'env' whose next-sandbox is 'in' 926 # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox - 927 def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ + 927 def previous-sandbox env:&:environment, in:&:sandbox -> out:&:sandbox [ 928 local-scope 929 load-ingredients 930 curr:&:sandbox <- get *env, sandbox:offset 931 return-unless curr, 0/nil - 932 next:&:sandbox <- get *curr, next-sandbox:offset + 932 next:&:sandbox <- get *curr, next-sandbox:offset 933 { - 934 return-unless next, 0/nil - 935 found?:bool <- equal next, in + 934 return-unless next, 0/nil + 935 found?:bool <- equal next, in 936 break-if found? - 937 curr <- copy next - 938 next <- get *curr, next-sandbox:offset + 937 curr <- copy next + 938 next <- get *curr, next-sandbox:offset 939 loop 940 } 941 return curr @@ -1011,20 +1011,20 @@ if ('onhashchange' in window) { 952 ] 953 ] 954 # create a sandbox - 955 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] - 956 render-all screen, env, render + 955 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] + 956 render-all screen, env, render 957 assume-console [ 958 press F4 959 ] - 960 event-loop screen, console, env, resources + 960 event-loop screen, console, env, resources 961 # hit 'down' in recipe editor 962 assume-console [ - 963 press page-down + 963 press page-down 964 ] 965 run [ - 966 event-loop screen, console, env, resources + 966 event-loop screen, console, env, resources 967 cursor:char <- copy 9251/␣ - 968 print screen, cursor + 968 print screen, cursor 969 ] 970 # cursor doesn't move when the end is already on-screen 971 screen-should-contain [ @@ -1043,8 +1043,8 @@ if ('onhashchange' in window) { 984 # initialize environment 985 assume-resources [ 986 ] - 987 env:&:environment <- new-programming-environment resources, screen, [] - 988 render-all screen, env, render + 987 env:&:environment <- new-programming-environment resources, screen, [] + 988 render-all screen, env, render 989 # create 2 sandboxes 990 assume-console [ 991 press ctrl-n @@ -1053,9 +1053,9 @@ if ('onhashchange' in window) { 994 type [add 1, 1] 995 press F4 996 ] - 997 event-loop screen, console, env, resources + 997 event-loop screen, console, env, resources 998 cursor:char <- copy 9251/␣ - 999 print screen, cursor + 999 print screen, cursor 1000 screen-should-contain [ 1001 . run (F4) . 1002 . ╎␣ . @@ -1070,12 +1070,12 @@ if ('onhashchange' in window) { 1011 ] 1012 # hit 'page-down' 1013 assume-console [ -1014 press page-down +1014 press page-down 1015 ] 1016 run [ -1017 event-loop screen, console, env, resources +1017 event-loop screen, console, env, resources 1018 cursor:char <- copy 9251/␣ -1019 print screen, cursor +1019 print screen, cursor 1020 ] 1021 # sandbox editor hidden; first sandbox displayed 1022 # cursor moves to first sandbox @@ -1092,10 +1092,10 @@ if ('onhashchange' in window) { 1033 ] 1034 # hit 'page-down' again 1035 assume-console [ -1036 press page-down +1036 press page-down 1037 ] 1038 run [ -1039 event-loop screen, console, env, resources +1039 event-loop screen, console, env, resources 1040 ] 1041 # just second sandbox displayed 1042 screen-should-contain [ @@ -1109,10 +1109,10 @@ if ('onhashchange' in window) { 1050 ] 1051 # hit 'page-down' again 1052 assume-console [ -1053 press page-down +1053 press page-down 1054 ] 1055 run [ -1056 event-loop screen, console, env, resources +1056 event-loop screen, console, env, resources 1057 ] 1058 # no change 1059 screen-should-contain [ @@ -1126,10 +1126,10 @@ if ('onhashchange' in window) { 1067 ] 1068 # hit 'page-up' 1069 assume-console [ -1070 press page-up +1070 press page-up 1071 ] 1072 run [ -1073 event-loop screen, console, env, resources +1073 event-loop screen, console, env, resources 1074 ] 1075 # back to displaying both sandboxes without editor 1076 screen-should-contain [ @@ -1145,12 +1145,12 @@ if ('onhashchange' in window) { 1086 ] 1087 # hit 'page-up' again 1088 assume-console [ -1089 press page-up +1089 press page-up 1090 ] 1091 run [ -1092 event-loop screen, console, env, resources +1092 event-loop screen, console, env, resources 1093 cursor:char <- copy 9251/␣ -1094 print screen, cursor +1094 print screen, cursor 1095 ] 1096 # back to displaying both sandboxes as well as editor 1097 screen-should-contain [ @@ -1167,12 +1167,12 @@ if ('onhashchange' in window) { 1108 ] 1109 # hit 'page-up' again 1110 assume-console [ -1111 press page-up +1111 press page-up 1112 ] 1113 run [ -1114 event-loop screen, console, env, resources +1114 event-loop screen, console, env, resources 1115 cursor:char <- copy 9251/␣ -1116 print screen, cursor +1116 print screen, cursor 1117 ] 1118 # no change 1119 screen-should-contain [ @@ -1196,15 +1196,15 @@ if ('onhashchange' in window) { 1137 # initialize environment 1138 assume-resources [ 1139 ] -1140 env:&:environment <- new-programming-environment resources, screen, [] -1141 render-all screen, env, render +1140 env:&:environment <- new-programming-environment resources, screen, [] +1141 render-all screen, env, render 1142 # create a sandbox 1143 assume-console [ 1144 press ctrl-n 1145 type [add 1, 1] 1146 press F4 1147 ] -1148 event-loop screen, console, env, resources +1148 event-loop screen, console, env, resources 1149 screen-should-contain [ 1150 . run (F4) . 1151 . ╎ . @@ -1217,10 +1217,10 @@ if ('onhashchange' in window) { 1158 ] 1159 # hit 'page-down' and 'page-up' a couple of times. sandbox index should be stable 1160 assume-console [ -1161 press page-down +1161 press page-down 1162 ] 1163 run [ -1164 event-loop screen, console, env, resources +1164 event-loop screen, console, env, resources 1165 ] 1166 # sandbox editor hidden; first sandbox displayed 1167 # cursor moves to first sandbox @@ -1235,10 +1235,10 @@ if ('onhashchange' in window) { 1176 ] 1177 # hit 'page-up' again 1178 assume-console [ -1179 press page-up +1179 press page-up 1180 ] 1181 run [ -1182 event-loop screen, console, env, resources +1182 event-loop screen, console, env, resources 1183 ] 1184 # back to displaying both sandboxes as well as editor 1185 screen-should-contain [ @@ -1253,10 +1253,10 @@ if ('onhashchange' in window) { 1194 ] 1195 # hit 'page-down' 1196 assume-console [ -1197 press page-down +1197 press page-down 1198 ] 1199 run [ -1200 event-loop screen, console, env, resources +1200 event-loop screen, console, env, resources 1201 ] 1202 # sandbox editor hidden; first sandbox displayed 1203 # cursor moves to first sandbox diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index afe578cf..43baf39f 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -66,12 +66,12 @@ if ('onhashchange' in window) { 8 # empty recipes 9 assume-resources [ 10 ] - 11 env:&:environment <- new-programming-environment resources, screen, [add 1, 1] # contents of sandbox editor + 11 env:&:environment <- new-programming-environment resources, screen, [add 1, 1] # contents of sandbox editor 12 # run it 13 assume-console [ 14 press F4 15 ] - 16 event-loop screen, console, env, resources + 16 event-loop screen, console, env, resources 17 screen-should-contain [ 18 . run (F4) . 19 . ╎ . @@ -87,7 +87,7 @@ if ('onhashchange' in window) { 29 left-click 3, 69 30 ] 31 run [ - 32 event-loop screen, console, env, resources + 32 event-loop screen, console, env, resources 33 ] 34 # it copies into editor 35 screen-should-contain [ @@ -105,7 +105,7 @@ if ('onhashchange' in window) { 47 type [0] 48 ] 49 run [ - 50 event-loop screen, console, env, resources + 50 event-loop screen, console, env, resources 51 ] 52 screen-should-contain [ 53 . run (F4) . @@ -126,12 +126,12 @@ if ('onhashchange' in window) { 68 # empty recipes 69 assume-resources [ 70 ] - 71 env:&:environment <- new-programming-environment resources, screen, [add 1, 1] # contents of sandbox editor + 71 env:&:environment <- new-programming-environment resources, screen, [add 1, 1] # contents of sandbox editor 72 # run it 73 assume-console [ 74 press F4 75 ] - 76 event-loop screen, console, env, resources + 76 event-loop screen, console, env, resources 77 screen-should-contain [ 78 . run (F4) . 79 . ╎ . @@ -147,7 +147,7 @@ if ('onhashchange' in window) { 89 left-click 3, 84 90 ] 91 run [ - 92 event-loop screen, console, env, resources + 92 event-loop screen, console, env, resources 93 ] 94 # it copies into editor 95 screen-should-contain [ @@ -165,7 +165,7 @@ if ('onhashchange' in window) { 107 type [0] 108 ] 109 run [ -110 event-loop screen, console, env, resources +110 event-loop screen, console, env, resources 111 ] 112 screen-should-contain [ 113 . run (F4) . @@ -182,55 +182,55 @@ if ('onhashchange' in window) { 124 after <global-touch> [ 125 # support 'copy' button 126 { -127 copy?:bool <- should-attempt-copy? click-row, click-column, env +127 copy?:bool <- should-attempt-copy? click-row, click-column, env 128 break-unless copy? -129 copy?, env <- try-copy-sandbox click-row, env +129 copy?, env <- try-copy-sandbox click-row, env 130 break-unless copy? -131 hide-screen screen -132 screen <- render-sandbox-side screen, env, render -133 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env -134 show-screen screen +131 hide-screen screen +132 screen <- render-sandbox-side screen, env, render +133 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +134 show-screen screen 135 loop +next-event 136 } 137 ] 138 139 # some preconditions for attempting to copy a sandbox -140 def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> result:bool [ +140 def should-attempt-copy? click-row:num, click-column:num, env:&:environment -> result:bool [ 141 local-scope 142 load-ingredients 143 # are we below the sandbox editor? -144 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env +144 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env 145 return-unless click-sandbox-area?, 0/false 146 # narrower, is the click in the columns spanning the 'copy' button? 147 first-sandbox:&:editor <- get *env, current-sandbox:offset 148 assert first-sandbox, [!!] 149 sandbox-left-margin:num <- get *first-sandbox, left:offset 150 sandbox-right-margin:num <- get *first-sandbox, right:offset -151 _, _, copy-button-left:num, copy-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin -152 copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right +151 _, _, copy-button-left:num, copy-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin +152 copy-button-vertical-area?:bool <- within-range? click-column, copy-button-left, copy-button-right 153 return-unless copy-button-vertical-area?, 0/false 154 # finally, is sandbox editor empty? 155 current-sandbox:&:editor <- get *env, current-sandbox:offset -156 result <- empty-editor? current-sandbox +156 result <- empty-editor? current-sandbox 157 ] 158 -159 def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button?:bool, env:&:environment [ +159 def try-copy-sandbox click-row:num, env:&:environment -> clicked-on-copy-button?:bool, env:&:environment [ 160 local-scope 161 load-ingredients 162 # identify the sandbox to copy, if the click was actually on the 'copy' button -163 sandbox:&:sandbox <- find-sandbox env, click-row +163 sandbox:&:sandbox <- find-sandbox env, click-row 164 return-unless sandbox, 0/false 165 clicked-on-copy-button? <- copy 1/true 166 text:text <- get *sandbox, data:offset 167 current-sandbox:&:editor <- get *env, current-sandbox:offset -168 current-sandbox <- insert-text current-sandbox, text +168 current-sandbox <- insert-text current-sandbox, text 169 # reset scroll 170 *env <- put *env, render-from:offset, -1 171 # position cursor in sandbox editor 172 *env <- put *env, sandbox-in-focus?:offset, 1/true 173 ] 174 -175 def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [ +175 def find-sandbox env:&:environment, click-row:num -> result:&:sandbox [ 176 local-scope 177 load-ingredients 178 curr-sandbox:&:sandbox <- get *env, sandbox:offset @@ -245,7 +245,7 @@ if ('onhashchange' in window) { 187 return 0/not-found 188 ] 189 -190 def click-on-sandbox-area? click-row:num, click-column:num, env:&:environment -> result:bool [ +190 def click-on-sandbox-area? click-row:num, click-column:num, env:&:environment -> result:bool [ 191 local-scope 192 load-ingredients 193 current-sandbox:&:editor <- get *env, current-sandbox:offset @@ -258,15 +258,15 @@ if ('onhashchange' in window) { 200 result <- greater-or-equal click-row, first-sandbox-begins 201 ] 202 -203 def empty-editor? editor:&:editor -> result:bool [ +203 def empty-editor? editor:&:editor -> result:bool [ 204 local-scope 205 load-ingredients 206 head:&:duplex-list:char <- get *editor, data:offset -207 first:&:duplex-list:char <- next head +207 first:&:duplex-list:char <- next head 208 result <- not first 209 ] 210 -211 def within-range? x:num, low:num, high:num -> result:bool [ +211 def within-range? x:num, low:num, high:num -> result:bool [ 212 local-scope 213 load-ingredients 214 not-too-far-left?:bool <- greater-or-equal x, low @@ -281,12 +281,12 @@ if ('onhashchange' in window) { 223 # empty recipes 224 assume-resources [ 225 ] -226 env:&:environment <- new-programming-environment resources, screen, [add 1, 1] # contents of sandbox editor +226 env:&:environment <- new-programming-environment resources, screen, [add 1, 1] # contents of sandbox editor 227 # run it 228 assume-console [ 229 press F4 230 ] -231 event-loop screen, console, env, resources +231 event-loop screen, console, env, resources 232 screen-should-contain [ 233 . run (F4) . 234 . ╎ . @@ -304,7 +304,7 @@ if ('onhashchange' in window) { 246 left-click 3, 70 # click 'copy' button 247 ] 248 run [ -249 event-loop screen, console, env, resources +249 event-loop screen, console, env, resources 250 ] 251 # copy doesn't happen 252 screen-should-contain [ @@ -322,7 +322,7 @@ if ('onhashchange' in window) { 264 type [1] 265 ] 266 run [ -267 event-loop screen, console, env, resources +267 event-loop screen, console, env, resources 268 ] 269 screen-should-contain [ 270 . run (F4) . diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 620fc495..b2c9dcd5 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -64,7 +64,7 @@ if ('onhashchange' in window) { 6 assume-screen 100/width, 15/height 7 assume-resources [ 8 ] - 9 env:&:environment <- new-programming-environment resources, screen, [] + 9 env:&:environment <- new-programming-environment resources, screen, [] 10 # run a few commands 11 assume-console [ 12 left-click 1, 80 @@ -73,7 +73,7 @@ if ('onhashchange' in window) { 15 type [add 2, 2] 16 press F4 17 ] - 18 event-loop screen, console, env, resources + 18 event-loop screen, console, env, resources 19 screen-should-contain [ 20 . run (F4) . 21 . ╎ . @@ -94,7 +94,7 @@ if ('onhashchange' in window) { 36 left-click 7, 85 37 ] 38 run [ - 39 event-loop screen, console, env, resources + 39 event-loop screen, console, env, resources 40 ] 41 screen-should-contain [ 42 . run (F4) . @@ -112,7 +112,7 @@ if ('onhashchange' in window) { 54 left-click 3, 99 55 ] 56 run [ - 57 event-loop screen, console, env, resources + 57 event-loop screen, console, env, resources 58 ] 59 screen-should-contain [ 60 . run (F4) . @@ -126,45 +126,45 @@ if ('onhashchange' in window) { 68 after <global-touch> [ 69 # support 'delete' button 70 { - 71 delete?:bool <- should-attempt-delete? click-row, click-column, env + 71 delete?:bool <- should-attempt-delete? click-row, click-column, env 72 break-unless delete? - 73 delete?, env <- try-delete-sandbox click-row, env + 73 delete?, env <- try-delete-sandbox click-row, env 74 break-unless delete? - 75 hide-screen screen - 76 screen <- render-sandbox-side screen, env, render - 77 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - 78 show-screen screen + 75 hide-screen screen + 76 screen <- render-sandbox-side screen, env, render + 77 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + 78 show-screen screen 79 loop +next-event 80 } 81 ] 82 83 # some preconditions for attempting to delete a sandbox - 84 def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [ + 84 def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [ 85 local-scope 86 load-ingredients 87 # are we below the sandbox editor? - 88 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env + 88 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env 89 return-unless click-sandbox-area?, 0/false 90 # narrower, is the click in the columns spanning the 'copy' button? 91 first-sandbox:&:editor <- get *env, current-sandbox:offset 92 assert first-sandbox, [!!] 93 sandbox-left-margin:num <- get *first-sandbox, left:offset 94 sandbox-right-margin:num <- get *first-sandbox, right:offset - 95 _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - 96 result <- within-range? click-column, delete-button-left, sandbox-right-margin + 95 _, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + 96 result <- within-range? click-column, delete-button-left, sandbox-right-margin 97 ] 98 - 99 def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [ + 99 def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [ 100 local-scope 101 load-ingredients 102 # identify the sandbox to delete, if the click was actually on the 'delete' button -103 sandbox:&:sandbox <- find-sandbox env, click-row +103 sandbox:&:sandbox <- find-sandbox env, click-row 104 return-unless sandbox, 0/false 105 clicked-on-delete-button? <- copy 1/true -106 env <- delete-sandbox env, sandbox +106 env <- delete-sandbox env, sandbox 107 ] 108 -109 def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ +109 def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [ 110 local-scope 111 load-ingredients 112 curr-sandbox:&:sandbox <- get *env, sandbox:offset @@ -213,8 +213,8 @@ if ('onhashchange' in window) { 155 # initialize environment 156 assume-resources [ 157 ] -158 env:&:environment <- new-programming-environment resources, screen, [] -159 render-all screen, env, render +158 env:&:environment <- new-programming-environment resources, screen, [] +159 render-all screen, env, render 160 # create 2 sandboxes and scroll to second 161 assume-console [ 162 press ctrl-n @@ -222,9 +222,9 @@ if ('onhashchange' in window) { 164 press F4 165 type [add 1, 1] 166 press F4 -167 press page-down +167 press page-down 168 ] -169 event-loop screen, console, env, resources +169 event-loop screen, console, env, resources 170 screen-should-contain [ 171 . run (F4) . 172 . ╎─────────────────────────────────────────────────. @@ -239,7 +239,7 @@ if ('onhashchange' in window) { 181 left-click 6, 99 182 ] 183 run [ -184 event-loop screen, console, env, resources +184 event-loop screen, console, env, resources 185 ] 186 # second sandbox shows in editor; scroll resets to display first sandbox 187 screen-should-contain [ @@ -260,8 +260,8 @@ if ('onhashchange' in window) { 202 # initialize environment 203 assume-resources [ 204 ] -205 env:&:environment <- new-programming-environment resources, screen, [] -206 render-all screen, env, render +205 env:&:environment <- new-programming-environment resources, screen, [] +206 render-all screen, env, render 207 # create 2 sandboxes and scroll to second 208 assume-console [ 209 press ctrl-n @@ -269,9 +269,9 @@ if ('onhashchange' in window) { 211 press F4 212 type [add 1, 1] 213 press F4 -214 press page-down +214 press page-down 215 ] -216 event-loop screen, console, env, resources +216 event-loop screen, console, env, resources 217 screen-should-contain [ 218 . run (F4) . 219 . ╎─────────────────────────────────────────────────. @@ -286,7 +286,7 @@ if ('onhashchange' in window) { 228 left-click 2, 99 229 ] 230 run [ -231 event-loop screen, console, env, resources +231 event-loop screen, console, env, resources 232 ] 233 # second sandbox shows in editor; scroll resets to display first sandbox 234 screen-should-contain [ @@ -307,8 +307,8 @@ if ('onhashchange' in window) { 249 # initialize environment 250 assume-resources [ 251 ] -252 env:&:environment <- new-programming-environment resources, screen, [] -253 render-all screen, env, render +252 env:&:environment <- new-programming-environment resources, screen, [] +253 render-all screen, env, render 254 # create 2 sandboxes and scroll to second 255 assume-console [ 256 press ctrl-n @@ -316,10 +316,10 @@ if ('onhashchange' in window) { 258 press F4 259 type [add 1, 1] 260 press F4 -261 press page-down -262 press page-down +261 press page-down +262 press page-down 263 ] -264 event-loop screen, console, env, resources +264 event-loop screen, console, env, resources 265 screen-should-contain [ 266 . run (F4) . 267 . ╎─────────────────────────────────────────────────. @@ -334,7 +334,7 @@ if ('onhashchange' in window) { 276 left-click 2, 99 277 ] 278 run [ -279 event-loop screen, console, env, resources +279 event-loop screen, console, env, resources 280 ] 281 # implicitly scroll up to first sandbox 282 screen-should-contain [ @@ -356,8 +356,8 @@ if ('onhashchange' in window) { 298 # initialize environment 299 assume-resources [ 300 ] -301 env:&:environment <- new-programming-environment resources, screen, [] -302 render-all screen, env, render +301 env:&:environment <- new-programming-environment resources, screen, [] +302 render-all screen, env, render 303 # create 2 sandboxes 304 assume-console [ 305 press ctrl-n @@ -366,7 +366,7 @@ if ('onhashchange' in window) { 308 type [add 1, 1] 309 press F4 310 ] -311 event-loop screen, console, env, resources +311 event-loop screen, console, env, resources 312 screen-should-contain [ 313 . run (F4) . 314 . ╎ . @@ -382,11 +382,11 @@ if ('onhashchange' in window) { 324 # delete the second sandbox, then try to scroll down twice 325 assume-console [ 326 left-click 3, 99 -327 press page-down -328 press page-down +327 press page-down +328 press page-down 329 ] 330 run [ -331 event-loop screen, console, env, resources +331 event-loop screen, console, env, resources 332 ] 333 # shouldn't go past last sandbox 334 screen-should-contain [ diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 1085b8ab..4f4281a1 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -65,12 +65,12 @@ if ('onhashchange' in window) { 7 # empty recipes 8 assume-resources [ 9 ] - 10 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] + 10 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] 11 # run it 12 assume-console [ 13 press F4 14 ] - 15 event-loop screen, console, env, resources + 15 event-loop screen, console, env, resources 16 screen-should-contain [ 17 . run (F4) . 18 . ╎ . @@ -86,7 +86,7 @@ if ('onhashchange' in window) { 28 left-click 3, 55 29 ] 30 run [ - 31 event-loop screen, console, env, resources + 31 event-loop screen, console, env, resources 32 ] 33 # it pops back into editor 34 screen-should-contain [ @@ -100,7 +100,7 @@ if ('onhashchange' in window) { 42 type [0] 43 ] 44 run [ - 45 event-loop screen, console, env, resources + 45 event-loop screen, console, env, resources 46 ] 47 screen-should-contain [ 48 . run (F4) . @@ -117,12 +117,12 @@ if ('onhashchange' in window) { 59 # empty recipes 60 assume-resources [ 61 ] - 62 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] + 62 env:&:environment <- new-programming-environment resources, screen, [add 2, 2] 63 # run it 64 assume-console [ 65 press F4 66 ] - 67 event-loop screen, console, env, resources + 67 event-loop screen, console, env, resources 68 screen-should-contain [ 69 . run (F4) . 70 . ╎ . @@ -138,7 +138,7 @@ if ('onhashchange' in window) { 80 left-click 3, 68 81 ] 82 run [ - 83 event-loop screen, console, env, resources + 83 event-loop screen, console, env, resources 84 ] 85 # it pops back into editor 86 screen-should-contain [ @@ -152,7 +152,7 @@ if ('onhashchange' in window) { 94 type [0] 95 ] 96 run [ - 97 event-loop screen, console, env, resources + 97 event-loop screen, console, env, resources 98 ] 99 screen-should-contain [ 100 . run (F4) . @@ -165,50 +165,50 @@ if ('onhashchange' in window) { 107 after <global-touch> [ 108 # support 'edit' button 109 { -110 edit?:bool <- should-attempt-edit? click-row, click-column, env +110 edit?:bool <- should-attempt-edit? click-row, click-column, env 111 break-unless edit? -112 edit?, env <- try-edit-sandbox click-row, env +112 edit?, env <- try-edit-sandbox click-row, env 113 break-unless edit? -114 hide-screen screen -115 screen <- render-sandbox-side screen, env, render -116 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env -117 show-screen screen +114 hide-screen screen +115 screen <- render-sandbox-side screen, env, render +116 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +117 show-screen screen 118 loop +next-event 119 } 120 ] 121 122 # some preconditions for attempting to edit a sandbox -123 def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [ +123 def should-attempt-edit? click-row:num, click-column:num, env:&:environment -> result:bool [ 124 local-scope 125 load-ingredients 126 # are we below the sandbox editor? -127 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env +127 click-sandbox-area?:bool <- click-on-sandbox-area? click-row, click-column, env 128 return-unless click-sandbox-area?, 0/false 129 # narrower, is the click in the columns spanning the 'edit' button? 130 first-sandbox:&:editor <- get *env, current-sandbox:offset 131 assert first-sandbox, [!!] 132 sandbox-left-margin:num <- get *first-sandbox, left:offset 133 sandbox-right-margin:num <- get *first-sandbox, right:offset -134 edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin -135 edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right +134 edit-button-left:num, edit-button-right:num, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin +135 edit-button-vertical-area?:bool <- within-range? click-column, edit-button-left, edit-button-right 136 return-unless edit-button-vertical-area?, 0/false 137 # finally, is sandbox editor empty? 138 current-sandbox:&:editor <- get *env, current-sandbox:offset -139 result <- empty-editor? current-sandbox +139 result <- empty-editor? current-sandbox 140 ] 141 -142 def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [ +142 def try-edit-sandbox click-row:num, env:&:environment -> clicked-on-edit-button?:bool, env:&:environment [ 143 local-scope 144 load-ingredients 145 # identify the sandbox to edit, if the click was actually on the 'edit' button -146 sandbox:&:sandbox <- find-sandbox env, click-row +146 sandbox:&:sandbox <- find-sandbox env, click-row 147 return-unless sandbox, 0/false 148 clicked-on-edit-button? <- copy 1/true 149 # 'edit' button = 'copy' button + 'delete' button 150 text:text <- get *sandbox, data:offset 151 current-sandbox:&:editor <- get *env, current-sandbox:offset -152 current-sandbox <- insert-text current-sandbox, text -153 env <- delete-sandbox env, sandbox +152 current-sandbox <- insert-text current-sandbox, text +153 env <- delete-sandbox env, sandbox 154 # reset scroll 155 *env <- put *env, render-from:offset, -1 156 # position cursor in sandbox editor @@ -223,18 +223,18 @@ if ('onhashchange' in window) { 165 assume-resources [ 166 ] 167 # right editor contains a print instruction -168 env:&:environment <- new-programming-environment resources, screen, [print-integer screen, 4] +168 env:&:environment <- new-programming-environment resources, screen, [print-integer screen, 4] 169 # run the sandbox 170 assume-console [ 171 press F4 172 ] -173 event-loop screen, console, env, resources +173 event-loop screen, console, env, resources 174 screen-should-contain [ 175 . run (F4) . 176 . ╎ . 177 .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. 178 . ╎0 edit copy delete . -179 . ╎print-integer screen, 4 . +179 . ╎print-integer screen, 4 . 180 . ╎screen: . 181 . ╎ .4 . . 182 . ╎ . . . @@ -249,11 +249,11 @@ if ('onhashchange' in window) { 191 left-click 3, 65 192 ] 193 run [ -194 event-loop screen, console, env, resources +194 event-loop screen, console, env, resources 195 ] 196 screen-should-contain [ 197 . run (F4) . -198 . ╎print-integer screen, 4 . +198 . ╎print-integer screen, 4 . 199 .╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────. 200 . ╎ . 201 . ╎ . @@ -267,8 +267,8 @@ if ('onhashchange' in window) { 209 # initialize environment 210 assume-resources [ 211 ] -212 env:&:environment <- new-programming-environment resources, screen, [] -213 render-all screen, env, render +212 env:&:environment <- new-programming-environment resources, screen, [] +213 render-all screen, env, render 214 # create 2 sandboxes and scroll to second 215 assume-console [ 216 press ctrl-n @@ -276,10 +276,10 @@ if ('onhashchange' in window) { 218 press F4 219 type [add 1, 1] 220 press F4 -221 press page-down -222 press page-down +221 press page-down +222 press page-down 223 ] -224 event-loop screen, console, env, resources +224 event-loop screen, console, env, resources 225 screen-should-contain [ 226 . run (F4) . 227 . ╎─────────────────────────────────────────────────. @@ -294,7 +294,7 @@ if ('onhashchange' in window) { 236 left-click 2, 55 237 ] 238 run [ -239 event-loop screen, console, env, resources +239 event-loop screen, console, env, resources 240 ] 241 # second sandbox shows in editor; scroll resets to display first sandbox 242 screen-should-contain [ @@ -316,8 +316,8 @@ if ('onhashchange' in window) { 258 # initialize environment 259 assume-resources [ 260 ] -261 env:&:environment <- new-programming-environment resources, screen, [] -262 render-all screen, env, render +261 env:&:environment <- new-programming-environment resources, screen, [] +262 render-all screen, env, render 263 # create 2 sandboxes 264 assume-console [ 265 press ctrl-n @@ -326,7 +326,7 @@ if ('onhashchange' in window) { 268 type [add 1, 1] 269 press F4 270 ] -271 event-loop screen, console, env, resources +271 event-loop screen, console, env, resources 272 screen-should-contain [ 273 . run (F4) . 274 . ╎ . @@ -345,7 +345,7 @@ if ('onhashchange' in window) { 287 press F4 288 ] 289 run [ -290 event-loop screen, console, env, resources +290 event-loop screen, console, env, resources 291 ] 292 # no change in contents 293 screen-should-contain [ @@ -362,12 +362,12 @@ if ('onhashchange' in window) { 304 ] 305 # now try to scroll past end 306 assume-console [ -307 press page-down -308 press page-down -309 press page-down +307 press page-down +308 press page-down +309 press page-down 310 ] 311 run [ -312 event-loop screen, console, env, resources +312 event-loop screen, console, env, resources 313 ] 314 # screen should show just final sandbox with the right index (1) 315 screen-should-contain [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 52631e6f..d376f209 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -71,12 +71,12 @@ if ('onhashchange' in window) { 12 |]| 13 ] 14 ] - 15 env:&:environment <- new-programming-environment resources, screen, [foo] + 15 env:&:environment <- new-programming-environment resources, screen, [foo] 16 # run it 17 assume-console [ 18 press F4 19 ] - 20 event-loop screen, console, env, resources + 20 event-loop screen, console, env, resources 21 screen-should-contain [ 22 . run (F4) . 23 .recipe foo [ ╎ . @@ -92,7 +92,7 @@ if ('onhashchange' in window) { 33 left-click 5, 51 34 ] 35 run [ - 36 event-loop screen, console, env, resources + 36 event-loop screen, console, env, resources 37 ] 38 # color toggles to green 39 screen-should-contain-in-color 2/green, [ @@ -108,7 +108,7 @@ if ('onhashchange' in window) { 49 # cursor should remain unmoved 50 run [ 51 cursor:char <- copy 9251/␣ - 52 print screen, cursor + 52 print screen, cursor 53 ] 54 screen-should-contain [ 55 . run (F4) . @@ -129,7 +129,7 @@ if ('onhashchange' in window) { 70 press F4 71 ] 72 run [ - 73 event-loop screen, console, env, resources + 73 event-loop screen, console, env, resources 74 ] 75 # result turns red 76 screen-should-contain-in-color 1/red, [ @@ -156,14 +156,14 @@ if ('onhashchange' in window) { 97 expected-response:text <- get *curr, expected-response:offset 98 break-unless expected-response 99 filename <- append filename, [.out] -100 resources <- dump resources, filename, expected-response +100 resources <- dump resources, filename, expected-response 101 } 102 ] 103 104 before <end-restore-sandbox> [ 105 { 106 filename <- append filename, [.out] -107 contents <- slurp resources, filename +107 contents <- slurp resources, filename 108 break-unless contents 109 *curr <- put *curr, expected-response:offset, contents 110 } @@ -184,21 +184,21 @@ if ('onhashchange' in window) { 125 below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins 126 break-unless below-sandbox-editor? 127 # identify the sandbox whose output is being clicked on -128 sandbox:&:sandbox <- find-click-in-sandbox-output env, click-row +128 sandbox:&:sandbox <- find-click-in-sandbox-output env, click-row 129 break-unless sandbox 130 # toggle its expected-response, and save session -131 sandbox <- toggle-expected-response sandbox -132 save-sandboxes env, resources -133 hide-screen screen -134 screen <- render-sandbox-side screen, env, render -135 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +131 sandbox <- toggle-expected-response sandbox +132 save-sandboxes env, resources +133 hide-screen screen +134 screen <- render-sandbox-side screen, env, render +135 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 136 # no change in cursor -137 show-screen screen +137 show-screen screen 138 loop +next-event 139 } 140 ] 141 -142 def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox [ +142 def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox [ 143 local-scope 144 load-ingredients 145 # assert click-row >= sandbox.starting-row-on-screen @@ -224,7 +224,7 @@ if ('onhashchange' in window) { 165 return sandbox 166 ] 167 -168 def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ +168 def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [ 169 local-scope 170 load-ingredients 171 expected-response:text <- get *sandbox, expected-response:offset @@ -251,11 +251,11 @@ if ('onhashchange' in window) { 192 response-is-expected?:bool <- equal expected-response, sandbox-response 193 { 194 break-if response-is-expected?:bool -195 row, screen <- render-text screen, sandbox-response, left, right, 1/red, row +195 row, screen <- render-text screen, sandbox-response, left, right, 1/red, row 196 } 197 { 198 break-unless response-is-expected?:bool -199 row, screen <- render-text screen, sandbox-response, left, right, 2/green, row +199 row, screen <- render-text screen, sandbox-response, left, right, 2/green, row 200 } 201 jump +render-sandbox-end 202 } diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 1a5147af..fdc6f188 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -71,12 +71,12 @@ if ('onhashchange' in window) { 12 |]| 13 ] 14 ] - 15 env:&:environment <- new-programming-environment resources, screen, [foo] + 15 env:&:environment <- new-programming-environment resources, screen, [foo] 16 # run it 17 assume-console [ 18 press F4 19 ] - 20 event-loop screen, console, env, resources + 20 event-loop screen, console, env, resources 21 screen-should-contain [ 22 . run (F4) . 23 .recipe foo [ ╎ . @@ -91,9 +91,9 @@ if ('onhashchange' in window) { 32 left-click 4, 51 33 ] 34 run [ - 35 event-loop screen, console, env, resources + 35 event-loop screen, console, env, resources 36 cursor:char <- copy 9251/␣ - 37 print screen, cursor + 37 print screen, cursor 38 ] 39 # trace now printed and cursor shouldn't have budged 40 screen-should-contain [ @@ -117,8 +117,8 @@ if ('onhashchange' in window) { 58 left-click 4, 55 59 ] 60 run [ - 61 event-loop screen, console, env, resources - 62 print screen, cursor + 61 event-loop screen, console, env, resources + 62 print screen, cursor 63 ] 64 # trace hidden again 65 screen-should-contain [ @@ -145,12 +145,12 @@ if ('onhashchange' in window) { 86 |]| 87 ] 88 ] - 89 env:&:environment <- new-programming-environment resources, screen, [foo] + 89 env:&:environment <- new-programming-environment resources, screen, [foo] 90 # run it 91 assume-console [ 92 press F4 93 ] - 94 event-loop screen, console, env, resources + 94 event-loop screen, console, env, resources 95 screen-should-contain [ 96 . run (F4) . 97 .recipe foo [ ╎ . @@ -166,7 +166,7 @@ if ('onhashchange' in window) { 107 left-click 4, 51 108 ] 109 run [ -110 event-loop screen, console, env, resources +110 event-loop screen, console, env, resources 111 ] 112 # trace now printed above result 113 screen-should-contain [ @@ -189,13 +189,13 @@ if ('onhashchange' in window) { 130 assume-screen 100/width, 10/height 131 assume-resources [ 132 ] -133 env:&:environment <- new-programming-environment resources, screen, [stash 123456789] +133 env:&:environment <- new-programming-environment resources, screen, [stash 123456789] 134 # create and expand the trace 135 assume-console [ 136 press F4 137 left-click 4, 51 138 ] -139 event-loop screen, console, env, resources +139 event-loop screen, console, env, resources 140 screen-should-contain [ 141 . run (F4) . 142 . ╎ . @@ -209,7 +209,7 @@ if ('onhashchange' in window) { 150 left-click 5, 57 151 ] 152 run [ -153 event-loop screen, console, env, resources +153 event-loop screen, console, env, resources 154 ] 155 # no change; doesn't die 156 screen-should-contain [ @@ -232,9 +232,9 @@ if ('onhashchange' in window) { 173 local-scope 174 load-ingredients 175 data:text <- get *sandbox, data:offset -176 response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed data +176 response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed data 177 *sandbox <- put *sandbox, response:offset, response -178 *sandbox <- put *sandbox, screen:offset, fake-screen +178 *sandbox <- put *sandbox, screen:offset, fake-screen 179 *sandbox <- put *sandbox, trace:offset, trace 180 ] 181 @@ -253,22 +253,22 @@ if ('onhashchange' in window) { 194 below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins 195 break-unless below-sandbox-editor? 196 # identify the sandbox whose code is being clicked on -197 sandbox:&:sandbox <- find-click-in-sandbox-code env, click-row +197 sandbox:&:sandbox <- find-click-in-sandbox-code env, click-row 198 break-unless sandbox 199 # toggle its display-trace? property 200 x:bool <- get *sandbox, display-trace?:offset 201 x <- not x 202 *sandbox <- put *sandbox, display-trace?:offset, x -203 hide-screen screen -204 screen <- render-sandbox-side screen, env, render -205 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env +203 hide-screen screen +204 screen <- render-sandbox-side screen, env, render +205 screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env 206 # no change in cursor -207 show-screen screen +207 show-screen screen 208 loop +next-event 209 } 210 ] 211 -212 def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [ +212 def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [ 213 local-scope 214 load-ingredients 215 # assert click-row >= sandbox.starting-row-on-screen @@ -306,7 +306,7 @@ if ('onhashchange' in window) { 247 break-unless display-trace? 248 sandbox-trace:text <- get *sandbox, trace:offset 249 break-unless sandbox-trace # nothing to print; move on -250 row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row +250 row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row 251 } 252 <render-sandbox-trace-done> 253 ] diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 03b629e2..e38feeea 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -64,18 +64,18 @@ if ('onhashchange' in window) { 5 ] 6 7 # copy code from recipe editor, persist to disk, load, save any errors - 8 def! update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ + 8 def! update-recipes env:&:environment, resources:&:resources, screen:&:screen -> errors-found?:bool, env:&:environment, resources:&:resources, screen:&:screen [ 9 local-scope 10 load-ingredients 11 recipes:&:editor <- get *env, recipes:offset - 12 in:text <- editor-contents recipes - 13 resources <- dump resources, [lesson/recipes.mu], in + 12 in:text <- editor-contents recipes + 13 resources <- dump resources, [lesson/recipes.mu], in 14 recipe-errors:text <- reload in 15 *env <- put *env, recipe-errors:offset, recipe-errors 16 # if recipe editor has errors, stop 17 { 18 break-unless recipe-errors - 19 update-status screen, [errors found ], 1/red + 19 update-status screen, [errors found ], 1/red 20 errors-found? <- copy 1/true 21 return 22 } @@ -87,7 +87,7 @@ if ('onhashchange' in window) { 28 recipe-errors:text <- get *env, recipe-errors:offset 29 { 30 break-unless recipe-errors - 31 update-status screen, [errors found ], 1/red + 31 update-status screen, [errors found ], 1/red 32 } 33 ] 34 @@ -95,7 +95,7 @@ if ('onhashchange' in window) { 36 { 37 recipe-errors:text <- get *env, recipe-errors:offset 38 break-unless recipe-errors - 39 row, screen <- render-text screen, recipe-errors, left, right, 1/red, row + 39 row, screen <- render-text screen, recipe-errors, left, right, 1/red, row 40 } 41 ] 42 @@ -127,8 +127,8 @@ if ('onhashchange' in window) { 68 sandboxes-completed-successfully?:bool <- equal error-index, -1 69 break-if sandboxes-completed-successfully? 70 error-index-text:text <- to-text error-index - 71 status:text <- interpolate [errors found (_) ], error-index-text - 72 update-status screen, status, 1/red + 71 status:text <- interpolate [errors found (_) ], error-index-text + 72 update-status screen, status, 1/red 73 } 74 ] 75 @@ -140,10 +140,10 @@ if ('onhashchange' in window) { 81 local-scope 82 load-ingredients 83 data:text <- get *sandbox, data:offset - 84 response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data + 84 response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <- run-sandboxed data 85 *sandbox <- put *sandbox, response:offset, response 86 *sandbox <- put *sandbox, errors:offset, errors - 87 *sandbox <- put *sandbox, screen:offset, fake-screen + 87 *sandbox <- put *sandbox, screen:offset, fake-screen 88 *sandbox <- put *sandbox, trace:offset, trace 89 { 90 break-if errors @@ -167,7 +167,7 @@ if ('onhashchange' in window) { 108 sandbox-errors:text <- get *sandbox, errors:offset 109 break-unless sandbox-errors 110 *sandbox <- put *sandbox, response-starting-row-on-screen:offset, 0 # no response -111 row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row +111 row, screen <- render-text screen, sandbox-errors, left, right, 1/red, row 112 # don't try to print anything more for this sandbox 113 jump +render-sandbox-end 114 } @@ -184,8 +184,8 @@ if ('onhashchange' in window) { 125 |]| 126 ] 127 ] -128 env:&:environment <- new-programming-environment resources, screen, [foo] -129 render-all screen, env, render +128 env:&:environment <- new-programming-environment resources, screen, [foo] +129 render-all screen, env, render 130 screen-should-contain [ 131 . run (F4) . 132 .recipe foo [ ╎foo . @@ -199,7 +199,7 @@ if ('onhashchange' in window) { 140 press F4 141 ] 142 run [ -143 event-loop screen, console, env, resources +143 event-loop screen, console, env, resources 144 ] 145 screen-should-contain [ 146 . errors found run (F4) . @@ -232,7 +232,7 @@ if ('onhashchange' in window) { 173 assume-screen 100/width, 15/height 174 assume-resources [ 175 ] -176 env:&:environment <- new-programming-environment resources, screen, [] +176 env:&:environment <- new-programming-environment resources, screen, [] 177 assume-console [ 178 left-click 3, 80 179 # create invalid sandbox 1 @@ -243,7 +243,7 @@ if ('onhashchange' in window) { 184 press F4 185 ] 186 run [ -187 event-loop screen, console, env, resources +187 event-loop screen, console, env, resources 188 ] 189 # status line shows that error is in first sandbox 190 screen-should-contain [ @@ -257,7 +257,7 @@ if ('onhashchange' in window) { 198 assume-screen 100/width, 15/height 199 assume-resources [ 200 ] -201 env:&:environment <- new-programming-environment resources, screen, [] +201 env:&:environment <- new-programming-environment resources, screen, [] 202 assume-console [ 203 left-click 3, 80 204 # create invalid sandbox 2 @@ -271,7 +271,7 @@ if ('onhashchange' in window) { 212 press F4 213 ] 214 run [ -215 event-loop screen, console, env, resources +215 event-loop screen, console, env, resources 216 ] 217 # status line shows that error is in second sandbox 218 screen-should-contain [ @@ -285,11 +285,11 @@ if ('onhashchange' in window) { 226 assume-screen 100/width, 15/height 227 assume-resources [ 228 ] -229 env:&:environment <- new-programming-environment resources, screen, [get foo, x:offset] # invalid +229 env:&:environment <- new-programming-environment resources, screen, [get foo, x:offset] # invalid 230 assume-console [ 231 press F4 # generate error 232 ] -233 event-loop screen, console, env, resources +233 event-loop screen, console, env, resources 234 assume-console [ 235 left-click 3, 58 236 press ctrl-k @@ -297,7 +297,7 @@ if ('onhashchange' in window) { 238 press F4 # update sandbox 239 ] 240 run [ -241 event-loop screen, console, env, resources +241 event-loop screen, console, env, resources 242 ] 243 # error should disappear 244 screen-should-contain [ @@ -327,11 +327,11 @@ if ('onhashchange' in window) { 268 |]| 269 ] 270 ] -271 env:&:environment <- new-programming-environment resources, screen, [foo 2] +271 env:&:environment <- new-programming-environment resources, screen, [foo 2] 272 assume-console [ 273 press F4 274 ] -275 event-loop screen, console, env, resources +275 event-loop screen, console, env, resources 276 screen-should-contain [ 277 . errors found (0) run (F4) . 278 .recipe foo x:_elem -> z:_elem [ ╎ . @@ -349,7 +349,7 @@ if ('onhashchange' in window) { 290 press F4 291 ] 292 run [ -293 event-loop screen, console, env, resources +293 event-loop screen, console, env, resources 294 ] 295 # error should remain unchanged 296 screen-should-contain [ @@ -380,12 +380,12 @@ if ('onhashchange' in window) { 321 # call code that uses other variants of it, but not it itself 322 test-sandbox:text <- new [x:&:list:num <- copy 0 323 to-text x] -324 env:&:environment <- new-programming-environment resources, screen, test-sandbox +324 env:&:environment <- new-programming-environment resources, screen, test-sandbox 325 # run it once 326 assume-console [ 327 press F4 328 ] -329 event-loop screen, console, env, resources +329 event-loop screen, console, env, resources 330 # no errors anywhere on screen (can't check anything else, since to-text will return an address) 331 screen-should-contain-in-color 1/red, [ 332 . . @@ -409,7 +409,7 @@ if ('onhashchange' in window) { 350 press F4 351 ] 352 run [ -353 event-loop screen, console, env, resources +353 event-loop screen, console, env, resources 354 ] 355 # still no errors 356 screen-should-contain-in-color 1/red, [ @@ -442,12 +442,12 @@ if ('onhashchange' in window) { 383 |]| 384 ] 385 ] -386 env:&:environment <- new-programming-environment resources, screen, [foo] +386 env:&:environment <- new-programming-environment resources, screen, [foo] 387 assume-console [ 388 press F4 389 ] 390 run [ -391 event-loop screen, console, env, resources +391 event-loop screen, console, env, resources 392 ] 393 screen-should-contain [ 394 . errors found run (F4) . @@ -473,12 +473,12 @@ if ('onhashchange' in window) { 414 | x <- copy 0| 415 ] 416 ] -417 env:&:environment <- new-programming-environment resources, screen, [foo] +417 env:&:environment <- new-programming-environment resources, screen, [foo] 418 assume-console [ 419 press F4 420 ] 421 run [ -422 event-loop screen, console, env, resources +422 event-loop screen, console, env, resources 423 ] 424 screen-should-contain [ 425 . errors found run (F4) . @@ -504,12 +504,12 @@ if ('onhashchange' in window) { 445 |]| 446 ] 447 ] -448 env:&:environment <- new-programming-environment resources, screen, [foo] +448 env:&:environment <- new-programming-environment resources, screen, [foo] 449 assume-console [ 450 press F4 451 ] 452 run [ -453 event-loop screen, console, env, resources +453 event-loop screen, console, env, resources 454 ] 455 screen-should-contain [ 456 . errors found run (F4) . @@ -540,12 +540,12 @@ if ('onhashchange' in window) { 481 |]| 482 ] 483 ] -484 env:&:environment <- new-programming-environment resources, screen, [foo] +484 env:&:environment <- new-programming-environment resources, screen, [foo] 485 assume-console [ 486 press F4 487 ] 488 run [ -489 event-loop screen, console, env, resources +489 event-loop screen, console, env, resources 490 ] 491 screen-should-contain [ 492 . errors found run (F4) . @@ -576,11 +576,11 @@ if ('onhashchange' in window) { 517 |]| 518 ] 519 ] -520 env:&:environment <- new-programming-environment resources, screen, [foo] +520 env:&:environment <- new-programming-environment resources, screen, [foo] 521 assume-console [ 522 press F4 523 ] -524 event-loop screen, console, env, resources +524 event-loop screen, console, env, resources 525 screen-should-contain [ 526 . errors found run (F4) . 527 .recipe foo [ ╎foo . @@ -598,7 +598,7 @@ if ('onhashchange' in window) { 539 press F4 540 ] 541 run [ -542 event-loop screen, console, env, resources +542 event-loop screen, console, env, resources 543 ] 544 screen-should-contain [ 545 . errors found run (F4) . @@ -621,12 +621,12 @@ if ('onhashchange' in window) { 562 assume-resources [ 563 ] 564 # sandbox editor contains an illegal instruction -565 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] +565 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] 566 assume-console [ 567 press F4 568 ] 569 run [ -570 event-loop screen, console, env, resources +570 event-loop screen, console, env, resources 571 ] 572 # check that screen prints error message in red 573 screen-should-contain [ @@ -683,14 +683,14 @@ if ('onhashchange' in window) { 624 assume-resources [ 625 ] 626 # sandbox editor contains an illegal instruction -627 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] +627 env:&:environment <- new-programming-environment resources, screen, [get 1234:num, foo:offset] 628 # run the code in the editors multiple times 629 assume-console [ 630 press F4 631 press F4 632 ] 633 run [ -634 event-loop screen, console, env, resources +634 event-loop screen, console, env, resources 635 ] 636 # check that screen prints error message just once 637 screen-should-contain [ @@ -721,13 +721,13 @@ if ('onhashchange' in window) { 662 |]| 663 ] 664 ] -665 env:&:environment <- new-programming-environment resources, screen, [foo] +665 env:&:environment <- new-programming-environment resources, screen, [foo] 666 # run the sandbox 667 assume-console [ 668 press F4 669 ] 670 run [ -671 event-loop screen, console, env, resources +671 event-loop screen, console, env, resources 672 ] 673 screen-should-contain [ 674 . errors found (0) run (F4) . @@ -759,12 +759,12 @@ if ('onhashchange' in window) { 700 |]| 701 ] 702 ] -703 env:&:environment <- new-programming-environment resources, screen, [foo 4, 0] +703 env:&:environment <- new-programming-environment resources, screen, [foo 4, 0] 704 # run 705 assume-console [ 706 press F4 707 ] -708 event-loop screen, console, env, resources +708 event-loop screen, console, env, resources 709 # screen prints error message 710 screen-should-contain [ 711 . errors found (0) run (F4) . @@ -783,7 +783,7 @@ if ('onhashchange' in window) { 724 left-click 4, 55 725 ] 726 run [ -727 event-loop screen, console, env, resources +727 event-loop screen, console, env, resources 728 ] 729 # screen should expand trace 730 screen-should-contain [ diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index 00996c79..ad378ce0 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -61,13 +61,13 @@ if ('onhashchange' in window) { 2 3 # for every undoable event, create a type of *operation* that contains all the 4 # information needed to reverse it - 5 exclusive-container operation [ - 6 typing:insert-operation - 7 move:move-operation - 8 delete:delete-operation + 5 exclusive-container operation [ + 6 typing:insert-operation + 7 move:move-operation + 8 delete:delete-operation 9 ] 10 - 11 container insert-operation [ + 11 container insert-operation [ 12 before-row:num 13 before-column:num 14 before-top-of-screen:&:duplex-list:char @@ -82,7 +82,7 @@ if ('onhashchange' in window) { 23 # 1: regular alphanumeric characters 24 ] 25 - 26 container move-operation [ + 26 container move-operation [ 27 before-row:num 28 before-column:num 29 before-top-of-screen:&:duplex-list:char @@ -97,7 +97,7 @@ if ('onhashchange' in window) { 38 # 4: down arrow 39 ] 40 - 41 container delete-operation [ + 41 container delete-operation [ 42 before-row:num 43 before-column:num 44 before-top-of-screen:&:duplex-list:char @@ -115,8 +115,8 @@ if ('onhashchange' in window) { 56 57 # every editor accumulates a list of operations to undo/redo 58 container editor [ - 59 undo:&:list:&:operation - 60 redo:&:list:&:operation + 59 undo:&:list:&:operation + 60 redo:&:list:&:operation 61 ] 62 63 # ctrl-z - undo operation @@ -124,12 +124,12 @@ if ('onhashchange' in window) { 65 { 66 undo?:bool <- equal c, 26/ctrl-z 67 break-unless undo? - 68 undo:&:list:&:operation <- get *editor, undo:offset + 68 undo:&:list:&:operation <- get *editor, undo:offset 69 break-unless undo - 70 op:&:operation <- first undo - 71 undo <- rest undo + 70 op:&:operation <- first undo + 71 undo <- rest undo 72 *editor <- put *editor, undo:offset, undo - 73 redo:&:list:&:operation <- get *editor, redo:offset + 73 redo:&:list:&:operation <- get *editor, redo:offset 74 redo <- push op, redo 75 *editor <- put *editor, redo:offset, redo 76 <handle-undo> @@ -142,12 +142,12 @@ if ('onhashchange' in window) { 83 { 84 redo?:bool <- equal c, 25/ctrl-y 85 break-unless redo? - 86 redo:&:list:&:operation <- get *editor, redo:offset + 86 redo:&:list:&:operation <- get *editor, redo:offset 87 break-unless redo - 88 op:&:operation <- first redo - 89 redo <- rest redo + 88 op:&:operation <- first redo + 89 redo <- rest redo 90 *editor <- put *editor, redo:offset, redo - 91 undo:&:list:&:operation <- get *editor, undo:offset + 91 undo:&:list:&:operation <- get *editor, undo:offset 92 undo <- push op, undo 93 *editor <- put *editor, undo:offset, undo 94 <handle-redo> @@ -161,18 +161,18 @@ if ('onhashchange' in window) { 102 local-scope 103 # create an editor and type a character 104 assume-screen 10/width, 5/height - 105 e:&:editor <- new-editor [], 0/left, 10/right - 106 editor-render screen, e + 105 e:&:editor <- new-editor [], 0/left, 10/right + 106 editor-render screen, e 107 assume-console [ 108 type [0] 109 ] - 110 editor-event-loop screen, console, e + 110 editor-event-loop screen, console, e 111 # undo 112 assume-console [ 113 press ctrl-z 114 ] 115 run [ - 116 editor-event-loop screen, console, e + 116 editor-event-loop screen, console, e 117 ] 118 # character should be gone 119 screen-should-contain [ @@ -186,7 +186,7 @@ if ('onhashchange' in window) { 127 type [1] 128 ] 129 run [ - 130 editor-event-loop screen, console, e + 130 editor-event-loop screen, console, e 131 ] 132 screen-should-contain [ 133 . . @@ -205,17 +205,17 @@ if ('onhashchange' in window) { 146 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 147 cursor-row:num <- get *editor, cursor-row:offset 148 cursor-column:num <- get *editor, cursor-column:offset - 149 undo:&:list:&:operation <- get *editor, undo:offset + 149 undo:&:list:&:operation <- get *editor, undo:offset 150 { 151 # if previous operation was an insert, coalesce this operation with it 152 break-unless undo - 153 op:&:operation <- first undo - 154 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant + 153 op:&:operation <- first undo + 154 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 155 break-unless is-insert? 156 previous-coalesce-tag:num <- get typing, tag:offset 157 break-unless previous-coalesce-tag 158 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 159 insert-until:&:duplex-list:char <- next before-cursor + 159 insert-until:&:duplex-list:char <- next before-cursor 160 typing <- put typing, insert-until:offset, insert-until 161 typing <- put typing, after-row:offset, cursor-row 162 typing <- put typing, after-column:offset, cursor-column @@ -224,11 +224,11 @@ if ('onhashchange' in window) { 165 break +done-adding-insert-operation 166 } 167 # if not, create a new operation - 168 insert-from:&:duplex-list:char <- next cursor-before - 169 insert-to:&:duplex-list:char <- next insert-from - 170 op:&:operation <- new operation:type + 168 insert-from:&:duplex-list:char <- next cursor-before + 169 insert-to:&:duplex-list:char <- next insert-from + 170 op:&:operation <- new operation:type 171 *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 1/coalesce - 172 editor <- add-operation editor, op + 172 editor <- add-operation editor, op 173 +done-adding-insert-operation 174 ] 175 @@ -244,39 +244,39 @@ if ('onhashchange' in window) { 185 cursor-row:num <- get *editor, cursor-row:offset 186 cursor-column:num <- get *editor, cursor-row:offset 187 # never coalesce - 188 insert-from:&:duplex-list:char <- next cursor-before + 188 insert-from:&:duplex-list:char <- next cursor-before 189 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset - 190 insert-to:&:duplex-list:char <- next before-cursor - 191 op:&:operation <- new operation:type + 190 insert-to:&:duplex-list:char <- next before-cursor + 191 op:&:operation <- new operation:type 192 *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce - 193 editor <- add-operation editor, op + 193 editor <- add-operation editor, op 194 ] 195 196 # Everytime you add a new operation to the undo stack, be sure to clear the 197 # redo stack, because it's now obsolete. 198 # Beware: since we're counting cursor moves as operations, this means just 199 # moving the cursor can lose work on the undo stack. - 200 def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ + 200 def add-operation editor:&:editor, op:&:operation -> editor:&:editor [ 201 local-scope 202 load-ingredients - 203 undo:&:list:&:operation <- get *editor, undo:offset + 203 undo:&:list:&:operation <- get *editor, undo:offset 204 undo <- push op undo 205 *editor <- put *editor, undo:offset, undo - 206 redo:&:list:&:operation <- get *editor, redo:offset + 206 redo:&:list:&:operation <- get *editor, redo:offset 207 redo <- copy 0 208 *editor <- put *editor, redo:offset, redo 209 ] 210 211 after <handle-undo> [ 212 { - 213 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant + 213 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 214 break-unless is-insert? 215 start:&:duplex-list:char <- get typing, insert-from:offset 216 end:&:duplex-list:char <- get typing, insert-until:offset 217 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen - 218 before-cursor:&:duplex-list:char <- prev start + 218 before-cursor:&:duplex-list:char <- prev start 219 *editor <- put *editor, before-cursor:offset, before-cursor - 220 remove-between before-cursor, end + 220 remove-between before-cursor, end 221 cursor-row <- get typing, before-row:offset 222 *editor <- put *editor, cursor-row:offset, cursor-row 223 cursor-column <- get typing, before-column:offset @@ -290,18 +290,18 @@ if ('onhashchange' in window) { 231 local-scope 232 # create an editor and type multiple characters 233 assume-screen 10/width, 5/height - 234 e:&:editor <- new-editor [], 0/left, 10/right - 235 editor-render screen, e + 234 e:&:editor <- new-editor [], 0/left, 10/right + 235 editor-render screen, e 236 assume-console [ 237 type [012] 238 ] - 239 editor-event-loop screen, console, e + 239 editor-event-loop screen, console, e 240 # undo 241 assume-console [ 242 press ctrl-z 243 ] 244 run [ - 245 editor-event-loop screen, console, e + 245 editor-event-loop screen, console, e 246 ] 247 # all characters must be gone 248 screen-should-contain [ @@ -316,13 +316,13 @@ if ('onhashchange' in window) { 257 local-scope 258 # create an editor with some text 259 assume-screen 10/width, 5/height - 260 e:&:editor <- new-editor [a], 0/left, 10/right - 261 editor-render screen, e + 260 e:&:editor <- new-editor [a], 0/left, 10/right + 261 editor-render screen, e 262 # type some characters 263 assume-console [ 264 type [012] 265 ] - 266 editor-event-loop screen, console, e + 266 editor-event-loop screen, console, e 267 screen-should-contain [ 268 . . 269 .012a . @@ -334,7 +334,7 @@ if ('onhashchange' in window) { 275 press ctrl-z 276 ] 277 run [ - 278 editor-event-loop screen, console, e + 278 editor-event-loop screen, console, e 279 ] 280 # back to original text 281 screen-should-contain [ @@ -348,7 +348,7 @@ if ('onhashchange' in window) { 289 type [3] 290 ] 291 run [ - 292 editor-event-loop screen, console, e + 292 editor-event-loop screen, console, e 293 ] 294 screen-should-contain [ 295 . . @@ -362,14 +362,14 @@ if ('onhashchange' in window) { 303 local-scope 304 # create an editor with some text 305 assume-screen 10/width, 5/height - 306 e:&:editor <- new-editor [ abc], 0/left, 10/right - 307 editor-render screen, e + 306 e:&:editor <- new-editor [ abc], 0/left, 10/right + 307 editor-render screen, e 308 # new line 309 assume-console [ 310 left-click 1, 8 311 press enter 312 ] - 313 editor-event-loop screen, console, e + 313 editor-event-loop screen, console, e 314 screen-should-contain [ 315 . . 316 . abc . @@ -389,7 +389,7 @@ if ('onhashchange' in window) { 330 press ctrl-z 331 ] 332 run [ - 333 editor-event-loop screen, console, e + 333 editor-event-loop screen, console, e 334 ] 335 3:num/raw <- get *e, cursor-row:offset 336 4:num/raw <- get *e, cursor-column:offset @@ -409,7 +409,7 @@ if ('onhashchange' in window) { 350 type [1] 351 ] 352 run [ - 353 editor-event-loop screen, console, e + 353 editor-event-loop screen, console, e 354 ] 355 screen-should-contain [ 356 . . @@ -425,13 +425,13 @@ if ('onhashchange' in window) { 366 local-scope 367 # create an editor, type something, undo 368 assume-screen 10/width, 5/height - 369 e:&:editor <- new-editor [a], 0/left, 10/right - 370 editor-render screen, e + 369 e:&:editor <- new-editor [a], 0/left, 10/right + 370 editor-render screen, e 371 assume-console [ 372 type [012] 373 press ctrl-z 374 ] - 375 editor-event-loop screen, console, e + 375 editor-event-loop screen, console, e 376 screen-should-contain [ 377 . . 378 .a . @@ -443,7 +443,7 @@ if ('onhashchange' in window) { 384 press ctrl-y 385 ] 386 run [ - 387 editor-event-loop screen, console, e + 387 editor-event-loop screen, console, e 388 ] 389 # all characters must be back 390 screen-should-contain [ @@ -457,7 +457,7 @@ if ('onhashchange' in window) { 398 type [3] 399 ] 400 run [ - 401 editor-event-loop screen, console, e + 401 editor-event-loop screen, console, e 402 ] 403 screen-should-contain [ 404 . . @@ -469,12 +469,12 @@ if ('onhashchange' in window) { 410 411 after <handle-redo> [ 412 { - 413 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant + 413 typing:insert-operation, is-insert?:bool <- maybe-convert *op, typing:variant 414 break-unless is-insert? 415 before-cursor <- get *editor, before-cursor:offset 416 insert-from:&:duplex-list:char <- get typing, insert-from:offset # ignore insert-to because it's already been spliced away 417 # assert insert-to matches next(before-cursor) - 418 insert-range before-cursor, insert-from + 418 insert-range before-cursor, insert-from 419 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 420 cursor-row <- get typing, after-row:offset 421 *editor <- put *editor, cursor-row:offset, cursor-row @@ -489,13 +489,13 @@ if ('onhashchange' in window) { 430 local-scope 431 # create an editor, type something, undo 432 assume-screen 10/width, 5/height - 433 e:&:editor <- new-editor [], 0/left, 10/right - 434 editor-render screen, e + 433 e:&:editor <- new-editor [], 0/left, 10/right + 434 editor-render screen, e 435 assume-console [ 436 type [012] 437 press ctrl-z 438 ] - 439 editor-event-loop screen, console, e + 439 editor-event-loop screen, console, e 440 screen-should-contain [ 441 . . 442 . . @@ -507,7 +507,7 @@ if ('onhashchange' in window) { 448 press ctrl-y 449 ] 450 run [ - 451 editor-event-loop screen, console, e + 451 editor-event-loop screen, console, e 452 ] 453 # all characters must be back 454 screen-should-contain [ @@ -521,7 +521,7 @@ if ('onhashchange' in window) { 462 type [3] 463 ] 464 run [ - 465 editor-event-loop screen, console, e + 465 editor-event-loop screen, console, e 466 ] 467 screen-should-contain [ 468 . . @@ -538,18 +538,18 @@ if ('onhashchange' in window) { 479 contents:text <- new [abc 480 def 481 ghi] - 482 e:&:editor <- new-editor contents, 0/left, 10/right - 483 editor-render screen, e + 482 e:&:editor <- new-editor contents, 0/left, 10/right + 483 editor-render screen, e 484 assume-console [ 485 type [1] 486 press ctrl-z 487 ] - 488 editor-event-loop screen, console, e + 488 editor-event-loop screen, console, e 489 # do some more work 490 assume-console [ 491 type [0] 492 ] - 493 editor-event-loop screen, console, e + 493 editor-event-loop screen, console, e 494 screen-should-contain [ 495 . . 496 .0abc . @@ -562,7 +562,7 @@ if ('onhashchange' in window) { 503 press ctrl-y 504 ] 505 run [ - 506 editor-event-loop screen, console, e + 506 editor-event-loop screen, console, e 507 ] 508 # nothing should happen 509 screen-should-contain [ @@ -578,8 +578,8 @@ if ('onhashchange' in window) { 519 local-scope 520 # create an editor 521 assume-screen 10/width, 5/height - 522 e:&:editor <- new-editor [], 0/left, 10/right - 523 editor-render screen, e + 522 e:&:editor <- new-editor [], 0/left, 10/right + 523 editor-render screen, e 524 # insert some text and tabs, hit enter, some more text and tabs 525 assume-console [ 526 press tab @@ -590,7 +590,7 @@ if ('onhashchange' in window) { 531 press tab 532 type [efg] 533 ] - 534 editor-event-loop screen, console, e + 534 editor-event-loop screen, console, e 535 screen-should-contain [ 536 . . 537 . ab cd . @@ -609,7 +609,7 @@ if ('onhashchange' in window) { 550 press ctrl-z 551 ] 552 run [ - 553 editor-event-loop screen, console, e + 553 editor-event-loop screen, console, e 554 ] 555 # typing in second line deleted, but not indent 556 3:num/raw <- get *e, cursor-row:offset @@ -630,7 +630,7 @@ if ('onhashchange' in window) { 571 press ctrl-z 572 ] 573 run [ - 574 editor-event-loop screen, console, e + 574 editor-event-loop screen, console, e 575 ] 576 # indent and newline deleted 577 3:num/raw <- get *e, cursor-row:offset @@ -650,7 +650,7 @@ if ('onhashchange' in window) { 591 press ctrl-z 592 ] 593 run [ - 594 editor-event-loop screen, console, e + 594 editor-event-loop screen, console, e 595 ] 596 # empty screen 597 3:num/raw <- get *e, cursor-row:offset @@ -670,7 +670,7 @@ if ('onhashchange' in window) { 611 press ctrl-y 612 ] 613 run [ - 614 editor-event-loop screen, console, e + 614 editor-event-loop screen, console, e 615 ] 616 # first line inserted 617 3:num/raw <- get *e, cursor-row:offset @@ -690,7 +690,7 @@ if ('onhashchange' in window) { 631 press ctrl-y 632 ] 633 run [ - 634 editor-event-loop screen, console, e + 634 editor-event-loop screen, console, e 635 ] 636 # newline and indent inserted 637 3:num/raw <- get *e, cursor-row:offset @@ -711,7 +711,7 @@ if ('onhashchange' in window) { 652 press ctrl-y 653 ] 654 run [ - 655 editor-event-loop screen, console, e + 655 editor-event-loop screen, console, e 656 ] 657 # indent and newline deleted 658 3:num/raw <- get *e, cursor-row:offset @@ -738,19 +738,19 @@ if ('onhashchange' in window) { 679 contents:text <- new [abc 680 def 681 ghi] - 682 e:&:editor <- new-editor contents, 0/left, 10/right - 683 editor-render screen, e + 682 e:&:editor <- new-editor contents, 0/left, 10/right + 683 editor-render screen, e 684 # move the cursor 685 assume-console [ 686 left-click 3, 1 687 ] - 688 editor-event-loop screen, console, e + 688 editor-event-loop screen, console, e 689 # undo 690 assume-console [ 691 press ctrl-z 692 ] 693 run [ - 694 editor-event-loop screen, console, e + 694 editor-event-loop screen, console, e 695 ] 696 # click undone 697 3:num/raw <- get *e, cursor-row:offset @@ -764,7 +764,7 @@ if ('onhashchange' in window) { 705 type [1] 706 ] 707 run [ - 708 editor-event-loop screen, console, e + 708 editor-event-loop screen, console, e 709 ] 710 screen-should-contain [ 711 . . @@ -788,10 +788,10 @@ if ('onhashchange' in window) { 729 break-unless undo-coalesce-tag 730 # if previous operation was also a move, and also had the same coalesce 731 # tag, coalesce with it - 732 undo:&:list:&:operation <- get *editor, undo:offset + 732 undo:&:list:&:operation <- get *editor, undo:offset 733 break-unless undo - 734 op:&:operation <- first undo - 735 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant + 734 op:&:operation <- first undo + 735 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant 736 break-unless is-move? 737 previous-coalesce-tag:num <- get move, tag:offset 738 coalesce?:bool <- equal undo-coalesce-tag, previous-coalesce-tag @@ -802,15 +802,15 @@ if ('onhashchange' in window) { 743 *op <- merge 1/move-operation, move 744 break +done-adding-move-operation 745 } - 746 op:&:operation <- new operation:type + 746 op:&:operation <- new operation:type 747 *op <- merge 1/move-operation, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag - 748 editor <- add-operation editor, op + 748 editor <- add-operation editor, op 749 +done-adding-move-operation 750 ] 751 752 after <handle-undo> [ 753 { - 754 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant + 754 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant 755 break-unless is-move? 756 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 757 cursor-row <- get move, before-row:offset @@ -830,13 +830,13 @@ if ('onhashchange' in window) { 771 contents:text <- new [a 772 b 773 cdefgh] - 774 e:&:editor <- new-editor contents, 0/left, 5/right + 774 e:&:editor <- new-editor contents, 0/left, 5/right 775 # position cursor at end of screen and try to move right 776 assume-console [ 777 left-click 3, 3 778 press right-arrow 779 ] - 780 editor-event-loop screen, console, e + 780 editor-event-loop screen, console, e 781 3:num/raw <- get *e, cursor-row:offset 782 4:num/raw <- get *e, cursor-column:offset 783 # screen scrolls @@ -855,7 +855,7 @@ if ('onhashchange' in window) { 796 press ctrl-z 797 ] 798 run [ - 799 editor-event-loop screen, console, e + 799 editor-event-loop screen, console, e 800 ] 801 # cursor moved back 802 3:num/raw <- get *e, cursor-row:offset @@ -876,7 +876,7 @@ if ('onhashchange' in window) { 817 type [1] 818 ] 819 run [ - 820 editor-event-loop screen, console, e + 820 editor-event-loop screen, console, e 821 ] 822 screen-should-contain [ 823 . . @@ -893,20 +893,20 @@ if ('onhashchange' in window) { 834 contents:text <- new [abc 835 def 836 ghi] - 837 e:&:editor <- new-editor contents, 0/left, 10/right - 838 editor-render screen, e + 837 e:&:editor <- new-editor contents, 0/left, 10/right + 838 editor-render screen, e 839 # move the cursor 840 assume-console [ 841 left-click 3, 1 842 press left-arrow 843 ] - 844 editor-event-loop screen, console, e + 844 editor-event-loop screen, console, e 845 # undo 846 assume-console [ 847 press ctrl-z 848 ] 849 run [ - 850 editor-event-loop screen, console, e + 850 editor-event-loop screen, console, e 851 ] 852 # cursor moves back 853 3:num/raw <- get *e, cursor-row:offset @@ -920,7 +920,7 @@ if ('onhashchange' in window) { 861 type [1] 862 ] 863 run [ - 864 editor-event-loop screen, console, e + 864 editor-event-loop screen, console, e 865 ] 866 screen-should-contain [ 867 . . @@ -938,14 +938,14 @@ if ('onhashchange' in window) { 879 contents:text <- new [abc 880 def 881 ghi] - 882 e:&:editor <- new-editor contents, 0/left, 10/right - 883 editor-render screen, e + 882 e:&:editor <- new-editor contents, 0/left, 10/right + 883 editor-render screen, e 884 # move the cursor 885 assume-console [ 886 left-click 3, 1 887 press up-arrow 888 ] - 889 editor-event-loop screen, console, e + 889 editor-event-loop screen, console, e 890 3:num/raw <- get *e, cursor-row:offset 891 4:num/raw <- get *e, cursor-column:offset 892 memory-should-contain [ @@ -957,7 +957,7 @@ if ('onhashchange' in window) { 898 press ctrl-z 899 ] 900 run [ - 901 editor-event-loop screen, console, e + 901 editor-event-loop screen, console, e 902 ] 903 # cursor moves back 904 3:num/raw <- get *e, cursor-row:offset @@ -971,7 +971,7 @@ if ('onhashchange' in window) { 912 type [1] 913 ] 914 run [ - 915 editor-event-loop screen, console, e + 915 editor-event-loop screen, console, e 916 ] 917 screen-should-contain [ 918 . . @@ -989,20 +989,20 @@ if ('onhashchange' in window) { 930 contents:text <- new [abc 931 def 932 ghi] - 933 e:&:editor <- new-editor contents, 0/left, 10/right - 934 editor-render screen, e + 933 e:&:editor <- new-editor contents, 0/left, 10/right + 934 editor-render screen, e 935 # move the cursor 936 assume-console [ 937 left-click 2, 1 938 press down-arrow 939 ] - 940 editor-event-loop screen, console, e + 940 editor-event-loop screen, console, e 941 # undo 942 assume-console [ 943 press ctrl-z 944 ] 945 run [ - 946 editor-event-loop screen, console, e + 946 editor-event-loop screen, console, e 947 ] 948 # cursor moves back 949 3:num/raw <- get *e, cursor-row:offset @@ -1016,7 +1016,7 @@ if ('onhashchange' in window) { 957 type [1] 958 ] 959 run [ - 960 editor-event-loop screen, console, e + 960 editor-event-loop screen, console, e 961 ] 962 screen-should-contain [ 963 . . @@ -1037,19 +1037,19 @@ if ('onhashchange' in window) { 978 d 979 e 980 f] - 981 e:&:editor <- new-editor contents, 0/left, 10/right - 982 editor-render screen, e + 981 e:&:editor <- new-editor contents, 0/left, 10/right + 982 editor-render screen, e 983 # scroll the page 984 assume-console [ 985 press ctrl-f 986 ] - 987 editor-event-loop screen, console, e + 987 editor-event-loop screen, console, e 988 # undo 989 assume-console [ 990 press ctrl-z 991 ] 992 run [ - 993 editor-event-loop screen, console, e + 993 editor-event-loop screen, console, e 994 ] 995 # screen should again show page 1 996 screen-should-contain [ @@ -1071,19 +1071,19 @@ if ('onhashchange' in window) { 1012 d 1013 e 1014 f] -1015 e:&:editor <- new-editor contents, 0/left, 10/right -1016 editor-render screen, e +1015 e:&:editor <- new-editor contents, 0/left, 10/right +1016 editor-render screen, e 1017 # scroll the page 1018 assume-console [ -1019 press page-down +1019 press page-down 1020 ] -1021 editor-event-loop screen, console, e +1021 editor-event-loop screen, console, e 1022 # undo 1023 assume-console [ 1024 press ctrl-z 1025 ] 1026 run [ -1027 editor-event-loop screen, console, e +1027 editor-event-loop screen, console, e 1028 ] 1029 # screen should again show page 1 1030 screen-should-contain [ @@ -1105,20 +1105,20 @@ if ('onhashchange' in window) { 1046 d 1047 e 1048 f] -1049 e:&:editor <- new-editor contents, 0/left, 10/right -1050 editor-render screen, e +1049 e:&:editor <- new-editor contents, 0/left, 10/right +1050 editor-render screen, e 1051 # scroll the page down and up 1052 assume-console [ -1053 press page-down +1053 press page-down 1054 press ctrl-b 1055 ] -1056 editor-event-loop screen, console, e +1056 editor-event-loop screen, console, e 1057 # undo 1058 assume-console [ 1059 press ctrl-z 1060 ] 1061 run [ -1062 editor-event-loop screen, console, e +1062 editor-event-loop screen, console, e 1063 ] 1064 # screen should again show page 2 1065 screen-should-contain [ @@ -1140,20 +1140,20 @@ if ('onhashchange' in window) { 1081 d 1082 e 1083 f] -1084 e:&:editor <- new-editor contents, 0/left, 10/right -1085 editor-render screen, e +1084 e:&:editor <- new-editor contents, 0/left, 10/right +1085 editor-render screen, e 1086 # scroll the page down and up 1087 assume-console [ -1088 press page-down -1089 press page-up +1088 press page-down +1089 press page-up 1090 ] -1091 editor-event-loop screen, console, e +1091 editor-event-loop screen, console, e 1092 # undo 1093 assume-console [ 1094 press ctrl-z 1095 ] 1096 run [ -1097 editor-event-loop screen, console, e +1097 editor-event-loop screen, console, e 1098 ] 1099 # screen should again show page 2 1100 screen-should-contain [ @@ -1172,20 +1172,20 @@ if ('onhashchange' in window) { 1113 contents:text <- new [abc 1114 def 1115 ghi] -1116 e:&:editor <- new-editor contents, 0/left, 10/right -1117 editor-render screen, e +1116 e:&:editor <- new-editor contents, 0/left, 10/right +1117 editor-render screen, e 1118 # move the cursor, then to start of line 1119 assume-console [ 1120 left-click 2, 1 1121 press ctrl-a 1122 ] -1123 editor-event-loop screen, console, e +1123 editor-event-loop screen, console, e 1124 # undo 1125 assume-console [ 1126 press ctrl-z 1127 ] 1128 run [ -1129 editor-event-loop screen, console, e +1129 editor-event-loop screen, console, e 1130 ] 1131 # cursor moves back 1132 3:num/raw <- get *e, cursor-row:offset @@ -1199,7 +1199,7 @@ if ('onhashchange' in window) { 1140 type [1] 1141 ] 1142 run [ -1143 editor-event-loop screen, console, e +1143 editor-event-loop screen, console, e 1144 ] 1145 screen-should-contain [ 1146 . . @@ -1217,20 +1217,20 @@ if ('onhashchange' in window) { 1158 contents:text <- new [abc 1159 def 1160 ghi] -1161 e:&:editor <- new-editor contents, 0/left, 10/right -1162 editor-render screen, e +1161 e:&:editor <- new-editor contents, 0/left, 10/right +1162 editor-render screen, e 1163 # move the cursor, then to start of line 1164 assume-console [ 1165 left-click 2, 1 1166 press home 1167 ] -1168 editor-event-loop screen, console, e +1168 editor-event-loop screen, console, e 1169 # undo 1170 assume-console [ 1171 press ctrl-z 1172 ] 1173 run [ -1174 editor-event-loop screen, console, e +1174 editor-event-loop screen, console, e 1175 ] 1176 # cursor moves back 1177 3:num/raw <- get *e, cursor-row:offset @@ -1244,7 +1244,7 @@ if ('onhashchange' in window) { 1185 type [1] 1186 ] 1187 run [ -1188 editor-event-loop screen, console, e +1188 editor-event-loop screen, console, e 1189 ] 1190 screen-should-contain [ 1191 . . @@ -1262,20 +1262,20 @@ if ('onhashchange' in window) { 1203 contents:text <- new [abc 1204 def 1205 ghi] -1206 e:&:editor <- new-editor contents, 0/left, 10/right -1207 editor-render screen, e +1206 e:&:editor <- new-editor contents, 0/left, 10/right +1207 editor-render screen, e 1208 # move the cursor, then to start of line 1209 assume-console [ 1210 left-click 2, 1 1211 press ctrl-e 1212 ] -1213 editor-event-loop screen, console, e +1213 editor-event-loop screen, console, e 1214 # undo 1215 assume-console [ 1216 press ctrl-z 1217 ] 1218 run [ -1219 editor-event-loop screen, console, e +1219 editor-event-loop screen, console, e 1220 ] 1221 # cursor moves back 1222 3:num/raw <- get *e, cursor-row:offset @@ -1289,7 +1289,7 @@ if ('onhashchange' in window) { 1230 type [1] 1231 ] 1232 run [ -1233 editor-event-loop screen, console, e +1233 editor-event-loop screen, console, e 1234 ] 1235 screen-should-contain [ 1236 . . @@ -1307,20 +1307,20 @@ if ('onhashchange' in window) { 1248 contents:text <- new [abc 1249 def 1250 ghi] -1251 e:&:editor <- new-editor contents, 0/left, 10/right -1252 editor-render screen, e +1251 e:&:editor <- new-editor contents, 0/left, 10/right +1252 editor-render screen, e 1253 # move the cursor, then to start of line 1254 assume-console [ 1255 left-click 2, 1 1256 press end 1257 ] -1258 editor-event-loop screen, console, e +1258 editor-event-loop screen, console, e 1259 # undo 1260 assume-console [ 1261 press ctrl-z 1262 ] 1263 run [ -1264 editor-event-loop screen, console, e +1264 editor-event-loop screen, console, e 1265 ] 1266 # cursor moves back 1267 3:num/raw <- get *e, cursor-row:offset @@ -1334,7 +1334,7 @@ if ('onhashchange' in window) { 1275 type [1] 1276 ] 1277 run [ -1278 editor-event-loop screen, console, e +1278 editor-event-loop screen, console, e 1279 ] 1280 screen-should-contain [ 1281 . . @@ -1352,8 +1352,8 @@ if ('onhashchange' in window) { 1293 contents:text <- new [abc 1294 def 1295 ghi] -1296 e:&:editor <- new-editor contents, 0/left, 10/right -1297 editor-render screen, e +1296 e:&:editor <- new-editor contents, 0/left, 10/right +1297 editor-render screen, e 1298 # move the cursor 1299 assume-console [ 1300 left-click 2, 1 @@ -1361,7 +1361,7 @@ if ('onhashchange' in window) { 1302 press right-arrow 1303 press up-arrow 1304 ] -1305 editor-event-loop screen, console, e +1305 editor-event-loop screen, console, e 1306 3:num/raw <- get *e, cursor-row:offset 1307 4:num/raw <- get *e, cursor-column:offset 1308 memory-should-contain [ @@ -1373,7 +1373,7 @@ if ('onhashchange' in window) { 1314 press ctrl-z 1315 ] 1316 run [ -1317 editor-event-loop screen, console, e +1317 editor-event-loop screen, console, e 1318 ] 1319 # up-arrow is undone 1320 3:num/raw <- get *e, cursor-row:offset @@ -1387,7 +1387,7 @@ if ('onhashchange' in window) { 1328 press ctrl-z 1329 ] 1330 run [ -1331 editor-event-loop screen, console, e +1331 editor-event-loop screen, console, e 1332 ] 1333 # both right-arrows are undone 1334 3:num/raw <- get *e, cursor-row:offset @@ -1407,19 +1407,19 @@ if ('onhashchange' in window) { 1348 contents:text <- new [abc 1349 def 1350 ghi] -1351 e:&:editor <- new-editor contents, 0/left, 10/right -1352 editor-render screen, e +1351 e:&:editor <- new-editor contents, 0/left, 10/right +1352 editor-render screen, e 1353 assume-console [ 1354 left-click 3, 1 1355 press ctrl-z 1356 ] -1357 editor-event-loop screen, console, e +1357 editor-event-loop screen, console, e 1358 # redo 1359 assume-console [ 1360 press ctrl-y 1361 ] 1362 run [ -1363 editor-event-loop screen, console, e +1363 editor-event-loop screen, console, e 1364 ] 1365 # cursor moves to left-click 1366 3:num/raw <- get *e, cursor-row:offset @@ -1433,7 +1433,7 @@ if ('onhashchange' in window) { 1374 type [1] 1375 ] 1376 run [ -1377 editor-event-loop screen, console, e +1377 editor-event-loop screen, console, e 1378 ] 1379 screen-should-contain [ 1380 . . @@ -1446,7 +1446,7 @@ if ('onhashchange' in window) { 1387 1388 after <handle-redo> [ 1389 { -1390 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant +1390 move:move-operation, is-move?:bool <- maybe-convert *op, move:variant 1391 break-unless is-move? 1392 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1393 cursor-row <- get move, after-row:offset @@ -1462,14 +1462,14 @@ if ('onhashchange' in window) { 1403 local-scope 1404 # create an editor, type some text, move the cursor, type some more text 1405 assume-screen 10/width, 5/height -1406 e:&:editor <- new-editor [], 0/left, 10/right -1407 editor-render screen, e +1406 e:&:editor <- new-editor [], 0/left, 10/right +1407 editor-render screen, e 1408 assume-console [ 1409 type [abc] 1410 left-click 1, 1 1411 type [d] 1412 ] -1413 editor-event-loop screen, console, e +1413 editor-event-loop screen, console, e 1414 3:num/raw <- get *e, cursor-row:offset 1415 4:num/raw <- get *e, cursor-column:offset 1416 screen-should-contain [ @@ -1487,7 +1487,7 @@ if ('onhashchange' in window) { 1428 press ctrl-z 1429 ] 1430 run [ -1431 editor-event-loop screen, console, e +1431 editor-event-loop screen, console, e 1432 3:num/raw <- get *e, cursor-row:offset 1433 4:num/raw <- get *e, cursor-column:offset 1434 ] @@ -1507,7 +1507,7 @@ if ('onhashchange' in window) { 1448 press ctrl-z 1449 ] 1450 run [ -1451 editor-event-loop screen, console, e +1451 editor-event-loop screen, console, e 1452 3:num/raw <- get *e, cursor-row:offset 1453 4:num/raw <- get *e, cursor-column:offset 1454 ] @@ -1527,7 +1527,7 @@ if ('onhashchange' in window) { 1468 press ctrl-z 1469 ] 1470 run [ -1471 editor-event-loop screen, console, e +1471 editor-event-loop screen, console, e 1472 3:num/raw <- get *e, cursor-row:offset 1473 4:num/raw <- get *e, cursor-column:offset 1474 ] @@ -1547,7 +1547,7 @@ if ('onhashchange' in window) { 1488 press ctrl-y 1489 ] 1490 run [ -1491 editor-event-loop screen, console, e +1491 editor-event-loop screen, console, e 1492 3:num/raw <- get *e, cursor-row:offset 1493 4:num/raw <- get *e, cursor-column:offset 1494 ] @@ -1567,7 +1567,7 @@ if ('onhashchange' in window) { 1508 press ctrl-y 1509 ] 1510 run [ -1511 editor-event-loop screen, console, e +1511 editor-event-loop screen, console, e 1512 3:num/raw <- get *e, cursor-row:offset 1513 4:num/raw <- get *e, cursor-column:offset 1514 ] @@ -1588,7 +1588,7 @@ if ('onhashchange' in window) { 1529 press ctrl-y 1530 ] 1531 run [ -1532 editor-event-loop screen, console, e +1532 editor-event-loop screen, console, e 1533 3:num/raw <- get *e, cursor-row:offset 1534 4:num/raw <- get *e, cursor-column:offset 1535 ] @@ -1611,15 +1611,15 @@ if ('onhashchange' in window) { 1552 local-scope 1553 # create an editor 1554 assume-screen 10/width, 5/height -1555 e:&:editor <- new-editor [], 0/left, 10/right -1556 editor-render screen, e +1555 e:&:editor <- new-editor [], 0/left, 10/right +1556 editor-render screen, e 1557 # insert some text and hit backspace 1558 assume-console [ 1559 type [abc] 1560 press backspace 1561 press backspace 1562 ] -1563 editor-event-loop screen, console, e +1563 editor-event-loop screen, console, e 1564 screen-should-contain [ 1565 . . 1566 .a . @@ -1637,7 +1637,7 @@ if ('onhashchange' in window) { 1578 press ctrl-z 1579 ] 1580 run [ -1581 editor-event-loop screen, console, e +1581 editor-event-loop screen, console, e 1582 ] 1583 3:num/raw <- get *e, cursor-row:offset 1584 4:num/raw <- get *e, cursor-column:offset @@ -1656,7 +1656,7 @@ if ('onhashchange' in window) { 1597 press ctrl-y 1598 ] 1599 run [ -1600 editor-event-loop screen, console, e +1600 editor-event-loop screen, console, e 1601 ] 1602 3:num/raw <- get *e, cursor-row:offset 1603 4:num/raw <- get *e, cursor-column:offset @@ -1683,19 +1683,19 @@ if ('onhashchange' in window) { 1624 cursor-row:num <- get *editor, cursor-row:offset 1625 cursor-column:num <- get *editor, cursor-row:offset 1626 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1627 undo:&:list:&:operation <- get *editor, undo:offset +1627 undo:&:list:&:operation <- get *editor, undo:offset 1628 { 1629 # if previous operation was an insert, coalesce this operation with it 1630 break-unless undo -1631 op:&:operation <- first undo -1632 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1631 op:&:operation <- first undo +1632 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1633 break-unless is-delete? 1634 previous-coalesce-tag:num <- get deletion, tag:offset 1635 coalesce?:bool <- equal previous-coalesce-tag, 1/coalesce-backspace 1636 break-unless coalesce? 1637 deletion <- put deletion, delete-from:offset, before-cursor 1638 backspaced-so-far:&:duplex-list:char <- get deletion, deleted-text:offset -1639 insert-range backspaced-cell, backspaced-so-far +1639 insert-range backspaced-cell, backspaced-so-far 1640 deletion <- put deletion, deleted-text:offset, backspaced-cell 1641 deletion <- put deletion, after-row:offset, cursor-row 1642 deletion <- put deletion, after-column:offset, cursor-column @@ -1704,23 +1704,23 @@ if ('onhashchange' in window) { 1645 break +done-adding-backspace-operation 1646 } 1647 # if not, create a new operation -1648 op:&:operation <- new operation:type -1649 deleted-until:&:duplex-list:char <- next before-cursor +1648 op:&:operation <- new operation:type +1649 deleted-until:&:duplex-list:char <- next before-cursor 1650 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, backspaced-cell/deleted, before-cursor/delete-from, deleted-until, 1/coalesce-backspace -1651 editor <- add-operation editor, op +1651 editor <- add-operation editor, op 1652 +done-adding-backspace-operation 1653 } 1654 ] 1655 1656 after <handle-undo> [ 1657 { -1658 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1658 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1659 break-unless is-delete? 1660 anchor:&:duplex-list:char <- get deletion, delete-from:offset 1661 break-unless anchor 1662 deleted:&:duplex-list:char <- get deletion, deleted-text:offset -1663 old-cursor:&:duplex-list:char <- last deleted -1664 insert-range anchor, deleted +1663 old-cursor:&:duplex-list:char <- last deleted +1664 insert-range anchor, deleted 1665 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1666 before-cursor <- copy old-cursor 1667 cursor-row <- get deletion, before-row:offset @@ -1734,12 +1734,12 @@ if ('onhashchange' in window) { 1675 1676 after <handle-redo> [ 1677 { -1678 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1678 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1679 break-unless is-delete? 1680 start:&:duplex-list:char <- get deletion, delete-from:offset 1681 end:&:duplex-list:char <- get deletion, delete-until:offset 1682 data:&:duplex-list:char <- get *editor, data:offset -1683 remove-between start, end +1683 remove-between start, end 1684 # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen 1685 cursor-row <- get deletion, after-row:offset 1686 *editor <- put *editor, cursor-row:offset, cursor-row @@ -1756,8 +1756,8 @@ if ('onhashchange' in window) { 1697 local-scope 1698 # create an editor 1699 assume-screen 10/width, 5/height -1700 e:&:editor <- new-editor [], 0/left, 10/right -1701 editor-render screen, e +1700 e:&:editor <- new-editor [], 0/left, 10/right +1701 editor-render screen, e 1702 # insert some text and hit delete and backspace a few times 1703 assume-console [ 1704 type [abcdef] @@ -1767,7 +1767,7 @@ if ('onhashchange' in window) { 1708 press delete 1709 press delete 1710 ] -1711 editor-event-loop screen, console, e +1711 editor-event-loop screen, console, e 1712 screen-should-contain [ 1713 . . 1714 .af . @@ -1785,7 +1785,7 @@ if ('onhashchange' in window) { 1726 press ctrl-z 1727 ] 1728 run [ -1729 editor-event-loop screen, console, e +1729 editor-event-loop screen, console, e 1730 ] 1731 3:num/raw <- get *e, cursor-row:offset 1732 4:num/raw <- get *e, cursor-column:offset @@ -1804,7 +1804,7 @@ if ('onhashchange' in window) { 1745 press ctrl-z 1746 ] 1747 run [ -1748 editor-event-loop screen, console, e +1748 editor-event-loop screen, console, e 1749 ] 1750 3:num/raw <- get *e, cursor-row:offset 1751 4:num/raw <- get *e, cursor-column:offset @@ -1823,7 +1823,7 @@ if ('onhashchange' in window) { 1764 press ctrl-z 1765 ] 1766 run [ -1767 editor-event-loop screen, console, e +1767 editor-event-loop screen, console, e 1768 ] 1769 3:num/raw <- get *e, cursor-row:offset 1770 4:num/raw <- get *e, cursor-column:offset @@ -1842,7 +1842,7 @@ if ('onhashchange' in window) { 1783 press ctrl-y 1784 ] 1785 run [ -1786 editor-event-loop screen, console, e +1786 editor-event-loop screen, console, e 1787 ] 1788 # first line inserted 1789 3:num/raw <- get *e, cursor-row:offset @@ -1862,7 +1862,7 @@ if ('onhashchange' in window) { 1803 press ctrl-y 1804 ] 1805 run [ -1806 editor-event-loop screen, console, e +1806 editor-event-loop screen, console, e 1807 ] 1808 # first line inserted 1809 3:num/raw <- get *e, cursor-row:offset @@ -1882,7 +1882,7 @@ if ('onhashchange' in window) { 1823 press ctrl-y 1824 ] 1825 run [ -1826 editor-event-loop screen, console, e +1826 editor-event-loop screen, console, e 1827 ] 1828 # first line inserted 1829 3:num/raw <- get *e, cursor-row:offset @@ -1909,17 +1909,17 @@ if ('onhashchange' in window) { 1850 cursor-row:num <- get *editor, cursor-row:offset 1851 cursor-column:num <- get *editor, cursor-column:offset 1852 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -1853 undo:&:list:&:operation <- get *editor, undo:offset +1853 undo:&:list:&:operation <- get *editor, undo:offset 1854 { 1855 # if previous operation was an insert, coalesce this operation with it 1856 break-unless undo -1857 op:&:operation <- first undo -1858 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant +1857 op:&:operation <- first undo +1858 deletion:delete-operation, is-delete?:bool <- maybe-convert *op, delete:variant 1859 break-unless is-delete? 1860 previous-coalesce-tag:num <- get deletion, tag:offset 1861 coalesce?:bool <- equal previous-coalesce-tag, 2/coalesce-delete 1862 break-unless coalesce? -1863 delete-until:&:duplex-list:char <- next before-cursor +1863 delete-until:&:duplex-list:char <- next before-cursor 1864 deletion <- put deletion, delete-until:offset, delete-until 1865 deleted-so-far:&:duplex-list:char <- get deletion, deleted-text:offset 1866 deleted-so-far <- append deleted-so-far, deleted-cell @@ -1931,10 +1931,10 @@ if ('onhashchange' in window) { 1872 break +done-adding-delete-operation 1873 } 1874 # if not, create a new operation -1875 op:&:operation <- new operation:type -1876 deleted-until:&:duplex-list:char <- next before-cursor +1875 op:&:operation <- new operation:type +1876 deleted-until:&:duplex-list:char <- next before-cursor 1877 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cell/deleted, before-cursor/delete-from, deleted-until, 2/coalesce-delete -1878 editor <- add-operation editor, op +1878 editor <- add-operation editor, op 1879 +done-adding-delete-operation 1880 } 1881 ] @@ -1947,14 +1947,14 @@ if ('onhashchange' in window) { 1888 assume-screen 10/width, 5/height 1889 contents:text <- new [abc 1890 def] -1891 e:&:editor <- new-editor contents, 0/left, 10/right -1892 editor-render screen, e +1891 e:&:editor <- new-editor contents, 0/left, 10/right +1892 editor-render screen, e 1893 # insert some text and hit delete and backspace a few times 1894 assume-console [ 1895 left-click 1, 1 1896 press ctrl-k 1897 ] -1898 editor-event-loop screen, console, e +1898 editor-event-loop screen, console, e 1899 screen-should-contain [ 1900 . . 1901 .a . @@ -1973,7 +1973,7 @@ if ('onhashchange' in window) { 1914 press ctrl-z 1915 ] 1916 run [ -1917 editor-event-loop screen, console, e +1917 editor-event-loop screen, console, e 1918 ] 1919 screen-should-contain [ 1920 . . @@ -1993,7 +1993,7 @@ if ('onhashchange' in window) { 1934 press ctrl-y 1935 ] 1936 run [ -1937 editor-event-loop screen, console, e +1937 editor-event-loop screen, console, e 1938 ] 1939 # first line inserted 1940 screen-should-contain [ @@ -2014,7 +2014,7 @@ if ('onhashchange' in window) { 1955 type [1] 1956 ] 1957 run [ -1958 editor-event-loop screen, console, e +1958 editor-event-loop screen, console, e 1959 ] 1960 screen-should-contain [ 1961 . . @@ -2034,10 +2034,10 @@ if ('onhashchange' in window) { 1975 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset 1976 cursor-row:num <- get *editor, cursor-row:offset 1977 cursor-column:num <- get *editor, cursor-column:offset -1978 deleted-until:&:duplex-list:char <- next before-cursor -1979 op:&:operation <- new operation:type +1978 deleted-until:&:duplex-list:char <- next before-cursor +1979 op:&:operation <- new operation:type 1980 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce -1981 editor <- add-operation editor, op +1981 editor <- add-operation editor, op 1982 +done-adding-delete-operation 1983 } 1984 ] @@ -2050,14 +2050,14 @@ if ('onhashchange' in window) { 1991 assume-screen 10/width, 5/height 1992 contents:text <- new [abc 1993 def] -1994 e:&:editor <- new-editor contents, 0/left, 10/right -1995 editor-render screen, e +1994 e:&:editor <- new-editor contents, 0/left, 10/right +1995 editor-render screen, e 1996 # insert some text and hit delete and backspace a few times 1997 assume-console [ 1998 left-click 1, 2 1999 press ctrl-u 2000 ] -2001 editor-event-loop screen, console, e +2001 editor-event-loop screen, console, e 2002 screen-should-contain [ 2003 . . 2004 .c . @@ -2076,7 +2076,7 @@ if ('onhashchange' in window) { 2017 press ctrl-z 2018 ] 2019 run [ -2020 editor-event-loop screen, console, e +2020 editor-event-loop screen, console, e 2021 ] 2022 screen-should-contain [ 2023 . . @@ -2096,7 +2096,7 @@ if ('onhashchange' in window) { 2037 press ctrl-y 2038 ] 2039 run [ -2040 editor-event-loop screen, console, e +2040 editor-event-loop screen, console, e 2041 ] 2042 # first line inserted 2043 screen-should-contain [ @@ -2117,7 +2117,7 @@ if ('onhashchange' in window) { 2058 type [1] 2059 ] 2060 run [ -2061 editor-event-loop screen, console, e +2061 editor-event-loop screen, console, e 2062 ] 2063 screen-should-contain [ 2064 . . @@ -2135,13 +2135,13 @@ if ('onhashchange' in window) { 2076 { 2077 break-unless deleted-cells # delete failed; don't add an undo operation 2078 top-after:&:duplex-list:char <- get *editor, top-of-screen:offset -2079 op:&:operation <- new operation:type +2079 op:&:operation <- new operation:type 2080 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset -2081 deleted-until:&:duplex-list:char <- next before-cursor +2081 deleted-until:&:duplex-list:char <- next before-cursor 2082 cursor-row:num <- get *editor, cursor-row:offset 2083 cursor-column:num <- get *editor, cursor-column:offset 2084 *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, deleted-cells/deleted, before-cursor/delete-from, deleted-until, 0/never-coalesce -2085 editor <- add-operation editor, op +2085 editor <- add-operation editor, op 2086 +done-adding-delete-operation 2087 } 2088 ] @@ -2150,15 +2150,15 @@ if ('onhashchange' in window) { 2091 local-scope 2092 # create an editor 2093 assume-screen 10/width, 5/height -2094 e:&:editor <- new-editor [], 0/left, 10/right -2095 editor-render screen, e +2094 e:&:editor <- new-editor [], 0/left, 10/right +2095 editor-render screen, e 2096 # insert some text and hit delete and backspace a few times 2097 assume-console [ 2098 type [abc] 2099 press ctrl-u 2100 press ctrl-z 2101 ] -2102 editor-event-loop screen, console, e +2102 editor-event-loop screen, console, e 2103 screen-should-contain [ 2104 . . 2105 .abc . -- cgit 1.4.1-2-gfad0