From 9e751bb8c0cdf771d34c839cb6591d892b8e62de Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 7 Mar 2017 01:41:48 -0800 Subject: 3761 --- html/edit/001-editor.mu.html | 397 ++++++++++++++++++++++--------------------- 1 file changed, 199 insertions(+), 198 deletions(-) (limited to 'html/edit/001-editor.mu.html') diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index fc380b8d..1355cf75 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -15,16 +15,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color a { text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } -.muData { color: #ffff00; } -.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } .Special { color: #c00000; } +.Conceal { color: #4e4e4e; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } .Constant { color: #00a0a0; } .LineNr { color: #444444; } .Comment { color: #9090ff; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } +.muControl { color: #c0a020; } +.muData { color: #ffff00; } --> @@ -80,13 +81,13 @@ if ('onhashchange' in window) { 19 assume-screen 10/width, 5/height 20 e:&:editor <- new-editor [abc], 0/left, 10/right 21 run [ - 22 render screen, e + 22 ¦ render screen, e 23 ] 24 screen-should-contain [ - 25 # top line of screen reserved for menu - 26 . . - 27 .abc . - 28 . . + 25 ¦ # top line of screen reserved for menu + 26 ¦ . . + 27 ¦ .abc . + 28 ¦ . . 29 ] 30 ] 31 @@ -142,14 +143,14 @@ if ('onhashchange' in window) { 81 # now we can start appending the rest, character by character 82 curr:&:duplex-list:char <- get *editor, data:offset 83 { - 84 done?:bool <- greater-or-equal idx, len - 85 break-if done? - 86 c:char <- index *text, idx - 87 insert c, curr - 88 # next iter - 89 curr <- next curr - 90 idx <- add idx, 1 - 91 loop + 84 ¦ done?:bool <- greater-or-equal idx, len + 85 ¦ break-if done? + 86 ¦ c:char <- index *text, idx + 87 ¦ insert c, curr + 88 ¦ # next iter + 89 ¦ curr <- next curr + 90 ¦ idx <- add idx, 1 + 91 ¦ loop 92 } 93 ] 94 @@ -157,24 +158,24 @@ if ('onhashchange' in window) { 96 local-scope 97 assume-screen 5/width, 3/height 98 run [ - 99 e:&:editor <- new-editor 0/data, 2/left, 5/right -100 2:editor/raw <- copy *e + 99 ¦ e:&:editor <- new-editor 0/data, 2/left, 5/right +100 ¦ 2:editor/raw <- copy *e 101 ] 102 memory-should-contain [ -103 # 2 (data) <- just the § sentinel -104 # 3 (top of screen) <- the § sentinel -105 4 <- 0 # bottom-of-screen; null since text fits on screen -106 # 5 (before cursor) <- the § sentinel -107 6 <- 2 # left -108 7 <- 4 # right (inclusive) -109 8 <- 0 # bottom (not set until render) -110 9 <- 1 # cursor row -111 10 <- 2 # cursor column +103 ¦ # 2 (data) <- just the § sentinel +104 ¦ # 3 (top of screen) <- the § sentinel +105 ¦ 4 <- 0 # bottom-of-screen; null since text fits on screen +106 ¦ # 5 (before cursor) <- the § sentinel +107 ¦ 6 <- 2 # left +108 ¦ 7 <- 4 # right (inclusive) +109 ¦ 8 <- 0 # bottom (not set until render) +110 ¦ 9 <- 1 # cursor row +111 ¦ 10 <- 2 # cursor column 112 ] 113 screen-should-contain [ -114 . . -115 . . -116 . . +114 ¦ . . +115 ¦ . . +116 ¦ . . 117 ] 118 ] 119 @@ -202,78 +203,78 @@ if ('onhashchange' in window) { 141 before-cursor:&:duplex-list:char <- get *editor, before-cursor:offset 142 screen <- move-cursor screen, row, column 143 { -144 +next-character -145 break-unless curr -146 off-screen?:bool <- greater-or-equal row, screen-height -147 break-if off-screen? -148 # update editor.before-cursor -149 # Doing so at the start of each iteration ensures it stays one step behind -150 # the current character. -151 { -152 at-cursor-row?:bool <- equal row, cursor-row -153 break-unless at-cursor-row? -154 at-cursor?:bool <- equal column, cursor-column -155 break-unless at-cursor? -156 before-cursor <- copy prev -157 } -158 c:char <- get *curr, value:offset -159 <character-c-received> -160 { -161 # newline? move to left rather than 0 -162 newline?:bool <- equal c, 10/newline -163 break-unless newline? -164 # adjust cursor if necessary -165 { -166 at-cursor-row?:bool <- equal row, cursor-row -167 break-unless at-cursor-row? -168 left-of-cursor?:bool <- lesser-than column, cursor-column -169 break-unless left-of-cursor? -170 cursor-column <- copy column -171 before-cursor <- prev curr -172 } -173 # clear rest of line in this window -174 clear-line-until screen, right -175 # skip to next line -176 row <- add row, 1 -177 column <- copy left -178 screen <- move-cursor screen, row, column -179 curr <- next curr -180 prev <- next prev -181 loop +next-character -182 } -183 { -184 # at right? wrap. even if there's only one more letter left; we need -185 # room for clicking on the cursor after it. -186 at-right?:bool <- equal column, right -187 break-unless at-right? -188 # print wrap icon -189 wrap-icon:char <- copy 8617/loop-back-to-left -190 print screen, wrap-icon, 245/grey -191 column <- copy left -192 row <- add row, 1 -193 screen <- move-cursor screen, row, column -194 # don't increment curr -195 loop +next-character -196 } -197 print screen, c, color -198 curr <- next curr -199 prev <- next prev -200 column <- add column, 1 -201 loop +144 ¦ +next-character +145 ¦ break-unless curr +146 ¦ off-screen?:bool <- greater-or-equal row, screen-height +147 ¦ break-if off-screen? +148 ¦ # update editor.before-cursor +149 ¦ # Doing so at the start of each iteration ensures it stays one step behind +150 ¦ # the current character. +151 ¦ { +152 ¦ ¦ at-cursor-row?:bool <- equal row, cursor-row +153 ¦ ¦ break-unless at-cursor-row? +154 ¦ ¦ at-cursor?:bool <- equal column, cursor-column +155 ¦ ¦ break-unless at-cursor? +156 ¦ ¦ before-cursor <- copy prev +157 ¦ } +158 ¦ c:char <- get *curr, value:offset +159 ¦ <character-c-received> +160 ¦ { +161 ¦ ¦ # newline? move to left rather than 0 +162 ¦ ¦ newline?:bool <- equal c, 10/newline +163 ¦ ¦ break-unless newline? +164 ¦ ¦ # adjust cursor if necessary +165 ¦ ¦ { +166 ¦ ¦ ¦ at-cursor-row?:bool <- equal row, cursor-row +167 ¦ ¦ ¦ break-unless at-cursor-row? +168 ¦ ¦ ¦ left-of-cursor?:bool <- lesser-than column, cursor-column +169 ¦ ¦ ¦ break-unless left-of-cursor? +170 ¦ ¦ ¦ cursor-column <- copy column +171 ¦ ¦ ¦ before-cursor <- prev curr +172 ¦ ¦ } +173 ¦ ¦ # clear rest of line in this window +174 ¦ ¦ clear-line-until screen, right +175 ¦ ¦ # skip to next line +176 ¦ ¦ row <- add row, 1 +177 ¦ ¦ column <- copy left +178 ¦ ¦ screen <- move-cursor screen, row, column +179 ¦ ¦ curr <- next curr +180 ¦ ¦ prev <- next prev +181 ¦ ¦ loop +next-character +182 ¦ } +183 ¦ { +184 ¦ ¦ # at right? wrap. even if there's only one more letter left; we need +185 ¦ ¦ # room for clicking on the cursor after it. +186 ¦ ¦ at-right?:bool <- equal column, right +187 ¦ ¦ break-unless at-right? +188 ¦ ¦ # print wrap icon +189 ¦ ¦ wrap-icon:char <- copy 8617/loop-back-to-left +190 ¦ ¦ print screen, wrap-icon, 245/grey +191 ¦ ¦ column <- copy left +192 ¦ ¦ row <- add row, 1 +193 ¦ ¦ screen <- move-cursor screen, row, column +194 ¦ ¦ # don't increment curr +195 ¦ ¦ loop +next-character +196 ¦ } +197 ¦ print screen, c, color +198 ¦ curr <- next curr +199 ¦ prev <- next prev +200 ¦ column <- add column, 1 +201 ¦ loop 202 } 203 # save first character off-screen 204 *editor <- put *editor, bottom-of-screen:offset, curr 205 # is cursor to the right of the last line? move to end 206 { -207 at-cursor-row?:bool <- equal row, cursor-row -208 cursor-outside-line?:bool <- lesser-or-equal column, cursor-column -209 before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line? -210 above-cursor-row?:bool <- lesser-than row, cursor-row -211 before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row? -212 break-unless before-cursor? -213 cursor-row <- copy row -214 cursor-column <- copy column -215 before-cursor <- copy prev +207 ¦ at-cursor-row?:bool <- equal row, cursor-row +208 ¦ cursor-outside-line?:bool <- lesser-or-equal column, cursor-column +209 ¦ before-cursor-on-same-line?:bool <- and at-cursor-row?, cursor-outside-line? +210 ¦ above-cursor-row?:bool <- lesser-than row, cursor-row +211 ¦ before-cursor?:bool <- or before-cursor-on-same-line?, above-cursor-row? +212 ¦ break-unless before-cursor? +213 ¦ cursor-row <- copy row +214 ¦ cursor-column <- copy column +215 ¦ before-cursor <- copy prev 216 } 217 *editor <- put *editor, bottom:offset, row 218 *editor <- put *editor, cursor-row:offset, cursor-row @@ -287,9 +288,9 @@ if ('onhashchange' in window) { 226 load-ingredients 227 # if it's the real screen, use the optimized primitive 228 { -229 break-if screen -230 clear-display-from row, column, left, right -231 return +229 ¦ break-if screen +230 ¦ clear-display-from row, column, left, right +231 ¦ return 232 } 233 # if not, go the slower route 234 screen <- move-cursor screen, row, column @@ -304,12 +305,12 @@ if ('onhashchange' in window) { 243 screen <- move-cursor screen, row, left 244 screen-height:num <- screen-height screen 245 { -246 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height -247 break-if at-bottom-of-screen? -248 screen <- move-cursor screen, row, left -249 clear-line-until screen, right -250 row <- add row, 1 -251 loop +246 ¦ at-bottom-of-screen?:bool <- greater-or-equal row, screen-height +247 ¦ break-if at-bottom-of-screen? +248 ¦ screen <- move-cursor screen, row, left +249 ¦ clear-line-until screen, right +250 ¦ row <- add row, 1 +251 ¦ loop 252 } 253 ] 254 @@ -320,13 +321,13 @@ if ('onhashchange' in window) { 259 def] 260 e:&:editor <- new-editor s, 0/left, 5/right 261 run [ -262 render screen, e +262 ¦ render screen, e 263 ] 264 screen-should-contain [ -265 . . -266 .abc . -267 .def . -268 . . +265 ¦ . . +266 ¦ .abc . +267 ¦ .def . +268 ¦ . . 269 ] 270 ] 271 @@ -335,12 +336,12 @@ if ('onhashchange' in window) { 274 assume-screen 5/width, 5/height 275 e:&:editor <- new-editor [abc], 1/left, 5/right 276 run [ -277 render screen, e +277 ¦ render screen, e 278 ] 279 screen-should-contain [ -280 . . -281 . abc . -282 . . +280 ¦ . . +281 ¦ . abc . +282 ¦ . . 283 ] 284 ] 285 @@ -351,13 +352,13 @@ if ('onhashchange' in window) { 290 def] 291 e:&:editor <- new-editor s, 1/left, 5/right 292 run [ -293 render screen, e +293 ¦ render screen, e 294 ] 295 screen-should-contain [ -296 . . -297 . abc . -298 . def . -299 . . +296 ¦ . . +297 ¦ . abc . +298 ¦ . def . +299 ¦ . . 300 ] 301 ] 302 @@ -366,19 +367,19 @@ if ('onhashchange' in window) { 305 assume-screen 5/width, 5/height 306 e:&:editor <- new-editor [abc def], 0/left, 5/right 307 run [ -308 render screen, e +308 ¦ render screen, e 309 ] 310 screen-should-contain [ -311 . . -312 .abc ↩. -313 .def . -314 . . +311 ¦ . . +312 ¦ .abc ↩. +313 ¦ .def . +314 ¦ . . 315 ] 316 screen-should-contain-in-color 245/grey [ -317 . . -318 . ↩. -319 . . -320 . . +317 ¦ . . +318 ¦ . ↩. +319 ¦ . . +320 ¦ . . 321 ] 322 ] 323 @@ -387,21 +388,21 @@ if ('onhashchange' in window) { 326 assume-screen 5/width, 5/height 327 e:&:editor <- new-editor [abcde], 0/left, 5/right 328 run [ -329 render screen, e +329 ¦ render screen, e 330 ] 331 # still wrap, even though the line would fit. We need room to click on the 332 # end of the line 333 screen-should-contain [ -334 . . -335 .abcd↩. -336 .e . -337 . . +334 ¦ . . +335 ¦ .abcd↩. +336 ¦ .e . +337 ¦ . . 338 ] 339 screen-should-contain-in-color 245/grey [ -340 . . -341 . ↩. -342 . . -343 . . +340 ¦ . . +341 ¦ . ↩. +342 ¦ . . +343 ¦ . . 344 ] 345 ] 346 @@ -410,18 +411,18 @@ if ('onhashchange' in window) { 349 assume-screen 5/width, 5/height 350 e:&:editor <- new-editor [], 0/left, 5/right 351 run [ -352 render screen, e -353 3:num/raw <- get *e, cursor-row:offset -354 4:num/raw <- get *e, cursor-column:offset +352 ¦ render screen, e +353 ¦ 3:num/raw <- get *e, cursor-row:offset +354 ¦ 4:num/raw <- get *e, cursor-column:offset 355 ] 356 screen-should-contain [ -357 . . -358 . . -359 . . +357 ¦ . . +358 ¦ . . +359 ¦ . . 360 ] 361 memory-should-contain [ -362 3 <- 1 # cursor row -363 4 <- 0 # cursor column +362 ¦ 3 <- 1 # cursor row +363 ¦ 4 <- 0 # cursor column 364 ] 365 ] 366 @@ -435,28 +436,28 @@ if ('onhashchange' in window) { 374 f] 375 e:&:editor <- new-editor s, 0/left, 5/right 376 run [ -377 render screen, e +377 ¦ render screen, e 378 ] 379 screen-should-contain [ -380 . . -381 .abc . -382 .# de . -383 .f . -384 . . +380 ¦ . . +381 ¦ .abc . +382 ¦ .# de . +383 ¦ .f . +384 ¦ . . 385 ] 386 screen-should-contain-in-color 12/lightblue, [ -387 . . -388 . . -389 .# de . -390 . . -391 . . +387 ¦ . . +388 ¦ . . +389 ¦ .# de . +390 ¦ . . +391 ¦ . . 392 ] 393 screen-should-contain-in-color 7/white, [ -394 . . -395 .abc . -396 . . -397 .f . -398 . . +394 ¦ . . +395 ¦ .abc . +396 ¦ . . +397 ¦ .f . +398 ¦ . . 399 ] 400 ] 401 @@ -471,39 +472,39 @@ if ('onhashchange' in window) { 410 color-is-white?:bool <- equal color, 7/white 411 # if color is white and next character is '#', switch color to blue 412 { -413 break-unless color-is-white? -414 starting-comment?:bool <- equal c, 35/# -415 break-unless starting-comment? -416 trace 90, [app], [switch color back to blue] -417 color <- copy 12/lightblue -418 jump +exit +413 ¦ break-unless color-is-white? +414 ¦ starting-comment?:bool <- equal c, 35/# +415 ¦ break-unless starting-comment? +416 ¦ trace 90, [app], [switch color back to blue] +417 ¦ color <- copy 12/lightblue +418 ¦ jump +exit 419 } 420 # if color is blue and next character is newline, switch color to white 421 { -422 color-is-blue?:bool <- equal color, 12/lightblue -423 break-unless color-is-blue? -424 ending-comment?:bool <- equal c, 10/newline -425 break-unless ending-comment? -426 trace 90, [app], [switch color back to white] -427 color <- copy 7/white -428 jump +exit +422 ¦ color-is-blue?:bool <- equal color, 12/lightblue +423 ¦ break-unless color-is-blue? +424 ¦ ending-comment?:bool <- equal c, 10/newline +425 ¦ break-unless ending-comment? +426 ¦ trace 90, [app], [switch color back to white] +427 ¦ color <- copy 7/white +428 ¦ jump +exit 429 } 430 # if color is white (no comments) and next character is '<', switch color to red 431 { -432 break-unless color-is-white? -433 starting-assignment?:bool <- equal c, 60/< -434 break-unless starting-assignment? -435 color <- copy 1/red -436 jump +exit +432 ¦ break-unless color-is-white? +433 ¦ starting-assignment?:bool <- equal c, 60/< +434 ¦ break-unless starting-assignment? +435 ¦ color <- copy 1/red +436 ¦ jump +exit 437 } 438 # if color is red and next character is space, switch color to white 439 { -440 color-is-red?:bool <- equal color, 1/red -441 break-unless color-is-red? -442 ending-assignment?:bool <- equal c, 32/space -443 break-unless ending-assignment? -444 color <- copy 7/white -445 jump +exit +440 ¦ color-is-red?:bool <- equal color, 1/red +441 ¦ break-unless color-is-red? +442 ¦ ending-assignment?:bool <- equal c, 32/space +443 ¦ break-unless ending-assignment? +444 ¦ color <- copy 7/white +445 ¦ jump +exit 446 } 447 # otherwise no change 448 +exit @@ -518,21 +519,21 @@ if ('onhashchange' in window) { 457 f] 458 e:&:editor <- new-editor s, 0/left, 8/right 459 run [ -460 render screen, e +460 ¦ render screen, e 461 ] 462 screen-should-contain [ -463 . . -464 .abc . -465 .d <- e . -466 .f . -467 . . +463 ¦ . . +464 ¦ .abc . +465 ¦ .d <- e . +466 ¦ .f . +467 ¦ . . 468 ] 469 screen-should-contain-in-color 1/red, [ -470 . . -471 . . -472 . <- . -473 . . -474 . . +470 ¦ . . +471 ¦ . . +472 ¦ . <- . +473 ¦ . . +474 ¦ . . 475 ] 476 ] -- cgit 1.4.1-2-gfad0