1
1
mirror of https://github.com/tstack/lnav.git synced 2024-11-10 21:59:10 +03:00

[hotkeys] change the filename hotkey to left/right arrow

This commit is contained in:
Timothy Stack 2018-03-27 22:11:57 -07:00
parent 4760765c1d
commit 8257f188cb
8 changed files with 88 additions and 31 deletions

View File

@ -27,3 +27,4 @@ Justin Berger
Jan Chren Jan Chren
Geoff Crompton Geoff Crompton
Medina Maza Medina Maza
Phil Hord

11
NEWS
View File

@ -1,4 +1,15 @@
lnav v0.8.4:
Features:
* Pressing left-arrow while viewing log messages will reveal the source
file name for each line. Pressing again will reveal the full path.
Fixes:
* The HOME key should now work in the command-prompt and move the cursor
to the beginning of the line.
* The :delete-filter command should now tab-complete existing filters.
* Milliseconds can now be used in relative times (e.g. 10:00:00.123)
lnav v0.8.3: lnav v0.8.3:
Features: Features:
* Support for the Bro Network Security Monitor (https://www.bro.org) log * Support for the Bro Network Security Monitor (https://www.bro.org) log

View File

@ -70,7 +70,9 @@ Spatial Navigation
* - |ks| h |ke| * - |ks| h |ke|
- |ks| ← |ke| - |ks| ← |ke|
- -
- Left half a page - Left half a page. In the log view, pressing left while at the start of
the message text will reveal the source file name for each line.
Pressing again will reveal the full path.
* - |ks| Shift |ke| + |ks| h |ke| * - |ks| Shift |ke| + |ks| h |ke|
- |ks| Shift |ke| + |ks| ← |ke| - |ks| Shift |ke| + |ks| ← |ke|
- -
@ -209,8 +211,6 @@ Display
log_line column log_line column
* - |ks| p |ke| * - |ks| p |ke|
- Toggle the display of the log parser results - Toggle the display of the log parser results
* - |ks| . |ke|
- Toggle the display of the log file names
* - |ks| Tab |ke| * - |ks| Tab |ke|
- Cycle through colums to graph in the SQL result view - Cycle through colums to graph in the SQL result view
* - |ks| Ctrl |ke| + |ks| l |ke| * - |ks| Ctrl |ke| + |ks| l |ke|

View File

@ -119,8 +119,10 @@ the file where warnings or errors are detected by coloring the bar
yellow or red, respectively. Tick marks will also be added to the yellow or red, respectively. Tick marks will also be added to the
left and right hand side of the bar, for search hits and bookmarks. left and right hand side of the bar, for search hits and bookmarks.
When multiple files are open, a bar on the left side is color coded and A bar on the left side is color coded and broken up to indicate which
broken up to indicate which messages are from the same file. messages are from the same file. Pressing the left-arrow or 'h' will
reveal the source file names for each message and pressing again will
show the full paths.
When at the bottom of the log view, a summary line will be displayed on the When at the bottom of the log view, a summary line will be displayed on the
right-hand-side to give you some more information about your logs, including: right-hand-side to give you some more information about your logs, including:
@ -190,7 +192,9 @@ Spatial Navigation
b/bs/pgup Move up a page. b/bs/pgup Move up a page.
j/cr/down-arrow Move down a line. j/cr/down-arrow Move down a line.
k/up-arrow Move up a line. k/up-arrow Move up a line.
h/left-arrow Move to the left. h/left-arrow Move to the left. In the log view, moving left will reveal
the source log file names for each line. Pressing again
will reveal the full path.
l/right-arrow Move to the right. l/right-arrow Move to the right.
H/Shift+left Move to the left by a smaller increment. H/Shift+left Move to the left by a smaller increment.
L/Shift+right Move to the right by a smaller increment. L/Shift+right Move to the right by a smaller increment.
@ -295,9 +299,6 @@ Display options
means it has sped up. You can use the "s/S" hotkeys to means it has sped up. You can use the "s/S" hotkeys to
scan through the slow downs. scan through the slow downs.
. In the log view, toggle the display of filenames showing
where each log line comes from.
i View/leave a histogram of the log messages over i View/leave a histogram of the log messages over
time. The histogram counts the number of time. The histogram counts the number of
displayed log lines for each bucket of time. The displayed log lines for each bucket of time. The

View File

@ -985,11 +985,6 @@ void handle_paging_key(int ch)
tc->reload_data(); tc->reload_data();
break; break;
case '.':
lnav_data.ld_log_source.toggle_filename();
tc->reload_data();
break;
case 'i': case 'i':
if (toggle_view(&lnav_data.ld_views[LNV_HISTOGRAM])) { if (toggle_view(&lnav_data.ld_views[LNV_HISTOGRAM])) {
lnav_data.ld_rl_view->set_alt_value( lnav_data.ld_rl_view->set_alt_value(

View File

@ -1836,6 +1836,33 @@ static void handle_key(int ch) {
if (lnav_data.ld_mode == LNM_PAGING) { if (lnav_data.ld_mode == LNM_PAGING) {
if (!lnav_data.ld_view_stack.empty()) { if (!lnav_data.ld_view_stack.empty()) {
textview_curses *tc = lnav_data.ld_view_stack.back(); textview_curses *tc = lnav_data.ld_view_stack.back();
logfile_sub_source *lss = NULL;
lss = dynamic_cast<logfile_sub_source *>(tc->get_sub_source());
if (lss != nullptr) {
switch (ch) {
case 'h':
case 'H':
case KEY_SLEFT:
case KEY_LEFT:
if (tc->get_left() == 0) {
lss->increase_line_context();
tc->set_needs_update();
return;
}
break;
case 'l':
case 'L':
case KEY_SRIGHT:
case KEY_RIGHT:
if (lss->decrease_line_context()) {
tc->set_needs_update();
return;
}
break;
}
}
if (tc->handle_key(ch)) { if (tc->handle_key(ch)) {
return; return;

View File

@ -97,19 +97,38 @@ public:
this->clear_line_size_cache(); this->clear_line_size_cache();
}; };
void toggle_filename(void) { void increase_line_context(void) {
// NONE -> F_BASENAME -> F_FILENAME -> NONE ... long old_flags = this->lss_flags;
if (this->lss_flags & F_BASENAME) {
// F_BASENAME -> F_FILENAME if (this->lss_flags & F_FILENAME) {
this->lss_flags ^= F_BASENAME | F_FILENAME; // Nothing to do
} else if (this->lss_flags & F_FILENAME) { } else if (this->lss_flags & F_BASENAME) {
// F_FILENAME -> NONE this->lss_flags &= ~F_NAME_MASK;
this->lss_flags ^= F_FILENAME; this->lss_flags |= F_FILENAME;
} else { } else {
// NONE -> F_BASENAME this->lss_flags |= F_BASENAME;
this->lss_flags ^= F_BASENAME;
} }
if (old_flags != this->lss_flags) {
this->clear_line_size_cache(); this->clear_line_size_cache();
}
};
bool decrease_line_context(void) {
long old_flags = this->lss_flags;
if (this->lss_flags & F_FILENAME) {
this->lss_flags &= ~F_NAME_MASK;
this->lss_flags |= F_BASENAME;
} else if (this->lss_flags & F_BASENAME) {
this->lss_flags &= ~F_NAME_MASK;
}
if (old_flags != this->lss_flags) {
this->clear_line_size_cache();
return true;
}
return false;
}; };
void set_time_offset(bool enabled) { void set_time_offset(bool enabled) {
@ -523,6 +542,8 @@ private:
F_TIME_OFFSET = (1L << B_TIME_OFFSET), F_TIME_OFFSET = (1L << B_TIME_OFFSET),
F_FILENAME = (1L << B_FILENAME), F_FILENAME = (1L << B_FILENAME),
F_BASENAME = (1L << B_BASENAME), F_BASENAME = (1L << B_BASENAME),
F_NAME_MASK = (F_FILENAME | F_BASENAME),
}; };
struct __attribute__((__packed__)) indexed_content { struct __attribute__((__packed__)) indexed_content {

View File

@ -119,8 +119,10 @@ the file where warnings or errors are detected by coloring the bar
yellow or red, respectively. Tick marks will also be added to the yellow or red, respectively. Tick marks will also be added to the
left and right hand side of the bar, for search hits and bookmarks. left and right hand side of the bar, for search hits and bookmarks.
When multiple files are open, a bar on the left side is color coded and A bar on the left side is color coded and broken up to indicate which
broken up to indicate which messages are from the same file. messages are from the same file. Pressing the left-arrow or 'h' will
reveal the source file names for each message and pressing again will
show the full paths.
When at the bottom of the log view, a summary line will be displayed on the When at the bottom of the log view, a summary line will be displayed on the
right-hand-side to give you some more information about your logs, including: right-hand-side to give you some more information about your logs, including:
@ -190,7 +192,9 @@ Spatial Navigation
b/bs/pgup Move up a page. b/bs/pgup Move up a page.
j/cr/down-arrow Move down a line. j/cr/down-arrow Move down a line.
k/up-arrow Move up a line. k/up-arrow Move up a line.
h/left-arrow Move to the left. h/left-arrow Move to the left. In the log view, moving left will reveal
the source log file names for each line. Pressing again
will reveal the full path.
l/right-arrow Move to the right. l/right-arrow Move to the right.
H/Shift+left Move to the left by a smaller increment. H/Shift+left Move to the left by a smaller increment.
L/Shift+right Move to the right by a smaller increment. L/Shift+right Move to the right by a smaller increment.
@ -295,9 +299,6 @@ Display options
means it has sped up. You can use the "s/S" hotkeys to means it has sped up. You can use the "s/S" hotkeys to
scan through the slow downs. scan through the slow downs.
. In the log view, toggle the display of filenames showing
where each log line comes from.
i View/leave a histogram of the log messages over i View/leave a histogram of the log messages over
time. The histogram counts the number of time. The histogram counts the number of
displayed log lines for each bucket of time. The displayed log lines for each bucket of time. The