From bd81c4382da3eb3a7897be6c4ec4fb7803422f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCnchbach?= Date: Sun, 11 Dec 2022 21:53:34 +0100 Subject: [PATCH] Add configuration option for cursor movement --- src/lnav_config.cc | 17 +++++++++++++++++ src/lnav_config.hh | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/lnav_config.cc b/src/lnav_config.cc index 4e9396a0..5d273fae 100644 --- a/src/lnav_config.cc +++ b/src/lnav_config.cc @@ -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("(?\\w+)") .with_synopsis("") @@ -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), diff --git a/src/lnav_config.hh b/src/lnav_config.hh index f9df8609..61ccebca 100644 --- a/src/lnav_config.hh +++ b/src/lnav_config.hh @@ -85,12 +85,22 @@ struct key_map { std::map 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 lc_ui_keymaps; std::map lc_ui_key_overrides; std::map lc_global_vars;