-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_platform
More file actions
235 lines (208 loc) · 12.2 KB
/
demo_platform
File metadata and controls
235 lines (208 loc) · 12.2 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
# -----------------------------------------------------------------------------
#
# Demo menu 'Platform'
#
# Aliases:
#
# 'dev' - to display all the demo menus
# 'PL' - shows PLATFORM menu
#
# -----------------------------------------------------------------------------
# [IN] handle - the menu's name/handle
# [IN] name - the menu's name (if specified)
MENU_PlCallback() {
echo " PL.$2..."
echo ' ...'
}
# [IN] handle - the menu's name/handle
# [IN] name - the item's selected
MENU_PlLinuxCallback() {
if [ "$2" != 'Linux' ]; then
MENU__error "Wrong callback!"
return
fi
echo " PL.Linux.Callback..."
echo ' ...'
}
MENU_PlQemuCallback() {
echo " PL.$2..."
echo ' ...'
}
MENU_PlChild1Callback() {
echo " PL.It..."
echo ' ...'
}
MENU_PlChild1RadioCallback() {
echo " PL.SubMENU_$2..."
echo ' ...'
}
# [IN] handle - the menu's name/handle
# [IN] name - the name of the selected item
# [IN][OPT] state - {on, off} item's state (check.button type only)
MENU_PlChild1CheckCallback() {
echo " PL.SubMENU_$2.[$3]..."
echo ' ...'
}
MENU_PlChild2RadioCallback() {
echo " PL.Extra.$2..."
echo ' ...'
}
DEMO_CreatePlatformMenu() {
# See menu_ex:'Functions and parameters acronims' for 'MENU_Null' explanation
local null='MENU_Null'
# -----------------------------------------------------------------------------------------------------------------
# Create a menu
#
# 1 handle - a name/handle of the menu to be used w/ the API
# 2 [OPT] | name - a displayed name of the menu
# 3 [OPT] | | alias - an alias to be created that displays the menu
# 4 [OPT] | | | callback - a function to be called when the menu is displayed
MENU_Create pl_menu PLATFORM PL MENU_PlCallback
#MENU_Create pl_menu $null PL MENU_DemoMainMenu
#MENU_Create pl_menu $null $null MENU_DemoMainMenu
#MENU_Create pl_menu
# -----------------------------------------------------------------------------------------------------------------
# Under the hood 'PL' is just an alias for: 'MENU_Show pl_menu'
#
# 1 [OPT] flag1 - whether to call the main menu's callback
# 2 [OPT] | flag2 - whether to call the selected radio button item's callback
# 3 [OPT] | | mode - call-mode of all the check button item's callbacks, for modes see documentation for .Show
# > PL false false all
#
# Alias 'PL' usage examples:
#
# > PL - displays the menu
# > PL true - displays the menu + calls the menu's callback
# > PL false true - displays the menu + calls the selected radio button item's callback
# > PL true true - displays the menu + calls both the selected item and the main menu's callbacks
# > PL false false all - displays the menu + calls all the radio button item's callbacks
# -----------------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------------
# Set the menu's style (replace the default style)
#
# 1 handle - a name/handle of the menu to be used w/ the API
# 2 [OPT] | divider - devider to be used w/ .AddDivider ('|' by default)
# 3 [OPT] | | alignment - alignent of the items (none by default)
# 4 [OPT] | | | background.color - the background color (black by default)
# 5 [OPT] | | | | foreground.color - the regular text color (white by default)
# 6 [OPT] | | | | | highlighter.color - the hightlighted items color (green by default)
# 7 [OPT] | | | | | | radio.symbol - the select symbol for the radio button when selected
# 8 [OPT] | | | | | | | check.symbol - the check symbol for the check button when checked
#MENU_SetStyle pl_menu default none default cyan red '○' default
#MENU_SetStyle pl_menu default by.largest.item
# -----------------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------------
# Set the extra style of the menu (replace the default style)
# 1 handle - a name/handle of the menu to be used w/ the API
# 2 [OPT] | separator.show - {true/false} whether to print the menu's separator (true by default)
# 3 [OPT] | | separator.symbol - separator symbol ('-' by default)
# 4 [OPT] | | | name.header - menu's name header (' * ' by default)
# 5 [OPT] | | | | name.footer - menu's name footer (':' by default)
# 6 [OPT] | | | | | symbol.radio.start - radio.button opening symbol ('(' by default)
# 7 [OPT] | | | | | | symbol.radio.end - radio.button closing symbol (')' by default)
# 8 [OPT] | | | | | | | symbol.chk.start - check.button opening symbol ('[' by default)
# 9 [OPT] | | | | | | | | symbol.chk.end - check.button closing symbol (']' by default)
#MENU_SetStyleEx pl_menu true '-' " * " ":" '(' ')' '[' ']'
#
# For example:
#
#MENU_SetStyleEx pl_menu true '=' " + '" "':" '[[' ']]' '((' '))'
#MENU_SetStyle pl_menu default by.largest.item cyan 'xx' '***'
# -----------------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------------
# Add a radio.button item into the menu
#
# 1 handle - a name/handle of the menu to be used w/ the API
# 2 | name - an item's name to be added into the menu
# 3 [OPT] | | alias - an alias to be created that triggers the item's callback
# 4 [OPT] | | | callback - a function to be called when an item is selected
MENU_AddRadioButton pl_menu Linux nux MENU_PlLinuxCallback
#MENU_AddRadioButton pl_menu Linux $null MENU_DemoPlLinuxCb
#MENU_AddRadioButton pl_menu Linux
#
# In the invocation example #2, there is no alias for item 'Linux', so the only way to call it is by using
# the .Select command, like so: MENU_Select pl_menu Linux true false true
# Please, look into .Select command demo to understand all the flags
#
# -----------------------------------------------------------------------------------------------------------------
# Under the hood 'nux' is just an alias for: 'MENU_Select pl_menu Linux true false true'
#
# Alias 'nux' can take additional optional arguments:
#
# 1 [OPT] flag1 - {true, false} whether to call the main menu's callback
# 2 [OPT] | mode - call-mode of the check button callbacks {no(false), all(true), on, off}
# > nux true no
#
# Alias 'nux' usage examples:
#
# > nux - selects 'Linux' item, displays the 'PLATFORM' menu and triggers the 'Linux' item's callback
# > nux true - all the above + triggers the 'PLATFORM' menu's callback
# > nux true all - all the above + triggers all the check button item's callbacks
# -----------------------------------------------------------------------------------------------------------------
MENU_AddDivider pl_menu
MENU_AddLabel pl_menu QEMU:
MENU_AddRadioButton pl_menu v8 v8 MENU_PlQemuCallback
MENU_AddRadioButton pl_menu arm32 arm MENU_PlQemuCallback
#MENU_AddRadioButton pl_menu "Name w/ space" ace MENU_DemoPlQemuCb
# -----------------------------------------------------------------------------------------------------------------
# Select an item of the menu
#
# 1 handle - a name/handle of the menu to be used w/ the API
# 2 | name - a name of an item to be set as 'selected' in the menu
# 3 [OPT] | | show - whether to show the menu after the item has been selected/checked
# 4 [OPT] | | | flag1 - whether to call the main menu's callback
# 5 [OPT] | | | | flag2 - whether to call the selected radio button item's callback
# 6 [OPT] | | | | | mode - call-mode of the check button callbacks [no (false), all (true), on, off]
MENU_Select pl_menu v8 false false true no
# -----------------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------------
# Create two child menus and add them into the main (parent) PLATFORM menu
# -----------------------------------------------------------------------------------------------------------------
MENU_Create pl_child_menu1 $null $null MENU_PlChild1Callback
#MENU_SetStyle pl_child_menu1 default none default custom1 custom2
#MENU_AddLabel pl_child_menu1 It:
MENU_AddRadioButton pl_child_menu1 Item1 m1 MENU_PlChild1RadioCallback
MENU_AddRadioButton pl_child_menu1 Item2 m2 MENU_PlChild1RadioCallback
MENU_AddRadioButton pl_child_menu1 Item3 m3 MENU_PlChild1RadioCallback
# -----------------------------------------------------------------------------------------------------------------
MENU_AddDivider pl_child_menu1
#MENU_AddLabel pl_child_menu1 Mode:
MENU_AddCheckButton pl_child_menu1 Ps1 s1 MENU_PlChild1CheckCallback
MENU_AddCheckButton pl_child_menu1 Nx Nx MENU_PlChild1CheckCallback
MENU_Select pl_child_menu1 Item2 false
MENU_Select pl_child_menu1 Ps1 false
# -----------------------------------------------------------------------------------------------------------------
MENU_Create pl_child_menu2
#MENU_SetStyle pl_child_menu2 default none default custom1 custom2
MENU_AddDivider pl_child_menu2
#MENU_AddLabel pl_child_menu2 Extra:
MENU_AddRadioButton pl_child_menu2 Sub1 b1 MENU_PlChild2RadioCallback
MENU_AddRadioButton pl_child_menu2 Sub2 b2 MENU_PlChild2RadioCallback
# -----------------------------------------------------------------------------------------------------------------
MENU_AddDivider pl_menu
MENU_AddMenu pl_menu pl_child_menu1
MENU_AddMenu pl_menu pl_child_menu2
# -----------------------------------------------------------------------------------------------------------------
# Show/display the menu
#
# handle - a name/handle of the menu to be used w/ the API
# | flag1 - whether to call the main menu's callback
# | | flag2 - whether to call the selected radio button item's callback
# | | | mode - call-mode of the check button callbacks [no (false), all (true), on, off]
#MENU_Show pl_menu true true all
#
# mode:
# no (false) - do not call any callback for any check button itmes
# all (true) - call all the callbacks for all the check button items regardless of the state
# on - call all the callbacks for all on (checked) check button items
# off - call all the callbacks for all off (un-checked) check button items
#
# -----------------------------------------------------------------------------------------------------------------
#MENU_debug_print_all
}
DEMO_CreatePlatformMenu
alias dev='MENU_ShowAll true'
# Display all the menus and calls all the item's callbacks, which sets the environment,
# controlled by the menus. It's like setting everything up into a default state
#MENU_ShowAll true true true all