1 # menu for DCT, by Shiar
3 # 1.006.1 2004-09-15 23:32 - moved @menus from 1.6 main
4 # 1.009.1 2004-10-11 21:50 - everything related to menus moved here
10 #my %falias = ("\033"=>0);
13 "\033\117\120" => 1, # f1
14 "\033\133\061\061\176" => 1, # f1
15 "\033\133\061\062\176" => 2, # f2
16 "\033\133\061\063\176" => 3, # f3
17 "\033\133\061\064\176" => 4, # f4
18 "\033\117\121" => 2, # f2
19 "\033\117\122" => 3, # f3
20 "\033\117\123" => 4, # f4
21 "\033\133\061\065\176" => 5, # f5
22 "\033\133\061\067\176" => 6, # f6
23 "\033\133\061\070\176" => 7, # f7
24 "\033\133\061\071\176" => 8, # f8
25 "\033\133\062\060\176" => 9, # f9
26 "\033\133\062\061\176" => 10, # f10
27 "\033\133\062\063\176" => 11, # f11/F1
28 "\033\133\062\064\176" => 12, # f12/F2
29 "\033\133\062\065\176" => 13, # F3
30 "\033\133\062\066\176" => 14, # F4
31 "\033\133\062\070\176" => 15, # F5
32 "\033\133\062\071\176" => 16, # F6
33 "\033\133\063\061\176" => 17, # F7
34 "\033\133\063\062\176" => 18, # F8
35 "\033\133\063\063\176" => 19, # F9
36 "\033\133\063\064\176" => 20, # F10
37 "\033\133\062\063\073\062\176" => 21, # F11
38 "\033\133\062\064\073\062\176" => 22, # F12
41 #my @menus = ([qw(refresh quit)]);
43 [qw(refresh math>8 prog> mode>7 unit>11)],
44 [qw(main>0 log alog ln exp sin cos tan 0 asin acos atan)], #1 math
45 [qw(main>0 dec bin oct hex logic>3 bit>4)], #2 base
46 [qw(base>2 and or xor not)], #3 base logic
47 [qw(base>2 rl sl asr sr rr)], #4 base bit
48 [qw(base>2 rlb slb srb rrb)], #5 base byte
49 [qw(main>0 sq sqrt ^ xroot)], #6
50 [qw(main>0 number_format angle_measure coord_system)], #7 mode
52 vector> matrix> list> hyperbolic>9 real>10 base>2
53 probability> fft> complex> constants>
56 sinh cosh tanh asinh acosh atanh
58 )], #9 math hyperbolic
61 abs sign mant xpon ip fp
62 rnd trnc floor ceil r>d d>r
65 tools> length>12 area>13 volume>14 time>15 speed>16
66 mass>17 force>18 energy>19 power>20 pressure>21 temperature>22
67 electric_current>23 angle>24 light>25 radiation>26 viscosity>27
69 # mm cm m in ft yd km mile mmile lt-yr mil Ang fermi rod fath)],
71 _m _cm _mm _yd _ft _in _Mpc _pc _lyr _au _km _mi
72 _nmi _miUS _chain _rd _fath _ftUS _Mil _μ _Å _fermi
75 _m^2 _cm^2 _b _yd^2 _ft^2 _in^2
76 _km^2 _ha _a _mi^2 _miUS^2 _acre
79 _m^3 _st _cm^3 _yd^3 _ft^3 _in^3
80 _l _galUK _galC _gal _qt _pt
81 _ml _cu _ozfl _ozUK _tbsp _tsp
88 _m/s _cm/s _ft/s _kph _mph _knot
92 _kg _g _Lb _oz _slug _lbt
93 _ton _tonUS _t _ozt _ct _grain
97 _N _dyn _gf _kip _lbf _pdl
100 _J _erg _Kcal _Cal _Btu _ftxlbf
107 _Pa _atm _bar _psi _torr _mmHg
113 )], #23 electric_current
127 my @menu = @{$menus[0]};
129 push @{ $hook{init} }, sub {
130 $set{height}--; # make space for menubar
131 $set{menushow} = int($set{width}/(4+$set{width}/20))+1 # menu items to show simultaneously
132 unless defined $set{menushow};
136 clrtoeol($set{height}+2, 1);
138 for (grep exists $menu[$_], $menumin+1..$menumin+$set{menushow}) {
139 my $sub = (my $s = $menu[$_]) =~ s/>\d+$//;
140 addstr($set{height}+2, $set{width}/$set{menushow}*($nr++), $_);
145 } # display menu txts
148 $action{more} = [-1, sub {
149 $menumin += $set{menushow};
150 $menumin = 0 if $menumin>=$#menu;
154 push @{ $hook{refresh} }, sub {
158 unshift @{ $hook{precmd} }, sub {
159 return unless exists $falias{$_}; # not a function key
160 return if $_ = $menu[$falias{$_}]; # execute found menu item instead
161 error("* no such menu entry *");
165 push @{ $hook{precmd} }, sub {
166 return unless />(\d+)$/;
167 @menu = @{ $menus[$1] }; # go to submenu
168 $menumin = 0; # reset to first item