(GH-8) Improve Editor UI#14
Open
michaeltlombardi wants to merge 18 commits intoFlagrantGarden:mainfrom
Open
Conversation
Prior to this commit, the editor UI butted up against the top left of the terminal and had no custom styling to indicate that an app was running beyond the prompt messages. This commit updates the styling so the app displays centered in a bordered box with the app title and subtitle at the top. It introduces two new functions and one new method to the TUI library: - The TerminalSettings function includes standard styles and colors for the app so we do not need to recreate the settings everywhere. - The Title function creates the app title, centered and colored. - The Display method pulls the view body and title together, placing them inside a box with a colored border and centering the view.
Prior to this commit, the UpdateOnSubmodelEnded method was misimplemented, causing the program to error silently when adding a newly created (not copied) group to a company. This commit fixes the implementation, ensuring groups can be created and added both at company creation and after.
Prior to this commit, using the Done and Cancel methods to exit a program behaved strangely, requiring an additional key press to exit. This is because they were returning the tea.Quit *function* instead of the quit message that function returns, so the program never actually quit and only exited because of an unhandled keypress. This commit updates the end methods of the compositor to actually call tea.Quit() instead of returning the function, ensuring the program exits.
Prior to this commit, the player model did not handle pressing the escape key in any of the menus, meaning users could not cancel or back out of them. This commit implements handling for cancelling menus, moving to the next appropriate menu. If cancelling a prompt would end the model, the implementation is aware of whether or not it is run as a submodel; if it is not, cancelling a main or critical menu returns tea.Quit. If it is a submodel, it instead returns cancel. This commit also modifies the implementation to handle replacing the player persona the user is editing in the parent menu gracefully.
Prior to this commit, the group and company models did not handle pressing the escape key. This commit adds handling and ensures the behavior is correct when a user cancels out of a menu, moving to the next prompt or ending the model as appropriate, sending a cancel message if the model is run as a submodel or tea.Quit if it is not.
Prior to this commit the SaveConfig shared method ostensibly returned a command but instead of returning a message from the anonymous function returned a command. This commit updates the logic to ensure the return is correct so it can be appropriately processed.
This commit updates the editor model to handle the submodels which now appropriately send cancel messages, to enable switching the current player persona, and to gracefully quit.
This commit updates the display method on the shared model to render the app view with more awareness of the size of the buffer to improve how the app displays in different terminals and no longer requiring terminals of a precise size. A future commit will need to address the sizing for the prompts.
Prior to this commit, developers could use terminal settings to pull together the necessary information to style their text but it was clunky and there was no good way to define compositional styles which built on the extra styles and/or colors. This commit extends the definition of the Settings struct to include a list of dynamic styles as a map of operations to compile that style. Because the operations are run when they are called to apply, this allows a developer to compose complex styles and modify the settings before calling them. This should enable some refactoring to support the shift towards a TUI theme that can be extended/overwritten from data to enable module theming.
Prior to this commit, the implementation of the Copy method for terminal Settings failed to copy over the styles at all and colors in the extra map. This was due to the nature of encoding/decoding private fields on structs (it does not work) and the infeasibility of replacing a pointer variable in child scope func in a loop without actually reassigning the variable in the parent scope. This commit updates the signature of a terminal settings option to also return the settings object so that it can be reassigned, which solved half of the copy problem. The other half is addressed by reimplementing copy to use copystructure and a short loop to clone the styles explicitly, since no other method works. Finally, this commit adds the new From option, which developers can use when creating terminal settings to start from the settings of an existing instance. This is most useful for when you want to provide defaults for a model but also enable folks to override/extend without having to manually update every style one after the other.
This commit adds terminal settings to the Compositor so they can be used for styling. It adds the DefaultTerminalSettings method to define the terminal settings needed for styling the view of a fatal error, updates the ViewFatalError method to use the settings, and adds a New function for creating a Compositor while allowing you to extend/override the default terminal settings.
Prior to this commit, using a flag required retrieving it and comparing its value to the constants in the terminal package. Additionally, copying terminal settings broke flags via the copystruct operation. This commit ensures flags are retained in their correct state during a copy and adds three new helper methods: FlagIsOn, FlagIsOff, and FlagIsUnset to retrieve a flag and return true if the flag is on/off/unset respectively, removing the need to manually compare values every time.
Prior to this commit, the selector table template would render incorrectly when the first entry had multiple lines, breaking a lot of views. This commit injects an explicit newline to prevent that issue.
Prior to this commit, dynamic styles did not have a way to specify if they should only apply some operation conditionally, requiring dynamic styles for each possible case or to add style handling by the caller, defeating the purpose. This commit adds the concept of conditions to the terminal package, functions which have access to an instance of terminal Settings and must return true or false. They are used in the new conditional operations, which all take a condition as input and only apply the operation if the condition returns true. This commit adds some default conditions for developers to leverage flags.
This commit modifies the TUI styling drastically, taking advantage of the new dynamic styles and conditional operations from the terminal package to define settings once and propagate them throughout the application, using them in various prompts and displays. This necessitated touching nearly everything with prompts, as the overhaul required passing the terminal settings to each prompt-builder.
Prior to this commit, a developer needed to either use the default styling for selected entries or write their own choice style function. This commit adds helpers to use the default selection and final choice style functions but with their own preferred foreground color instead of the default royal blue.
This commit updates the selection prompts to use one of three colors: - Adding (light blue) when selecting something to add - Removing (orange) when selecting something to remove - Highlight (light green) for everything else
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This round of improvements substantially modifies the UI, making it look more like an app, fixing errors, handling prompt cancellations, and improving colorization.
Along the way, it extended several Tympan packages for convenience.