From 76755b2836b0dadd88f82635f661f9d9df77604d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 10 Nov 2015 21:35:42 -0800 Subject: 2423 - describe shape-shifting in html docs --- html/edit/001-editor.mu.html | 100 +++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 60 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 be568c9d..916e93c6 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } +.muControl { color: #c0a020; } .muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } .muData { color: #ffff00; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } .Delimiter { color: #a04060; } -.muControl { color: #c0a020; } --> @@ -37,9 +37,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } # temporary main for this layer: just render the given string at the given # screen dimensions, then stop -recipe! main [ +recipe! main text:address:array:character [ local-scope - text:address:array:character <- next-ingredient + load-ingredients open-console hide-screen 0/screen new-editor text, 0/screen, 0/left, 5/right @@ -52,7 +52,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen 10/width, 5/height run [ 1:address:array:character <- new [abc] - new-editor 1:address:array:character, screen:address, 0/left, 10/right + new-editor 1:address:array:character, screen:address:screen, 0/left, 10/right ] screen-should-contain [ # top line of screen reserved for menu @@ -79,19 +79,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } cursor-column:number ] -# editor:address, screen <- new-editor s:address:array:character, screen:address, left:number, right:number -# creates a new editor widget and renders its initial appearance to screen. -# top/left/right constrain the screen area available to the new editor. -# right is exclusive. -recipe new-editor [ +# creates a new editor widget and renders its initial appearance to screen +# top/left/right constrain the screen area available to the new editor +# right is exclusive +recipe new-editor s:address:array:character, screen:address:screen, left:number, right:number -> result:address:editor-data [ local-scope - s:address:array:character <- next-ingredient - screen:address <- next-ingredient + load-ingredients # no clipping of bounds - left:number <- next-ingredient - right:number <- next-ingredient right <- subtract right, 1 - result:address:editor-data <- new editor-data:type + result <- new editor-data:type # initialize screen-related fields x:address:number <- get-address *result, left:offset *x <- copy left @@ -102,11 +98,11 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } *x <- copy 1/top x <- get-address *result, cursor-column:offset *x <- copy left - init:address:address:duplex-list <- get-address *result, data:offset + init:address:address:duplex-list:character <- get-address *result, data:offset *init <- push-duplex 167/ยง, 0/tail - top-of-screen:address:address:duplex-list <- get-address *result, top-of-screen:offset + top-of-screen:address:address:duplex-list:character <- get-address *result, top-of-screen:offset *top-of-screen <- copy *init - y:address:address:duplex-list <- get-address *result, before-cursor:offset + y:address:address:duplex-list:character <- get-address *result, before-cursor:offset *y <- copy *init result <- insert-text result, s # initialize cursor to top of screen @@ -115,20 +111,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } # initial render to screen, just for some old tests _, _, screen, result <- render screen, result <editor-initialization> - reply result ] -recipe insert-text [ +recipe insert-text editor:address:editor-data, text:address:array:character -> editor:address:editor-data [ local-scope - editor:address:editor-data <- next-ingredient - text:address:array:character <- next-ingredient + load-ingredients # early exit if text is empty reply-unless text, editor/same-as-ingredient:0 len:number <- length *text reply-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character - curr:address:duplex-list <- get *editor, data:offset + curr:address:duplex-list:character <- get *editor, data:offset { done?:boolean <- greater-or-equal idx, len break-if done? @@ -145,7 +139,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } scenario editor-initializes-without-data [ assume-screen 5/width, 3/height run [ - 1:address:editor-data <- new-editor 0/data, screen:address, 2/left, 5/right + 1:address:editor-data <- new-editor 0/data, screen:address:screen, 2/left, 5/right 2:editor-data <- copy *1:address:editor-data ] memory-should-contain [ @@ -165,22 +159,19 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] ] -# last-row:number, last-column:number, screen, editor <- render screen:address, editor:address:editor-data -# # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -recipe render [ +recipe render screen:address:screen, editor:address:editor-data -> last-row:number, last-column:number, screen:address:screen, editor:address:editor-data [ local-scope - screen:address <- next-ingredient - editor:address:editor-data <- next-ingredient + load-ingredients reply-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 left:number <- get *editor, left:offset screen-height:number <- screen-height screen right:number <- get *editor, right:offset # traversing editor - curr:address:duplex-list <- get *editor, top-of-screen:offset - prev:address:duplex-list <- copy curr # just in case curr becomes null and we can't compute prev-duplex + curr:address:duplex-list:character <- get *editor, top-of-screen:offset + prev:address:duplex-list:character <- copy curr # just in case curr becomes null and we can't compute prev-duplex curr <- next-duplex curr # traversing screen +render-loop-initialization @@ -189,7 +180,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } column:number <- copy left cursor-row:address:number <- get-address *editor, cursor-row:offset cursor-column:address:number <- get-address *editor, cursor-column:offset - before-cursor:address:address:duplex-list <- get-address *editor, before-cursor:offset + before-cursor:address:address:duplex-list:character <- get-address *editor, before-cursor:offset screen <- move-cursor screen, row, column { +next-character @@ -251,7 +242,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } loop } # save first character off-screen - bottom-of-screen:address:address:duplex-list <- get-address *editor, bottom-of-screen:offset + bottom-of-screen:address:address:duplex-list:character <- get-address *editor, bottom-of-screen:offset *bottom-of-screen <- copy curr # is cursor to the right of the last line? move to end { @@ -268,11 +259,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited [ +recipe clear-line-delimited screen:address:screen, column:number, right:number [ local-scope - screen:address <- next-ingredient - column:number <- next-ingredient - right:number <- next-ingredient + load-ingredients { done?:boolean <- greater-than column, right break-if done? @@ -282,13 +271,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } } ] -recipe clear-screen-from [ +recipe clear-screen-from screen:address:screen, row:number, column:number, left:number, right:number -> screen:address:screen [ local-scope - screen:address <- next-ingredient - row:number <- next-ingredient - column:number <- next-ingredient - left:number <- next-ingredient - right:number <- next-ingredient + load-ingredients # if it's the real screen, use the optimized primitive { break-if screen @@ -302,12 +287,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } reply screen/same-as-ingredient:0 ] -recipe clear-rest-of-screen [ +recipe clear-rest-of-screen screen:address:screen, row:number, left:number, right:number [ local-scope - screen:address <- next-ingredient - row:number <- next-ingredient - left:number <- next-ingredient - right:number <- next-ingredient + load-ingredients row <- add row, 1 screen <- move-cursor screen, row, left screen-height:number <- screen-height screen @@ -326,7 +308,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } run [ s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address, 0/left, 5/right + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -340,7 +322,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc] - new-editor s:address:array:character, screen:address, 1/left, 5/right + new-editor s:address:array:character, screen:address:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -354,7 +336,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } run [ s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address, 1/left, 5/right + new-editor s:address:array:character, screen:address:screen, 1/left, 5/right ] screen-should-contain [ . . @@ -368,7 +350,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen 5/width, 5/height run [ s:address:array:character <- new [abc def] - new-editor s:address:array:character, screen:address, 0/left, 5/right + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -388,7 +370,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen 5/width, 5/height run [ s:address:array:character <- new [abcde] - new-editor s:address:array:character, screen:address, 0/left, 5/right + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] # still wrap, even though the line would fit. We need room to click on the # end of the line @@ -410,7 +392,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } assume-screen 5/width, 5/height run [ 1:address:array:character <- new [] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right + 2:address:editor-data <- new-editor 1:address:array:character, screen:address:screen, 0/left, 5/right 3:number <- get *2:address:editor-data, cursor-row:offset 4:number <- get *2:address:editor-data, cursor-column:offset ] @@ -433,7 +415,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } s:address:array:character <- new [abc # de f] - new-editor s:address:array:character, screen:address, 0/left, 5/right + new-editor s:address:array:character, screen:address:screen, 0/left, 5/right ] screen-should-contain [ . . @@ -462,12 +444,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } color <- get-color color, c ] -# color <- get-color color:number, c:character # so far the previous color is all the information we need; that may change -recipe get-color [ +recipe get-color color:number, c:character -> color:number [ local-scope - color:number <- next-ingredient - c:character <- next-ingredient + load-ingredients color-is-white?:boolean <- equal color, 7/white # if color is white and next character is '#', switch color to blue { @@ -516,7 +496,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } s:address:array:character <- new [abc d <- e f] - new-editor s:address:array:character, screen:address, 0/left, 8/right + new-editor s:address:array:character, screen:address:screen, 0/left, 8/right ] screen-should-contain [ . . -- cgit 1.4.1-2-gfad0