helix-term: ui: Refactor statusline rendering, set configurable #2610
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.
In an effort to help bring custom statusline (related issue #708), I created a first refactor that changes almost nothing in the render but would allow future configuration of the statusline:
render_statusline
function, created aStatuslineRender
struct instead.StatuslineElement
enum to store every element that can be rendered, with configurable data associated.Every new "feature" to add to the statusline will just be a new element in this enum.
String
(user config) toStatuslineRender
will take placeStill have to decide the format and implement it.
I was thinking of something like:
{mode} blah blah {filename} bli blouh {diagnostic W E}
"blah blah" being static strings added to the statusline, (spaces, dashes, dots, etc ...)
"W" and "E" being configurable data associated to the statusline element
Changes in the rendered UI:
Questions I have regarding the implementation:
struct
well placed in the code ?render
functions in order to implement any further features on the bar ?EditorView
struct can access the user configuration in order to load theStatuslineRender
struct from the placeholder string ?First contribution here, please tell me if there's something wrong :-)