blob: 3575d95a59d891673643db5d0c57987f0fad302b (
plain)
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
72
73
74
75
76
77
|
#!/usr/bin/env tclsh
## -*- tcl -*-
lappend auto_path [file join [file dirname [file dirname [file dirname [info script]]]] modules]
package require term::ansi::send
package require term::ansi::code::macros
package require term::receive::bind
package require term::ansi::ctrl::unix
package require term::ansi::code::ctrl
term::ansi::send::import vt
term::ansi::code::ctrl::import ctrl
set menu {Hello World {How } {Are } {You }}
set max [llength $menu]
set at 0
proc Up {args} {
global at
if {$at == 0} return
incr at -1
Show
return
}
proc Down {args} {
global at max
if {$at >= ($max - 1)} return
incr at
Show
return
}
proc Do {args} {
term::ansi::ctrl::unix::cooked
vt::clear
exit
}
proc Default {string} {
return
}
proc Show {} {
global at menu
set i 0
set str ""
foreach m $menu {
if {$i != $at} {
append str $m
} else {
append str [ctrl::sda_revers]
append str $m
append str [ctrl::sda_reset]
}
append str \n
incr i
}
vt::showat 5 5 [string trimright $str \n]
return
}
term::receive::bind B
B map [ctrl::cu] Up
B map [ctrl::cd] Down
B map \r Do
B map \n Do
B default Default
term::ansi::ctrl::unix::raw
vt::init
vt::clear
Show
#term::ansi::ctrl::unix::cooked
B listen
vwait forever
term::ansi::ctrl::unix::cooked
exit
|