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-03-20 18:26:38 +0100
committerAnton Hvornum <anton@hvornum.se>2021-03-20 18:26:38 +0100
commite209767d13bb8887ad7449cab59501fdc0eb4f77 (patch)
tree5688b5c6407978b0d472484e50c0e1effd463c6b /archinstall/lib
parentb67257233f43fa8d34dacd6ecc3dc7cbbf60d221 (diff)
Added helper functions for #81. So that we have a basic information about the terminal when outputting large lists/options.
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/user_interaction.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 6b3e5faa..b9689d05 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -1,4 +1,4 @@
-import getpass, pathlib
+import getpass, pathlib, os, shutil
from .exceptions import *
from .profiles import Profile
from .locale_helpers import search_keyboard_layout
@@ -9,6 +9,15 @@ from .networking import list_interfaces
## TODO: Some inconsistencies between the selection processes.
## Some return the keys from the options, some the values?
+def get_terminal_height():
+ return shutil.get_terminal_size().lines
+
+def get_terminal_width():
+ return shutil.get_terminal_size().columns
+
+def get_longest_option(options):
+ return max([len(x) for x in options])
+
def get_password(prompt="Enter a password: "):
while (passwd := getpass.getpass(prompt)):
passwd_verification = getpass.getpass(prompt='And one more time for verification: ')