Skip to content

TUI rewrite #1255

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

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

TUI rewrite #1255

wants to merge 43 commits into from

Conversation

dfordivam
Copy link
Collaborator

  • Removes use of existentials. fixes Remove existential types in TUI #1217

  • Makes use of GHC.Generics to take care of the Menu boilerplate

  • Improves the structure of code as each widget now need to implement the instance of BaseWidget, which captures the two essential parts, rendering and event handling.

  • The structure of the widget state matches directly to the "tree" structure of widgets. And the use of enums, like Mode, have been removed.

  • The input fields are more generic and we can nest them, like EditInput is being used inside SelectInput

  • The value of input fields can be modified like this

  compileGHCMenu % innerWidget % GenericMenu.fields % CompileGHCMenu.installTargetsF % EditInput.editInputOverlay % innerWidget % EditInput.editor %~ Edit.applyEdit (const (textZipper ["new-value"] Nothing))
  • The child widget does not modify the state of parent (as it was earlier being done via lens)

  • The 'quit' key handling logic is now mostly part of the BasicOverlay abstraction, and has been removed from the event handlers of individual widgets.

  • We can even do nesting of GenericMenu, in case we want to make fancy sub-menus

@dfordivam dfordivam requested a review from lsmor April 21, 2025 13:53
Copy link
Collaborator

@lsmor lsmor left a comment

Choose a reason for hiding this comment

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

I am not able to fully review this as the code is way more complex than my knowledge 😅 . My understading is:

  • Menus are defined by two parallel datatypes The "Fields" + "Options", and then this GenericMenu thing which I barely understand... Instead of Having "Options" + list of fields as before.
  • Existentials are hidden behind TypeClasses + Data.Some if I understand correctly.
  • I don't get the Overlays part. AFAIU, brick dispatches events to the frontward layers, so there is no need to pass events to the "child"/overlayed widget... but maybe I got this wrong

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.

Remove existential types in TUI
2 participants