summary refs log tree commit diff stats
path: root/widgets/dirlist.go
Commit message (Collapse)AuthorAgeFilesLines
* Move msgstore map to dirstoreJeffas2019-07-261-0/+12
| | | | | | This map represents a mapping from directory names to their associated messagestores anyway so they should be under dirstore. This simply moves them there and adds some methods required to interact with them.
* Show the directory being selected in grayJeffas2019-07-251-0/+3
|
* Factor UI models out of the worker message packageBen Burwell2019-07-081-1/+1
| | | | | | | | Before, the information needed to display different parts of the UI was tightly coupled to the specific messages being sent back and forth to the backend worker. Separating out a models package allows us to be more specific about exactly what a backend is able to and required to provide for the UI.
* Sort out dirstore once and for allDrew DeVault2019-07-041-0/+1
|
* dirlist: simplify nextPrev() considerablyReto Brunner2019-07-041-25/+11
| | | | | | | Assuming we always have a sorted dirlist (other code depends on that already), we don't need to loop over the dirStore. Any filtering done should be performed elsewhere
* dirlist: remove the additional filtering in Draw()Reto Brunner2019-07-041-7/+0
|
* dirlist: sync dirstore in filterDirsByFoldersConfigReto Brunner2019-07-041-9/+7
| | | | | Also sets the public List() method to return the unfiltered list of directories directly from the store.
* Add IMAP folder tab completionGregory Mullen2019-07-041-1/+5
| | | | | Credit for this fix goes to Reto; I guess if we're not gonna be mutt we should probabaly do things correctly.
* Revert "Remove dirs field and references to it"Drew DeVault2019-07-021-11/+10
| | | | This reverts commit 0e55637aac92e748267559b7aa91a188a17c386f.
* Remove dirs field and references to itRobert Günzler2019-06-301-10/+11
| | | | | This fixes prev/next-folder that broke after 546dfcd76dd228e0605359e9985f0b6a5672e8fa
* Add new lib/dirstore to source completions fromGregory Mullen2019-06-291-4/+7
|
* Implement basic tab completion supportGregory Mullen2019-06-291-0/+4
| | | | | Tab completion currently only works on commands. Contextual completion will be added in the future.
* Set empty message in dirlist if no folder exist.Reto Brunner2019-06-141-16/+24
|
* imap: respect the folder config optionReto Brunner2019-06-141-11/+31
|
* s/aerc2/aerc/gDrew DeVault2019-05-171-3/+3
|
* Force INBOX to be included in dirlistDrew DeVault2019-05-141-0/+11
|
* Split ex line text handling into dedicated widgetDrew DeVault2019-05-111-7/+7
|
* lib/ui: introduce InvalidatableSimon Ser2019-04-271-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many Drawable implementations have their own Invalidate and OnInvalidate functions, with an unexported onInvalidate field. However OnInvalidate and Invalidate are usually not called in the same goroutine. This results in a race on this field, e.g.: Read at 0x00c000094748 by goroutine 7: git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList.func1() /home/simon/src/aerc2/widgets/dirlist.go:85 +0x56 git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1() /home/simon/src/aerc2/widgets/spinner.go:93 +0x1bb Previous write at 0x00c000094748 by main goroutine: [failed to restore the stack] Goroutine 7 (running) created at: git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start() /home/simon/src/aerc2/widgets/spinner.go:46 +0x8f git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList() /home/simon/src/aerc2/widgets/dirlist.go:37 +0x286 git.sr.ht/~sircmpwn/aerc2/widgets.NewAccountView() /home/simon/src/aerc2/widgets/account.go:50 +0x5ca git.sr.ht/~sircmpwn/aerc2/widgets.NewAerc() /home/simon/src/aerc2/widgets/aerc.go:60 +0x800 main.main() /home/simon/src/aerc2/aerc.go:65 +0x33e To fix this, introduce a new type, Invalidatable, which protects the field. Unfortunately the Drawable must be passed to the callback function in Invalidate, so we still need to re-implement this in each Invalidatable user.
* Use tcell.Style.Reverse instead of black on whiteDrew DeVault2019-03-301-2/+1
|
* Fix nil dereference on rapidly cycling foldersDrew DeVault2019-03-151-1/+1
|
* widgets/directories.go -> widgets/dirlist.goDrew DeVault2019-03-141-0/+156
word.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 082scenario_screen.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.traceAbsent { color: #c00000; }
.cSpecial { color: #008000; }
.traceContains { color: #008000; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Special { color: #c00000; }
.Identifier { color: #fcb165; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Clean syntax to manipulate and check the screen in scenarios.</span>
<span class="Comment">//: Instructions 'assume-screen' and 'screen-should-contain' implicitly create</span>
<span class="Comment">//: a variable called 'screen' that is accessible inside other 'run'</span>
<span class="Comment">//: instructions in the scenario. 'screen-should-contain' can check unicode</span>
<span class="Comment">//: characters in the fake screen</span>

<span class="Delimiter">:(scenarios run_mu_scenario)</span>
<span class="Delimiter">:(scenario screen_in_scenario)</span>
scenario screen-in-scenario [
  assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height
  run [
    <span class="Constant">1</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">97</span>/a
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a
  ]
  screen-should-contain [
  <span class="Comment">#  01234</span>
    <span class="Delimiter">.</span>a    <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
]

<span class="Delimiter">:(scenario screen_in_scenario_unicode)</span>
scenario screen-in-scenario-unicode-color [
  assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height
  run [
    <span class="Constant">1</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">955</span>/greek-small-lambda
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red
    <span class="Constant">2</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">97</span>/a
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a
  ]
  screen-should-contain [
  <span class="Comment">#  01234</span>
    <span class="Delimiter">.</span>λa   <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
]

<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 [
  assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height
  run [
    <span class="Constant">1</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">955</span>/greek-small-lambda
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/lambda<span class="Delimiter">,</span> <span class="Constant">1</span>/red
    <span class="Constant">2</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">97</span>/a
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">2</span>:character/a<span class="Delimiter">,</span> <span class="Constant">7</span>/white
  ]
  <span class="Comment"># screen-should-contain shows everything</span>
  screen-should-contain [
  <span class="Comment">#  01234</span>
    <span class="Delimiter">.</span>λa   <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
  <span class="Comment"># screen-should-contain-in-color filters out everything except the given</span>
  <span class="Comment"># color, all you see is the 'a' in white.</span>
  screen-should-contain-in-color <span class="Constant">7</span>/white<span class="Delimiter">,</span> [
  <span class="Comment">#  01234</span>
    <span class="Delimiter">.</span> a   <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
  <span class="Comment"># ..and the λ in red.</span>
  screen-should-contain-in-color <span class="Constant">1</span>/red<span class="Delimiter">,</span> [
  <span class="Comment">#  01234</span>
    <span class="Delimiter">.</span>λ    <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
]

<span class="Delimiter">:(scenario screen_in_scenario_error)</span>
<span class="Special">% Scenario_testing_scenario = true;</span>
<span class="Special">% Hide_errors = true;</span>
scenario screen-in-scenario-error [
  assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height
  run [
    <span class="Constant">1</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">97</span>/a
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/a
  ]
  screen-should-contain [
  <span class="Comment">#  01234</span>
    <span class="Delimiter">.</span>b    <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
]
<span class="traceContains">+error: expected screen location (0, 0) to contain 98 ('b') instead of 97 ('a')</span>

<span class="Delimiter">:(scenario screen_in_scenario_color_error)</span>
<span class="Special">% Scenario_testing_scenario = true;</span>
<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 [
  assume-screen <span class="Constant">5</span>/width<span class="Delimiter">,</span> <span class="Constant">3</span>/height
  run [
    <span class="Constant">1</span>:character<span class="Special"> &lt;- </span>copy <span class="Constant">97</span>/a
    <span class="Normal">screen</span>:address:screen<span class="Special"> &lt;- </span>print screen:address:screen<span class="Delimiter">,</span> <span class="Constant">1</span>:character/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>
    <span class="Delimiter">.</span>a    <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
    <span class="Delimiter">.</span>     <span class="Delimiter">.</span>
  ]
]
<span class="traceContains">+error: expected screen location (0, 0) to be in color 2 instead of 1</span>

<span class="Comment">//: allow naming just for 'screen'</span>
<span class="Delimiter">:(before &quot;End is_special_name Cases&quot;)</span>
<span class="Normal">if</span> <span class="Delimiter">(</span>s == <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span>

<span class="Delimiter">:(scenarios run)</span>
<span class="Delimiter">:(scenario convert_names_does_not_fail_when_mixing_special_names_and_numeric_locations)</span>
<span class="Special">% Scenario_testing_scenario = true;</span>
def main [
  <span class="Normal">screen</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>:number
]
<span class="traceAbsent">-error: mixing variable names and numeric addresses in main</span>
$error: <span class="Constant">0</span>
<span class="Delimiter">:(scenarios run_mu_scenario)</span>

<span class="Delimiter">:(before &quot;End Globals&quot;)</span>
<span class="Comment">// Scenarios may not define default-space, so they should fit within the</span>
<span class="Comment">// initial area of memory reserved for tests. We'll put the predefined</span>
<span class="Comment">// variables available to them at the end of that region.</span>
<span class="Normal">const</span> <span class="Normal">int</span> Max_variables_in_scenarios = Reserved_for_tests-<span class="Constant">100</span><span class="Delimiter">;</span>
<span class="Normal">int</span> Next_predefined_global_for_scenarios = Max_variables_in_scenarios<span class="Delimiter">;</span>
<span class="Delimiter">:(before &quot;End Setup&quot;)</span>
assert<span class="Delimiter">(</span>Next_predefined_global_for_scenarios &lt; Reserved_for_tests<span class="Delimiter">);</span>
<span class="Delimiter">:(after &quot;transform_all()&quot; following &quot;case RUN:&quot;)</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">&quot;&quot;</span>] &lt; Max_variables_in_scenarios<span class="Delimiter">);</span>

<span class="Delimiter">:(before &quot;End Globals&quot;)</span>
<span class="Comment">// Scenario Globals.</span>
<span class="Normal">const</span> <span class="Normal">int</span> SCREEN = Next_predefined_global_for_scenarios++<span class="Delimiter">;</span>
<span class="Comment">// End Scenario Globals.</span>
<span class="Delimiter">:(before &quot;End Special Scenario Variable Names(r)&quot;)</span>
Name[r][<span class="Constant">&quot;screen&quot;</span>] = SCREEN<span class="Delimiter">;</span>

<span class="Delimiter">:(before &quot;End Rewrite Instruction(curr, recipe result)&quot;)</span>
<span class="Comment">// rewrite `assume-screen width, height` to</span>
<span class="Comment">// `screen:address:screen &lt;- new-fake-screen width, height`</span>
<span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;assume-screen&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
  curr<span class="Delimiter">.</span>name = <span class="Constant">&quot;new-fake-screen&quot;</span><span class="Delimiter">;</span>
  assert<span class="Delimiter">(</span>curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">());</span>
  curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">&quot;screen:address:screen&quot;</span><span class="Delimiter">));</span>
  curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>SCREEN<span class="Delimiter">);</span>
<span class="Delimiter">}</span>

<span class="Comment">//: screen-should-contain is a regular instruction</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
SCREEN_SHOULD_CONTAIN<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen-should-contain&quot;</span><span class="Delimiter">,</span> SCREEN_SHOULD_CONTAIN<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> SCREEN_SHOULD_CONTAIN: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> SCREEN_SHOULD_CONTAIN: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
  assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span>
  check_screen<span class="Delimiter">(</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="Delimiter">,</span> -<span class="Constant">1</span><span class="Delimiter">);</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
SCREEN_SHOULD_CONTAIN_IN_COLOR<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen-should-contain-in-color&quot;</span><span class="Delimiter">,</span> SCREEN_SHOULD_CONTAIN_IN_COLOR<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> SCREEN_SHOULD_CONTAIN_IN_COLOR: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> SCREEN_SHOULD_CONTAIN_IN_COLOR: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
  assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span>
  assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)));</span>
  check_screen<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">,</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Types&quot;)</span>
<span class="Comment">// scan an array of characters in a unicode-aware, bounds-checked manner</span>
<span class="Normal">struct</span> raw_string_stream <span class="Delimiter">{</span>
  <span class="Normal">int</span> index<span class="Delimiter">;</span>
  <span class="Normal">const</span> <span class="Normal">int</span> max<span class="Delimiter">;</span>
  <span class="Normal">const</span> <span class="Normal">char</span>* buf<span class="Delimiter">;</span>

  raw_string_stream<span class="Delimiter">(</span><span class="Normal">const</span> string&amp;<span class="Delimiter">);</span>
  <span class="Normal">uint32_t</span> get<span class="Delimiter">();</span>  <span class="Comment">// unicode codepoint</span>
  <span class="Normal">uint32_t</span> peek<span class="Delimiter">();</span>  <span class="Comment">// unicode codepoint</span>
  <span class="Normal">bool</span> at_end<span class="Delimiter">()</span> <span class="Normal">const</span><span class="Delimiter">;</span>
  <span class="Normal">void</span> skip_whitespace_and_comments<span class="Delimiter">();</span>
<span class="Delimiter">};</span>

<span class="Delimiter">:(code)</span>
<span class="Normal">void</span> check_screen<span class="Delimiter">(</span><span class="Normal">const</span> string&amp; expected_contents<span class="Delimiter">,</span> <span class="Normal">const</span> <span class="Normal">int</span> color<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>!current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span>  <span class="Comment">// not supported</span>
  <span class="Normal">int</span> screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span>+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> data_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">),</span> <span class="Constant">&quot;data&quot;</span><span class="Delimiter">,</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">);</span>
  assert<span class="Delimiter">(</span>data_offset &gt;= <span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> screen_data_location = screen_location+data_offset<span class="Delimiter">;</span>  <span class="Comment">// type: address:array:character</span>
  <span class="Normal">int</span> screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>  <span class="Comment">// type: array:character</span>
  <span class="Normal">int</span> width_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">),</span> <span class="Constant">&quot;num-columns&quot;</span><span class="Delimiter">,</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span>
  <span class="Normal">int</span> height_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">),</span> <span class="Constant">&quot;num-rows&quot;</span><span class="Delimiter">,</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span>
  raw_string_stream cursor<span class="Delimiter">(</span>expected_contents<span class="Delimiter">);</span>
  <span class="Comment">// todo: too-long expected_contents should fail</span>
  <span class="Normal">int</span> addr = screen_data_start+<span class="Comment">/*</span><span class="Comment">skip length</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> row = <span class="Constant">0</span><span class="Delimiter">;</span> row &lt; screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    cursor<span class="Delimiter">.</span>skip_whitespace_and_comments<span class="Delimiter">();</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>at_end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
    assert<span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>get<span class="Delimiter">()</span> == <span class="Constant">'.'</span><span class="Delimiter">);</span>
    <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> column = <span class="Constant">0</span><span class="Delimiter">;</span>  column &lt; screen_width<span class="Delimiter">;</span>  ++column<span class="Delimiter">,</span> addr+= <span class="Comment">/*</span><span class="Comment">size of screen-cell</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
      <span class="Normal">const</span> <span class="Normal">int</span> cell_color_offset = <span class="Constant">1</span><span class="Delimiter">;</span>
      <span class="Normal">uint32_t</span> curr = cursor<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)</span> == <span class="Constant">0</span> &amp;&amp; isspace<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>curr == <span class="Constant">' '</span> &amp;&amp; color != -<span class="Constant">1</span> &amp;&amp; color != get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr+cell_color_offset<span class="Delimiter">))</span> <span class="Delimiter">{</span>
        <span class="Comment">// filter out other colors</span>
        <span class="Identifier">continue</span><span class="Delimiter">;</span>
      <span class="Delimiter">}</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)</span> != <span class="Constant">0</span> &amp;&amp; get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)</span> == curr<span class="Delimiter">)</span> <span class="Delimiter">{</span>
        <span class="Normal">if</span> <span class="Delimiter">(</span>color == -<span class="Constant">1</span> || color == get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr+cell_color_offset<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
        <span class="Comment">// contents match but color is off</span>
        <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario &amp;&amp; !Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span>
          <span class="Comment">// genuine test in a mu file</span>
          raise &lt;&lt; <span class="Constant">&quot;</span><span class="cSpecial">\n</span><span class="Constant">F - &quot;</span> &lt;&lt; Current_scenario<span class="Delimiter">-&gt;</span>name &lt;&lt; <span class="Constant">&quot;: expected screen location (&quot;</span> &lt;&lt; row &lt;&lt; <span class="Constant">&quot;, &quot;</span> &lt;&lt; column &lt;&lt; <span class="Constant">&quot;, address &quot;</span> &lt;&lt; addr &lt;&lt; <span class="Constant">&quot;, value &quot;</span> &lt;&lt; no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">))</span> &lt;&lt; <span class="Constant">&quot;) to be in color &quot;</span> &lt;&lt; color &lt;&lt; <span class="Constant">&quot; instead of &quot;</span> &lt;&lt; no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr+cell_color_offset<span class="Delimiter">))</span> &lt;&lt; <span class="Constant">&quot;</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
          dump_screen<span class="Delimiter">();</span>
        <span class="Delimiter">}</span>
        <span class="Normal">else</span> <span class="Delimiter">{</span>
          <span class="Comment">// just testing check_screen</span>
          raise &lt;&lt; <span class="Constant">&quot;expected screen location (&quot;</span> &lt;&lt; row &lt;&lt; <span class="Constant">&quot;, &quot;</span> &lt;&lt; column &lt;&lt; <span class="Constant">&quot;) to be in color &quot;</span> &lt;&lt; color &lt;&lt; <span class="Constant">&quot; instead of &quot;</span> &lt;&lt; no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr+cell_color_offset<span class="Delimiter">))</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
        <span class="Delimiter">}</span>
        <span class="Normal">if</span> <span class="Delimiter">(</span>!Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span>
          Passed = <span class="Constant">false</span><span class="Delimiter">;</span>
          ++Num_failures<span class="Delimiter">;</span>
        <span class="Delimiter">}</span>
        <span class="Identifier">return</span><span class="Delimiter">;</span>
      <span class="Delimiter">}</span>

      <span class="Comment">// really a mismatch</span>
      <span class="Comment">// can't print multi-byte unicode characters in errors just yet. not very useful for debugging anyway.</span>
      <span class="Normal">char</span> expected_pretty[<span class="Constant">10</span>] = <span class="Delimiter">{</span><span class="Constant">0</span><span class="Delimiter">};</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>curr &lt; <span class="Constant">256</span> &amp;&amp; !iscntrl<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Delimiter">{</span>
        <span class="Comment">// &quot; ('&lt;curr&gt;')&quot;</span>
        expected_pretty[<span class="Constant">0</span>] = <span class="Constant">' '</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">1</span>] = <span class="Constant">'('</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">2</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">3</span>] = <span class="Normal">static_cast</span>&lt;<span class="Normal">unsigned</span> <span class="Normal">char</span>&gt;<span class="Delimiter">(</span>curr<span class="Delimiter">),</span> expected_pretty[<span class="Constant">4</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">5</span>] = <span class="Constant">')'</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">6</span>] = <span class="cSpecial">'\0'</span><span class="Delimiter">;</span>
      <span class="Delimiter">}</span>
      <span class="Normal">char</span> actual_pretty[<span class="Constant">10</span>] = <span class="Delimiter">{</span><span class="Constant">0</span><span class="Delimiter">};</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)</span> &lt; <span class="Constant">256</span> &amp;&amp; !iscntrl<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)))</span> <span class="Delimiter">{</span>
        <span class="Comment">// &quot; ('&lt;curr&gt;')&quot;</span>
        actual_pretty[<span class="Constant">0</span>] = <span class="Constant">' '</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">1</span>] = <span class="Constant">'('</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">2</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">3</span>] = <span class="Normal">static_cast</span>&lt;<span class="Normal">unsigned</span> <span class="Normal">char</span>&gt;<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">)),</span> actual_pretty[<span class="Constant">4</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">5</span>] = <span class="Constant">')'</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">6</span>] = <span class="cSpecial">'\0'</span><span class="Delimiter">;</span>
      <span class="Delimiter">}</span>

      ostringstream color_phrase<span class="Delimiter">;</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>color != -<span class="Constant">1</span><span class="Delimiter">)</span> color_phrase &lt;&lt; <span class="Constant">&quot; in color &quot;</span> &lt;&lt; color<span class="Delimiter">;</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>Current_scenario &amp;&amp; !Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span>
        <span class="Comment">// genuine test in a mu file</span>
        raise &lt;&lt; <span class="Constant">&quot;</span><span class="cSpecial">\n</span><span class="Constant">F - &quot;</span> &lt;&lt; Current_scenario<span class="Delimiter">-&gt;</span>name &lt;&lt; <span class="Constant">&quot;: expected screen location (&quot;</span> &lt;&lt; row &lt;&lt; <span class="Constant">&quot;, &quot;</span> &lt;&lt; column &lt;&lt; <span class="Constant">&quot;) to contain &quot;</span> &lt;&lt; curr &lt;&lt; expected_pretty &lt;&lt; color_phrase<span class="Delimiter">.</span>str<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot; instead of &quot;</span> &lt;&lt; no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">))</span> &lt;&lt; actual_pretty &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
        dump_screen<span class="Delimiter">();</span>
      <span class="Delimiter">}</span>
      <span class="Normal">else</span> <span class="Delimiter">{</span>
        <span class="Comment">// just testing check_screen</span>
        raise &lt;&lt; <span class="Constant">&quot;expected screen location (&quot;</span> &lt;&lt; row &lt;&lt; <span class="Constant">&quot;, &quot;</span> &lt;&lt; column &lt;&lt; <span class="Constant">&quot;) to contain &quot;</span> &lt;&lt; curr &lt;&lt; expected_pretty &lt;&lt; color_phrase<span class="Delimiter">.</span>str<span class="Delimiter">()</span> &lt;&lt; <span class="Constant">&quot; instead of &quot;</span> &lt;&lt; no_scientific<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> addr<span class="Delimiter">))</span> &lt;&lt; actual_pretty &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
      <span class="Delimiter">}</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>!Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span>
        Passed = <span class="Constant">false</span><span class="Delimiter">;</span>
        ++Num_failures<span class="Delimiter">;</span>
      <span class="Delimiter">}</span>
      <span class="Identifier">return</span><span class="Delimiter">;</span>
    <span class="Delimiter">}</span>
    assert<span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>get<span class="Delimiter">()</span> == <span class="Constant">'.'</span><span class="Delimiter">);</span>
  <span class="Delimiter">}</span>
  cursor<span class="Delimiter">.</span>skip_whitespace_and_comments<span class="Delimiter">();</span>
  assert<span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>at_end<span class="Delimiter">());</span>
<span class="Delimiter">}</span>

raw_string_stream::raw_string_stream<span class="Delimiter">(</span><span class="Normal">const</span> string&amp; backing<span class="Delimiter">)</span> :index<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> max<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>backing<span class="Delimiter">)),</span> buf<span class="Delimiter">(</span>backing<span class="Delimiter">.</span>c_str<span class="Delimiter">())</span> <span class="Delimiter">{}</span>

<span class="Normal">bool</span> raw_string_stream::at_end<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>index &gt;= max<span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>tb_utf8_char_length<span class="Delimiter">(</span>buf[index]<span class="Delimiter">)</span> &gt; max-index<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; <span class="Constant">&quot;unicode string seems corrupted at index &quot;</span>&lt;&lt; index &lt;&lt; <span class="Constant">&quot; character &quot;</span> &lt;&lt; <span class="Normal">static_cast</span>&lt;<span class="Normal">int</span>&gt;<span class="Delimiter">(</span>buf[index]<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span>
  <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">uint32_t</span> raw_string_stream::get<span class="Delimiter">()</span> <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>index &lt; max<span class="Delimiter">);</span>  <span class="Comment">// caller must check bounds before calling 'get'</span>
  <span class="Normal">uint32_t</span> result = <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> length = tb_utf8_char_to_unicode<span class="Delimiter">(</span>&amp;result<span class="Delimiter">,</span> &amp;buf[index]<span class="Delimiter">);</span>
  assert<span class="Delimiter">(</span>length != TB_EOF<span class="Delimiter">);</span>
  index += length<span class="Delimiter">;</span>
  <span class="Identifier">return</span> result<span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Normal">uint32_t</span> raw_string_stream::peek<span class="Delimiter">()</span> <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>index &lt; max<span class="Delimiter">);</span>  <span class="Comment">// caller must check bounds before calling 'get'</span>
  <span class="Normal">uint32_t</span> result = <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> length = tb_utf8_char_to_unicode<span class="Delimiter">(</span>&amp;result<span class="Delimiter">,</span> &amp;buf[index]<span class="Delimiter">);</span>
  assert<span class="Delimiter">(</span>length != TB_EOF<span class="Delimiter">);</span>
  <span class="Identifier">return</span> result<span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Normal">void</span> raw_string_stream::skip_whitespace_and_comments<span class="Delimiter">()</span> <span class="Delimiter">{</span>
  <span class="Normal">while</span> <span class="Delimiter">(</span>!at_end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>peek<span class="Delimiter">()))</span> get<span class="Delimiter">();</span>
    <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>peek<span class="Delimiter">()</span> == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
      <span class="Comment">// skip comment</span>
      get<span class="Delimiter">();</span>
      <span class="Normal">while</span> <span class="Delimiter">(</span>peek<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> get<span class="Delimiter">();</span>  <span class="Comment">// implicitly also handles CRLF</span>
    <span class="Delimiter">}</span>
    <span class="Normal">else</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
_DUMP_SCREEN<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;$dump-screen&quot;</span><span class="Delimiter">,</span> _DUMP_SCREEN<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> _DUMP_SCREEN: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> _DUMP_SCREEN: <span class="Delimiter">{</span>
  dump_screen<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(code)</span>
<span class="Normal">void</span> dump_screen<span class="Delimiter">()</span> <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>!current_call<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span>  <span class="Comment">// not supported</span>
  <span class="Normal">int</span> screen_location = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> SCREEN<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> width_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">),</span> <span class="Constant">&quot;num-columns&quot;</span><span class="Delimiter">,</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> screen_width = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+width_offset<span class="Delimiter">);</span>
  <span class="Normal">int</span> height_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">),</span> <span class="Constant">&quot;num-rows&quot;</span><span class="Delimiter">,</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> screen_height = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_location+height_offset<span class="Delimiter">);</span>
  <span class="Normal">int</span> data_offset = find_element_name<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;screen&quot;</span><span class="Delimiter">),</span> <span class="Constant">&quot;data&quot;</span><span class="Delimiter">,</span> <span class="Constant">&quot;&quot;</span><span class="Delimiter">);</span>
  assert<span class="Delimiter">(</span>data_offset &gt;= <span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> screen_data_location = screen_location+data_offset<span class="Delimiter">;</span>  <span class="Comment">// type: address:array:character</span>
  <span class="Normal">int</span> screen_data_start = get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_location<span class="Delimiter">)</span> + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span>  <span class="Comment">// type: array:character</span>
  assert<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> screen_data_start<span class="Delimiter">)</span> == screen_width*screen_height<span class="Delimiter">);</span>
  <span class="Normal">int</span> curr = screen_data_start+<span class="Constant">1</span><span class="Delimiter">;</span>  <span class="Comment">// skip length</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> row = <span class="Constant">0</span><span class="Delimiter">;</span> row &lt; screen_height<span class="Delimiter">;</span> ++row<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    cerr &lt;&lt; <span class="Constant">'.'</span><span class="Delimiter">;</span>
    <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> col = <span class="Constant">0</span><span class="Delimiter">;</span> col &lt; screen_width<span class="Delimiter">;</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">))</span>
        cerr &lt;&lt; to_unicode<span class="Delimiter">(</span><span class="Normal">static_cast</span>&lt;<span class="Normal">uint32_t</span>&gt;<span class="Delimiter">(</span>get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> curr<span class="Delimiter">)));</span>
      <span class="Normal">else</span>
        cerr &lt;&lt; <span class="Constant">' '</span><span class="Delimiter">;</span>
      curr += <span class="Comment">/*</span><span class="Comment">size of screen-cell</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span>
    <span class="Delimiter">}</span>
    cerr &lt;&lt; <span class="Constant">&quot;.</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
<span class="Delimiter">}</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->