Files
bshell/bshell.runtime/line-editor/syntax.c
T
wash ad8b284869 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.
2026-06-20 15:13:34 +01:00

46 lines
1.3 KiB
C

#include <bshell/line-editor/line-editor.h>
#include <bshell/line-editor/plugin.h>
#include <bshell/line-editor/syntax.h>
#include <fx/term/tty.h>
struct bshell_line_ed_syntax_p {
};
static void init(fx_object *obj, void *priv)
{
}
static void fini(fx_object *obj, void *priv)
{
}
static enum bshell_status buffer_changed(
bshell_line_ed_plugin *plugin,
bshell_line_ed *ed)
{
// fprintf(stderr, "buffer changed!\n");
return BSHELL_SUCCESS;
}
FX_TYPE_CLASS_BEGIN(bshell_line_ed_syntax)
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_INTERFACE_ENTRY(p_buffer_changed) = buffer_changed;
FX_TYPE_VTABLE_INTERFACE_END(bshell_command, BSHELL_TYPE_COMMAND)
FX_TYPE_CLASS_END(bshell_line_ed_syntax)
FX_TYPE_DEFINITION_BEGIN(bshell_line_ed_syntax)
FX_TYPE_ID(0x4d9dea6c, 0x2ed8, 0x40e0, 0x943d, 0xfd70a7a9f54a);
FX_TYPE_NAME("bshell.runtime.line_editor.plugins.syntax");
FX_TYPE_EXTENDS(BSHELL_TYPE_LINE_EDITOR_PLUGIN);
FX_TYPE_CLASS(bshell_line_ed_syntax_class);
FX_TYPE_INSTANCE_INIT(init);
FX_TYPE_INSTANCE_FINI(fini);
FX_TYPE_INSTANCE_PRIVATE(struct bshell_line_ed_syntax_p);
FX_TYPE_DEFINITION_END(bshell_line_ed_syntax)