Add configuration option for cursor movement

This commit is contained in:
Florian Münchbach 2022-12-11 21:53:34 +01:00
parent 2b5c291a86
commit bd81c4382d
2 changed files with 27 additions and 0 deletions

View File

@ -508,6 +508,20 @@ static const struct json_path_container keymap_defs_handlers = {
.with_children(keymap_def_handlers),
};
static const json_path_handler_base::enum_value_t _movement_values[] = {
{"top", config_movement_mode::TOP},
{"cursor", config_movement_mode::CURSOR}};
static const struct json_path_container movement_handlers = {
yajlpp::property_handler("mode")
.with_synopsis("mode_name")
.with_enum_values(_movement_values)
.with_example("top")
.with_example("cursor")
.with_description("The mode of cursor movement to use.")
.for_field<>(&_lnav_config::lc_ui_movement, &movement_config::mode),
};
static const struct json_path_container global_var_handlers = {
yajlpp::pattern_property_handler("(?<var_name>\\w+)")
.with_synopsis("<name>")
@ -992,6 +1006,9 @@ static const struct json_path_container ui_handlers = {
yajlpp::property_handler("theme-defs")
.with_description("Theme definitions.")
.with_children(theme_defs_handlers),
yajlpp::property_handler("movement")
.with_description("Log file cursor movement mode settings")
.with_children(movement_handlers),
yajlpp::property_handler("keymap-defs")
.with_description("Keymap definitions.")
.with_children(keymap_defs_handlers),

View File

@ -85,12 +85,22 @@ struct key_map {
std::map<std::string, key_command> km_seq_to_cmd;
};
enum class config_movement_mode : unsigned int {
TOP,
CURSOR,
};
struct movement_config {
config_movement_mode mode;
};
struct _lnav_config {
top_status_source_cfg lc_top_status_cfg;
bool lc_ui_dim_text;
bool lc_ui_default_colors{true};
std::string lc_ui_keymap;
std::string lc_ui_theme;
movement_config lc_ui_movement;
std::unordered_map<std::string, key_map> lc_ui_keymaps;
std::map<std::string, std::string> lc_ui_key_overrides;
std::map<std::string, std::string> lc_global_vars;