Files
bshell/bshell.runtime/include/bshell/line-editor/keybind.h
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

45 lines
1.2 KiB
C

#ifndef BSHELL_LINE_EDITOR_KEYBIND_H_
#define BSHELL_LINE_EDITOR_KEYBIND_H_
#include <bshell/status.h>
#include <fx/macros.h>
#include <fx/term/tty.h>
FX_DECLS_BEGIN;
#define BSHELL_LINE_EDITOR_KEYBIND_RESULT(status, action) \
((struct bshell_line_ed_keybind_result) { \
.r_status = (status), \
.r_action = (action), \
})
typedef FX_TYPE_FWDREF(bshell_line_ed) bshell_line_ed;
struct bshell_line_ed_keybind_result {
enum bshell_status r_status;
enum {
BSHELL_LINE_EDITOR_KEYBIND_CONTINUE = 0,
BSHELL_LINE_EDITOR_KEYBIND_STOP,
} r_action;
};
typedef struct bshell_line_ed_keybind_result (
*bshell_line_ed_keybind_callback_t)(bshell_line_ed *, fx_keycode);
#define BSHELL_TYPE_LINE_EDITOR_KEYBIND (bshell_line_ed_keybind_get_type())
FX_DECLARE_TYPE(bshell_line_ed_keybind);
FX_TYPE_CLASS_DECLARATION_BEGIN(bshell_line_ed_keybind)
FX_TYPE_CLASS_DECLARATION_END(bshell_line_ed_keybind)
extern fx_type_id bshell_line_ed_keybind_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(
bshell_line_ed_keybind,
BSHELL_TYPE_LINE_EDITOR_KEYBIND);
FX_DECLS_END;
#endif