-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple menu for better UX #660
Merged
Merged
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
deff005
Add simple menu for better UX
svartkanin 0e7969c
PR feedback
svartkanin 697dce9
Merge remote-tracking branch 'origin/master' into add-menu
svartkanin bdcf33c
Add remove external dependency
svartkanin 36ed68b
Fix harddisk return value on skip
svartkanin 5e555f7
Table output for partitioning process
svartkanin bb915a3
Switch partitioning to simple menu
svartkanin 956b614
fixup! Switch partitioning to simple menu
svartkanin e3bf635
Uncomment
svartkanin 4028936
Update
svartkanin cbfcf33
Simplify code
svartkanin ac173c0
Calling fs_types() to get the response
Torxed c57bf22
Ignoring complexity and binary operator issues
Torxed 07a520e
Added license text to the MIT licensed file
Torxed 67ae610
Added in versioning information
Torxed 638f970
Linting issue fix
Torxed 4e9330a
Merged latest master
Torxed 54a65b6
Pulled fix for multi select search
svartkanin 1f8f487
Merged master
73a5e0b
Fixed some imports and removed the last generic_select() from user_in…
399cfd7
Incorrect usage of archinstall. inside the library.
a5eee0c
Update color scheme to match Arch style better
dylanmtaylor 9b2252d
Use cyan as default cursor color
dylanmtaylor c7194da
Leave simple menu the same
dylanmtaylor fc2e72a
Merge pull request #1 from dylanmtaylor/patch-1
svartkanin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ SAFETY_LOCK | |
/guided.py | ||
/install.log | ||
venv | ||
.venv | ||
.idea/** | ||
**/install.log | ||
**/install.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
from .simple_menu import TerminalMenu | ||
|
||
|
||
class Menu(TerminalMenu): | ||
def __init__(self, title, options, skip=True, multi=False, default_option=None, sort=True): | ||
""" | ||
Creates a new menu | ||
|
||
:param title: Text that will be displayed above the menu | ||
:type title: str | ||
|
||
:param options: Options to be displayed in the menu to chose from; | ||
if dict is specified then the keys of such will be used as options | ||
:type options: list, dict | ||
|
||
:param skip: Indicate if the selection is not mandatory and can be skipped | ||
:type skip: bool | ||
|
||
:param multi: Indicate if multiple options can be selected | ||
:type multi: bool | ||
|
||
:param default_option: The default option to be used in case the selection processes is skipped | ||
:type default_option: str | ||
|
||
:param sort: Indicate if the options should be sorted alphabetically before displaying | ||
:type sort: bool | ||
""" | ||
|
||
if isinstance(options, dict): | ||
options = list(options) | ||
|
||
if sort: | ||
options = sorted(options) | ||
|
||
self.menu_options = options | ||
self.skip = skip | ||
self.default_option = default_option | ||
self.multi = multi | ||
|
||
menu_title = f'\n{title}\n\n' | ||
|
||
if skip: | ||
menu_title += "Use ESC to skip\n\n" | ||
|
||
if default_option: | ||
# if a default value was specified we move that one | ||
# to the top of the list and mark it as default as well | ||
default = f'{default_option} (default)' | ||
self.menu_options = [default] + [o for o in self.menu_options if default_option != o] | ||
|
||
cursor = "> " | ||
main_menu_cursor_style = ("fg_red", "bold") | ||
main_menu_style = ("bg_red", "fg_yellow") | ||
|
||
super().__init__( | ||
menu_entries=self.menu_options, | ||
title=menu_title, | ||
menu_cursor=cursor, | ||
menu_cursor_style=main_menu_cursor_style, | ||
menu_highlight_style=main_menu_style, | ||
cycle_cursor=True, | ||
clear_screen=True, | ||
multi_select=multi, | ||
show_search_hint=True | ||
) | ||
|
||
def _show(self): | ||
idx = self.show() | ||
if idx is not None: | ||
if isinstance(idx, (list, tuple)): | ||
return [self.menu_options[i] for i in idx] | ||
else: | ||
selected = self.menu_options[idx] | ||
if ' (default)' in selected and self.default_option: | ||
return self.default_option | ||
return selected | ||
else: | ||
if self.default_option: | ||
if self.multi: | ||
return [self.default_option] | ||
else: | ||
return self.default_option | ||
return None | ||
|
||
def run(self): | ||
ret = self._show() | ||
|
||
if ret is None and not self.skip: | ||
return self.run() | ||
|
||
return ret |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of this color scheme. Maybe we could go with something close to the Arch blue to match?