Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/menu/menu.py
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2022-09-12 05:23:21 +1000
committerGitHub <noreply@github.com>2022-09-11 21:23:21 +0200
commit94df913e0f2e68178ad64d385bbc453416b7e4b0 (patch)
tree7daa03555a3a0ff9834f91166481c41a2a6e0346 /archinstall/lib/menu/menu.py
parentc373607f8c9548bf9de55988629b747f32d67b3d (diff)
Update handling of unsupported translations (#1467)
* Handle unsupported fonts * Update archinstall/locales/README.md Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com> Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com> Co-authored-by: codefiles <11915375+codefiles@users.noreply.github.com>
Diffstat (limited to 'archinstall/lib/menu/menu.py')
-rw-r--r--archinstall/lib/menu/menu.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/archinstall/lib/menu/menu.py b/archinstall/lib/menu/menu.py
index 16153e2c..112bc0ae 100644
--- a/archinstall/lib/menu/menu.py
+++ b/archinstall/lib/menu/menu.py
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from enum import Enum, auto
from os import system
-from typing import Dict, List, Union, Any, TYPE_CHECKING, Optional
+from typing import Dict, List, Union, Any, TYPE_CHECKING, Optional, Callable
from archinstall.lib.menu.simple_menu import TerminalMenu
@@ -52,9 +52,9 @@ class Menu(TerminalMenu):
sort :bool = True,
preset_values :Union[str, List[str]] = None,
cursor_index : Optional[int] = None,
- preview_command=None,
- preview_size=0.75,
- preview_title='Info',
+ preview_command: Optional[Callable] = None,
+ preview_size: float = 0.75,
+ preview_title: str = 'Info',
header :Union[List[str],str] = None,
raise_error_on_interrupt :bool = False,
raise_error_warning_msg :str = '',
@@ -152,6 +152,7 @@ class Menu(TerminalMenu):
self._multi = multi
self._raise_error_on_interrupt = raise_error_on_interrupt
self._raise_error_warning_msg = raise_error_warning_msg
+ self._preview_command = preview_command
menu_title = f'\n{title}\n\n'
@@ -198,7 +199,7 @@ class Menu(TerminalMenu):
# show_search_hint=True,
preselected_entries=self.preset_values,
cursor_index=self.cursor_index,
- preview_command=preview_command,
+ preview_command=lambda x: self._preview_wrapper(preview_command, x),
preview_size=preview_size,
preview_title=preview_title,
raise_error_on_interrupt=self._raise_error_on_interrupt,
@@ -235,6 +236,13 @@ class Menu(TerminalMenu):
else:
return MenuSelection(type_=MenuSelectionType.Esc)
+ def _preview_wrapper(self, preview_command: Optional[Callable], current_selection: str) -> Optional[str]:
+ if preview_command:
+ if self._default_option is not None and f'{self._default_option} {self._default_str}' == current_selection:
+ current_selection = self._default_option
+ return preview_command(current_selection)
+ return None
+
def run(self) -> MenuSelection:
ret = self._show()