index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Werner Llácer <wllacer@gmail.com> | 2022-08-01 09:44:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 09:44:26 +0200 |
commit | 3bc39225458b32fcd43b8a5b76dbb6797723a86c (patch) | |
tree | 28d33463384af8298374540c447fc0677d1b4ee9 | |
parent | d2f58362c9035be57670784584a666eea8c09e60 (diff) |
-rw-r--r-- | archinstall/lib/menu/list_manager.py | 13 | ||||
-rw-r--r-- | archinstall/lib/menu/selection_menu.py | 9 |
diff --git a/archinstall/lib/menu/list_manager.py b/archinstall/lib/menu/list_manager.py index e7a9c2ac..ae3a6eb5 100644 --- a/archinstall/lib/menu/list_manager.py +++ b/archinstall/lib/menu/list_manager.py @@ -44,6 +44,12 @@ class ListManager: self._base_actions = base_actions self._sub_menu_actions = sub_menu_actions + self._last_choice = None + + @property + def last_choice(self): + return self._last_choice + def run(self): while True: # this will return a dictionary with the key as the menu entry to be displayed @@ -73,6 +79,7 @@ class ListManager: selected_entry = data_formatted[choice.value] self._run_actions_on_entry(selected_entry) + self._last_choice = choice if choice.value == self._cancel_action: return self._original_data # return the original list else: @@ -97,7 +104,7 @@ class ListManager: return options, header def _run_actions_on_entry(self, entry: Any): - options = self._sub_menu_actions + [self._cancel_action] + options = self.filter_options(entry,self._sub_menu_actions) + [self._cancel_action] display_value = self.selected_action_display(entry) prompt = _("Select an action for '{}'").format(display_value) @@ -129,3 +136,7 @@ class ListManager: # this function is called when a base action or # a specific action for an entry is triggered raise NotImplementedError('Please implement me in the child class') + + def filter_options(self, selection :Any, options :List[str]) -> List[str]: + # filter which actions to show for an specific selection + return options diff --git a/archinstall/lib/menu/selection_menu.py b/archinstall/lib/menu/selection_menu.py index 8dd6fcce..c6ac5852 100644 --- a/archinstall/lib/menu/selection_menu.py +++ b/archinstall/lib/menu/selection_menu.py @@ -188,6 +188,11 @@ class GeneralMenu: self._menu_options: Dict[str, Selector] = {} self._setup_selection_menu_options() self.preview_size = preview_size + self._last_choice = None + + @property + def last_choice(self): + return self._last_choice def __enter__(self, *args :Any, **kwargs :Any) -> GeneralMenu: self.is_context_mgr = True @@ -325,6 +330,10 @@ class GeneralMenu: if not self._process_selection(value): break + # we get the last action key + actions = {str(v.description):k for k,v in self._menu_options.items()} + self._last_choice = actions[selection.value.strip()] + if not self.is_context_mgr: self.__exit__() |