about summary refs log blame commit diff stats
path: root/html/edit.mu.html
blob: 16ba4cacd08be70515ae60b59f0a2cf74a61fd03 (plain) (tree)


















                                                                                                 
                                  

                              











                                           
                                                                                                                                                                   
                   














                                                                                                                                                                                                                                                                                        



                            





































                                                                                                                                                                   
                                                        

                                                                                                                                                                   
                                                            
                                                                                             

                                                                                                                   
                                                            

                                                                                              
                                                                                              

                                                                                                                    
                                                            

                                                                                               
                                                                                                


                                                                                                 
                                                            

                                                                                                                    
                                                                                               


                                                                                               
                                                            










                                                                                                                                                     
                                                                 

                                                                                                                                         
                                       







                                                                                                                                                     
                                                                 

                                                                                                                                         
                                       





                                                                                                                                                    
                                                                 




                                                                                                                                       
                                       









                                                           
<!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 - edit.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: #eeeeee; background-color: #080808; }
body { font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 1em; }
.Delimiter { color: #c000c0; }
.Comment { color: #8080ff; }
.Constant { color: #008080; }
.Special { color: #ff6060; }
.CommentedCode { color: #6c6c6c; }
.muControl { color: #804000; }
.muRecipe { color: #ff8700; }
-->
</style>

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

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="muRecipe">recipe</span> main [
  <span class="Constant">default-space</span>:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
  switch-to-display
  width:number<span class="Special"> &lt;- </span>display-width
  <span class="Delimiter">{</span>
    wide-enough?:boolean<span class="Special"> &lt;- </span>greater-than width:number, <span class="Constant">100:literal</span>
    <span class="muControl">break-if</span> wide-enough?:boolean
    return-to-console
    assert wide-enough?:boolean, <span class="Constant">[screen too narrow; we don't support less than 100 characters yet]</span>
  <span class="Delimiter">}</span>
  divider:number, _<span class="Special"> &lt;- </span>divide-with-remainder width:number, <span class="Constant">2:literal</span>
  draw-column <span class="Constant">0:literal/screen</span>, divider:number
  x:address:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[1:integer &lt;- add 2:literal, 2:literal]</span>
  y:address:array:character<span class="Special"> &lt;- </span>edit x:address:array:character, <span class="Constant">0:literal/screen</span>, <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>, <span class="Constant">5:literal</span>, divider:number
<span class="CommentedCode">#?   draw-bounding-box 0:literal/screen, 0:literal, 0:literal, 5:literal, divider:number</span>
  left:number<span class="Special"> &lt;- </span>add divider:number, <span class="Constant">1:literal</span>
  y:address:array:character<span class="Special"> &lt;- </span>edit <span class="Constant">0:literal</span>, <span class="Constant">0:literal/screen</span>, <span class="Constant">0:literal</span>, left:number, <span class="Constant">2:literal</span>, width:number
  move-cursor <span class="Constant">0:literal/screen</span>, <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>
  wait-for-key-from-keyboard
  return-to-console
]

<span class="muRecipe">recipe</span> draw-column [
  <span class="Constant">default-space</span>:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  col:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  curr:number<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
  max:number<span class="Special"> &lt;- </span>screen-height screen:address
  <span class="Delimiter">{</span>
    continue?:boolean<span class="Special"> &lt;- </span>lesser-than curr:number, max:number
    <span class="muControl">break-unless</span> continue?:boolean
    move-cursor screen:address, curr:number, col:number
    print-character screen:address, <span class="Constant">9474:literal/vertical</span>, <span class="Constant">245:literal/grey</span>
    curr:number<span class="Special"> &lt;- </span>add curr:number, <span class="Constant">1:literal</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  move-cursor screen:address, <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>
]

<span class="muRecipe">recipe</span> edit [
  <span class="Constant">default-space</span>:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
  in:address:array:character<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  top:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  left:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  bottom:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  right:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Comment"># draw bottom boundary</span>
  curr:number<span class="Special"> &lt;- </span>copy left:number
  <span class="Delimiter">{</span>
    continue?:boolean<span class="Special"> &lt;- </span>lesser-than curr:number, right:number
    <span class="muControl">break-unless</span> continue?:boolean
    move-cursor screen:address, bottom:number, curr:number
    print-character screen:address, <span class="Constant">9472:literal/vertical</span>, <span class="Constant">245:literal/grey</span>
    curr:number<span class="Special"> &lt;- </span>add curr:number, <span class="Constant">1:literal</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  move-cursor screen:address, top:number, left:number
]

<span class="muRecipe">recipe</span> draw-bounding-box [
  <span class="Constant">default-space</span>:address:array:location<span class="Special"> &lt;- </span>new location:type, <span class="Constant">30:literal</span>
  screen:address<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Comment"># sanity-check the box bounds</span>
  top:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    out?:boolean<span class="Special"> &lt;- </span>lesser-than top:number, <span class="Constant">0:literal</span>
    <span class="muControl">break-unless</span> out?:boolean
    top:number<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
  <span class="Delimiter">}</span>
  left:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    out?:boolean<span class="Special"> &lt;- </span>lesser-than left:number, <span class="Constant">0:literal</span>
    <span class="muControl">break-unless</span> out?:boolean
    left:number<span class="Special"> &lt;- </span>copy <span class="Constant">0:literal</span>
  <span class="Delimiter">}</span>
  bottom:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    height:number<span class="Special"> &lt;- </span>screen-height screen:address
    out?:boolean<span class="Special"> &lt;- </span>greater-or-equal bottom:number, height:number
    <span class="muControl">break-unless</span> out?:boolean
    bottom:number<span class="Special"> &lt;- </span>subtract height:number, <span class="Constant">1:literal</span>
  <span class="Delimiter">}</span>
  right:number<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    width:number<span class="Special"> &lt;- </span>screen-width screen:address
    out?:boolean<span class="Special"> &lt;- </span>greater-or-equal right:number, width:number
    <span class="muControl">break-unless</span> out?:boolean
    right:number<span class="Special"> &lt;- </span>subtract width:number, <span class="Constant">1:literal</span>
  <span class="Delimiter">}</span>
<span class="CommentedCode">#?   print-integer screen:address, bottom:number</span>
<span class="CommentedCode">#?   print-character screen:address, 32:literal/space</span>
<span class="CommentedCode">#?   print-integer screen:address, right:number</span>
  <span class="Comment"># top border</span>
  move-cursor screen:address, top:number, left:number
  print-character screen:address, <span class="Constant">9484:literal/down-right</span>, <span class="Constant">245:literal/grey</span>
  x:number<span class="Special"> &lt;- </span>add left:number, <span class="Constant">1:literal</span>  <span class="Comment"># exclude corner</span>
  <span class="Delimiter">{</span>
    continue?:boolean<span class="Special"> &lt;- </span>lesser-than x:number, right:number
    <span class="muControl">break-unless</span> continue?:boolean
    print-character screen:address, <span class="Constant">9472:literal/horizontal</span>, <span class="Constant">245:literal/grey</span>
    x:number<span class="Special"> &lt;- </span>add x:number, <span class="Constant">1:literal</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  print-character screen:address, <span class="Constant">9488:literal/down-left</span>, <span class="Constant">245:literal/grey</span>
  <span class="Comment"># bottom border</span>
  move-cursor screen:address, bottom:number, left:number
  print-character screen:address, <span class="Constant">9492:literal/up-right</span>, <span class="Constant">245:literal/grey</span>
  x:number<span class="Special"> &lt;- </span>add left:number, <span class="Constant">1:literal</span>  <span class="Comment"># exclude corner</span>
  <span class="Delimiter">{</span>
    continue?:boolean<span class="Special"> &lt;- </span>lesser-than x:number, right:number
    <span class="muControl">break-unless</span> continue?:boolean
    print-character screen:address, <span class="Constant">9472:literal/horizontal</span>, <span class="Constant">245:literal/grey</span>
    x:number<span class="Special"> &lt;- </span>add x:number, <span class="Constant">1:literal</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  print-character screen:address, <span class="Constant">9496:literal/up-left</span>, <span class="Constant">245:literal/grey</span>
  <span class="Comment"># left and right borders</span>
  x:number<span class="Special"> &lt;- </span>add top:number, <span class="Constant">1:literal</span>  <span class="Comment"># exclude corner</span>
  <span class="Delimiter">{</span>
    continue?:boolean<span class="Special"> &lt;- </span>lesser-than x:number, bottom:number
    <span class="muControl">break-unless</span> continue?:boolean
    move-cursor screen:address, x:number, left:number
    print-character screen:address, <span class="Constant">9474:literal/vertical</span>, <span class="Constant">245:literal/grey</span>
    move-cursor screen:address, x:number, right:number
    print-character screen:address, <span class="Constant">9474:literal/vertical</span>, <span class="Constant">245:literal/grey</span>
    x:number<span class="Special"> &lt;- </span>add x:number, <span class="Constant">1:literal</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># position cursor inside box</span>
  move-cursor screen:address, top:number, left:number
  cursor-down screen:address
  cursor-right screen:address
]
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->