about summary refs log tree commit diff stats
path: root/090trace_browser.cc
Commit message (Expand)AuthorAgeFilesLines
* 2680Kartik K. Agaram2016-02-201-7/+7
* 2625Kartik K. Agaram2015-12-151-4/+1
* 2621Kartik K. Agaram2015-12-081-2/+11
* 2619Kartik K. Agaram2015-12-071-1/+1
* 2609 - run $browse-trace on old runsKartik K. Agaram2015-11-291-0/+30
* 2430 - make room for more transformsKartik K. Agaram2015-11-131-0/+213
/a> 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
<!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 - 074keyboard.mu</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v1">
<meta name="syntax" content="none">
<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: #d0d0d0; background-color: #000000; }
body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
* { font-size: 1em; }
.Identifier { color: #008080; }
.Comment { color: #8080ff; }
.Delimiter { color: #c000c0; }
.Special { color: #ff6060; }
.CommentedCode { color: #6c6c6c; }
-->
</style>

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

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment"># Wrappers around keyboard primitives that take a 'keyboard' object and are thus</span>
<span class="Comment"># easier to test.</span>

container keyboard <span class="Delimiter">[</span>  <span class="Comment"># can't think of another word like screen/display, so real and fake keyboards use the same name</span>
  index:integer
  data:address:array:character
<span class="Delimiter">]</span>

recipe init-fake-keyboard <span class="Delimiter">[</span>
  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
  result:address:keyboard<span class="Special"> &lt;- </span>new keyboard:type
  buf:address:address:array:character<span class="Special"> &lt;- </span>get-address result:address:keyboard/deref data:offset
<span class="CommentedCode">#?   $start-tracing #? 1</span>
  buf:address:address:array:character/deref<span class="Special"> &lt;- </span>next-ingredient
<span class="CommentedCode">#?   $stop-tracing #? 1</span>
  idx:address:integer<span class="Special"> &lt;- </span>get-address result:address:keyboard/deref index:offset
  idx:address:integer/deref<span class="Special"> &lt;- </span>copy 0:literal
  <span class="Identifier">reply</span> result:address:keyboard
<span class="Delimiter">]</span>

recipe read-key <span class="Delimiter">[</span>
  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
  x:address:keyboard<span class="Special"> &lt;- </span>next-ingredient
  <span class="Delimiter">{</span>
    <span class="Identifier">break-unless</span> x:address:keyboard
    idx:address:integer<span class="Special"> &lt;- </span>get-address x:address:keyboard/deref, index:offset
    buf:address:array:character<span class="Special"> &lt;- </span>get x:address:keyboard/deref, data:offset
    max:integer<span class="Special"> &lt;- </span>length buf:address:array:character/deref
    <span class="Delimiter">{</span>
      done?:boolean<span class="Special"> &lt;- </span>greater-or-equal idx:address:integer/deref, max:integer
      <span class="Identifier">break-unless</span> done?:boolean
      <span class="Identifier">reply</span> 0:literal, 0:literal/done, x:address:keyboard/same-as-ingredient:0
    <span class="Delimiter">}</span>
    c:character<span class="Special"> &lt;- </span>index buf:address:array:character/deref, idx:address:integer/deref
    idx:address:integer/deref<span class="Special"> &lt;- </span>add idx:address:integer/deref, 1:literal
    <span class="Identifier">reply</span> c:character, 1:literal/found, x:address:keyboard/same-as-ingredient:0
  <span class="Delimiter">}</span>
  c:character, found?:boolean<span class="Special"> &lt;- </span>read-key-from-keyboard
  <span class="Identifier">reply</span> c:character, found?:boolean, x:address:keyboard/same-as-ingredient:0
<span class="Delimiter">]</span>

recipe wait-for-key <span class="Delimiter">[</span>
  default-space:address:array:location<span class="Special"> &lt;- </span>new location:type, 30:literal
  x:address:keyboard<span class="Special"> &lt;- </span>next-ingredient
  <span class="Delimiter">{</span>
    <span class="Identifier">break-unless</span> x:address:keyboard
    <span class="Comment"># on fake keyboards 'wait-for-key' behaves just like 'read-key'</span>
    c:character, x:address:keyboard<span class="Special"> &lt;- </span>read-key x:address:keyboard
    <span class="Identifier">reply</span> c:character, x:address:keyboard/same-as-ingredient:0
  <span class="Delimiter">}</span>
  c:character<span class="Special"> &lt;- </span>wait-for-key-from-keyboard
  <span class="Identifier">reply</span> c:character, x:address:keyboard/same-as-ingredient:0
<span class="Delimiter">]</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->