summary refs log tree commit diff stats
path: root/test/tc_history.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/tc_history.py')
0 files changed, 0 insertions, 0 deletions
5-05-13 09:09:22 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-05-13 09:11:16 -0700 1362' href='/akkartik/mu/commit/074keyboard.mu?h=hlt&id=01caf342d072115c27926b1a61c2fc75ab9fbee0'>01caf342 ^
e3092e7b ^


5497090a ^

e3092e7b ^







5497090a ^
e3092e7b ^
5497090a ^
e3092e7b ^
5497090a ^
e3092e7b ^
5d6d9110 ^
e3092e7b ^
5497090a ^

e3092e7b ^

134dad7c ^

e3092e7b ^















f8c0ef3e ^






cf9af278 ^

3f367cb9 ^
f8c0ef3e ^





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71



                                                                                                                     
              





                                                                       
                                                                                               


                                                              

                                                                               







                                                                       
                                                                            
                                                                            
                                                          
     
                                                                            
                                
                                                                                   
     

                                                                                    

                                                                               

                                                                















                                                                            






                                                                       

                                                            
                                                     





                                                                   
# Wrappers around keyboard primitives that take a 'keyboard' object and are thus
# easier to test.

container keyboard [  # can't think of another word like screen/display, so real and fake keyboards use the same name
  index:number
  data:address:array:character
]

recipe init-fake-keyboard [
  default-space:address:array:location <- new location:type, 30:literal
  result:address:keyboard <- new keyboard:type
  buf:address:address:array:character <- get-address result:address:keyboard/deref, data:offset
#?   $start-tracing #? 1
  buf:address:address:array:character/deref <- next-ingredient
#?   $stop-tracing #? 1
  idx:address:number <- get-address result:address:keyboard/deref, index:offset
  idx:address:number/deref <- copy 0:literal
  reply result:address:keyboard
]

recipe read-key [
  default-space:address:array:location <- new location:type, 30:literal
  x:address:keyboard <- next-ingredient
  {
    break-unless x:address:keyboard
    idx:address:number <- get-address x:address:keyboard/deref, index:offset
    buf:address:array:character <- get x:address:keyboard/deref, data:offset
    max:number <- length buf:address:array:character/deref
    {
      done?:boolean <- greater-or-equal idx:address:number/deref, max:number
      break-unless done?:boolean
      reply 0:literal/eof, 1:literal/found, x:address:keyboard/same-as-ingredient:0
    }
    c:character <- index buf:address:array:character/deref, idx:address:number/deref
    idx:address:number/deref <- add idx:address:number/deref, 1:literal
    reply c:character, 1:literal/found, x:address:keyboard/same-as-ingredient:0
  }
  # real keyboard input is infrequent; avoid polling it too much
  switch
  c:character, found?:boolean <- read-key-from-keyboard
  reply c:character, found?:boolean, x:address:keyboard/same-as-ingredient:0
]

recipe wait-for-key [
  default-space:address:array:location <- new location:type, 30:literal
  x:address:keyboard <- next-ingredient
  {
    break-unless x:address:keyboard
    # on fake keyboards 'wait-for-key' behaves just like 'read-key'
    c:character, x:address:keyboard <- read-key x:address:keyboard
    reply c:character, x:address:keyboard/same-as-ingredient:0
  }
  c:character <- wait-for-key-from-keyboard
  reply c:character, x:address:keyboard/same-as-ingredient:0
]

recipe send-keys-to-channel [
  default-space:address:array:location <- new location:type, 30:literal
  keyboard:address <- next-ingredient
  chan:address:channel <- next-ingredient
  screen:address <- next-ingredient
  {
    c:character, found?:boolean <- read-key keyboard:address
    loop-unless found?:boolean
#?     print-integer screen:address, c:character #? 1
    print-character screen:address, c:character
    chan:address:channel <- write chan:address:channel, c:character
    # todo: eof
    loop
  }
]