runtime: implement an extensible line editor

the line editor supports custom keybinds and data storage, allowing for
a wide range of functionality to be implemented via plugins.

included plugins include:
* core: basic input and cursor movement.
* history: input history storage and retrieval (unfinished)
* highlight: support for colour-highlighting the line buffer (unfinished)
* syntax: parses the line buffer and uses `highlight` to apply syntax highlighting (unfinished).
* shell-integration:
  - allows a `prompt` function to be defined, which will be called to get the text to
    be used for the prompt
  - exposes key properties of the line editor to the shell environment, allowing line editor
    functionality to be extended via shell scripts.
This commit is contained in:
2026-06-20 15:13:34 +01:00
parent f622c2eba3
commit ad8b284869
21 changed files with 1857 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
#include <bshell/line-editor/history.h>
#include <bshell/line-editor/plugin.h>
struct bshell_line_ed_history_p {
};
static void init(fx_object *obj, void *priv)
{
}
static void fini(fx_object *obj, void *priv)
{
}
FX_TYPE_CLASS_BEGIN(bshell_line_ed_history)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_VTABLE_INTERFACE_BEGIN(
bshell_line_ed_plugin,
BSHELL_TYPE_LINE_EDITOR_PLUGIN)
FX_TYPE_VTABLE_INTERFACE_END(bshell_command, BSHELL_TYPE_COMMAND)
FX_TYPE_CLASS_END(bshell_line_ed_history)
FX_TYPE_DEFINITION_BEGIN(bshell_line_ed_history)
FX_TYPE_ID(0xa08c98d5, 0x9512, 0x4a65, 0xaf57, 0x0daa8a943e52);
FX_TYPE_NAME("bshell.runtime.line_editor.plugins.history");
FX_TYPE_EXTENDS(BSHELL_TYPE_LINE_EDITOR_PLUGIN);
FX_TYPE_CLASS(bshell_line_ed_history_class);
FX_TYPE_INSTANCE_INIT(init);
FX_TYPE_INSTANCE_FINI(fini);
FX_TYPE_INSTANCE_PRIVATE(struct bshell_line_ed_history_p);
FX_TYPE_DEFINITION_END(bshell_line_ed_history)