Skip to content

Prompt widgets #374

@HalFrgrd

Description

@HalFrgrd

The user should be able to add custom widgets to the prompt similarly to how animations work.

They would create a widget via the command line as follows:
flyline create-prompt-widget mouse-mode --name FLYLINE_MOUSE_MODE 'mouse is enabled' 'mouse is disabled'

flyline create-prompt-widget custom --name CUSTOM_WIDGET1 --command 'run_something.sh' --placholder-length 10

flyline create-prompt-widget custom --name CUSTOM_WIDGET1 --command 'run_something.sh' --blocking

Rename create-anim to create-prompt-anim for uniformity. Be sure to update all documentation.

If the name string is found in the prompt, then a PromptSegment::WidgetMouseMode or a PromptSegment::WidgetCustom should be inserted. Similar to how animations work.
WidgetMouseMode should hold two strings. The first for when mouse mode is enabled and the second for when mouse mode is disabled. The mouse mode state can be passed to get_ps1_lines.

WidgetCustom should hold either a vec of TaggedSpans or the receiver end of a channel and the placeholder string. When we first create this segment, we start a process running the custom command. If blocking is true, we wait for this command to finish. If it is false (default) then we spawn the process and give the receiver end of a channel to the WidgetCustom to hold.
When rendering, we either use the placeholder string or the result if it is done. The output of the command should be passed through expand_prompt_through_bash. If the command fails with a nonzero exit code, the string "command failed" in bold red blinking should be used. Log the output and stderr to logs.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions