Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project Setup Script
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Tools
Project Setup Script
Commits
21724e17
Commit
21724e17
authored
2 years ago
by
Jan Frieder Milke
Browse files
Options
Downloads
Patches
Plain Diff
menu.py now recognizes MacOS arrow keys and will exit with [Q] or 2x[Esc] on MacOS
parent
21f45ed1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
menu.py
+12
-9
12 additions, 9 deletions
menu.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
13 additions
and
10 deletions
menu.py
+
12
−
9
View file @
21724e17
...
@@ -74,17 +74,20 @@ def get_key():
...
@@ -74,17 +74,20 @@ def get_key():
while
True
:
while
True
:
k
=
inkey
()
k
=
inkey
()
value
=
value
+
k
value
=
value
+
k
if
k
==
'
\x00
'
or
k
==
'
\xe0
'
:
pass
# 1st check if Esc was hit twice: then only return 1x Esc
if
(
value
==
'
\x1b\x1b
'
):
return
k
# Else read until no special characters are found anymore
elif
k
==
'
\x00
'
or
k
==
'
\xe0
'
or
k
==
'
\x1b
'
or
k
==
'
[
'
:
pass
elif
k
!=
''
:
break
elif
k
!=
''
:
break
return
value
return
value
# Different platforms have different escape keys
# Different platforms have different escape keys
arrow_up
=
[
'
\x00
H
'
,
'
\xe0
H
'
]
arrow_up
=
[
'
\x00
H
'
,
'
\xe0
H
'
,
'
\x1b
[A
'
]
arrow_down
=
[
'
\x00
P
'
,
'
\xe0
P
'
]
arrow_down
=
[
'
\x00
P
'
,
'
\xe0
P
'
,
'
\x1b
[B
'
]
arrow_right
=
[
'
\x00
M
'
,
'
\xe0
M
'
]
arrow_right
=
[
'
\x00
M
'
,
'
\xe0
M
'
,
'
\x1b
[C
'
]
arrow_left
=
[
'
\x00
K
'
,
'
\xe0
K
'
]
arrow_left
=
[
'
\x00
K
'
,
'
\xe0
K
'
,
'
\x1b
[D
'
]
enter
=
'
\x0d
'
enter
=
'
\x0d
'
escape
=
'
\x1b
'
escape
=
[
'
\x1b
'
,
'
q
'
,
'
Q
'
]
class
Terminal
:
class
Terminal
:
REVERSE
=
'
\u001b
[7m
'
REVERSE
=
'
\u001b
[7m
'
...
@@ -121,7 +124,7 @@ class Terminal:
...
@@ -121,7 +124,7 @@ class Terminal:
DEFAULT_BOTTOM_TEXT
=
'
[Arrow Up/Down] Change Selection
\n
'
+
\
DEFAULT_BOTTOM_TEXT
=
'
[Arrow Up/Down] Change Selection
\n
'
+
\
'
[Enter] Confirm Selection
\n
'
+
\
'
[Enter] Confirm Selection
\n
'
+
\
'
[Esc]
Abort
'
'
[Esc]
/[Q]
Abort
'
def
showmenu
(
menu_items
,
top_text
=
None
,
bottom_text
=
DEFAULT_BOTTOM_TEXT
,
default_selection
=
0
):
def
showmenu
(
menu_items
,
top_text
=
None
,
bottom_text
=
DEFAULT_BOTTOM_TEXT
,
default_selection
=
0
):
"""
Displays a menu.
"""
Displays a menu.
...
@@ -161,7 +164,7 @@ def showmenu(menu_items, top_text=None, bottom_text=DEFAULT_BOTTOM_TEXT, default
...
@@ -161,7 +164,7 @@ def showmenu(menu_items, top_text=None, bottom_text=DEFAULT_BOTTOM_TEXT, default
elif
k
==
enter
:
elif
k
==
enter
:
Terminal
.
clear_screen
()
Terminal
.
clear_screen
()
return
current_selection
return
current_selection
elif
k
==
escape
:
elif
k
in
escape
:
Terminal
.
clear_screen
()
Terminal
.
clear_screen
()
return
None
return
None
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
21724e17
...
@@ -100,7 +100,7 @@ def manage_plugins():
...
@@ -100,7 +100,7 @@ def manage_plugins():
menu_items
=
[
get_plugin_string
(
plugin_id
)
for
plugin_id
in
plugin_ids
]
menu_items
=
[
get_plugin_string
(
plugin_id
)
for
plugin_id
in
plugin_ids
]
BOTTOM_TEXT
=
'
[Arrow Up/Down] Select Plugin
\n
'
+
\
BOTTOM_TEXT
=
'
[Arrow Up/Down] Select Plugin
\n
'
+
\
'
[Enter] Select Plugin branch
\n
'
+
\
'
[Enter] Select Plugin branch
\n
'
+
\
'
[Esc]
Confirm selection
'
'
[Esc]
/[Q]
Confirm selection
'
plugin_selection
=
menu
.
showmenu
(
menu_items
,
bottom_text
=
BOTTOM_TEXT
)
plugin_selection
=
menu
.
showmenu
(
menu_items
,
bottom_text
=
BOTTOM_TEXT
)
if
plugin_selection
==
None
:
if
plugin_selection
==
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment