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

New menu implementation with curses #2506

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

svartkanin
Copy link
Collaborator

@svartkanin svartkanin commented May 15, 2024

Custom menu with curses - collecting feedback

Addresses #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:

  • Preview menu can be displayed on either bottom, right, top
  • Multi column menus are available
  • Overlay windows are available

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()

@svartkanin svartkanin requested a review from Torxed as a code owner May 15, 2024 11:32
@codefiles
Copy link
Contributor

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.

@@ -29,13 +29,13 @@ repos:
- id: check-ast # Simply check whether files parse as valid python
- id: check-docstring-first # Checks for a common error of placing code before the docstring
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to update these versions to align with the pyproject.toml versions

@svartkanin svartkanin changed the title [WIP] - New menu implementation with curses New menu implementation with curses Jun 1, 2024
@svartkanin
Copy link
Collaborator Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants