diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 18:03:26 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 18:03:26 -0700 |
commit | cebb5fca612321f9436f324d6b95e94b0f1ac614 (patch) | |
tree | bc6c4f0e659990da24c019cdaefef4d9cb3ac2b1 /html/edit/001-editor.mu.html | |
parent | 2d91279bacda12ea42608b4aa74f66589772fce9 (diff) | |
download | mu-cebb5fca612321f9436f324d6b95e94b0f1ac614.tar.gz |
3397
Diffstat (limited to 'html/edit/001-editor.mu.html')
-rw-r--r-- | html/edit/001-editor.mu.html | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index b61e405d..a5b87d06 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muData">container</span> editor-data [ +<span class="muData">container</span> editor [ <span class="Comment"># editable text: doubly linked list of characters (head contains a special sentinel)</span> data:&:duplex-list:char top-of-screen:&:duplex-list:char @@ -83,12 +83,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># creates a new editor widget and renders its initial appearance to screen</span> <span class="Comment"># top/left/right constrain the screen area available to the new editor</span> <span class="Comment"># right is exclusive</span> -<span class="muRecipe">def</span> new-editor s:text, screen:&:screen, left:num, right:num<span class="muRecipe"> -> </span>result:&:editor-data, screen:&:screen [ +<span class="muRecipe">def</span> new-editor s:text, screen:&:screen, left:num, right:num<span class="muRecipe"> -> </span>result:&:editor, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> right<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> - result<span class="Special"> <- </span>new <span class="Constant">editor-data:type</span> + result<span class="Special"> <- </span>new <span class="Constant">editor:type</span> <span class="Comment"># initialize screen-related fields</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">left:offset</span>, left *result<span class="Special"> <- </span>put *result, <span class="Constant">right:offset</span>, right @@ -106,7 +106,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <editor-initialization></span> ] -<span class="muRecipe">def</span> insert-text editor:&:editor-data, text:text<span class="muRecipe"> -> </span>editor:&:editor-data [ +<span class="muRecipe">def</span> insert-text editor:&:editor, text:text<span class="muRecipe"> -> </span>editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># early exit if text is empty</span> @@ -132,8 +132,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-initializes-without-data [ assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ - <span class="Constant">1</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> - <span class="Constant">2</span>:editor-data<span class="Special"> <- </span>copy *<span class="Constant">1</span>:&:editor-data + <span class="Constant">1</span>:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> + <span class="Constant">2</span>:editor<span class="Special"> <- </span>copy *<span class="Constant">1</span>:&:editor ] memory-should-contain [ <span class="Comment"># 2 (data) <- just the § sentinel</span> @@ -156,7 +156,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># Assumes cursor should be at coordinates (cursor-row, cursor-column) and</span> <span class="Comment"># updates before-cursor to match. Might also move coordinates if they're</span> <span class="Comment"># outside text.</span> -<span class="muRecipe">def</span> render screen:&:screen, editor:&:editor-data<span class="muRecipe"> -> </span>last-row:num, last-column:num, screen:&:screen, editor:&:editor-data [ +<span class="muRecipe">def</span> render screen:&:screen, editor:&:editor<span class="muRecipe"> -> </span>last-row:num, last-column:num, screen:&:screen, editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> @@ -181,7 +181,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-unless</span> curr off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? - <span class="Comment"># update editor-data.before-cursor</span> + <span class="Comment"># update editor.before-cursor</span> <span class="Comment"># Doing so at the start of each iteration ensures it stays one step behind</span> <span class="Comment"># the current character.</span> <span class="Delimiter">{</span> @@ -378,9 +378,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:&:editor-data<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor-data, <span class="Constant">cursor-column:offset</span> + <span class="Constant">2</span>:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">3</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> |