Skip to content
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

Fix misaligned table headers #3120

Merged
merged 1 commit into from
Jan 21, 2025
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
20 changes: 14 additions & 6 deletions archinstall/tui/curses_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ def __init__(
self._interrupt_warning = reset_warning_msg
self._header = header

header_offset = self._get_header_offset()
header_offset = self._get_header_offset(header)
self._headers = self.get_header_entries(header, offset=header_offset)

if self._interrupt_warning is None:
Expand All @@ -875,11 +875,19 @@ def __init__(

self._init_viewports(preview_size)

def _get_header_offset(self) -> int:
# any changes here will impact the list manager table view
offset = len(self._cursor_char) + 1
if self._multi:
offset += 3
def _get_header_offset(self, header: str | None) -> int:
# WARNING: any changes here will impact the list manager table view
if self._orientation == Orientation.HORIZONTAL:
return 0

lines = header.split('\n') if header else []
table_header = [line for line in lines if '|' in line]
longest_header = len(table_header[0]) if table_header else 0
longest_entry = self._item_group.max_width

delta = abs(longest_header - longest_entry)
offset = delta + 3 # 3 because it seems to align it...

return offset

def run(self) -> Result:
Expand Down
Loading