Skip to content

Commit 60be3a4

Browse files
committed
[timeline] add bookmarks for files
1 parent ad13203 commit 60be3a4

19 files changed

Lines changed: 377 additions & 353 deletions

src/base/lnav.console.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@
2828
*/
2929

3030
#include <algorithm>
31+
#include <set>
3132

3233
#include "lnav.console.hh"
3334

35+
#include <stdio.h>
36+
#include <stdlib.h>
37+
3438
#include "color_spaces.hh"
3539
#include "config.h"
3640
#include "fmt/color.h"
41+
#include "fmt/format.h"
3742
#include "itertools.hh"
3843
#include "lnav.console.into.hh"
3944
#include "lnav_log.hh"

src/hotkeys.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ DELETE FROM lnav_user_notifications WHERE id = 'org.lnav.mouse-support'
311311
break;
312312

313313
case 'f':
314-
if (tc == &lnav_data.ld_views[LNV_LOG]) {
314+
if (tc == &lnav_data.ld_views[LNV_LOG]
315+
|| tc == &lnav_data.ld_views[LNV_TIMELINE])
316+
{
315317
bm[&logfile_sub_source::BM_FILES].next(
316318
tc->get_selection().value_or(0_vl))
317319
| [&tc](auto vl) { tc->set_selection(vl); };
@@ -326,7 +328,8 @@ DELETE FROM lnav_user_notifications WHERE id = 'org.lnav.mouse-support'
326328
break;
327329

328330
case 'F':
329-
if (tc == &lnav_data.ld_views[LNV_LOG]) {
331+
if (tc == &lnav_data.ld_views[LNV_LOG]
332+
|| tc == &lnav_data.ld_views[LNV_TIMELINE]) {
330333
bm[&logfile_sub_source::BM_FILES].prev(
331334
tc->get_selection().value_or(0_vl))
332335
| [&tc](auto vl) {

src/timeline_source.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const std::vector<std::chrono::microseconds> TIME_SPANS = {
6363

6464
static constexpr size_t MAX_OPID_WIDTH = 80;
6565
static constexpr size_t MAX_DESC_WIDTH = 256;
66-
static constexpr int CHART_INDENT = 22;
66+
static constexpr int CHART_INDENT = 24;
6767

6868
size_t
6969
abbrev_ftime(char* datebuf, size_t db_size, const tm& lb_tm, const tm& dt)
@@ -640,7 +640,7 @@ timeline_source::text_attrs_for_line(textview_curses& tc,
640640

641641
if (width > CHART_INDENT) {
642642
width -= CHART_INDENT;
643-
double span = (sel_ub - sel_lb).count();
643+
const double span = (sel_ub - sel_lb).count();
644644
auto us_per_ch = std::chrono::microseconds{
645645
static_cast<int64_t>(ceil(span / (double) width))};
646646

@@ -692,6 +692,7 @@ timeline_source::rebuild_indexes()
692692

693693
auto op_guard = lnav_opid_guard::internal(op);
694694
auto& bm = this->tss_view->get_bookmarks();
695+
auto& bm_files = bm[&logfile_sub_source::BM_FILES];
695696
auto& bm_errs = bm[&textview_curses::BM_ERRORS];
696697
auto& bm_warns = bm[&textview_curses::BM_WARNINGS];
697698

@@ -982,6 +983,9 @@ timeline_source::rebuild_indexes()
982983
[](const auto* lhs, const auto* rhs) { return *lhs < *rhs; });
983984
for (size_t lpc = 0; lpc < this->gs_time_order.size(); lpc++) {
984985
const auto& row = *this->gs_time_order[lpc];
986+
if (row.or_type == row_type::logfile) {
987+
bm_files.insert_once(vis_line_t(lpc));
988+
}
985989
if (row.or_value.otr_level_stats.lls_error_count > 0) {
986990
bm_errs.insert_once(vis_line_t(lpc));
987991
} else if (row.or_value.otr_level_stats.lls_warning_count > 0) {

test/expected/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,8 @@ dist_noinst_DATA = \
17021702
test_text_file.sh_f7522b0a99550a3ff91aae6582eb861547c535e1.out \
17031703
test_timeline.sh_070a540e6ae8971dec18b4b69dee2e550a1db20e.err \
17041704
test_timeline.sh_070a540e6ae8971dec18b4b69dee2e550a1db20e.out \
1705+
test_timeline.sh_074ace0108a86fcf43408193a318587b85a181ab.err \
1706+
test_timeline.sh_074ace0108a86fcf43408193a318587b85a181ab.out \
17051707
test_timeline.sh_0b9d98b7ae18fc6bb61ddff4e698b365c8352723.err \
17061708
test_timeline.sh_0b9d98b7ae18fc6bb61ddff4e698b365c8352723.out \
17071709
test_timeline.sh_18f6dd738d8daece3db6e25e99322209dea604af.err \

test/expected/test_timeline.sh_074ace0108a86fcf43408193a318587b85a181ab.err

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
 Duration | ✘▲ | Item | 241d | 481d | 721d | 961d |1201d
2+
 3s000 ▂  📄 logfile_access_log.0 
3+
  █  03b4b515f3b3961f576c3b49f83194cf 10.112.81.15 
4+
  █  📄 logfile_access_log.1 
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
 Duration | ✘▲ | Item | 614 |1s229 |1s844 |2s459 |3s073 |3s688 |4s303 |4s918 |5s532 |6s147 |6s762 |7s377
2-
 2m15s609  ▂ 🧵   
3-
 2m15s609  ▂ 📄 caddy  
1+
 Duration | ✘▲ | Item | 625 |1s250 |1s875 |2s500 |3s125 |3s750 |4s375 |5s000 |5s625 |6s250 |6s875
2+
 2m15s609  ▂ 🧵   
3+
 2m15s609  ▂ 📄 caddy  
44
 2m09s311    f468d0fb9dcc7d8c6a1c40a203564946 172.19.0.1 Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0

0 commit comments

Comments
 (0)