From 7f8b031b83318054a9b450b684e69b2356449518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCnchbach?= Date: Tue, 1 Nov 2022 20:45:54 +0100 Subject: [PATCH] Use selected line instead of top --- src/field_overlay_source.cc | 6 +++--- src/hotkeys.cc | 7 ++++++- src/lnav_commands.cc | 8 +++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/field_overlay_source.cc b/src/field_overlay_source.cc index 288d0736..943abb3a 100644 --- a/src/field_overlay_source.cc +++ b/src/field_overlay_source.cc @@ -57,7 +57,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv) return; } - content_line_t cl = lss.at(lv.get_top()); + content_line_t cl = lss.at(lv.get_selection()); std::shared_ptr file = lss.find(cl); auto ll = file->begin() + cl; auto format = file->get_format(); @@ -72,13 +72,13 @@ field_overlay_source::build_field_lines(const listview_curses& lv) display = display || this->fos_contexts.top().c_show; } - this->build_meta_line(lv, this->fos_lines, lv.get_top()); + this->build_meta_line(lv, this->fos_lines, lv.get_selection()); if (!display) { return; } - if (!this->fos_log_helper.parse_line(lv.get_top())) { + if (!this->fos_log_helper.parse_line(lv.get_selection())) { return; } diff --git a/src/hotkeys.cc b/src/hotkeys.cc index e8fa6dae..e519647c 100644 --- a/src/hotkeys.cc +++ b/src/hotkeys.cc @@ -338,7 +338,12 @@ handle_paging_key(int ch) case 'F': if (tc == &lnav_data.ld_views[LNV_LOG]) { bm[&logfile_sub_source::BM_FILES].prev(tc->get_top()) | - [&tc](auto vl) { tc->set_top(vl); }; + [&tc](auto vl) { + // setting the selection for movement to previous file + // marker instead of the top will move the cursor, too, + // if needed. + tc->set_selection(vl); + }; } else if (tc == &lnav_data.ld_views[LNV_TEXT]) { textfile_sub_source& tss = lnav_data.ld_text_source; diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index 363ce280..40537004 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -596,7 +596,7 @@ com_mark(exec_context& ec, std::string cmdline, std::vector& args) if (args.empty() || lnav_data.ld_view_stack.empty()) { } else if (!ec.ec_dry_run) { auto* tc = *lnav_data.ld_view_stack.top(); - lnav_data.ld_last_user_mark[tc] = tc->get_top(); + lnav_data.ld_last_user_mark[tc] = tc->get_selection(); tc->toggle_user_mark(&textview_curses::BM_USER, vis_line_t(lnav_data.ld_last_user_mark[tc])); tc->reload_data(); @@ -775,8 +775,10 @@ com_goto_mark(exec_context& ec, } } else { for (const auto& bt : mark_types) { - auto bt_top = next_cluster( - &bookmark_vector::prev, bt, tc->get_top()); + auto bt_top + = next_cluster(&bookmark_vector::prev, + bt, + tc->get_selection()); if (bt_top && (!new_top || bt_top > new_top.value())) { new_top = bt_top;