From a75d5c7cf36be60be763c9e0b5a6bb3359d403b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCnchbach?= Date: Tue, 1 Nov 2022 21:08:32 +0100 Subject: [PATCH] Add hotkey binding for toggling the cursor mode --- docs/source/hotkeys.rst | 3 +++ src/help.md | 1 + src/help.txt | 4 ++++ src/hotkeys.cc | 8 ++++++++ src/view_curses.hh | 1 + test/expected_help.txt | 3 +++ 6 files changed, 20 insertions(+) diff --git a/docs/source/hotkeys.rst b/docs/source/hotkeys.rst index f91c1e80..3be9add3 100644 --- a/docs/source/hotkeys.rst +++ b/docs/source/hotkeys.rst @@ -246,6 +246,9 @@ Display * - :kbd:`x` - Toggle the hiding of log message fields. The hidden fields will be replaced with three bullets and highlighted in yellow. + * - :kbd:`Ctrl` + :kbd:`x` + - Toggle the cursor mode. Allows moving the selected line instead of + keeping it fixed at the top of the current screen. * - :kbd:`=` - Pause/unpause loading of new file data. diff --git a/src/help.md b/src/help.md index 2a7aa21c..9ccdbf97 100644 --- a/src/help.md +++ b/src/help.md @@ -266,6 +266,7 @@ that you can always use `q` to pop the top view off of the stack. | CTRL-P | Show/hide the data preview panel that may be opened when entering commands or SQL queries. | | CTRL-F | Toggle the enabled/disabled state of all filters in the current view. | | x | Toggle the hiding of log message fields. The hidden fields will be replaced with three bullets and highlighted in yellow. | +| CTRL-X | Toggle the cursor mode. Allows moving the selected line instead of keeping it fixed at the top of the current screen. | | F2 | Toggle mouse support. | ### Query diff --git a/src/help.txt b/src/help.txt index 4797e4c3..8ef16a84 100644 --- a/src/help.txt +++ b/src/help.txt @@ -383,6 +383,10 @@ Display options will be replaced with three bullets and highlighted in yellow. + CTRL-X Toggle the cursor mode. Allows moving the selected line + instead of keeping it fixed at the top of the current + screen. + F2 Toggle mouse support. Query diff --git a/src/hotkeys.cc b/src/hotkeys.cc index e519647c..baf064a9 100644 --- a/src/hotkeys.cc +++ b/src/hotkeys.cc @@ -963,7 +963,15 @@ handle_paging_key(int ch) lnav_data.ld_preview_hidden = !lnav_data.ld_preview_hidden; break; + case KEY_CTRL_X: + for (int i = 0; i < LNV__MAX; ++i) { + lnav_data.ld_views[i].set_selectable(!lnav_data.ld_views[i].is_selectable()); + } + tc->reload_data(); + break; + default: + log_debug("key sequence %x", ch); return false; } return true; diff --git a/src/view_curses.hh b/src/view_curses.hh index afa0be39..23b90fd2 100644 --- a/src/view_curses.hh +++ b/src/view_curses.hh @@ -76,6 +76,7 @@ #define KEY_CTRL_P 16 #define KEY_CTRL_R 18 #define KEY_CTRL_W 23 +#define KEY_CTRL_X 24 class view_curses; diff --git a/test/expected_help.txt b/test/expected_help.txt index d741fd23..27f9c8af 100644 --- a/test/expected_help.txt +++ b/test/expected_help.txt @@ -349,6 +349,9 @@ Display options x Toggle the hiding of log message fields. The hidden fields will be replaced with three bullets and highlighted in yellow. + CTRL-X Toggle the cursor mode. Allows moving the selected + line instead of keeping it fixed at the top of the + current screen. F2 Toggle mouse support. Query