Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions archinstall/tui/ui/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class _SelectionList(SelectionList[ValueT]):
Binding('up', 'cursor_up', 'Up', show=True),
Binding('j', 'cursor_down', 'Down', show=False),
Binding('k', 'cursor_up', 'Up', show=False),
Binding('space', 'select', 'Toggle', show=True),
]


Expand Down Expand Up @@ -493,9 +494,18 @@ def on_mount(self) -> None:
self.query_one(SelectionList).focus()

def on_key(self, event: Key) -> None:
if self.query_one(SelectionList).has_focus:
if event.key == 'enter':
_ = self.dismiss(Result(ResultType.Selection, _item=self._selected_items))
selection_list = self.query_one(SelectionList)

if not selection_list.has_focus or event.key != 'enter':
return None

if len(self._selected_items) < 1:
index = selection_list.highlighted
if index is not None:
selection = selection_list.get_option_at_index(index)
self._selected_items.append(selection.value)

_ = self.dismiss(Result(ResultType.Selection, _item=self._selected_items))

def on_input_changed(self, event: Input.Changed) -> None:
search_term = event.value.lower()
Expand Down Expand Up @@ -842,12 +852,14 @@ class _DataTable(DataTable[ValueT]):
Binding('up', 'cursor_up', 'Up', show=True),
Binding('j', 'cursor_down', 'Down', show=False),
Binding('k', 'cursor_up', 'Up', show=False),
Binding('space', 'select', 'Toggle', show=True),
Binding('enter', 'select_cursor', 'Confirm', show=True),
]


class TableSelectionScreen(BaseScreen[ValueT]):
BINDINGS: ClassVar = [
Binding('space', 'toggle_selection', 'Toggle', show=True),
Binding('space', 'toggle_selection', 'Toggle', show=True), # expclit handling of space in multi-selection mode
]

CSS = """
Expand Down Expand Up @@ -1087,20 +1099,18 @@ def _set_cursor(self, row_index: int) -> None:
def on_data_table_row_selected(self, event: DataTable.RowSelected) -> None:
if self._multi:
if len(self._selected_keys) == 0:
if not self._allow_skip:
return

_ = self.dismiss(Result[ValueT](ResultType.Skip))
selection = [event.row_key.value]
else:
items = [row_key.value for row_key in self._selected_keys]
_ = self.dismiss(Result(ResultType.Selection, _item=items)) # type: ignore[arg-type]
selection = [row_key.value for row_key in self._selected_keys]
else:
_ = self.dismiss(
Result[ValueT](
ResultType.Selection,
_item=event.row_key.value, # type: ignore[arg-type]
)
selection = event.row_key.value # type: ignore[assignment]

_ = self.dismiss(
Result[ValueT](
ResultType.Selection,
_item=selection, # type: ignore[arg-type]
)
)


class InstanceRunnable[ValueT](ABC):
Expand Down
Loading