Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-05-12 10:58:00 +0000
committerGitHub <noreply@github.com>2021-05-12 10:58:00 +0000
commit0ef8cc579eba15803f542947c56a15ab9807b09c (patch)
treeaf03e5a889e145fb42c1e10f41af0eb8d7d6af3a /archinstall/lib
parenta85517513dce1277cf10be776bb0b764eec7383a (diff)
parent24a14d1800e990e2e90dd628b8460f85fe3d1495 (diff)
Merge pull request #422 from arieboven/print_large_list_fix
fix error when there are to many options to print and calculation spaces
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/user_interaction.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 7d3a34d5..c76dc9a5 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -83,16 +83,18 @@ def get_password(prompt="Enter a password: "):
def print_large_list(options, padding=5, margin_bottom=0, separator=': '):
highest_index_number_length = len(str(len(options)))
longest_line = highest_index_number_length + len(separator) + get_longest_option(options) + padding
+ spaces_without_option = longest_line - (len(separator) + highest_index_number_length)
max_num_of_columns = get_terminal_width() // longest_line
max_options_in_cells = max_num_of_columns * (get_terminal_height()-margin_bottom)
if (len(options) > max_options_in_cells):
for index, option in enumerate(options):
print(f"{index}: {option}")
+ return 1, index
else:
for row in range(0, (get_terminal_height()-margin_bottom)):
for column in range(row, len(options), (get_terminal_height()-margin_bottom)):
- spaces = " "*(longest_line - len(options[column]))
+ spaces = " "*(spaces_without_option - len(options[column]))
print(f"{str(column): >{highest_index_number_length}}{separator}{options[column]}", end = spaces)
print()