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

Add simple menu for better UX #660

Merged
merged 25 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
deff005
Add simple menu for better UX
svartkanin Oct 11, 2021
0e7969c
PR feedback
svartkanin Oct 27, 2021
697dce9
Merge remote-tracking branch 'origin/master' into add-menu
svartkanin Nov 7, 2021
bdcf33c
Add remove external dependency
svartkanin Nov 8, 2021
36ed68b
Fix harddisk return value on skip
svartkanin Nov 8, 2021
5e555f7
Table output for partitioning process
svartkanin Nov 8, 2021
bb915a3
Switch partitioning to simple menu
svartkanin Nov 9, 2021
956b614
fixup! Switch partitioning to simple menu
svartkanin Nov 10, 2021
e3bf635
Uncomment
svartkanin Nov 10, 2021
4028936
Update
svartkanin Nov 10, 2021
cbfcf33
Simplify code
svartkanin Nov 10, 2021
ac173c0
Calling fs_types() to get the response
Torxed Nov 11, 2021
c57bf22
Ignoring complexity and binary operator issues
Torxed Nov 11, 2021
07a520e
Added license text to the MIT licensed file
Torxed Nov 11, 2021
67ae610
Added in versioning information
Torxed Nov 11, 2021
638f970
Linting issue fix
Torxed Nov 11, 2021
4e9330a
Merged latest master
Torxed Nov 11, 2021
54a65b6
Pulled fix for multi select search
svartkanin Nov 20, 2021
1f8f487
Merged master
Nov 25, 2021
73a5e0b
Fixed some imports and removed the last generic_select() from user_in…
Nov 25, 2021
399cfd7
Incorrect usage of archinstall. inside the library.
Nov 25, 2021
a5eee0c
Update color scheme to match Arch style better
dylanmtaylor Nov 26, 2021
9b2252d
Use cyan as default cursor color
dylanmtaylor Nov 26, 2021
c7194da
Leave simple menu the same
dylanmtaylor Nov 29, 2021
fc2e72a
Merge pull request #1 from dylanmtaylor/patch-1
svartkanin Nov 30, 2021
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
Prev Previous commit
Next Next commit
Table output for partitioning process
  • Loading branch information
svartkanin committed Nov 8, 2021
commit 5e555f73b6af814dfe6f13abb90ff2670b537e8e
46 changes: 41 additions & 5 deletions archinstall/lib/user_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,44 @@ def get_default_partition_layout(block_devices):
# TODO: Implement sane generic layout for 2+ drives


def current_partition_layout(partitions):
def do_padding(name, max_len):
spaces = abs(len(str(name)) - max_len) + 2
pad_left = int(spaces/2)
pad_right = spaces - pad_left
return f'{pad_right * " "}{name}{pad_left * " "}|'

column_names = {}
# determine all attribute names and the max length
# of the value among all partitions to know the width
# of the table cells
for p in partitions:
for attribute, value in p.items():
if attribute in column_names.keys():
column_names[attribute] = max([column_names[attribute], len(str(value)), len(attribute)])
else:
column_names[attribute] = max([len(str(value)), len(attribute)])

title = ''
for name, max_len in column_names.items():
title += do_padding(name, max_len)

# remove last pipe
title = f'{title[:-1]}\n{"-" * len(title)}\n'

for p in partitions:
row = ''
for name, max_len in column_names.items():
if name in p:
row += do_padding(p[name], max_len)
else:
row += ' ' * (max_len + 2) + '|'

title += f'{row[:-1]}\n'

return title


def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
# if has_uefi():
# partition_type = 'gpt'
Expand Down Expand Up @@ -529,7 +567,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
# return struct

block_device_struct = {
"partitions" : [partition.__dump__() for partition in block_device.partitions.values()]
"partitions": [partition.__dump__() for partition in block_device.partitions.values()]
}
# Test code: [part.__dump__() for part in block_device.partitions.values()]
# TODO: Squeeze in BTRFS subvolumes here
Expand All @@ -551,10 +589,8 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:

# show current partition layout:
if len(block_device_struct["partitions"]):
title += '\n\nCurrent partition layout:\n'
for partition in block_device_struct["partitions"]:
title += json.dumps(partition)
title += '\n'
title += '\n\nCurrent partition layout:\n\n'
title += current_partition_layout(block_device_struct['partitions']) + '\n'

task = Menu(title, modes).run()

Expand Down
44 changes: 23 additions & 21 deletions examples/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,29 @@ def ask_user_questions():
Not until we're satisfied with what we want to install
will we continue with the actual installation steps.
"""
if not archinstall.arguments.get('keyboard-layout', None):
archinstall.arguments['keyboard-layout'] = archinstall.select_language()

# Before continuing, set the preferred keyboard layout/language in the current terminal.
# This will just help the user with the next following questions.
if len(archinstall.arguments['keyboard-layout']):
archinstall.set_keyboard_language(archinstall.arguments['keyboard-layout'])

# Set which region to download packages from during the installation
if not archinstall.arguments.get('mirror-region', None):
archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions()

if not archinstall.arguments.get('sys-language', None) and archinstall.arguments.get('advanced', False):
archinstall.arguments['sys-language'] = input("Enter a valid locale (language) for your OS, (Default: en_US): ").strip()
archinstall.arguments['sys-encoding'] = input("Enter a valid system default encoding for your OS, (Default: utf-8): ").strip()
archinstall.log("Keep in mind that if you want multiple locales, post configuration is required.", fg="yellow")

if not archinstall.arguments.get('sys-language', None):
archinstall.arguments['sys-language'] = 'en_US'
if not archinstall.arguments.get('sys-encoding', None):
archinstall.arguments['sys-encoding'] = 'utf-8'
# if not archinstall.arguments.get('keyboard-layout', None):
# archinstall.arguments['keyboard-layout'] = archinstall.select_language()
#
# # Before continuing, set the preferred keyboard layout/language in the current terminal.
# # This will just help the user with the next following questions.
# if len(archinstall.arguments['keyboard-layout']):
# archinstall.set_keyboard_language(archinstall.arguments['keyboard-layout'])
#
# # Set which region to download packages from during the installation
# if not archinstall.arguments.get('mirror-region', None):
# archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions()
#
# if not archinstall.arguments.get('sys-language', None) and archinstall.arguments.get('advanced', False):
# archinstall.arguments['sys-language'] = input("Enter a valid locale (language) for your OS, (Default: en_US): ").strip()
# archinstall.arguments['sys-encoding'] = input("Enter a valid system default encoding for your OS, (Default: utf-8): ").strip()
# archinstall.log("Keep in mind that if you want multiple locales, post configuration is required.", fg="yellow")
#
# if not archinstall.arguments.get('sys-language', None):
# archinstall.arguments['sys-language'] = 'en_US'
# if not archinstall.arguments.get('sys-encoding', None):
# archinstall.arguments['sys-encoding'] = 'utf-8'



# Ask which harddrives/block-devices we will install to
# and convert them into archinstall.BlockDevice() objects.
Expand Down