-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo_menu_fast
executable file
·93 lines (86 loc) · 3.94 KB
/
demo_menu_fast
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/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 {1..4}; do XY 1 $i "%${COLUMNS}s"; done; } # clear output area
but_d(){ defb "$1" "$2" D; }
but_e(){ defb "$1" "$2" E; }
but_f(){ defb "$1" "$2" F; }
fun_d(){ clr; XY 1 1 "butt D; target: $_target_"; }
fun_e(){ clr; XY 1 1 "butt E; description: ${_target_[1]}"; }
fun_f(){ clr; XY 1 1 "butt F; all items of target:"
printf -v text -- '%s\n' "${_target_[@]}"
XY 1 2 "$text"; }
clear
w=$((COLUMNS-10))
my_items(){
local mess="Fast columns via percent of Width(${bred}Esc to exit$bblk)"
items_fast 10 5 $w 20 '30 55 15' "$mess" "$wht" "$ylw" "$bblk" "$@"
}
data=(
#-------------{ first line - column descriptions }--------------------
$red'Item name' $blu'Item description' $grn'Status'
#-----------------------{ the data }----------------------------------
'first' 'Long description text' 'true'
'second' 'Description 2' 'O_o'
'third' 'description 3' 'false'
'fourth' 'Long description text' 'true'
'' '' ''
'fifth' 'Description 2' 'O_o'
'sixth' 'description 3' 'false'
'midle' 'Long description text' 'true'
'long name row2' 'Description 2' 'O_o'
'' '' ''
'row 3' 'description 3' 'false'
'row1' 'Long description text' 'true'
'row1' 'Long description text' 'true'
'last' 'Description 2' 'O_o'
'first' 'Long description text' 'true'
'second' 'Description 2' 'O_o'
'third' 'description 3' 'false'
'fourth' 'Long description text' 'true'
'' '' ''
'fifth' 'Description 2' 'O_o'
'sixth' 'description 3' 'false'
'midle' 'Long description text' 'true'
'long name row2' 'Description 2' 'O_o'
'' '' ''
'row 3' 'description 3' 'false'
'row1' 'Long description text' 'true'
'row1' 'Long description text' 'true'
'last' 'Description 2' 'O_o'
)
xbuttons=(but_d but_e but_f)
butts (){ x_row $LINES "${xbuttons[@]}"; }
ilist (){ my_items "${data[@]}" ; }
menu (){
cursor off
default_button but_d
while true; do
ilist
butts
read_input
case $_input_ in
up ) select_prev_item "${data[@]}" ;;
down ) select_next_item "${data[@]}" ;;
left ) select_prev_butt "${xbuttons[@]}";;
right ) select_next_butt "${xbuttons[@]}";;
enter ) press_button butts ;;
escape ) return;;
pgup ) select_prev_item --fast "${data[@]}";;
pgdown ) select_next_item --fast "${data[@]}";;
* ) select_by_hot_key $_input_ "${data[@]}";;
esac
done
}
menu