archlinux / archinstall

Arch Linux installer - guided, templates etc.
GNU General Public License v3.0
5.82k stars 509 forks source link

New menu implementation with curses #2506

Closed svartkanin closed 1 month ago

svartkanin commented 1 month ago

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 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()
codefiles commented 1 month ago

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.

svartkanin commented 1 month ago

@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

Torxed commented 1 month ago

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.