archinstall icon indicating copy to clipboard operation
archinstall copied to clipboard

[WIP] - New menu implementation with curses

Open svartkanin opened this issue 1 year ago • 1 comments

Custom menu with curses - collecting feedback

Addresses https://github.com/archlinux/archinstall/issues/2364

This is a draft PR to showcase and to ask for feedback and input :)

Currently archinstall is using simple-term-menu for rendering the interactive menu. Although the library does its job, it is also somewhat limited in terms of customization. Information can only be shown from a top to bottom approach and there is no way of utilizing other spaces on the screen to be more flexible.

This WIP PR is a step into moving away from the dependency and implementing a "similar" interactive menu. The initial step is to replicate functionality and then to extend and customize it further.

I managed to get the basics up and running to show what the possibilities are

image image image image

This example code triggers the new menu

from archinstall.tui.curses_menu import NewMenu, MenuItem, MenuItemGroup, PreviewStyle

def test_data():
	return """{
    "__separator__": null,
    "additional-repositories": [
        "multilib"
    ],
    "archinstall-language": "English",
    "audio_config": {
        "audio": "pipewire"
    },
    "bootloader": "Grub",
    "config_version": "2.7.2",
    "debug": false,
    "disk_config": {
        "config_type": "pre_mounted_config",
        "mountpoint": "/mnt"
    },
    "disk_encryption": null,
    ...
"""

items = [
	MenuItem(f'Language', preview_action=lambda x: test_data()),
	MenuItem(f'Disk configuration', preview_action=lambda x: test_data()),
	MenuItem(f'Install', preview_action=lambda x: test_data()),
	MenuItem(f'Abort', preview_action=lambda x: test_data()),
]

group = MenuItemGroup(items, sort_items=False, focus_item=items[0])

menu = NewMenu(
	group,
	header='Press <H> for help',
	reset_warning_msg='are you certain?',
	allow_skip=False,
	allow_reset=False,
	preview_style=PreviewStyle.RIGHT,
	preview_size='auto',
	preview_frame=True,
	preview_header='INFO'
).single()

svartkanin avatar May 15 '24 11:05 svartkanin

Your contributions are commendable, I respect that. My feedback is don't continue to entangle unrelated changes into your pull requests. Out of the 8 files listed as changed only 3 have to do with the pull request.

codefiles avatar May 15 '24 22:05 codefiles

@Torxed I think this is ready now. It's not integrated in any existing flows as that will be part of the next PR to keep things less overwhelming

svartkanin avatar Jun 01 '24 05:06 svartkanin

I also commend you on this effort. Great work! Left two small comments that could be tweaked in a follow up PR when we start using the new TUI.

Torxed avatar Jun 06 '24 20:06 Torxed