-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo_buttons
executable file
·59 lines (52 loc) · 1.61 KB
/
demo_buttons
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
#!/bin/bash
source bashui
defb(){
# Create default button to copy
#1 X(row) coordinate
#2 Y(line) coordinate
#3 Button name
#4 Function to run
#5 Text color
#6 Border color
#7 Background color
# 1 2 3 4 5 6 7
button "$1" "$2" "butt $3" "fun_${3,,}" "$wht" "$ylw" "$bblk"
}
clr(){ for i in {5..9}; do XY 15 $i "%$((COLUMNS-15))s"; done; } # clear output area
but_a(){ defb "$1" "$2" A; }
but_b(){ defb "$1" "$2" B; }
but_c(){ defb "$1" "$2" C; }
but_d(){ defb "$1" "$2" D; }
but_e(){ defb "$1" "$2" E; }
but_f(){ defb "$1" "$2" F; }
fun_a(){ clr; XY 15 5 "butt A pressed(${_button_[*]})"; }
fun_b(){ clr; XY 15 5 "butt B pressed(${_button_[*]})"; }
fun_c(){ clr; XY 15 5 "butt C pressed(${_button_[*]})"; }
fun_d(){ clr; XY 15 5 "butt D pressed(${_button_[*]})"; }
fun_e(){ clr; XY 15 5 "butt E pressed(${_button_[*]})"; }
fun_f(){ clr; XY 15 5 "butt F pressed(${_button_[*]})"; }
ybuttons=(but_a but_b but_c)
xbuttons=(but_d but_e but_f)
butts(){
y_row 2 "${ybuttons[@]}"
x_row $LINES "${xbuttons[@]}"
}
menu(){
cursor off
default_button but_b
XY 1 1 "$red Esc to exit"
while true; do
butts
read_input
case $_input_ in
up ) select_prev_butt "${ybuttons[@]}";;
down ) select_next_butt "${ybuttons[@]}";;
left ) select_prev_butt "${xbuttons[@]}";;
right ) select_next_butt "${xbuttons[@]}";;
enter ) press_button butts ;;
escape ) return ;;
esac
done
}
clear
menu