From 94ffc3776c8037416e4834eb5b94644587c18e10 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 18 Feb 2018 15:55:42 -0800 Subject: 4209 --- html/edit/001-editor.mu.html | 502 +++++++++++++++++++++---------------------- 1 file changed, 251 insertions(+), 251 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 34bac90e..ab509ba6 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -20,7 +20,6 @@ a:hover { text-decoration: underline; } .muScenario { color: #00af00; } .LineNr { color: #444444; } .Delimiter { color: #800080; } -.CommentedCode { color: #6c6c6c; } .Constant { color: #00a0a0; } .Special { color: #c00000; } .muData { color: #ffff00; } @@ -264,264 +263,265 @@ if ('onhashchange' in window) { 201 *editor <- put *editor, cursor-row:offset, cursor-row 202 *editor <- put *editor, cursor-column:offset, cursor-column 203 *editor <- put *editor, before-cursor:offset, before-cursor -204 return row, column -205 ] -206 -207 def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ -208 local-scope -209 load-inputs -210 #? stash [clear-screen-from] row column [between] left [and] right -211 # if it's the real screen, use the optimized primitive -212 { -213 break-if screen -214 clear-display-from row, column, left, right -215 return -216 } -217 # if not, go the slower route -218 screen <- move-cursor screen, row, column -219 clear-line-until screen, right -220 clear-rest-of-screen screen, row, left, right -221 ] -222 -223 def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ -224 local-scope -225 load-inputs -226 row <- add row, 1 -227 # if it's the real screen, use the optimized primitive -228 { -229 break-if screen -230 clear-display-from row, left, left, right -231 return -232 } -233 screen <- move-cursor screen, row, left -234 screen-height:num <- screen-height screen -235 { -236 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height -237 break-if at-bottom-of-screen? -238 screen <- move-cursor screen, row, left -239 clear-line-until screen, right -240 row <- add row, 1 -241 loop -242 } -243 ] -244 -245 scenario editor-prints-multiple-lines [ -246 local-scope -247 assume-screen 5/width, 5/height -248 s:text <- new [abc -249 def] -250 e:&:editor <- new-editor s, 0/left, 5/right -251 run [ -252 render screen, e -253 ] -254 screen-should-contain [ -255 . . -256 .abc . -257 .def . -258 . . -259 ] -260 ] -261 -262 scenario editor-handles-offsets [ -263 local-scope -264 assume-screen 5/width, 5/height -265 e:&:editor <- new-editor [abc], 1/left, 5/right -266 run [ -267 render screen, e -268 ] -269 screen-should-contain [ -270 . . -271 . abc . -272 . . -273 ] -274 ] -275 -276 scenario editor-prints-multiple-lines-at-offset [ -277 local-scope -278 assume-screen 5/width, 5/height -279 s:text <- new [abc -280 def] -281 e:&:editor <- new-editor s, 1/left, 5/right -282 run [ -283 render screen, e -284 ] -285 screen-should-contain [ -286 . . -287 . abc . -288 . def . -289 . . -290 ] -291 ] -292 -293 scenario editor-wraps-long-lines [ -294 local-scope -295 assume-screen 5/width, 5/height -296 e:&:editor <- new-editor [abc def], 0/left, 5/right -297 run [ -298 render screen, e -299 ] -300 screen-should-contain [ -301 . . -302 .abc ↩. -303 .def . -304 . . -305 ] -306 screen-should-contain-in-color 245/grey [ -307 . . -308 . ↩. -309 . . +204 clear-line-until screen, right +205 row <- add row, 1 +206 return row, left/column +207 ] +208 +209 def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ +210 local-scope +211 load-inputs +212 # if it's the real screen, use the optimized primitive +213 { +214 break-if screen +215 clear-display-from row, column, left, right +216 return +217 } +218 # if not, go the slower route +219 screen <- move-cursor screen, row, column +220 clear-line-until screen, right +221 clear-rest-of-screen screen, row, left, right +222 ] +223 +224 def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ +225 local-scope +226 load-inputs +227 row <- add row, 1 +228 # if it's the real screen, use the optimized primitive +229 { +230 break-if screen +231 clear-display-from row, left, left, right +232 return +233 } +234 screen <- move-cursor screen, row, left +235 screen-height:num <- screen-height screen +236 { +237 at-bottom-of-screen?:bool <- greater-or-equal row, screen-height +238 break-if at-bottom-of-screen? +239 screen <- move-cursor screen, row, left +240 clear-line-until screen, right +241 row <- add row, 1 +242 loop +243 } +244 ] +245 +246 scenario editor-prints-multiple-lines [ +247 local-scope +248 assume-screen 5/width, 5/height +249 s:text <- new [abc +250 def] +251 e:&:editor <- new-editor s, 0/left, 5/right +252 run [ +253 render screen, e +254 ] +255 screen-should-contain [ +256 . . +257 .abc . +258 .def . +259 . . +260 ] +261 ] +262 +263 scenario editor-handles-offsets [ +264 local-scope +265 assume-screen 5/width, 5/height +266 e:&:editor <- new-editor [abc], 1/left, 5/right +267 run [ +268 render screen, e +269 ] +270 screen-should-contain [ +271 . . +272 . abc . +273 . . +274 ] +275 ] +276 +277 scenario editor-prints-multiple-lines-at-offset [ +278 local-scope +279 assume-screen 5/width, 5/height +280 s:text <- new [abc +281 def] +282 e:&:editor <- new-editor s, 1/left, 5/right +283 run [ +284 render screen, e +285 ] +286 screen-should-contain [ +287 . . +288 . abc . +289 . def . +290 . . +291 ] +292 ] +293 +294 scenario editor-wraps-long-lines [ +295 local-scope +296 assume-screen 5/width, 5/height +297 e:&:editor <- new-editor [abc def], 0/left, 5/right +298 run [ +299 render screen, e +300 ] +301 screen-should-contain [ +302 . . +303 .abc ↩. +304 .def . +305 . . +306 ] +307 screen-should-contain-in-color 245/grey [ +308 . . +309 . ↩. 310 . . -311 ] -312 ] -313 -314 scenario editor-wraps-barely-long-lines [ -315 local-scope -316 assume-screen 5/width, 5/height -317 e:&:editor <- new-editor [abcde], 0/left, 5/right -318 run [ -319 render screen, e -320 ] -321 # still wrap, even though the line would fit. We need room to click on the -322 # end of the line -323 screen-should-contain [ -324 . . -325 .abcd↩. -326 .e . -327 . . -328 ] -329 screen-should-contain-in-color 245/grey [ -330 . . -331 . ↩. -332 . . +311 . . +312 ] +313 ] +314 +315 scenario editor-wraps-barely-long-lines [ +316 local-scope +317 assume-screen 5/width, 5/height +318 e:&:editor <- new-editor [abcde], 0/left, 5/right +319 run [ +320 render screen, e +321 ] +322 # still wrap, even though the line would fit. We need room to click on the +323 # end of the line +324 screen-should-contain [ +325 . . +326 .abcd↩. +327 .e . +328 . . +329 ] +330 screen-should-contain-in-color 245/grey [ +331 . . +332 . ↩. 333 . . -334 ] -335 ] -336 -337 scenario editor-with-empty-text [ -338 local-scope -339 assume-screen 5/width, 5/height -340 e:&:editor <- new-editor [], 0/left, 5/right -341 run [ -342 render screen, e -343 3:num/raw <- get *e, cursor-row:offset -344 4:num/raw <- get *e, cursor-column:offset -345 ] -346 screen-should-contain [ -347 . . +334 . . +335 ] +336 ] +337 +338 scenario editor-with-empty-text [ +339 local-scope +340 assume-screen 5/width, 5/height +341 e:&:editor <- new-editor [], 0/left, 5/right +342 run [ +343 render screen, e +344 3:num/raw <- get *e, cursor-row:offset +345 4:num/raw <- get *e, cursor-column:offset +346 ] +347 screen-should-contain [ 348 . . 349 . . -350 ] -351 memory-should-contain [ -352 3 <- 1 # cursor row -353 4 <- 0 # cursor column -354 ] -355 ] -356 -357 # just a little color for Mu code -358 -359 scenario render-colors-comments [ -360 local-scope -361 assume-screen 5/width, 5/height -362 s:text <- new [abc -363 # de -364 f] -365 e:&:editor <- new-editor s, 0/left, 5/right -366 run [ -367 render screen, e -368 ] -369 screen-should-contain [ -370 . . -371 .abc . -372 .# de . -373 .f . -374 . . -375 ] -376 screen-should-contain-in-color 12/lightblue, [ -377 . . +350 . . +351 ] +352 memory-should-contain [ +353 3 <- 1 # cursor row +354 4 <- 0 # cursor column +355 ] +356 ] +357 +358 # just a little color for Mu code +359 +360 scenario render-colors-comments [ +361 local-scope +362 assume-screen 5/width, 5/height +363 s:text <- new [abc +364 # de +365 f] +366 e:&:editor <- new-editor s, 0/left, 5/right +367 run [ +368 render screen, e +369 ] +370 screen-should-contain [ +371 . . +372 .abc . +373 .# de . +374 .f . +375 . . +376 ] +377 screen-should-contain-in-color 12/lightblue, [ 378 . . -379 .# de . -380 . . +379 . . +380 .# de . 381 . . -382 ] -383 screen-should-contain-in-color 7/white, [ -384 . . -385 .abc . -386 . . -387 .f . -388 . . -389 ] -390 ] -391 -392 after <character-c-received> [ -393 color <- get-color color, c -394 ] -395 -396 # so far the previous color is all the information we need; that may change -397 def get-color color:num, c:char -> color:num [ -398 local-scope -399 load-inputs -400 color-is-white?:bool <- equal color, 7/white -401 # if color is white and next character is '#', switch color to blue -402 { -403 break-unless color-is-white? -404 starting-comment?:bool <- equal c, 35/# -405 break-unless starting-comment? -406 trace 90, [app], [switch color back to blue] -407 return 12/lightblue -408 } -409 # if color is blue and next character is newline, switch color to white -410 { -411 color-is-blue?:bool <- equal color, 12/lightblue -412 break-unless color-is-blue? -413 ending-comment?:bool <- equal c, 10/newline -414 break-unless ending-comment? -415 trace 90, [app], [switch color back to white] -416 return 7/white -417 } -418 # if color is white (no comments) and next character is '<', switch color to red -419 { -420 break-unless color-is-white? -421 starting-assignment?:bool <- equal c, 60/< -422 break-unless starting-assignment? -423 return 1/red -424 } -425 # if color is red and next character is space, switch color to white -426 { -427 color-is-red?:bool <- equal color, 1/red -428 break-unless color-is-red? -429 ending-assignment?:bool <- equal c, 32/space -430 break-unless ending-assignment? -431 return 7/white -432 } -433 # otherwise no change -434 return color -435 ] -436 -437 scenario render-colors-assignment [ -438 local-scope -439 assume-screen 8/width, 5/height -440 s:text <- new [abc -441 d <- e -442 f] -443 e:&:editor <- new-editor s, 0/left, 8/right -444 run [ -445 render screen, e -446 ] -447 screen-should-contain [ -448 . . -449 .abc . -450 .d <- e . -451 .f . -452 . . -453 ] -454 screen-should-contain-in-color 1/red, [ -455 . . +382 . . +383 ] +384 screen-should-contain-in-color 7/white, [ +385 . . +386 .abc . +387 . . +388 .f . +389 . . +390 ] +391 ] +392 +393 after <character-c-received> [ +394 color <- get-color color, c +395 ] +396 +397 # so far the previous color is all the information we need; that may change +398 def get-color color:num, c:char -> color:num [ +399 local-scope +400 load-inputs +401 color-is-white?:bool <- equal color, 7/white +402 # if color is white and next character is '#', switch color to blue +403 { +404 break-unless color-is-white? +405 starting-comment?:bool <- equal c, 35/# +406 break-unless starting-comment? +407 trace 90, [app], [switch color back to blue] +408 return 12/lightblue +409 } +410 # if color is blue and next character is newline, switch color to white +411 { +412 color-is-blue?:bool <- equal color, 12/lightblue +413 break-unless color-is-blue? +414 ending-comment?:bool <- equal c, 10/newline +415 break-unless ending-comment? +416 trace 90, [app], [switch color back to white] +417 return 7/white +418 } +419 # if color is white (no comments) and next character is '<', switch color to red +420 { +421 break-unless color-is-white? +422 starting-assignment?:bool <- equal c, 60/< +423 break-unless starting-assignment? +424 return 1/red +425 } +426 # if color is red and next character is space, switch color to white +427 { +428 color-is-red?:bool <- equal color, 1/red +429 break-unless color-is-red? +430 ending-assignment?:bool <- equal c, 32/space +431 break-unless ending-assignment? +432 return 7/white +433 } +434 # otherwise no change +435 return color +436 ] +437 +438 scenario render-colors-assignment [ +439 local-scope +440 assume-screen 8/width, 5/height +441 s:text <- new [abc +442 d <- e +443 f] +444 e:&:editor <- new-editor s, 0/left, 8/right +445 run [ +446 render screen, e +447 ] +448 screen-should-contain [ +449 . . +450 .abc . +451 .d <- e . +452 .f . +453 . . +454 ] +455 screen-should-contain-in-color 1/red, [ 456 . . -457 . <- . -458 . . +457 . . +458 . <- . 459 . . -460 ] -461 ] +460 . . +461 ] +462 ] -- cgit 1.4.1-2-gfad0