mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibLine: Allow the user to override (or add) keybinds in the config file
This commit is contained in:
parent
32839d40e3
commit
5b9d563b4b
2 changed files with 84 additions and 32 deletions
|
@ -53,38 +53,6 @@
|
|||
|
||||
namespace Line {
|
||||
|
||||
struct Configuration {
|
||||
enum RefreshBehaviour {
|
||||
Lazy,
|
||||
Eager,
|
||||
};
|
||||
enum OperationMode {
|
||||
Unset,
|
||||
Full,
|
||||
NoEscapeSequences,
|
||||
NonInteractive,
|
||||
};
|
||||
|
||||
Configuration()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Arg, typename... Rest>
|
||||
Configuration(Arg arg, Rest... rest)
|
||||
: Configuration(rest...)
|
||||
{
|
||||
set(arg);
|
||||
}
|
||||
|
||||
void set(RefreshBehaviour refresh) { refresh_behaviour = refresh; }
|
||||
void set(OperationMode mode) { operation_mode = mode; }
|
||||
|
||||
static Configuration from_config(const StringView& libname = "line");
|
||||
|
||||
RefreshBehaviour refresh_behaviour { RefreshBehaviour::Lazy };
|
||||
OperationMode operation_mode { OperationMode::Unset };
|
||||
};
|
||||
|
||||
struct Key {
|
||||
enum Modifier : int {
|
||||
None = 0,
|
||||
|
@ -119,6 +87,40 @@ struct KeyBinding {
|
|||
String binding;
|
||||
};
|
||||
|
||||
struct Configuration {
|
||||
enum RefreshBehaviour {
|
||||
Lazy,
|
||||
Eager,
|
||||
};
|
||||
enum OperationMode {
|
||||
Unset,
|
||||
Full,
|
||||
NoEscapeSequences,
|
||||
NonInteractive,
|
||||
};
|
||||
|
||||
Configuration()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Arg, typename... Rest>
|
||||
Configuration(Arg arg, Rest... rest)
|
||||
: Configuration(rest...)
|
||||
{
|
||||
set(arg);
|
||||
}
|
||||
|
||||
void set(RefreshBehaviour refresh) { refresh_behaviour = refresh; }
|
||||
void set(OperationMode mode) { operation_mode = mode; }
|
||||
void set(const KeyBinding& binding) { keybindings.append(binding); }
|
||||
|
||||
static Configuration from_config(const StringView& libname = "line");
|
||||
|
||||
RefreshBehaviour refresh_behaviour { RefreshBehaviour::Lazy };
|
||||
OperationMode operation_mode { OperationMode::Unset };
|
||||
Vector<KeyBinding> keybindings;
|
||||
};
|
||||
|
||||
#define ENUMERATE_EDITOR_INTERNAL_FUNCTIONS(M) \
|
||||
M(clear_screen) \
|
||||
M(cursor_left_character) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue