Skip to content

Commit

Permalink
Fix misaligned table headers
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Jan 14, 2025
1 parent e7f2a8c commit a621826
Showing 1 changed file with 14 additions and 6 deletions.
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

0 comments on commit a621826

Please sign in to comment.