diff options
28 files changed, 1636 insertions, 1561 deletions
diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index 3130380a..2a1e847e 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -38,9 +38,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment">//: Mu scenarios. This will get long, but these are the tests we want to</span> <span class="Comment">//: support in this layer.</span> -<span class="Comment">//: You can use variable names in scenarios, but for the most part we'll use</span> -<span class="Comment">//: raw location numbers, because that lets us make assertions on memory.</span> -<span class="Comment">//: Tests should avoid abstraction as far as possible.</span> +<span class="Comment">//: We avoid raw numeric locations in Mu -- except in scenarios, where they're</span> +<span class="Comment">//: handy to check the values of specific variables</span> <span class="Delimiter">:(scenarios run_mu_scenario)</span> <span class="Delimiter">:(scenario scenario_block)</span> scenario foo [ @@ -107,6 +106,10 @@ vector<scenario> Scenarios<span class="Delimiter">;</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>command == <span class="Constant">"scenario"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> Scenarios<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>parse_scenario<span class="Delimiter">(</span>in<span class="Delimiter">));</span> <span class="Delimiter">}</span> +<span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>command == <span class="Constant">"pending-scenario"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// for temporary use only</span> + parse_scenario<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Comment">// discard</span> +<span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> scenario parse_scenario<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -290,7 +293,8 @@ def scenario-foo [ <span class="SalientComment">//:: The special instructions we want to support inside scenarios.</span> <span class="Comment">//: In a compiler for the mu VM these will require more work.</span> -<span class="Comment">//: 'run' interprets a string as a set of instructions</span> +<span class="Comment">//: 'run' is a purely lexical convenience to separate the code actually being</span> +<span class="Comment">//: tested from any setup or teardown</span> <span class="Delimiter">:(scenario run)</span> def main [ @@ -300,34 +304,14 @@ def main [ ] <span class="traceContains">+mem: storing 13 in location 1</span> -<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> -RUN<span class="Delimiter">,</span> -<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> -put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">,</span> RUN<span class="Delimiter">);</span> -<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> -<span class="Normal">case</span> RUN: <span class="Delimiter">{</span> - <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Rewrite Instruction(curr, recipe result)")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"run"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// Just inline all instructions inside the run block in the containing</span> + <span class="Comment">// recipe. 'run' is basically a comment; pretend it doesn't exist.</span> + istringstream in2<span class="Delimiter">(</span><span class="Constant">"[</span><span class="cSpecial">\n</span><span class="Constant">"</span>+curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name+<span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> + slurp_body<span class="Delimiter">(</span>in2<span class="Delimiter">,</span> result<span class="Delimiter">);</span> + curr<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> -<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> -<span class="Normal">case</span> RUN: <span class="Delimiter">{</span> - assert<span class="Delimiter">(</span>Name[Next_recipe_ordinal]<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> - ostringstream tmp<span class="Delimiter">;</span> - tmp << <span class="Constant">"recipe run_"</span> << Next_recipe_ordinal << <span class="Constant">" [ "</span> << current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name << <span class="Constant">" ]"</span><span class="Delimiter">;</span> - vector<recipe_ordinal> tmp_recipe = load<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>str<span class="Delimiter">());</span> - mark_autogenerated<span class="Delimiter">(</span>tmp_recipe<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - bind_special_scenario_names<span class="Delimiter">(</span>tmp_recipe<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - transform_all<span class="Delimiter">();</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span> - ++Trace_stream<span class="Delimiter">-></span>callstack_depth<span class="Delimiter">;</span> - trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"trace"</span><span class="Delimiter">)</span> << <span class="Constant">"run: incrementing callstack depth to "</span> << Trace_stream<span class="Delimiter">-></span>callstack_depth << end<span class="Delimiter">();</span> - assert<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>callstack_depth < <span class="Constant">9000</span><span class="Delimiter">);</span> <span class="Comment">// 9998-101 plus cushion</span> - <span class="Delimiter">}</span> - Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>tmp_recipe<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span> - <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not done with caller; don't increment current_step_index()</span> -<span class="Delimiter">}</span> -<span class="Delimiter">:(before "End maybe_make_raw")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>starts_with<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">,</span> <span class="Constant">"run_"</span><span class="Delimiter">))</span> - r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span> <span class="Delimiter">:(scenario run_multiple)</span> def main [ @@ -578,7 +562,6 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span ++curr_expected_line<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr_expected_line == SIZE<span class="Delimiter">(</span>expected_lines<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario && !Scenario_testing_scenario<span class="Delimiter">)</span> raise << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": missing ["</span> << expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>contents << <span class="Constant">"] "</span> << <span class="Constant">"in trace with label '"</span> << expected_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>curr_expected_line<span class="Delimiter">).</span>label << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -597,6 +580,11 @@ vector<trace_line> parse_trace<span class="Delimiter">(</span><span class= buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> = trim<span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">int</span> delim = buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>find<span class="Delimiter">(</span><span class="Constant">": "</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>delim == -<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": lines in 'trace-should-contain' should be of the form <label>: <contents>. Both parts are required.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + result<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> + <span class="Delimiter">}</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>trace_line<span class="Delimiter">(</span>trim<span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>substr<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> delim<span class="Delimiter">)),</span> trim<span class="Delimiter">(</span>buf<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>substr<span class="Delimiter">(</span>delim+<span class="Constant">2</span><span class="Delimiter">))));</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> diff --git a/html/056shape_shifting_recipe.cc.html b/html/056shape_shifting_recipe.cc.html index 2b120069..4bfbafc1 100644 --- a/html/056shape_shifting_recipe.cc.html +++ b/html/056shape_shifting_recipe.cc.html @@ -146,21 +146,13 @@ vector<recipe_ordinal> strictly_matching_shape_shifting_variants<span clas <span class="Delimiter">}</span> <span class="Normal">bool</span> all_concrete_header_reagents_strictly_match<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& variant<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"too few ingredients"</span> << end<span class="Delimiter">();</span> - <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">)</span> < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"too few products"</span> << end<span class="Delimiter">();</span> - <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!concrete_type_names_strictly_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"concrete-type match failed: ingredient "</span> << i << end<span class="Delimiter">();</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> - <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < min<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">),</span> SIZE<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>ingredients<span class="Delimiter">));</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!concrete_type_names_strictly_match<span class="Delimiter">(</span>variant<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"strict match failed: product "</span> << i << end<span class="Delimiter">();</span> @@ -359,10 +351,6 @@ recipe_ordinal new_variant<span class="Delimiter">(</span>recipe_ordinal exempla <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">int</span> min<span class="Delimiter">(</span><span class="Normal">int</span> a<span class="Delimiter">,</span> <span class="Normal">int</span> b<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</span> <span class="Delimiter">(</span>a < b<span class="Delimiter">)</span> ? a : b<span class="Delimiter">;</span> -<span class="Delimiter">}</span> - <span class="Normal">void</span> accumulate_type_ingredients<span class="Delimiter">(</span><span class="Normal">const</span> reagent& exemplar_reagent<span class="Delimiter">,</span> reagent& refinement<span class="Delimiter">,</span> map<string<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree*>& mappings<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& exemplar<span class="Delimiter">,</span> <span class="Normal">const</span> instruction& call_instruction<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller_recipe<span class="Delimiter">,</span> <span class="Normal">bool</span>* error<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>refinement<span class="Delimiter">.</span>type<span class="Delimiter">);</span> accumulate_type_ingredients<span class="Delimiter">(</span>exemplar_reagent<span class="Delimiter">.</span>type<span class="Delimiter">,</span> refinement<span class="Delimiter">.</span>type<span class="Delimiter">,</span> mappings<span class="Delimiter">,</span> exemplar<span class="Delimiter">,</span> exemplar_reagent<span class="Delimiter">,</span> call_instruction<span class="Delimiter">,</span> caller_recipe<span class="Delimiter">,</span> error<span class="Delimiter">);</span> diff --git a/html/061text.mu.html b/html/061text.mu.html index 0c97fd78..12a4c4e0 100644 --- a/html/061text.mu.html +++ b/html/061text.mu.html @@ -66,9 +66,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-equal-reflexive [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, x ] memory-should-contain [ @@ -77,10 +77,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-equal-identical [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -89,10 +89,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-equal-distinct-lengths [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -107,10 +107,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-equal-with-empty [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -119,10 +119,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-equal-common-lengths-but-distinct [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abd]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abd]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, y ] memory-should-contain [ @@ -239,18 +239,53 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muScenario">scenario</span> buffer-append-works [ +<span class="muScenario">scenario</span> append-to-empty-buffer [ + <span class="Constant">local-scope</span> + x:&:buffer<span class="Special"> <- </span>new-buffer run [ - <span class="Constant">local-scope</span> - x:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> - s1:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> c:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> x<span class="Special"> <- </span>append x, c - c:char<span class="Special"> <- </span>copy <span class="Constant">98/b</span> - x<span class="Special"> <- </span>append x, c - c:char<span class="Special"> <- </span>copy <span class="Constant">99/c</span> + <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *x, <span class="Constant">length:offset</span> + s:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>index *s, <span class="Constant">0</span> + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>index *s, <span class="Constant">1</span> + ] + memory-should-contain [ + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># buffer length</span> + <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># a</span> + <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># rest of buffer is empty</span> + ] +] + +<span class="muScenario">scenario</span> append-to-buffer [ + <span class="Constant">local-scope</span> + x:&:buffer<span class="Special"> <- </span>new-buffer + c:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + x<span class="Special"> <- </span>append x, c + run [ + c<span class="Special"> <- </span>copy <span class="Constant">98/b</span> x<span class="Special"> <- </span>append x, c - s2:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *x, <span class="Constant">length:offset</span> + s:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + <span class="Constant">11</span>:char/<span class="Special">raw <- </span>index *s, <span class="Constant">0</span> + <span class="Constant">12</span>:char/<span class="Special">raw <- </span>index *s, <span class="Constant">1</span> + <span class="Constant">13</span>:char/<span class="Special">raw <- </span>index *s, <span class="Constant">2</span> + ] + memory-should-contain [ + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># buffer length</span> + <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># a</span> + <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">98</span> <span class="Comment"># b</span> + <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># rest of buffer is empty</span> + ] +] + +<span class="muScenario">scenario</span> append-grows-buffer [ + <span class="Constant">local-scope</span> + x:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> + s1:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + x<span class="Special"> <- </span>append x, <span class="Constant">[abc]</span> <span class="Comment"># buffer is now full</span> + s2:text<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + run [ <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal s1, s2 <span class="Constant">11</span>:@:char/<span class="Special">raw <- </span>copy *s2 <span class="Constant"> +buffer-filled</span> @@ -263,13 +298,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] memory-should-contain [ <span class="Comment"># before +buffer-filled</span> - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># no change in data pointer</span> + <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># no change in data pointer after original append</span> <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># size of data</span> <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># data</span> <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">98</span> <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">99</span> <span class="Comment"># in the end</span> - <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># data pointer has grown</span> + <span class="Constant">20</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># data pointer has grown after second append</span> <span class="Constant">21</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># final length</span> <span class="Constant">30</span><span class="Special"> <- </span><span class="Constant">6</span> <span class="Comment"># but data's capacity has doubled</span> <span class="Constant">31</span><span class="Special"> <- </span><span class="Constant">97</span> <span class="Comment"># data</span> @@ -281,23 +316,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muScenario">scenario</span> buffer-append-to-empty [ - run [ - <span class="Constant">local-scope</span> - x:&:buffer<span class="Special"> <- </span>new-buffer - c:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - x<span class="Special"> <- </span>append x, c - ] -] - <span class="muScenario">scenario</span> buffer-append-handles-backspace [ + <span class="Constant">local-scope</span> + x:&:buffer<span class="Special"> <- </span>new-buffer + x<span class="Special"> <- </span>append x, <span class="Constant">[ab]</span> run [ - <span class="Constant">local-scope</span> - x:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">3</span> - c:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - x<span class="Special"> <- </span>append x, c - c:char<span class="Special"> <- </span>copy <span class="Constant">98/b</span> - x<span class="Special"> <- </span>append x, c c:char<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> x<span class="Special"> <- </span>append x, c s:text<span class="Special"> <- </span>buffer-to-array x @@ -362,10 +385,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-append-1 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> z:text<span class="Special"> <- </span>append x, y <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -375,10 +398,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-append-null [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>copy <span class="Constant">0</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>copy <span class="Constant">0</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[ world!]</span> z:text<span class="Special"> <- </span>append x, y <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -388,10 +411,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-append-null-2 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> + y:text<span class="Special"> <- </span>copy <span class="Constant">0</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[hello,]</span> - y:text<span class="Special"> <- </span>copy <span class="Constant">0</span> z:text<span class="Special"> <- </span>append x, y <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -401,11 +424,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-append-multiary [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[hello, ]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[world]</span> + z:text<span class="Special"> <- </span>new <span class="Constant">[!]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[hello, ]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[world]</span> - z:text<span class="Special"> <- </span>new <span class="Constant">[!]</span> z:text<span class="Special"> <- </span>append x, y, z <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -415,9 +438,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> replace-character-in-text [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">98/b</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *x ] @@ -439,9 +462,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> replace-character-at-start [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">97/a</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *x ] @@ -451,9 +474,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> replace-character-at-end [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">99/c</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *x ] @@ -463,9 +486,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> replace-character-missing [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">100/d</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *x ] @@ -475,9 +498,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> replace-all-characters [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[banana]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[banana]</span> x<span class="Special"> <- </span>replace x, <span class="Constant">97/a</span>, <span class="Constant">122/z</span> <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *x ] @@ -561,10 +584,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> interpolate-works [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc_ghi]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc_ghi]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> z:text<span class="Special"> <- </span>interpolate x, y <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -574,10 +597,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> interpolate-at-start [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[_, hello!]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[_, hello!]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> z:text<span class="Special"> <- </span>interpolate x, y <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -588,9 +611,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> interpolate-at-end [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[hello, _]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - x:text<span class="Special"> <- </span>new <span class="Constant">[hello, _]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> z:text<span class="Special"> <- </span>interpolate x, y <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *z ] @@ -711,9 +735,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> trim-unmodified [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -723,9 +747,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> trim-left [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[ abc]</span> y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -735,9 +759,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> trim-right [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc ]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc ]</span> y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -747,9 +771,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> trim-left-right [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ abc ]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[ abc ]</span> y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -759,10 +783,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> trim-newline-tab [ - run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[ abc</span> + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ abc</span> <span class="Constant">]</span> + run [ y:text<span class="Special"> <- </span>trim x <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -788,9 +812,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -799,9 +823,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-empty [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -810,9 +834,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-initial [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[/abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[/abc]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -821,9 +845,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-final [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc/]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc/]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -832,9 +856,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-missing [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -843,9 +867,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-invalid-index [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">4/start-index</span> ] memory-should-contain [ @@ -854,9 +878,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-first [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">0/start-index</span> ] memory-should-contain [ @@ -865,9 +889,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-find-next-second [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[ab/c/]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, <span class="Constant">47/slash</span>, <span class="Constant">3/start-index</span> ] memory-should-contain [ @@ -898,10 +922,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> find-next-text-1 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -910,10 +934,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> find-next-text-2 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">1</span> ] memory-should-contain [ @@ -922,10 +946,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> find-next-no-match [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bd]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[bd]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -934,10 +958,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> find-next-suffix-match [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[cd]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[cd]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -946,10 +970,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> find-next-suffix-match-2 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[cde]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[cde]</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>find-next x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -990,10 +1014,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-checks-pattern-at-index [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[ab]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[ab]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1002,9 +1026,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-reflexive [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, x, <span class="Constant">0</span> ] memory-should-contain [ @@ -1013,10 +1037,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-outside-bounds [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">4</span> ] memory-should-contain [ @@ -1025,10 +1049,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-empty-pattern [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1037,10 +1061,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-empty-pattern-outside-bound [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">4</span> ] memory-should-contain [ @@ -1049,10 +1073,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-empty-text [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1061,9 +1085,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-empty-against-empty [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, x, <span class="Constant">0</span> ] memory-should-contain [ @@ -1072,10 +1096,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-inside-bounds [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">1</span> ] memory-should-contain [ @@ -1084,10 +1108,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> match-at-inside-bounds-2 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - y:text<span class="Special"> <- </span>new <span class="Constant">[bc]</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>match-at x, y, <span class="Constant">0</span> ] memory-should-contain [ @@ -1103,7 +1127,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> empty?:bool<span class="Special"> <- </span>equal len, <span class="Constant">0</span> <span class="muControl">break-unless</span> empty? - result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): type<span class="Delimiter">}</span>, <span class="Constant">0</span> + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): <span class="muData">type</span><span class="Delimiter">}</span>, <span class="Constant">0</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># count #pieces we need room for</span> @@ -1118,7 +1142,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># allocate space</span> - result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): type<span class="Delimiter">}</span>, count + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): <span class="muData">type</span><span class="Delimiter">}</span>, count <span class="Comment"># repeatedly copy slices start..end until delimiter into result[curr-result]</span> curr-result:num<span class="Special"> <- </span>copy <span class="Constant">0</span> start:num<span class="Special"> <- </span>copy <span class="Constant">0</span> @@ -1138,9 +1162,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-split-1 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> y:&:@:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>length *y a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> @@ -1156,9 +1180,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-split-2 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b/c]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[a/b/c]</span> y:&:@:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>length *y a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> @@ -1177,9 +1201,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-split-missing [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:&:@:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>length *y a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> @@ -1192,9 +1216,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-split-empty [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[]</span> y:&:@:text<span class="Special"> <- </span>split x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>length *y ] @@ -1204,9 +1228,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-split-empty-piece [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b//c]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[a/b//c]</span> y:&:@:text<span class="Special"> <- </span>split x:text, <span class="Constant">47/slash</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>length *y a:text<span class="Special"> <- </span>index *y, <span class="Constant">0</span> @@ -1246,9 +1270,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> text-split-first [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[a/b]</span> y:text, z:text<span class="Special"> <- </span>split-first x, <span class="Constant">47/slash</span> <span class="Constant">10</span>:@:char/<span class="Special">raw <- </span>copy *y <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *z @@ -1282,10 +1306,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">}</span> ] -<span class="muScenario">scenario</span> text-copy-copies-partial-text [ +<span class="muScenario">scenario</span> copy-range-works [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:text<span class="Special"> <- </span>copy-range x, <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -1294,10 +1318,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muScenario">scenario</span> text-copy-out-of-bounds [ +<span class="muScenario">scenario</span> copy-range-out-of-bounds [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:text<span class="Special"> <- </span>copy-range x, <span class="Constant">2</span>, <span class="Constant">4</span> <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] @@ -1306,10 +1330,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] -<span class="muScenario">scenario</span> text-copy-out-of-bounds-2 [ +<span class="muScenario">scenario</span> copy-range-out-of-bounds-2 [ + <span class="Constant">local-scope</span> + x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> run [ - <span class="Constant">local-scope</span> - x:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:text<span class="Special"> <- </span>copy-range x, <span class="Constant">3</span>, <span class="Constant">3</span> <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *y ] diff --git a/html/063array.mu.html b/html/063array.mu.html index 48d3301a..01ed3938 100644 --- a/html/063array.mu.html +++ b/html/063array.mu.html @@ -91,9 +91,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> fill-on-an-empty-array [ + <span class="Constant">local-scope</span> + array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> run [ - <span class="Constant">local-scope</span> - array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> array<span class="Special"> <- </span>fill array, <span class="Constant">1</span> <span class="Constant">2</span> <span class="Constant">3</span> <span class="Constant">10</span>:@:num/<span class="Special">raw <- </span>copy *array ] @@ -106,10 +106,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> fill-overwrites-existing-values [ + <span class="Constant">local-scope</span> + array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> + *array<span class="Special"> <- </span>put-index *array, <span class="Constant">0</span>, <span class="Constant">4</span> run [ - <span class="Constant">local-scope</span> - array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> - *array<span class="Special"> <- </span>put-index *array, <span class="Constant">0</span>, <span class="Constant">4</span> array<span class="Special"> <- </span>fill array, <span class="Constant">1</span> <span class="Constant">2</span> <span class="Constant">3</span> <span class="Constant">10</span>:@:num/<span class="Special">raw <- </span>copy *array ] @@ -122,9 +122,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> fill-exits-gracefully-when-given-no-ingredients [ + <span class="Constant">local-scope</span> + array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> run [ - <span class="Constant">local-scope</span> - array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> array<span class="Special"> <- </span>fill array <span class="Constant">10</span>:@:num/<span class="Special">raw <- </span>copy *array ] @@ -148,10 +148,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> swap-works [ + <span class="Constant">local-scope</span> + array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">4</span> + array<span class="Special"> <- </span>fill array, <span class="Constant">4</span> <span class="Constant">3</span> <span class="Constant">2</span> <span class="Constant">1</span> run [ - <span class="Constant">local-scope</span> - array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">4</span> - array<span class="Special"> <- </span>fill array, <span class="Constant">4</span> <span class="Constant">3</span> <span class="Constant">2</span> <span class="Constant">1</span> array<span class="Special"> <- </span>swap array, <span class="Constant">0</span>, <span class="Constant">2</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>index *array, <span class="Constant">0</span> <span class="Constant">11</span>:num/<span class="Special">raw <- </span>index *array, <span class="Constant">2</span> @@ -181,10 +181,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> reverse-array-odd-length [ + <span class="Constant">local-scope</span> + array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> + array<span class="Special"> <- </span>fill array, <span class="Constant">3</span> <span class="Constant">2</span> <span class="Constant">1</span> run [ - <span class="Constant">local-scope</span> - array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">3</span> - array<span class="Special"> <- </span>fill array, <span class="Constant">3</span> <span class="Constant">2</span> <span class="Constant">1</span> array<span class="Special"> <- </span>reverse array <span class="Constant">10</span>:@:num/<span class="Special">raw <- </span>copy *array ] @@ -197,10 +197,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> reverse-array-even-length [ + <span class="Constant">local-scope</span> + array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">4</span> + array<span class="Special"> <- </span>fill array, <span class="Constant">4</span> <span class="Constant">3</span> <span class="Constant">2</span> <span class="Constant">1</span> run [ - <span class="Constant">local-scope</span> - array:&:@:num<span class="Special"> <- </span>new <span class="Constant">number:type</span>, <span class="Constant">4</span> - array<span class="Special"> <- </span>fill array, <span class="Constant">4</span> <span class="Constant">3</span> <span class="Constant">2</span> <span class="Constant">1</span> array<span class="Special"> <- </span>reverse array <span class="Constant">10</span>:@:num/<span class="Special">raw <- </span>copy *array ] diff --git a/html/064list.mu.html b/html/064list.mu.html index 236bf533..a0b2d805 100644 --- a/html/064list.mu.html +++ b/html/064list.mu.html @@ -45,7 +45,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> push x:_elem, in:&:list:_elem<span class="muRecipe"> -> </span>result:&:list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(list _elem): type<span class="Delimiter">}</span> + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(list _elem): <span class="muData">type</span><span class="Delimiter">}</span> *result<span class="Special"> <- </span>merge x, in ] @@ -95,7 +95,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> insert x:_elem, in:&:list:_elem<span class="muRecipe"> -> </span>in:&:list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - new-node:&:list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(list _elem): type<span class="Delimiter">}</span> + new-node:&:list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(list _elem): <span class="muData">type</span><span class="Delimiter">}</span> *new-node<span class="Special"> <- </span>put *new-node, <span class="Constant">value:offset</span>, x next-node:&:list:_elem<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> *in<span class="Special"> <- </span>put *in, <span class="Constant">next:offset</span>, new-node @@ -103,11 +103,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> inserting-into-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list2:&:list:char<span class="Special"> <- </span>rest list <span class="Comment"># inside list</span> list2<span class="Special"> <- </span>insert <span class="Constant">6</span>, list2 <span class="Comment"># check structure</span> @@ -129,11 +129,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> inserting-at-end-of-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list2:&:list:char<span class="Special"> <- </span>rest list <span class="Comment"># inside list</span> list2<span class="Special"> <- </span>rest list2 <span class="Comment"># now at end of list</span> list2<span class="Special"> <- </span>insert <span class="Constant">6</span>, list2 @@ -156,11 +156,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> inserting-after-start-of-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list<span class="Special"> <- </span>insert <span class="Constant">6</span>, list <span class="Comment"># check structure like before</span> list2:&:list:char<span class="Special"> <- </span>copy list @@ -210,11 +210,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list2:&:list:char<span class="Special"> <- </span>rest list <span class="Comment"># second element</span> list<span class="Special"> <- </span>remove list2, list <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> @@ -234,11 +234,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-start-of-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list<span class="Special"> <- </span>remove list, list <span class="Comment"># check structure like before</span> list2:&:list:char<span class="Special"> <- </span>copy list @@ -255,11 +255,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-end-of-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list <span class="Comment"># delete last element</span> list2:&:list:char<span class="Special"> <- </span>rest list list2<span class="Special"> <- </span>rest list2 @@ -281,9 +281,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-singleton-list [ + <span class="Constant">local-scope</span> + list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> run [ - <span class="Constant">local-scope</span> - list:&:list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>remove list, list <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy list ] @@ -305,13 +305,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> reverse-list [ + <span class="Constant">local-scope</span> + list:&:list:number<span class="Special"> <- </span>push <span class="Constant">1</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">2</span>, list + list<span class="Special"> <- </span>push <span class="Constant">3</span>, list run [ - <span class="Constant">local-scope</span> - list:&:list:number<span class="Special"> <- </span>push <span class="Constant">1</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">2</span>, list - list<span class="Special"> <- </span>push <span class="Constant">3</span>, list stash <span class="Constant">[list:]</span>, list - list<span class="Special"> <- </span>reverse list, <span class="Constant">0</span> + list<span class="Special"> <- </span>reverse list stash <span class="Constant">[reversed:]</span>, list ] trace-should-contain [ @@ -342,7 +342,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> in - buf<span class="Special"> <- </span>append buf, <span class="Constant">48/0</span> + buf<span class="Special"> <- </span>append buf, <span class="Constant">[[]</span>] <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># append in.value to buf</span> @@ -371,6 +371,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># past recursion depth; insert ellipses and stop</span> append buf, <span class="Constant">[...]</span> ] + +<span class="muScenario">scenario</span> stash-empty-list [ + <span class="Constant">local-scope</span> + x:&:list:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + run [ + stash x + ] + trace-should-contain [ + app: <span class="Constant">[]</span> + ] +] </pre> </body> </html> diff --git a/html/065duplex_list.mu.html b/html/065duplex_list.mu.html index 7cefee4d..430e9f71 100644 --- a/html/065duplex_list.mu.html +++ b/html/065duplex_list.mu.html @@ -44,7 +44,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> push x:_elem, in:&:duplex-list:_elem<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:&:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> + result:&:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): <span class="muData">type</span><span class="Delimiter">}</span> *result<span class="Special"> <- </span>merge x, in, <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> in @@ -121,7 +121,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> insert x:_elem, in:&:duplex-list:_elem<span class="muRecipe"> -> </span>in:&:duplex-list:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - new-node:&:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): type<span class="Delimiter">}</span> + new-node:&:duplex-list:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(duplex-list _elem): <span class="muData">type</span><span class="Delimiter">}</span> *new-node<span class="Special"> <- </span>put *new-node, <span class="Constant">value:offset</span>, x <span class="Comment"># save old next before changing it</span> next-node:&:duplex-list:_elem<span class="Special"> <- </span>get *in, <span class="Constant">next:offset</span> @@ -133,11 +133,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> inserting-into-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># inside list</span> list2<span class="Special"> <- </span>insert <span class="Constant">6</span>, list2 <span class="Comment"># check structure like before</span> @@ -170,11 +170,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> inserting-at-end-of-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># inside list</span> list2<span class="Special"> <- </span>next list2 <span class="Comment"># now at end of list</span> list2<span class="Special"> <- </span>insert <span class="Constant">6</span>, list2 @@ -208,11 +208,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> inserting-after-start-of-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list<span class="Special"> <- </span>insert <span class="Constant">6</span>, list <span class="Comment"># check structure like before</span> list2:&:duplex-list:char<span class="Special"> <- </span>copy list @@ -274,11 +274,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list2:&:duplex-list:char<span class="Special"> <- </span>next list <span class="Comment"># second element</span> list<span class="Special"> <- </span>remove list2, list <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal list2, <span class="Constant">0</span> @@ -303,11 +303,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-start-of-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list list<span class="Special"> <- </span>remove list, list <span class="Comment"># check structure like before</span> list2:&:duplex-list:char<span class="Special"> <- </span>copy list @@ -329,11 +329,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-end-of-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> + list<span class="Special"> <- </span>push <span class="Constant">4</span>, list + list<span class="Special"> <- </span>push <span class="Constant">5</span>, list run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> - list<span class="Special"> <- </span>push <span class="Constant">4</span>, list - list<span class="Special"> <- </span>push <span class="Constant">5</span>, list <span class="Comment"># delete last element</span> list2:&:duplex-list:char<span class="Special"> <- </span>next list list2<span class="Special"> <- </span>next list2 @@ -360,9 +360,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> removing-from-singleton-duplex-list [ + <span class="Constant">local-scope</span> + list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">3</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>remove list, list <span class="Constant">1</span>:num/<span class="Special">raw <- </span>copy list ] @@ -405,10 +405,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color list<span class="Special"> <- </span>push <span class="Constant">15</span>, list list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># delete 16 onwards</span> <span class="Comment"># first pointer: to the third element</span> list2:&:duplex-list:char<span class="Special"> <- </span>next list @@ -439,10 +436,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color list<span class="Special"> <- </span>push <span class="Constant">15</span>, list list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># delete 15, 16 and 17</span> <span class="Comment"># start pointer: to the second element</span> list2:&:duplex-list:char<span class="Special"> <- </span>next list @@ -474,10 +468,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color list:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">15</span>, <span class="Constant">0</span> list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># delete between first and second element (i.e. nothing)</span> list2:&:duplex-list:char<span class="Special"> <- </span>next list remove-between list, list2 @@ -507,10 +498,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color list<span class="Special"> <- </span>push <span class="Constant">15</span>, list list<span class="Special"> <- </span>push <span class="Constant">14</span>, list list<span class="Special"> <- </span>push <span class="Constant">13</span>, list - <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw <- </span>copy list <span class="Comment"># save list</span> run [ - <span class="Constant">local-scope</span> - list:&:duplex-list:char<span class="Special"> <- </span>copy <span class="Constant">1</span>:&:duplex-list:char/<span class="Special">raw</span> <span class="Comment"># restore list</span> <span class="Comment"># remove the third element and beyond</span> list2:&:duplex-list:char<span class="Special"> <- </span>next list remove-between list2, <span class="Constant">0</span> diff --git a/html/066stream.mu.html b/html/066stream.mu.html index 49abcfb6..6f4f0752 100644 --- a/html/066stream.mu.html +++ b/html/066stream.mu.html @@ -40,7 +40,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-stream s:&:@:_elem<span class="muRecipe"> -> </span>result:&:stream:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(stream _elem): type<span class="Delimiter">}</span> + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(stream _elem): <span class="muData">type</span><span class="Delimiter">}</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">index:offset</span>, <span class="Constant">0</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">data:offset</span>, s ] diff --git a/html/070table.mu.html b/html/070table.mu.html index af164bcd..42dae611 100644 --- a/html/070table.mu.html +++ b/html/070table.mu.html @@ -36,9 +36,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># arbitrary types.</span> <span class="muScenario">scenario</span> table-read-write [ + <span class="Constant">local-scope</span> + tab:&:table:num:num<span class="Special"> <- </span>new-table <span class="Constant">30</span> run [ - <span class="Constant">local-scope</span> - tab:&:table:num:num<span class="Special"> <- </span>new-table <span class="Constant">30</span> put-index tab, <span class="Constant">12</span>, <span class="Constant">34</span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>index tab, <span class="Constant">12</span> ] @@ -48,10 +48,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> table-read-write-non-integer [ + <span class="Constant">local-scope</span> + key:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> + <span class="Delimiter">{</span>tab: (address table text number)<span class="Delimiter">}</span><span class="Special"> <- </span>new-table <span class="Constant">30</span> run [ - <span class="Constant">local-scope</span> - key:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - <span class="Delimiter">{</span>tab: (address table text number)<span class="Delimiter">}</span><span class="Special"> <- </span>new-table <span class="Constant">30</span> put-index tab, key, <span class="Constant">34</span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>index tab, key ] @@ -75,8 +75,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-table capacity:num<span class="muRecipe"> -> </span>result:&:table:_key:_value [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(table _key _value): type<span class="Delimiter">}</span> - data:&:@:table_row:_key:_value<span class="Special"> <- </span>new <span class="Delimiter">{</span>(table_row _key _value): type<span class="Delimiter">}</span>, capacity + result<span class="Special"> <- </span>new <span class="Delimiter">{</span>(table _key _value): <span class="muData">type</span><span class="Delimiter">}</span> + data:&:@:table_row:_key:_value<span class="Special"> <- </span>new <span class="Delimiter">{</span>(table_row _key _value): <span class="muData">type</span><span class="Delimiter">}</span>, capacity *result<span class="Special"> <- </span>merge <span class="Constant">0/length</span>, capacity, data ] diff --git a/html/075channel.mu.html b/html/075channel.mu.html index a2b049a6..e02135ef 100644 --- a/html/075channel.mu.html +++ b/html/075channel.mu.html @@ -83,15 +83,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-channel capacity:num<span class="muRecipe"> -> </span>in:&:source:_elem, out:&:sink:_elem [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:&:channel:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(channel _elem): type<span class="Delimiter">}</span> + result:&:channel:_elem<span class="Special"> <- </span>new <span class="Delimiter">{</span>(channel _elem): <span class="muData">type</span><span class="Delimiter">}</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">first-full:offset</span>, <span class="Constant">0</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">first-free:offset</span>, <span class="Constant">0</span> capacity<span class="Special"> <- </span>add capacity, <span class="Constant">1</span> <span class="Comment"># unused slot for 'full?' below</span> data:&:@:_elem<span class="Special"> <- </span>new <span class="Constant">_elem:type</span>, capacity *result<span class="Special"> <- </span>put *result, <span class="Constant">data:offset</span>, data - in<span class="Special"> <- </span>new <span class="Delimiter">{</span>(source _elem): type<span class="Delimiter">}</span> + in<span class="Special"> <- </span>new <span class="Delimiter">{</span>(source _elem): <span class="muData">type</span><span class="Delimiter">}</span> *in<span class="Special"> <- </span>put *in, <span class="Constant">chan:offset</span>, result - out<span class="Special"> <- </span>new <span class="Delimiter">{</span>(sink _elem): type<span class="Delimiter">}</span> + out<span class="Special"> <- </span>new <span class="Delimiter">{</span>(sink _elem): <span class="muData">type</span><span class="Delimiter">}</span> *out<span class="Special"> <- </span>put *out, <span class="Constant">chan:offset</span>, result ] @@ -213,9 +213,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-write-increments-free [ + <span class="Constant">local-scope</span> + _, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> run [ - <span class="Constant">local-scope</span> - _, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> chan:&:channel:num<span class="Special"> <- </span>get *sink, <span class="Constant">chan:offset</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-full:offset</span> @@ -228,10 +228,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-read-increments-full [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> run [ - <span class="Constant">local-scope</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> _, _, source<span class="Special"> <- </span>read source chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-full:offset</span> @@ -244,14 +244,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-wrap [ + <span class="Constant">local-scope</span> + <span class="Comment"># channel with just 1 slot</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> + <span class="Comment"># write and read a value</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> + _, _, source<span class="Special"> <- </span>read source run [ - <span class="Constant">local-scope</span> - <span class="Comment"># channel with just 1 slot</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> - <span class="Comment"># write and read a value</span> - sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> - _, _, source<span class="Special"> <- </span>read source <span class="Comment"># first-free will now be 1</span> <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-free:offset</span> <span class="Constant">11</span>:num/<span class="Special">raw <- </span>get *chan, <span class="Constant">first-free:offset</span> @@ -285,9 +285,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-write-not-empty [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> run [ - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">3/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>channel-empty? chan <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>channel-full? chan @@ -299,10 +300,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-write-full [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> run [ - <span class="Constant">local-scope</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>channel-empty? chan <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>channel-full? chan @@ -314,11 +315,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> channel-read-not-full [ + <span class="Constant">local-scope</span> + source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> + chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> + sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> run [ - <span class="Constant">local-scope</span> - source:&:source:num, sink:&:sink:num<span class="Special"> <- </span>new-channel <span class="Constant">1/capacity</span> - chan:&:channel:num<span class="Special"> <- </span>get *source, <span class="Constant">chan:offset</span> - sink<span class="Special"> <- </span>write sink, <span class="Constant">34</span> _, _, source<span class="Special"> <- </span>read source <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>channel-empty? chan <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>channel-full? chan diff --git a/html/081print.mu.html b/html/081print.mu.html index 69bed0ed..74318453 100644 --- a/html/081print.mu.html +++ b/html/081print.mu.html @@ -207,9 +207,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-character-at-top-left [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> fake-screen<span class="Special"> <- </span>print fake-screen, a:char cell:&:@:screen-cell<span class="Special"> <- </span>get *fake-screen, <span class="Constant">data:offset</span> @@ -225,9 +225,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-character-in-color [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> fake-screen<span class="Special"> <- </span>print fake-screen, a:char, <span class="Constant">1/red</span> cell:&:@:screen-cell<span class="Special"> <- </span>get *fake-screen, <span class="Constant">data:offset</span> @@ -243,11 +243,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-backspace-character [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + fake-screen<span class="Special"> <- </span>print fake-screen, a run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - fake-screen<span class="Special"> <- </span>print fake-screen, a backspace:char<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> fake-screen<span class="Special"> <- </span>print fake-screen, backspace <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span> @@ -265,14 +265,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-extra-backspace-character [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + fake-screen<span class="Special"> <- </span>print fake-screen, a run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - fake-screen<span class="Special"> <- </span>print fake-screen, a backspace:char<span class="Special"> <- </span>copy <span class="Constant">8/backspace</span> fake-screen<span class="Special"> <- </span>print fake-screen, backspace - fake-screen<span class="Special"> <- </span>print fake-screen, backspace + fake-screen<span class="Special"> <- </span>print fake-screen, backspace <span class="Comment"># cursor already at left margin</span> <span class="Constant">1</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span> cell:&:@:screen-cell<span class="Special"> <- </span>get *fake-screen, <span class="Constant">data:offset</span> <span class="Constant">3</span>:@:screen-cell/<span class="Special">raw <- </span>copy *cell @@ -288,13 +288,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-character-at-right-margin [ + <span class="Comment"># fill top row of screen with text</span> + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + fake-screen<span class="Special"> <- </span>print fake-screen, a + b:char<span class="Special"> <- </span>copy <span class="Constant">98/b</span> + fake-screen<span class="Special"> <- </span>print fake-screen, b run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - fake-screen<span class="Special"> <- </span>print fake-screen, a - b:char<span class="Special"> <- </span>copy <span class="Constant">98/b</span> - fake-screen<span class="Special"> <- </span>print fake-screen, b + <span class="Comment"># cursor now at right margin</span> c:char<span class="Special"> <- </span>copy <span class="Constant">99/c</span> fake-screen<span class="Special"> <- </span>print fake-screen, c <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span> @@ -314,12 +316,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-newline-character [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + fake-screen<span class="Special"> <- </span>print fake-screen, a run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> newline:char<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - fake-screen<span class="Special"> <- </span>print fake-screen, a fake-screen<span class="Special"> <- </span>print fake-screen, newline <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-row:offset</span> <span class="Constant">11</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span> @@ -338,16 +340,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-newline-at-bottom-line [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + newline:char<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> + fake-screen<span class="Special"> <- </span>print fake-screen, newline + fake-screen<span class="Special"> <- </span>print fake-screen, newline run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - newline:char<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> - fake-screen<span class="Special"> <- </span>print fake-screen, newline - fake-screen<span class="Special"> <- </span>print fake-screen, newline + <span class="Comment"># cursor now at bottom of screen</span> fake-screen<span class="Special"> <- </span>print fake-screen, newline <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-row:offset</span> <span class="Constant">11</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span> ] + <span class="Comment"># doesn't move further down</span> memory-should-contain [ <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> @@ -355,18 +359,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-character-at-bottom-right [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> + newline:char<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> + fake-screen<span class="Special"> <- </span>print fake-screen, newline + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + fake-screen<span class="Special"> <- </span>print fake-screen, a + b:char<span class="Special"> <- </span>copy <span class="Constant">98/b</span> + fake-screen<span class="Special"> <- </span>print fake-screen, b + c:char<span class="Special"> <- </span>copy <span class="Constant">99/c</span> + fake-screen<span class="Special"> <- </span>print fake-screen, c + fake-screen<span class="Special"> <- </span>print fake-screen, newline run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span> - newline:char<span class="Special"> <- </span>copy <span class="Constant">10/newline</span> - fake-screen<span class="Special"> <- </span>print fake-screen, newline - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - fake-screen<span class="Special"> <- </span>print fake-screen, a - b:char<span class="Special"> <- </span>copy <span class="Constant">98/b</span> - fake-screen<span class="Special"> <- </span>print fake-screen, b - c:char<span class="Special"> <- </span>copy <span class="Constant">99/c</span> - fake-screen<span class="Special"> <- </span>print fake-screen, c - fake-screen<span class="Special"> <- </span>print fake-screen, newline + <span class="Comment"># cursor now at bottom right</span> d:char<span class="Special"> <- </span>copy <span class="Constant">100/d</span> fake-screen<span class="Special"> <- </span>print fake-screen, d <span class="Constant">10</span>:num/<span class="Special">raw <- </span>get *fake-screen, <span class="Constant">cursor-row:offset</span> @@ -466,15 +471,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> clear-line-erases-printed-characters [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> + <span class="Comment"># print a character</span> + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + fake-screen<span class="Special"> <- </span>print fake-screen, a + <span class="Comment"># move cursor to start of line</span> + fake-screen<span class="Special"> <- </span>move-cursor fake-screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - <span class="Comment"># print a character</span> - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - fake-screen<span class="Special"> <- </span>print fake-screen, a - <span class="Comment"># move cursor to start of line</span> - fake-screen<span class="Special"> <- </span>move-cursor fake-screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> - <span class="Comment"># clear line</span> fake-screen<span class="Special"> <- </span>clear-line fake-screen cell:&:@:screen-cell<span class="Special"> <- </span>get *fake-screen, <span class="Constant">data:offset</span> <span class="Constant">10</span>:@:screen-cell/<span class="Special">raw <- </span>copy *cell @@ -707,11 +711,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> print-text-stops-at-right-margin [ + <span class="Constant">local-scope</span> + fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">local-scope</span> - fake-screen:&:screen<span class="Special"> <- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> - fake-screen<span class="Special"> <- </span>print fake-screen, s:text + fake-screen<span class="Special"> <- </span>print fake-screen, <span class="Constant">[abcd]</span> cell:&:@:screen-cell<span class="Special"> <- </span>get *fake-screen, <span class="Constant">data:offset</span> <span class="Constant">10</span>:@:screen-cell/<span class="Special">raw <- </span>copy *cell ] diff --git a/html/082scenario_screen.cc.html b/html/082scenario_screen.cc.html index a59fe566..54d80832 100644 --- a/html/082scenario_screen.cc.html +++ b/html/082scenario_screen.cc.html @@ -47,10 +47,11 @@ recipes_taking_literal_strings<span class="Delimiter">.</span>insert<span class= <span class="Delimiter">:(scenarios run_mu_scenario)</span> <span class="Delimiter">:(scenario screen_in_scenario)</span> scenario screen-in-scenario [ + local-scope assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - <span class="Constant">1</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:<span class="Normal">char</span>/a + <span class="Normal">a</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -63,12 +64,13 @@ scenario screen-in-scenario [ <span class="Delimiter">:(scenario screen_in_scenario_unicode)</span> scenario screen-in-scenario-unicode-color [ + local-scope assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - <span class="Constant">1</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:<span class="Normal">char</span>/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red - <span class="Constant">2</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:<span class="Normal">char</span>/a + <span class="Normal">lambda</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Normal">a</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -82,12 +84,13 @@ scenario screen-in-scenario-unicode-color [ <span class="Delimiter">:(scenario screen_in_scenario_color)</span> <span class="Comment"># screen-should-contain can check unicode characters in the fake screen</span> scenario screen-in-scenario-color [ + local-scope assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - <span class="Constant">1</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:<span class="Normal">char</span>/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red - <span class="Constant">2</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:<span class="Normal">char</span>/a<span class="Delimiter">,</span> <span class="Constant">7</span>/white + <span class="Normal">lambda</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">955</span>/greek-small-lambda + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Normal">a</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> a<span class="Delimiter">,</span> <span class="Constant">7</span>/white ] <span class="Comment"># screen-should-contain shows everything</span> screen-should-contain [ @@ -118,10 +121,11 @@ scenario screen-in-scenario-color [ <span class="Special">% Scenario_testing_scenario = true;</span> <span class="Special">% Hide_errors = true;</span> scenario screen-in-scenario-error [ + local-scope assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - <span class="Constant">1</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:<span class="Normal">char</span>/a + <span class="Normal">a</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> a ] screen-should-contain [ <span class="Comment"># 01234</span> @@ -137,10 +141,11 @@ scenario screen-in-scenario-error [ <span class="Special">% Hide_errors = true;</span> <span class="Comment"># screen-should-contain can check unicode characters in the fake screen</span> scenario screen-in-scenario-color [ + local-scope assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height run [ - <span class="Constant">1</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a - <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:<span class="Normal">char</span>/a<span class="Delimiter">,</span> <span class="Constant">1</span>/red + <span class="Normal">a</span>:<span class="Normal">char</span><span class="Special"> <- </span>copy <span class="Constant">97</span>/a + <span class="Normal">screen</span>:&:screen<span class="Special"> <- </span>print screen:&:screen<span class="Delimiter">,</span> a<span class="Delimiter">,</span> <span class="Constant">1</span>/red ] screen-should-contain-in-color <span class="Constant">2</span>/green<span class="Delimiter">,</span> [ <span class="Comment"># 01234</span> @@ -172,11 +177,6 @@ $error: <span class="Constant">0</span> <span class="Normal">int</span> Next_predefined_global_for_scenarios = Max_variables_in_scenarios<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Setup")</span> assert<span class="Delimiter">(</span>Next_predefined_global_for_scenarios < Reserved_for_tests<span class="Delimiter">);</span> -<span class="Delimiter">:(after "transform_all()" following "case RUN:")</span> -<span class="Comment">// There's a restriction on the number of variables 'run' can use, so that</span> -<span class="Comment">// it can avoid colliding with the dynamic allocator in case it doesn't</span> -<span class="Comment">// initialize a default-space.</span> -assert<span class="Delimiter">(</span>Name[tmp_recipe<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>][<span class="Constant">""</span>] < Max_variables_in_scenarios<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Globals")</span> <span class="Comment">// Scenario Globals.</span> diff --git a/html/083scenario_screen_test.mu.html b/html/083scenario_screen_test.mu.html index 6aa4e9d6..81fb48ec 100644 --- a/html/083scenario_screen_test.mu.html +++ b/html/083scenario_screen_test.mu.html @@ -31,9 +31,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># To check our support for screens in scenarios, rewrite tests from print.mu</span> <span class="muScenario">scenario</span> print-character-at-top-left-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span> run [ - <span class="Constant">local-scope</span> a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> screen:&:screen<span class="Special"> <- </span>print screen:&:screen, a ] @@ -44,15 +44,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> clear-line-erases-printed-characters-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> + <span class="Comment"># print a character</span> + a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> + screen:&:screen<span class="Special"> <- </span>print screen:&:screen, a + <span class="Comment"># move cursor to start of line</span> + screen:&:screen<span class="Special"> <- </span>move-cursor screen:&:screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> run [ - <span class="Constant">local-scope</span> - <span class="Comment"># print a character</span> - a:char<span class="Special"> <- </span>copy <span class="Constant">97/a</span> - screen:&:screen<span class="Special"> <- </span>print screen:&:screen, a - <span class="Comment"># move cursor to start of line</span> - screen:&:screen<span class="Special"> <- </span>move-cursor screen:&:screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span> - <span class="Comment"># clear line</span> screen:&:screen<span class="Special"> <- </span>clear-line screen:&:screen ] screen-should-contain [ diff --git a/html/084console.mu.html b/html/084console.mu.html index 9a875427..221a3eb8 100644 --- a/html/084console.mu.html +++ b/html/084console.mu.html @@ -43,7 +43,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muData">container</span> touch-event [ - type:num + <span class="muData">type</span>:num row:num column:num ] diff --git a/html/086scenario_console_test.mu.html b/html/086scenario_console_test.mu.html index 4f7fcee9..a12c99ef 100644 --- a/html/086scenario_console_test.mu.html +++ b/html/086scenario_console_test.mu.html @@ -14,6 +14,7 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .muScenario { color: #00af00; } +.muData { color: #ffff00; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #c00000; } @@ -34,7 +35,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> read-key-in-mu [ assume-console [ - type <span class="Constant">[abc]</span> + <span class="muData">type</span> <span class="Constant">[abc]</span> ] run [ <span class="Constant">1</span>:char, console:&:console, <span class="Constant">2</span>:bool<span class="Special"> <- </span>read-key console:&:console diff --git a/html/091socket.cc.html b/html/091socket.cc.html index 00d178b8..d01a297f 100644 --- a/html/091socket.cc.html +++ b/html/091socket.cc.html @@ -179,7 +179,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">char</span> contents[bytes]<span class="Delimiter">;</span> bzero<span class="Delimiter">(</span>contents<span class="Delimiter">,</span> bytes<span class="Delimiter">);</span> <span class="Normal">int</span> bytes_read = read<span class="Delimiter">(</span>socket_fd<span class="Delimiter">,</span> contents<span class="Delimiter">,</span> bytes - <span class="Constant">1</span> <span class="Comment">/*</span><span class="Comment"> null-terminated </span><span class="Comment">*/</span><span class="Delimiter">);</span> - <span class="Comment">//?: cerr << "Read:\n" << string(contents) << "\n";</span> +<span class="CommentedCode">//? cerr << "Read:\n" << string(contents) << "\n";</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>new_mu_text<span class="Delimiter">(</span>string<span class="Delimiter">(</span>contents<span class="Delimiter">)));</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>bytes_read<span class="Delimiter">);</span> @@ -205,7 +205,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// Write one character to a session at a time.</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> y = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Normal">char</span> c = <span class="Normal">static_cast</span><<span class="Normal">char</span>><span class="Delimiter">(</span>y<span class="Delimiter">);</span> - write<span class="Delimiter">(</span>session<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> &c<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>write<span class="Delimiter">(</span>session<span class="Delimiter">-></span>fd<span class="Delimiter">,</span> &c<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"failed to write to socket</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + exit<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> result = <span class="Normal">reinterpret_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>session<span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 8d7e5c0c..8a382806 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -15,9 +15,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } -.Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } +.Special { color: #c00000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } @@ -60,7 +60,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">120/width</span>, <span class="Constant">20/height</span> <span class="Comment"># initialize keyboard to type in a move</span> assume-console [ - type <span class="Constant">[a2-a4</span> + <span class="muData">type</span> <span class="Constant">[a2-a4</span> <span class="Constant">]</span> ] run [ @@ -98,7 +98,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## Here's how 'chessboard' is implemented.</span> -type board = address:@:&:@:char +<span class="muData">type</span> board = address:@:&:@:char <span class="muRecipe">def</span> chessboard screen:&:screen, console:&:console<span class="muRecipe"> -> </span>screen:&:screen, console:&:console [ <span class="Constant">local-scope</span> @@ -146,7 +146,7 @@ type board = address:@:&:@:char correct-length?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">64</span> assert correct-length?, <span class="Constant">[chessboard had incorrect size]</span> <span class="Comment"># board is an array of pointers to files; file is an array of characters</span> - board<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): type<span class="Delimiter">}</span>, <span class="Constant">8</span> + board<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): <span class="muData">type</span><span class="Delimiter">}</span>, <span class="Constant">8</span> col:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal col, <span class="Constant">8</span> diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index a5b87d06..38865350 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -15,9 +15,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } -.Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } +.Special { color: #c00000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } @@ -49,10 +49,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initially-prints-text-to-screen [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> run [ - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> ] screen-should-contain [ <span class="Comment"># top line of screen reserved for menu</span> @@ -130,10 +130,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initializes-without-data [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ - <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 + e:&: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">raw <- </span>copy *e ] memory-should-contain [ <span class="Comment"># 2 (data) <- just the § sentinel</span> @@ -290,11 +291,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -305,10 +307,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initially-handles-offsets [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - new-editor s:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -318,11 +321,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initially-prints-multiple-lines-at-offset [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - new-editor s:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> + new-editor s, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -333,10 +337,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initially-wraps-long-lines [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> - new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -353,10 +358,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initially-wraps-barely-long-lines [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] <span class="Comment"># still wrap, even though the line would fit. We need room to click on the</span> <span class="Comment"># end of the line</span> @@ -375,12 +381,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-initializes-empty-text [ + <span class="Constant">local-scope</span> 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<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> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -396,12 +402,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># just a little color for mu code</span> <span class="muScenario">scenario</span> render-colors-comments [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant"># de</span> <span class="Constant">f]</span> - new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -477,12 +484,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> render-colors-assignment [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">8/width</span>, <span class="Constant">5/height</span> run [ s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d <- e</span> <span class="Constant">f]</span> - new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 469acd95..3c35ec6f 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -14,13 +14,13 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -316,13 +316,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-empty-event-queue [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console <span class="Constant">[]</span> run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -333,18 +333,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> <span class="Comment"># on the 'b'</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -360,17 +360,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># last line, to the right of text</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -380,18 +380,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># interior line, to the right of text</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> @@ -401,18 +402,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-3 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">7</span> <span class="Comment"># below text</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> @@ -422,20 +424,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-column [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> <span class="Comment"># editor occupies only left half of screen</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on right half of screen</span> left-click <span class="Constant">3</span>, <span class="Constant">8</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -451,19 +453,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-in-menu-area [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on first, 'menu' row</span> left-click <span class="Constant">0</span>, <span class="Constant">3</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to cursor</span> memory-should-contain [ @@ -473,16 +475,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-into-empty-editor [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - type <span class="Constant">[abc]</span> + <span class="muData">type</span> <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -494,19 +496,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> left-click <span class="Constant">1</span>, <span class="Constant">2</span> - type <span class="Constant">[d]</span> + <span class="muData">type</span> <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -518,17 +520,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of last line</span> - type <span class="Constant">[d]</span> + <span class="muData">type</span> <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -540,18 +542,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of non-last line</span> - type <span class="Constant">[e]</span> + <span class="muData">type</span> <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -564,17 +567,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> - type <span class="Constant">[d]</span> + <span class="muData">type</span> <span class="Constant">[d]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -586,18 +589,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> - type <span class="Constant">[e]</span> + <span class="muData">type</span> <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -610,18 +614,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> - type <span class="Constant">[ef]</span> + <span class="muData">type</span> <span class="Constant">[ef]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -634,15 +639,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[ab]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[01]</span> + <span class="muData">type</span> <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -655,16 +660,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if the cursor reaches the right margin, wrap the line</span> <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Comment"># type a letter</span> assume-console [ - type <span class="Constant">[e]</span> + <span class="muData">type</span> <span class="Constant">[e]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># no wrap yet</span> screen-should-contain [ @@ -676,10 +681,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># type a second letter</span> assume-console [ - type <span class="Constant">[f]</span> + <span class="muData">type</span> <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># now wrap</span> screen-should-contain [ @@ -692,21 +697,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-wraps-line-on-insert-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Comment"># type more text at the start</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> - type <span class="Constant">[abc]</span> + <span class="muData">type</span> <span class="Constant">[abc]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ @@ -775,17 +781,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</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> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Comment"># right before the wrap icon</span> - type <span class="Constant">[f]</span> + <span class="muData">type</span> <span class="Constant">[f]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -804,9 +810,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># create an editor containing two lines</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">xyz]</span> - <span class="Constant">1</span>:&:editor/<span class="Special">raw <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> @@ -815,10 +821,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">4</span> <span class="Comment"># at end of first line</span> - type <span class="Constant">[de]</span> <span class="Comment"># trigger wrap</span> + <span class="muData">type</span> <span class="Constant">[de]</span> <span class="Comment"># trigger wrap</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">1</span>:&:editor/<span class="Special">raw</span> + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -830,17 +836,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> - <span class="Constant">2</span>:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># line is full; no wrap icon yet</span> - type <span class="Constant">[01]</span> + <span class="muData">type</span> <span class="Constant">[01]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -866,15 +872,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ - type <span class="Constant">[0</span> + <span class="muData">type</span> <span class="Constant">[0</span> <span class="Constant">1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -972,15 +978,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> assume-console [ - type <span class="Constant">[0</span> + <span class="muData">type</span> <span class="Constant">[0</span> <span class="Constant">1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -992,9 +998,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-clears-previous-line-completely-after-inserting-newline [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</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> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -1006,7 +1012,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># line should be fully cleared</span> screen-should-contain [ @@ -1019,21 +1025,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> - type [ + <span class="muData">type</span> [ ] ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ @@ -1043,11 +1050,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline' surrounded by paste markers</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">8</span> @@ -1056,9 +1064,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press <span class="Constant">65506</span> <span class="Comment"># end paste</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 8a6f0fbc..e3085a78 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -20,6 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -39,16 +40,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># tab - insert two spaces</span> <span class="muScenario">scenario</span> editor-inserts-two-spaces-on-tab [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press tab ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -73,19 +75,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># backspace - delete character before cursor</span> <span class="muScenario">scenario</span> editor-handles-backspace-key [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -250,19 +252,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-clears-last-line-on-backspace [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">cd]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">0</span> <span class="Comment"># cursor at only character in final line</span> press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -277,12 +280,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-joins-and-wraps-lines-on-backspace [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc def</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc def</span> <span class="Constant">ghi jkl]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor at the start of the second and hit backspace</span> assume-console [ @@ -290,7 +294,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># resulting single line should wrap correctly</span> screen-should-contain [ @@ -303,11 +307,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-wraps-long-lines-on-backspace [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor in part of the screen with a long line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc def ghij]</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">8/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc def ghij]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + editor-render screen, e <span class="Comment"># confirm that it wraps</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -322,7 +326,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># resulting single line should wrap correctly and not overflow its bounds</span> screen-should-contain [ @@ -337,16 +341,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># delete - delete character at cursor</span> <span class="muScenario">scenario</span> editor-handles-delete-key [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -360,7 +364,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press delete ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -426,17 +430,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># right arrow</span> <span class="muScenario">scenario</span> editor-moves-cursor-right-with-key [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ press right-arrow - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -523,11 +527,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> assume-console [ @@ -537,15 +542,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow <span class="Comment"># next line</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># type something and ensure it goes where it should</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -558,20 +563,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</span> - <span class="Constant">2</span>:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ press right-arrow press right-arrow press right-arrow press right-arrow <span class="Comment"># next line</span> - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -583,19 +589,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcdef]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -612,11 +618,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># line just barely wrapping</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> assume-console [ @@ -624,9 +630,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -637,9 +643,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -649,19 +655,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</span> - <span class="Constant">2</span>:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">1</span>:text, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcdef]</span>, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">4</span> press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -678,20 +684,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press right-arrow - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># new character should be in next line</span> screen-should-contain [ @@ -709,18 +716,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># left arrow</span> <span class="muScenario">scenario</span> editor-moves-cursor-left-with-key [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press left-arrow - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -751,12 +758,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">d]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of second line (so there's no previous newline)</span> assume-console [ @@ -764,9 +772,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -776,23 +784,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with three lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s:text, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor further down (so there's a newline before the character at</span> <span class="Comment"># the cursor)</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> press left-arrow - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -805,21 +814,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of text, press left-arrow, then type a character</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">0</span> press left-arrow - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># left-arrow should have had no effect</span> screen-should-contain [ @@ -833,22 +843,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> d] - <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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e:&:editor <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> press left-arrow - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -861,11 +872,11 @@ d] ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-across-wrap-with-left-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcdef]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -880,9 +891,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> @@ -892,12 +903,13 @@ d] ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line followed by a second line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -912,9 +924,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># previous row</span> @@ -924,12 +936,13 @@ d] ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a line on the verge of wrapping, followed by a second line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcd</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcd</span> <span class="Constant">e]</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> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -944,9 +957,9 @@ d] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> @@ -960,20 +973,21 @@ d] <span class="Comment"># up arrow</span> <span class="muScenario">scenario</span> editor-moves-to-previous-line-with-up-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -981,10 +995,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1076,20 +1090,21 @@ d] ] <span class="muScenario">scenario</span> editor-adjusts-column-at-previous-line [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> <span class="Constant">def]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1097,10 +1112,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1112,20 +1127,21 @@ d] ] <span class="muScenario">scenario</span> editor-adjusts-column-at-empty-line [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new [ + s:text<span class="Special"> <- </span>new [ <span class="muRecipe">def</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1133,10 +1149,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1148,13 +1164,14 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-previous-line-from-left-margin [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># start out with three lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># click on the third line and hit up-arrow, so you end up just after a newline</span> assume-console [ @@ -1162,9 +1179,9 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1172,10 +1189,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1189,20 +1206,21 @@ d] <span class="Comment"># down arrow</span> <span class="muScenario">scenario</span> editor-moves-to-next-line-with-down-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> assume-console [ press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># ..and ends at (2, 0)</span> memory-should-contain [ @@ -1211,10 +1229,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1294,20 +1312,21 @@ d] ] <span class="muScenario">scenario</span> editor-adjusts-column-at-next-line [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1315,10 +1334,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1332,11 +1351,12 @@ d] <span class="Comment"># ctrl-a/home - move cursor to start of line</span> <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> assume-console [ @@ -1344,9 +1364,9 @@ d] press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1407,11 +1427,12 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> assume-console [ @@ -1419,9 +1440,9 @@ d] press ctrl-a ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1432,10 +1453,11 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press 'home'</span> assume-console [ @@ -1443,9 +1465,9 @@ d] press home ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1456,11 +1478,12 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> assume-console [ @@ -1468,9 +1491,9 @@ d] press home ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ @@ -1483,11 +1506,12 @@ d] <span class="Comment"># ctrl-e/end - move cursor to end of line</span> <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> assume-console [ @@ -1495,9 +1519,9 @@ d] press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1507,12 +1531,12 @@ d] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># editor inserts future characters at cursor</span> assume-console [ - type <span class="Constant">[z]</span> + <span class="muData">type</span> <span class="Constant">[z]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1575,11 +1599,12 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> assume-console [ @@ -1587,9 +1612,9 @@ d] press ctrl-e ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">2</span>:&:editor, <span class="Constant">cursor-column:offset</span> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1600,11 +1625,12 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> assume-console [ @@ -1612,9 +1638,9 @@ d] press end ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1625,11 +1651,12 @@ d] ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> assume-console [ @@ -1637,9 +1664,9 @@ d] press end ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ @@ -1652,17 +1679,18 @@ d] <span class="Comment"># ctrl-u - delete text from start of line until (but not at) cursor</span> <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line, press ctrl-u</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">2</span> press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1715,17 +1743,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line (no newline before), press ctrl-u</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1738,17 +1767,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-3 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line, press ctrl-u</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1761,17 +1791,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-start-of-final-line-with-ctrl-u [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of final line, press ctrl-u</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press ctrl-u ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes to start of line</span> screen-should-contain [ @@ -1786,17 +1817,18 @@ d] <span class="Comment"># ctrl-k - delete text from cursor to end of line (but not the newline)</span> <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line, press ctrl-k</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1841,17 +1873,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-2 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line (no newline after), press ctrl-k</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes to end of line</span> screen-should-contain [ @@ -1864,17 +1897,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-3 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes just last character</span> screen-should-contain [ @@ -1887,17 +1921,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-4 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">3</span> press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1910,17 +1945,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-5 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of text</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">2</span> press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes just the final character</span> screen-should-contain [ @@ -1933,17 +1969,18 @@ d] ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-6 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> <span class="Constant">456]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of text</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">3</span> press ctrl-k ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor deletes nothing</span> screen-should-contain [ @@ -1958,14 +1995,15 @@ d] <span class="Comment"># cursor-down can scroll if necessary</span> <span class="muScenario">scenario</span> editor-can-scroll-down-using-arrow-keys [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1978,7 +2016,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2035,15 +2073,16 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-down-past-wrapped-line-using-arrow-keys [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2056,7 +2095,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2068,21 +2107,22 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor starts with a long line wrapping twice</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">0</span> press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line containing a wrap icon</span> screen-should-contain [ @@ -2096,7 +2136,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2108,22 +2148,23 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-down-when-line-wraps [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long line in the third line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdef]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end, type a character</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> - type <span class="Constant">[g]</span> + <span class="muData">type</span> <span class="Constant">[g]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2139,21 +2180,22 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-down-on-newline [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># position cursor after last line and type newline</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">4</span> - type [ + <span class="muData">type</span> [ ] ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2169,22 +2211,23 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-down-on-right-arrow [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2200,23 +2243,24 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-down-on-right-arrow-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains more lines than can fit on screen</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> press right-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2232,11 +2276,12 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-at-end-on-down-arrow [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">de]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> assume-console [ @@ -2244,9 +2289,9 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should scroll, moving cursor to end of text</span> memory-should-contain [ @@ -2254,10 +2299,10 @@ d] <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> ] assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2272,9 +2317,9 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen stops scrolling because cursor is already at top</span> memory-should-contain [ @@ -2283,10 +2328,10 @@ d] ] check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2297,17 +2342,18 @@ d] ] <span class="muScenario">scenario</span> editor-combines-page-and-line-scroll [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a few pages of lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># scroll down one page and one line</span> assume-console [ press page-down @@ -2315,7 +2361,7 @@ d] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen scrolls down 3 lines</span> screen-should-contain [ @@ -2329,14 +2375,15 @@ d] <span class="Comment"># cursor-up can scroll if necessary</span> <span class="muScenario">scenario</span> editor-can-scroll-up-using-arrow-keys [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2349,7 +2396,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2416,15 +2463,16 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2436,7 +2484,7 @@ d] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2449,7 +2497,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2461,20 +2509,21 @@ d] ] <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 4 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor starts with a long line wrapping twice, occupying 3 of the 4 lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2488,7 +2537,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2503,7 +2552,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2518,7 +2567,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2533,15 +2582,16 @@ d] <span class="Comment"># same as editor-scrolls-up-past-wrapped-line-using-arrow-keys but length</span> <span class="Comment"># slightly off, just to prevent over-training</span> <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys-3 [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</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">6/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcde↩ .</span> @@ -2553,7 +2603,7 @@ d] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2566,7 +2616,7 @@ d] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows partial wrapped line</span> screen-should-contain [ @@ -2579,20 +2629,21 @@ d] <span class="Comment"># check empty lines</span> <span class="muScenario">scenario</span> editor-scrolls-up-past-wrapped-line-using-arrow-keys-4 [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with some lines around an empty line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> c d e] - <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">6/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> assume-console [ press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2604,7 +2655,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2616,7 +2667,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2627,21 +2678,22 @@ e] ] <span class="muScenario">scenario</span> editor-scrolls-up-on-left-arrow [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains >3 lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</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> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2654,9 +2706,9 @@ e] press left-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2672,14 +2724,15 @@ e] ] <span class="muScenario">scenario</span> editor-can-scroll-up-to-start-of-file [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2694,7 +2747,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen slides by one line</span> screen-should-contain [ @@ -2708,7 +2761,7 @@ e] press up-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen remains unchanged</span> screen-should-contain [ @@ -2722,12 +2775,13 @@ e] <span class="Comment"># ctrl-f/page-down - render next page if it exists</span> <span class="muScenario">scenario</span> editor-can-scroll [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2739,7 +2793,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2809,11 +2863,12 @@ e] ] <span class="muScenario">scenario</span> editor-does-not-scroll-past-end [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2825,7 +2880,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen remains unmodified</span> screen-should-contain [ @@ -2837,14 +2892,15 @@ e] ] <span class="muScenario">scenario</span> editor-starts-next-page-at-start-of-wrapped-line [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long last line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</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">4/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2857,7 +2913,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2869,13 +2925,14 @@ e] ] <span class="muScenario">scenario</span> editor-starts-next-page-at-start-of-wrapped-line-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</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">4/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2888,7 +2945,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -2902,12 +2959,13 @@ e] <span class="Comment"># ctrl-b/page-up - render previous page if it exists</span> <span class="muScenario">scenario</span> editor-can-scroll-up [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2919,7 +2977,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows next page</span> screen-should-contain [ @@ -2933,7 +2991,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -2996,10 +3054,11 @@ e] ] <span class="muScenario">scenario</span> editor-can-scroll-up-multiple-pages [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with 8 lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> @@ -3007,7 +3066,7 @@ e] <span class="Constant">f</span> <span class="Constant">g</span> <span class="Constant">h]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -3020,7 +3079,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows third page</span> screen-should-contain [ @@ -3034,7 +3093,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows second page</span> screen-should-contain [ @@ -3048,7 +3107,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows original page again</span> screen-should-contain [ @@ -3060,10 +3119,11 @@ e] ] <span class="muScenario">scenario</span> editor-can-scroll-up-wrapped-lines [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 5 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">6/height</span> <span class="Comment"># editor contains a long line in the first page</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh</span> <span class="Constant">i</span> @@ -3074,7 +3134,7 @@ e] <span class="Constant">n</span> <span class="Constant">o]</span> <span class="Comment"># editor screen triggers wrap of last line</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">4/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3091,7 +3151,7 @@ e] press down-arrow ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -3107,7 +3167,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3121,13 +3181,14 @@ e] ] <span class="muScenario">scenario</span> editor-can-scroll-up-wrapped-lines-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</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">4/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3140,7 +3201,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen shows entire wrapped line</span> screen-should-contain [ @@ -3154,7 +3215,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen resets</span> screen-should-contain [ @@ -3166,9 +3227,10 @@ e] ] <span class="muScenario">scenario</span> editor-can-scroll-up-past-nonempty-lines [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[axx</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[axx</span> <span class="Constant">bxx</span> <span class="Constant">cxx</span> <span class="Constant">dxx</span> @@ -3177,7 +3239,7 @@ e] <span class="Constant">gxx</span> <span class="Constant">hxx</span> <span class="Constant">]</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">4/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axx .</span> @@ -3188,7 +3250,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3200,7 +3262,7 @@ e] press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3213,7 +3275,7 @@ e] press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3224,9 +3286,10 @@ e] ] <span class="muScenario">scenario</span> editor-can-scroll-up-past-empty-lines [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[axy</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[axy</span> <span class="Constant">bxy</span> <span class="Constant">cxy</span> @@ -3235,7 +3298,7 @@ exy fxy gxy ] - <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">4/right</span> + e:&:editor<span class="Special"> <- </span>new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axy .</span> @@ -3246,7 +3309,7 @@ gxy press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3258,7 +3321,7 @@ gxy press page-down ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -3271,7 +3334,7 @@ gxy press page-up ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 39b29125..5b97c018 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -14,14 +14,13 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } -.CommentedCode { color: #6c6c6c; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -119,7 +118,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">break-unless</span> is-touch? <span class="Comment"># ignore all but 'left-click' events for now</span> <span class="Comment"># todo: test this</span> - touch-type:num<span class="Special"> <- </span>get t, <span class="Constant">type:offset</span> + touch-type:num<span class="Special"> <- </span>get t, <span class="muData">type</span>:offset is-left-click?:bool<span class="Special"> <- </span>equal touch-type, <span class="Constant">65513/mouse-left</span> <span class="muControl">loop-unless</span> is-left-click?, <span class="Constant">+next-event:label</span> click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> @@ -329,12 +328,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> point-at-multiple-editors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> <span class="Comment"># focus on both sides</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> @@ -342,11 +340,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># check cursor column in each</span> run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:&:editor<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:environment, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">4</span>:&:editor, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:&:editor<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:environment, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:num<span class="Special"> <- </span>get *<span class="Constant">6</span>:&:editor, <span class="Constant">cursor-column:offset</span> + event-loop screen:&:screen, console:&:console, env + recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *recipes, <span class="Constant">cursor-column:offset</span> + sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:num/<span class="Special">raw <- </span>get *sandbox, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -355,26 +353,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> edit-multiple-editors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + render-all screen, env, render <span class="Comment"># type one letter in each of them</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> left-click <span class="Constant">1</span>, <span class="Constant">17</span> - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:&:editor<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:environment, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:num<span class="Special"> <- </span>get *<span class="Constant">4</span>:&:editor, <span class="Constant">cursor-column:offset</span> - <span class="Constant">6</span>:&:editor<span class="Special"> <- </span>get *<span class="Constant">3</span>:&:environment, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:num<span class="Special"> <- </span>get *<span class="Constant">6</span>:&:editor, <span class="Constant">cursor-column:offset</span> + event-loop screen:&:screen, console:&:console, env + recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *recipes, <span class="Constant">cursor-column:offset</span> + sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + <span class="Constant">7</span>:num/<span class="Special">raw <- </span>get *sandbox, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . run (F4) . # this line has a different background, but we don't test that yet</span> @@ -388,8 +385,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># show the cursor at the right window</span> run [ - <span class="Constant">8</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">8</span>:char/cursor + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -400,13 +397,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> multiple-editors-cover-only-their-own-areas [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> run [ - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + render-all screen, env, render ] <span class="Comment"># divider isn't messed up</span> screen-should-contain [ @@ -419,18 +415,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-in-focus-keeps-cursor [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[def]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + render-all screen, env, render <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># is cursor at the right place?</span> screen-should-contain [ @@ -441,12 +436,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># now try typing a letter</span> assume-console [ - type <span class="Constant">[z]</span> + <span class="muData">type</span> <span class="Constant">[z]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># cursor should still be right</span> screen-should-contain [ @@ -458,14 +453,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> backspace-in-sandbox-editor-joins-lines [ -<span class="CommentedCode">#? trace-until 100/app # trace too long</span> + <span class="Constant">local-scope</span> + trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize sandbox side with two lines</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, s:text + render-all screen, env, render screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊abc .</span> @@ -479,9 +474,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press backspace ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># cursor moves to end of old line</span> screen-should-contain [ diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 6aea4d1f..5afc8a83 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -14,13 +14,13 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } -.muData { color: #ffff00; } .Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -77,19 +77,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-and-show-results [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[divide-with-remainder 11, 3]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># check that screen prints the results</span> screen-should-contain [ @@ -135,13 +134,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># run another command</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] - <span class="Comment"># check that screen prints the results</span> + <span class="Comment"># check that screen prints both sandboxes</span> screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -551,23 +550,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-updates-results [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">z:num <- add 2, 2</span> <span class="Constant">reply z</span> <span class="Constant">]</span>] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -583,11 +582,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ left-click <span class="Constant">4</span>, <span class="Constant">28</span> <span class="Comment"># one past the value of the second arg</span> press backspace - type <span class="Constant">[3]</span> + <span class="muData">type</span> <span class="Constant">[3]</span> press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># check that screen updates the result on the right</span> screen-should-contain [ @@ -604,19 +603,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-instruction-manages-screen-per-sandbox [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the code in the editor</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># check that it prints a little toy screen</span> screen-should-contain [ @@ -656,20 +654,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-provides-edited-contents [ + <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc]</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">10/right</span> + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> - type <span class="Constant">[def]</span> + <span class="muData">type</span> <span class="Constant">[def]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <span class="Constant">3</span>:text<span class="Special"> <- </span>editor-contents <span class="Constant">2</span>:&:editor - <span class="Constant">4</span>:@:char<span class="Special"> <- </span>copy *<span class="Constant">3</span>:text + editor-event-loop screen:&:screen, console:&:console, e + s:text<span class="Special"> <- </span>editor-contents e + <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *s ] memory-should-contain [ - <span class="Constant">4</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> + <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> ] ] @@ -830,18 +828,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># scrolling through sandboxes</span> <span class="muScenario">scenario</span> scrolling-down-past-bottom-of-sandbox-editor [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> + render-all screen, env, render assume-console [ <span class="Comment"># create a sandbox</span> press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -855,9 +852,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -873,9 +870,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># sandbox editor displays again, cursor is in editor</span> screen-should-contain [ @@ -963,27 +960,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> scrolling-down-on-recipe-side [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side and create a sandbox</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">]</span> <span class="Comment"># create a sandbox</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[add 2, 2]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes:text, <span class="Constant">[add 2, 2]</span> + render-all screen, env, render assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env <span class="Comment"># hit 'down' in recipe editor</span> assume-console [ press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># cursor moves down on recipe side</span> screen-should-contain [ @@ -996,24 +993,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> scrolling-through-multiple-sandboxes [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊␣ .</span> @@ -1031,9 +1027,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -1053,7 +1049,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># just second sandbox displayed</span> screen-should-contain [ @@ -1070,7 +1066,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># no change</span> screen-should-contain [ @@ -1087,7 +1083,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># back to displaying both sandboxes without editor</span> screen-should-contain [ @@ -1106,9 +1102,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> screen-should-contain [ @@ -1128,9 +1124,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># no change</span> screen-should-contain [ @@ -1148,20 +1144,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> scrolling-manages-sandbox-index-correctly [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create a sandbox</span> assume-console [ press ctrl-n - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -1177,7 +1172,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> @@ -1195,7 +1190,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-up ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> screen-should-contain [ @@ -1213,7 +1208,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> <span class="Comment"># cursor moves to first sandbox</span> diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index dd5adf80..4ed88981 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -20,6 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -36,20 +37,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## see code operate in multiple situations</span> <span class="muScenario">scenario</span> copy-a-sandbox-to-editor [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -65,7 +66,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">69</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># it copies into editor</span> screen-should-contain [ @@ -80,10 +81,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -98,20 +99,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> copy-a-sandbox-to-editor-2 [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -127,7 +128,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">84</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># it copies into editor</span> screen-should-contain [ @@ -142,10 +143,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -255,20 +256,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> copy-fails-if-sandbox-editor-not-empty [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -282,11 +283,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># type something into the sandbox editor, then click on the 'copy' button</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">70</span> <span class="Comment"># put cursor in sandbox editor</span> - type <span class="Constant">[0]</span> <span class="Comment"># type something</span> + <span class="muData">type</span> <span class="Constant">[0]</span> <span class="Comment"># type something</span> left-click <span class="Constant">3</span>, <span class="Constant">70</span> <span class="Comment"># click 'copy' button</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># copy doesn't happen</span> screen-should-contain [ @@ -301,10 +302,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index 21cb2be6..931df954 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -20,6 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -35,20 +36,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## deleting sandboxes</span> <span class="muScenario">scenario</span> deleting-sandboxes [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> <span class="Comment"># run a few commands</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">80</span> - type <span class="Constant">[divide-with-remainder 11, 3]</span> + <span class="muData">type</span> <span class="Constant">[divide-with-remainder 11, 3]</span> press F4 - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -69,7 +69,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">7</span>, <span class="Constant">85</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -87,7 +87,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">99</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -182,23 +182,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> deleting-sandbox-after-scroll [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 press page-down ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -213,7 +212,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">6</span>, <span class="Constant">99</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -228,23 +227,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> deleting-top-sandbox-after-scroll [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 press page-down ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -259,7 +257,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">99</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -274,24 +272,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> deleting-final-sandbox-after-scroll [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 press page-down press page-down ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -306,7 +303,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">99</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># implicitly scroll up to first sandbox</span> screen-should-contain [ @@ -322,22 +319,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> deleting-updates-sandbox-count [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -357,7 +353,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># shouldn't go past last sandbox</span> screen-should-contain [ diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index b7fbe660..9be5a9a1 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -20,6 +20,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -35,20 +36,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## editing sandboxes after they've been created</span> <span class="muScenario">scenario</span> clicking-on-a-sandbox-moves-it-to-editor [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -64,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">55</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -78,10 +79,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -95,20 +96,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> clicking-on-a-sandbox-moves-it-to-editor-2 [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -124,7 +125,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">68</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># it pops back into editor</span> screen-should-contain [ @@ -138,10 +139,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -208,18 +209,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> sandbox-with-print-can-be-edited [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[print-integer screen, 4]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -240,7 +240,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">3</span>, <span class="Constant">65</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -252,24 +252,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editing-sandbox-after-scrolling-resets-scroll [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 press page-down press page-down ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.</span> @@ -284,7 +283,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">2</span>, <span class="Constant">55</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># second sandbox shows in editor; scroll resets to display first sandbox</span> screen-should-contain [ @@ -300,22 +299,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editing-sandbox-updates-sandbox-count [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - render-all screen, <span class="Constant">3</span>:&:environment, render + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ press ctrl-n - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 - type <span class="Constant">[add 1, 1]</span> + <span class="muData">type</span> <span class="Constant">[add 1, 1]</span> press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -334,7 +332,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># no change in contents</span> screen-should-contain [ @@ -356,7 +354,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press page-down ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># screen should show just final sandbox with the right index (1)</span> screen-should-contain [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 579c4cf2..b9095f7e 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -14,13 +14,13 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .muScenario { color: #00af00; } -.muData { color: #ffff00; } .Special { color: #c00000; } .Delimiter { color: #800080; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -36,20 +36,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## clicking on sandbox results to 'fix' them and turn sandboxes into tests</span> <span class="muScenario">scenario</span> sandbox-click-on-result-toggles-color-to-green [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes:text, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">5</span>, <span class="Constant">51</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># color toggles to green</span> screen-should-contain-in-color <span class="Constant">2/green</span>, [ @@ -80,8 +80,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should remain unmoved</span> run [ - <span class="Constant">4</span>:char/cursor<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -100,11 +100,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">11</span> <span class="Comment"># cursor to end of line</span> press backspace - type <span class="Constant">[3]</span> + <span class="muData">type</span> <span class="Constant">[3]</span> press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># result turns red</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index 5ab47bb0..0bff823b 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -14,13 +14,13 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background- body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 12pt; font-size: 1em; } .muScenario { color: #00af00; } -.muData { color: #ffff00; } .Special { color: #c00000; } .Delimiter { color: #800080; } .muRecipe { color: #ff8700; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.muData { color: #ffff00; } .muControl { color: #c0a020; } --> </style> @@ -36,20 +36,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## clicking on the code typed into a sandbox toggles its trace</span> <span class="muScenario">scenario</span> sandbox-click-on-code-toggles-app-trace [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> ]] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -64,9 +64,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - <span class="Constant">4</span>:char/cursor-icon<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> - print screen:&:screen, <span class="Constant">4</span>:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + print screen:&:screen, cursor ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> screen-should-contain [ @@ -90,8 +90,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">4</span>, <span class="Constant">55</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment - print screen:&:screen, <span class="Constant">4</span>:char/cursor-icon + event-loop screen:&:screen, console:&:console, env + print screen:&:screen, cursor ] <span class="Comment"># trace hidden again</span> screen-should-contain [ @@ -106,21 +106,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> sandbox-shows-app-trace-and-result [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> <span class="muControl">reply</span> <span class="Constant">4</span> ]] + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> assume-console [ press F4 ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -136,7 +136,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># trace now printed above result</span> screen-should-contain [ @@ -154,17 +154,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> clicking-on-app-trace-does-nothing [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[stash 123456789]</span> <span class="Comment"># create and expand the trace</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[stash 123456789]</span> assume-console [ press F4 left-click <span class="Constant">4</span>, <span class="Constant">51</span> ] - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . run (F4) .</span> <span class="Constant"> . ┊ .</span> @@ -178,7 +177,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color left-click <span class="Constant">5</span>, <span class="Constant">57</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># no change; doesn't die</span> screen-should-contain [ diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 990dd470..d9228d0e 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -15,9 +15,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } -.Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } +.Special { color: #c00000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } @@ -150,19 +150,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-shows-errors-in-get [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> get 123:num, foo:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -190,22 +190,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> <span class="Comment"># create invalid sandbox 1</span> - type <span class="Constant">[get foo, x:offset]</span> + <span class="muData">type</span> <span class="Constant">[get foo, x:offset]</span> press F4 <span class="Comment"># create invalid sandbox 0</span> - type <span class="Constant">[get foo, x:offset]</span> + <span class="muData">type</span> <span class="Constant">[get foo, x:offset]</span> press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># status line shows that error is in first sandbox</span> screen-should-contain [ @@ -214,25 +213,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-updates-status-with-first-erroneous-sandbox-2 [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">80</span> <span class="Comment"># create invalid sandbox 2</span> - type <span class="Constant">[get foo, x:offset]</span> + <span class="muData">type</span> <span class="Constant">[get foo, x:offset]</span> press F4 <span class="Comment"># create invalid sandbox 1</span> - type <span class="Constant">[get foo, x:offset]</span> + <span class="muData">type</span> <span class="Constant">[get foo, x:offset]</span> press F4 <span class="Comment"># create valid sandbox 0</span> - type <span class="Constant">[add 2, 2]</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># status line shows that error is in second sandbox</span> screen-should-contain [ @@ -241,25 +239,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-hides-errors-from-past-sandboxes [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> assume-console [ press F4 <span class="Comment"># generate error</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">58</span> press ctrl-k - type <span class="Constant">[add 2, 2]</span> <span class="Comment"># valid code</span> + <span class="muData">type</span> <span class="Constant">[add 2, 2]</span> <span class="Comment"># valid code</span> press F4 <span class="Comment"># update sandbox</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># error should disappear</span> screen-should-contain [ @@ -275,21 +272,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-updates-errors-for-shape-shifting-recipes [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Constant">y:&:num <- copy 0</span> <span class="Constant">z <- add x, y</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo 2]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo 2]</span> assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> <span class="Constant"> .recipe foo x:_elem -> z:_elem [ ┊ .</span> @@ -306,7 +303,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># error should remain unchanged</span> screen-should-contain [ @@ -323,20 +320,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-avoids-spurious-errors-on-reloading-shape-shifting-recipes [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># overload a well-known shape-shifting recipe</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe length l:&:list:_elem -> n:num [</span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe length l:&:list:_elem -> n:num [</span> <span class="Constant">]</span>] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[x:&:list:num <- copy 0</span> + sandbox:text<span class="Special"> <- </span>new <span class="Constant">[x:&:list:num <- copy 0</span> <span class="Constant">to-text x]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, sandbox <span class="Comment"># run it once</span> assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env <span class="Comment"># no errors anywhere on screen (can't check anything else, since to-text will return an address)</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ <span class="Constant"> . .</span> @@ -360,7 +358,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># still no errors</span> screen-should-contain-in-color <span class="Constant">1/red</span>, [ @@ -383,19 +381,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-shows-missing-type-errors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -408,20 +406,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-shows-unbalanced-bracket-errors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo \\[</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -436,21 +434,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-shows-get-on-non-container-errors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:&:point <- new point:type</span> <span class="Constant"> get x:&:point, 1:offset</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -468,22 +466,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-shows-non-literal-get-argument-errors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:num <- copy 0</span> <span class="Constant"> y:&:point <- new point:type</span> <span class="Constant"> get *y:&:point, x:num</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -502,20 +500,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-shows-errors-everytime [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:num <- copy y:num</span> <span class="Constant">]</span>] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> <span class="Constant"> . ┊foo .</span> @@ -532,7 +530,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found run (F4) .</span> @@ -548,19 +546,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-instruction-and-print-errors [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + sandbox:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, sandbox <span class="Comment"># run the code in the editors</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># check that screen prints error message in red</span> screen-should-contain [ @@ -611,20 +608,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> run-instruction-and-print-errors-only-once [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</span> <span class="Comment"># right editor contains an illegal instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + sandbox:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">[]</span>, sandbox <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># check that screen prints error message just once</span> screen-should-contain [ @@ -642,23 +638,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> sandbox-can-handle-infinite-loop [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant"> {</span> <span class="Constant"> loop</span> <span class="Constant"> }</span> <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> @@ -673,10 +669,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> sandbox-with-errors-shows-trace [ + <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a error</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">a:num <- next-ingredient</span> <span class="Constant">b:num <- next-ingredient</span> @@ -684,13 +681,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color _, c:num<span class="Special"> <- </span>divide-with-remainder a, b <span class="muControl">reply</span> b ]] - <span class="Constant">2</span>:text<span class="Special"> <- </span>new <span class="Constant">[foo 4, 0]</span> - <span class="Constant">3</span>:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, <span class="Constant">1</span>:text, <span class="Constant">2</span>:text + env:&:environment<span class="Special"> <- </span>new-programming-environment screen:&:screen, recipes, <span class="Constant">[foo 4, 0]</span> <span class="Comment"># run</span> assume-console [ press F4 ] - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env <span class="Comment"># screen prints error message</span> screen-should-contain [ <span class="Constant"> . errors found (0) run (F4) .</span> @@ -708,7 +704,7 @@ _, c:num<span class="Special"> <- </span>divide-with-remainder a, b left-click <span class="Constant">4</span>, <span class="Constant">55</span> ] run [ - event-loop screen:&:screen, console:&:console, <span class="Constant">3</span>:&:environment + event-loop screen:&:screen, console:&:console, env ] <span class="Comment"># screen should expand trace</span> screen-should-contain [ diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index 45abb7e9..be0db050 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -15,9 +15,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } .muData { color: #ffff00; } -.Special { color: #c00000; } .muScenario { color: #00af00; } .Delimiter { color: #800080; } +.Special { color: #c00000; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } @@ -134,21 +134,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># undo typing</span> <span class="muScenario">scenario</span> editor-can-undo-typing [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor and type a character</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># character should be gone</span> screen-should-contain [ @@ -159,10 +159,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -264,21 +264,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-typing-multiple [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor and type multiple characters</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[012]</span> + <span class="muData">type</span> <span class="Constant">[012]</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># all characters must be gone</span> screen-should-contain [ @@ -290,16 +290,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-typing-multiple-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[a]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># type some characters</span> assume-console [ - type <span class="Constant">[012]</span> + <span class="muData">type</span> <span class="Constant">[012]</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .012a .</span> @@ -311,7 +311,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -322,10 +322,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[3]</span> + <span class="muData">type</span> <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -336,17 +336,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-typing-enter [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[ abc]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[ abc]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># new line</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">8</span> press enter ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . abc .</span> @@ -355,8 +355,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] <span class="Comment"># line is indented</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -366,10 +366,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - <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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">5</span> @@ -383,10 +383,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be at end of line</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -399,16 +399,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># redo typing</span> <span class="muScenario">scenario</span> editor-redo-typing [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[a]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[012]</span> + <span class="muData">type</span> <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -420,7 +420,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -431,10 +431,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[3]</span> + <span class="muData">type</span> <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -463,16 +463,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-redo-typing-empty [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[012]</span> + <span class="muData">type</span> <span class="Constant">[012]</span> press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . .</span> @@ -484,7 +484,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># all characters must be back</span> screen-should-contain [ @@ -495,10 +495,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[3]</span> + <span class="muData">type</span> <span class="Constant">[3]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -509,23 +509,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-work-clears-redo-stack [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text, do some work, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># do some more work</span> assume-console [ - type <span class="Constant">[0]</span> + <span class="muData">type</span> <span class="Constant">[0]</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .0abc .</span> @@ -538,7 +539,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># nothing should happen</span> screen-should-contain [ @@ -551,22 +552,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-redo-typing-and-enter-and-tab [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ press tab - type <span class="Constant">[ab]</span> + <span class="muData">type</span> <span class="Constant">[ab]</span> press tab - type <span class="Constant">[cd]</span> + <span class="muData">type</span> <span class="Constant">[cd]</span> press enter press tab - type <span class="Constant">[efg]</span> + <span class="muData">type</span> <span class="Constant">[efg]</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> . ab cd .</span> @@ -574,8 +575,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> @@ -585,11 +586,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># typing in second line deleted, but not indent</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -606,11 +607,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># indent and newline deleted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> @@ -626,11 +627,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># empty screen</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -646,11 +647,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># first line inserted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> @@ -666,11 +667,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># newline and indent inserted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -687,11 +688,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># indent and newline deleted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> @@ -708,38 +709,39 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># undo cursor movement and scroll</span> <span class="muScenario">scenario</span> editor-can-undo-touch [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># click undone</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -798,21 +800,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-scroll [ + <span class="Constant">local-scope</span> <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</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> + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">3</span> press right-arrow ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> <span class="Comment"># screen scrolls</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -829,11 +832,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moved back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -847,10 +850,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -861,39 +864,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-left-arrow [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press left-arrow ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -905,21 +909,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-up-arrow [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -929,21 +934,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -955,39 +960,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-down-arrow [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press down-arrow ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -999,29 +1005,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-ctrl-f [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># scroll the page</span> assume-console [ press ctrl-f ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1034,29 +1039,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-page-down [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># scroll the page</span> assume-console [ press page-down ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen should again show page 1</span> screen-should-contain [ @@ -1069,30 +1073,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-ctrl-b [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># scroll the page down and up</span> assume-console [ press page-down press ctrl-b ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1105,30 +1108,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-page-up [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># scroll the page down and up</span> assume-console [ press page-down press page-up ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># screen should again show page 2</span> screen-should-contain [ @@ -1141,39 +1143,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-ctrl-a [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press ctrl-a ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1185,39 +1188,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-home [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press home ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1229,39 +1233,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-ctrl-e [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press ctrl-e ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1273,39 +1278,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-end [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> press end ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># undo</span> assume-console [ press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves back</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1317,13 +1323,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-multiple-arrows-in-the-same-direction [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ left-click <span class="Constant">2</span>, <span class="Constant">1</span> @@ -1331,9 +1338,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press right-arrow press up-arrow ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1343,11 +1350,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># up-arrow is undone</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1357,11 +1364,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># both right-arrows are undone</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1371,38 +1378,39 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># redo cursor movement and scroll</span> <span class="muScenario">scenario</span> editor-redo-touch [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text, click on a character, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ left-click <span class="Constant">3</span>, <span class="Constant">1</span> press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e <span class="Comment"># redo</span> assume-console [ press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># cursor moves to left-click</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1428,19 +1436,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-separates-undo-insert-from-undo-cursor-move [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type some text, move the cursor, type some more text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e assume-console [ - type <span class="Constant">[abc]</span> + <span class="muData">type</span> <span class="Constant">[abc]</span> left-click <span class="Constant">1</span>, <span class="Constant">1</span> - type <span class="Constant">[d]</span> + <span class="muData">type</span> <span class="Constant">[d]</span> ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .adbc .</span> @@ -1456,9 +1464,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># last letter typed is deleted</span> screen-should-contain [ @@ -1476,9 +1484,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to screen; cursor moves</span> screen-should-contain [ @@ -1496,9 +1504,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen empty</span> screen-should-contain [ @@ -1516,9 +1524,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># first insert</span> screen-should-contain [ @@ -1536,9 +1544,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves</span> screen-should-contain [ @@ -1557,9 +1565,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor - <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> + editor-event-loop screen:&:screen, console:&:console, e + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># second insert</span> screen-should-contain [ @@ -1577,26 +1585,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># undo backspace</span> <span class="muScenario">scenario</span> editor-can-undo-and-redo-backspace [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># insert some text and hit backspace</span> assume-console [ - type <span class="Constant">[abc]</span> + <span class="muData">type</span> <span class="Constant">[abc]</span> press backspace press backspace ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1606,10 +1614,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - <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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> @@ -1625,10 +1633,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - <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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1722,29 +1730,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># undo delete</span> <span class="muScenario">scenario</span> editor-can-undo-and-redo-delete [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ - type <span class="Constant">[abcdef]</span> + <span class="muData">type</span> <span class="Constant">[abcdef]</span> left-click <span class="Constant">1</span>, <span class="Constant">2</span> press delete press backspace press delete press delete ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .af .</span> <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1754,10 +1762,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - <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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1773,10 +1781,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - <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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1792,10 +1800,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] - <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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1811,11 +1819,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># first line inserted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -1831,11 +1839,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># first line inserted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1851,11 +1859,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># first line inserted</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1911,18 +1919,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># undo ctrl-k</span> <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-k [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">1</span> press ctrl-k ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -1930,8 +1939,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1941,7 +1950,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1950,8 +1959,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> @@ -1961,7 +1970,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -1971,18 +1980,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2013,18 +2022,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># undo ctrl-u</span> <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> <span class="Constant">def]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor contents, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ left-click <span class="Constant">1</span>, <span class="Constant">2</span> press ctrl-u ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .c .</span> @@ -2032,8 +2042,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> @@ -2043,7 +2053,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-z ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2052,8 +2062,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> @@ -2063,7 +2073,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press ctrl-y ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] <span class="Comment"># first line inserted</span> screen-should-contain [ @@ -2073,18 +2083,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .┈┈┈┈┈┈┈┈┈┈.</span> <span class="Constant"> . .</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> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> + <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ - type <span class="Constant">[1]</span> + <span class="muData">type</span> <span class="Constant">[1]</span> ] run [ - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e ] screen-should-contain [ <span class="Constant"> . .</span> @@ -2114,18 +2124,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muScenario">scenario</span> editor-can-undo-and-redo-ctrl-u-2 [ + <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - <span class="Constant">1</span>:text<span class="Special"> <- </span>new <span class="Constant">[]</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">10/right</span> - editor-render screen, <span class="Constant">2</span>:&:editor + e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ - type <span class="Constant">[abc]</span> + <span class="muData">type</span> <span class="Constant">[abc]</span> press ctrl-u press ctrl-z ] - editor-event-loop screen:&:screen, console:&:console, <span class="Constant">2</span>:&:editor + editor-event-loop screen:&:screen, console:&:console, e screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> |