diff --git a/NEWS.md b/NEWS.md index 836f5561..74a7739d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -92,10 +92,11 @@ Interface changes: of only a single row. Numbers are also rendered using the "number" theme style as well. * The log message overlay in the LOG view is now limited - 2/3rds of the height and supports scrolling. The "alt-text" - theme style is also used to draw the overlay contents now - as well. (The overlay is used to display the parser - details, comments, and annotations.) + 2/3rds of the height. You can focus on the overlay panel + by pressing `CTRL-]`. The "alt-text" theme style is also + used to draw the overlay contents now as well. (The + overlay is used to display the parser details, comments, + and annotations.) Breaking changes: * Removed the `-w` command-line option. This option was diff --git a/src/gantt_source.cc b/src/gantt_source.cc index d1bd23d4..898f43a8 100644 --- a/src/gantt_source.cc +++ b/src/gantt_source.cc @@ -787,11 +787,15 @@ gantt_source::text_selection_changed(textview_curses& tc) const auto& row = this->gs_time_order[sel]; auto low_tv = row.or_value.otr_range.tr_begin; auto high_tv = row.or_value.otr_range.tr_end; + auto id_sf = row.or_name; + auto level_stats = row.or_value.otr_level_stats; auto ov_sel = tc.get_overlay_selection(); if (ov_sel) { const auto& sub = row.or_value.otr_sub_ops[ov_sel.value()]; + id_sf = sub.ostr_subid; low_tv = sub.ostr_range.tr_begin; high_tv = sub.ostr_range.tr_end; + level_stats = sub.ostr_level_stats; } high_tv.tv_sec += 1; auto low_vl = this->gs_lss.row_for_time(low_tv); @@ -841,8 +845,8 @@ gantt_source::text_selection_changed(textview_curses& tc) this->gs_preview_source.replace_with(preview_content); this->gs_preview_status_source.get_description().set_value( - " OPID %.*s", row.or_name.length(), row.or_name.data()); - auto err_count = row.or_value.otr_level_stats.lls_error_count; + " ID %.*s", id_sf.length(), id_sf.data()); + auto err_count = level_stats.lls_error_count; if (err_count == 0) { this->gs_preview_status_source .statusview_value_for_field(gantt_status_source::TSF_ERRORS) @@ -858,8 +862,7 @@ gantt_source::text_selection_changed(textview_curses& tc) } this->gs_preview_status_source .statusview_value_for_field(gantt_status_source::TSF_TOTAL) - .set_value("%'d messages ", - row.or_value.otr_level_stats.lls_total_count); + .set_value("%'d messages ", level_stats.lls_total_count); } void diff --git a/src/hotkeys.cc b/src/hotkeys.cc index a8957a89..f196b1a2 100644 --- a/src/hotkeys.cc +++ b/src/hotkeys.cc @@ -707,6 +707,9 @@ handle_paging_key(int ch) tc->get_overlay_source()); auto& top_context = fos->fos_contexts.top(); top_context.c_show = !top_context.c_show; + if (!top_context.c_show) { + tc->set_overlay_selection(nonstd::nullopt); + } tc->set_sync_selection_and_top(top_context.c_show); tc->set_needs_update(); } else if (tc == &lnav_data.ld_views[LNV_DB]) { diff --git a/src/listview_curses.cc b/src/listview_curses.cc index ed5f9d3a..f96396a1 100644 --- a/src/listview_curses.cc +++ b/src/listview_curses.cc @@ -175,6 +175,7 @@ listview_curses::handle_key(int ch) case KEY_ESCAPE: if (this->lv_overlay_focused) { this->lv_overlay_focused = false; + this->lv_source->listview_selection_changed(*this); this->set_needs_update(); } else { retval = false; @@ -189,6 +190,7 @@ listview_curses::handle_key(int ch) *this, this->get_selection(), overlay_content); if (!overlay_content.empty()) { this->lv_overlay_focused = !this->lv_overlay_focused; + this->lv_source->listview_selection_changed(*this); this->set_needs_update(); } } else { @@ -615,50 +617,57 @@ listview_curses::shift_selection(shift_amount_t sa) this->lv_overlay_source->list_value_for_overlay( *this, focused, overlay_content); - auto overlay_height - = this->get_overlay_height(overlay_content.size(), height); - auto ov_top_for_last = vis_line_t{ - static_cast(overlay_content.size() - overlay_height)}; - switch (sa) { - case shift_amount_t::up_line: - if (this->lv_focused_overlay_selection > 0_vl) { - this->lv_focused_overlay_selection -= 1_vl; + if (overlay_content.empty()) { + this->lv_overlay_focused = false; + this->lv_focused_overlay_top = 0_vl; + this->lv_focused_overlay_selection = 0_vl; + this->lv_source->listview_selection_changed(*this); + } else { + auto overlay_height + = this->get_overlay_height(overlay_content.size(), height); + auto ov_top_for_last = vis_line_t{ + static_cast(overlay_content.size() - overlay_height)}; + switch (sa) { + case shift_amount_t::up_line: + if (this->lv_focused_overlay_selection > 0_vl) { + this->lv_focused_overlay_selection -= 1_vl; + } + break; + case shift_amount_t::up_page: { + if (this->lv_focused_overlay_selection > overlay_height) { + this->lv_focused_overlay_selection + -= vis_line_t{static_cast(overlay_height - 1)}; + } else { + this->lv_focused_overlay_selection = 0_vl; + } + break; } - break; - case shift_amount_t::up_page: { - if (this->lv_focused_overlay_selection > overlay_height) { - this->lv_focused_overlay_selection - -= vis_line_t{static_cast(overlay_height - 1)}; - } else { - this->lv_focused_overlay_selection = 0_vl; + case shift_amount_t::down_line: + if (this->lv_focused_overlay_selection + 1 + < overlay_content.size()) + { + this->lv_focused_overlay_selection += 1_vl; + } + break; + case shift_amount_t::down_page: { + if (this->lv_focused_overlay_selection + overlay_height - 1 + >= ov_top_for_last) + { + this->lv_focused_overlay_selection + = vis_line_t(overlay_content.size() - 1); + } else { + this->lv_focused_overlay_selection + += vis_line_t{static_cast(overlay_height - 1)}; + } + break; } - break; + default: + break; } - case shift_amount_t::down_line: - if (this->lv_focused_overlay_selection + 1 - < overlay_content.size()) - { - this->lv_focused_overlay_selection += 1_vl; - } - break; - case shift_amount_t::down_page: { - if (this->lv_focused_overlay_selection + overlay_height - 1 - >= ov_top_for_last) - { - this->lv_focused_overlay_selection - = vis_line_t(overlay_content.size() - 1); - } else { - this->lv_focused_overlay_selection - += vis_line_t{static_cast(overlay_height - 1)}; - } - break; - } - default: - break; + this->lv_source->listview_selection_changed(*this); + this->set_needs_update(); + return; } - this->lv_source->listview_selection_changed(*this); - this->set_needs_update(); - return; } auto offset = 0_vl; @@ -1009,3 +1018,31 @@ listview_curses::get_overlay_height(size_t total, vis_line_t view_height) { return std::min(total, static_cast(2 * (view_height / 3))); } + +void +listview_curses::set_overlay_selection(nonstd::optional sel) +{ + if (sel) { + if (sel.value() == this->lv_focused_overlay_selection) { + return; + } + + std::vector overlay_content; + this->lv_overlay_source->list_value_for_overlay( + *this, this->get_selection(), overlay_content); + if (!overlay_content.empty()) { + if (sel.value() >= 0 && sel.value() < overlay_content.size()) { + this->lv_overlay_focused = true; + this->lv_focused_overlay_selection = sel.value(); + } else { + this->lv_overlay_focused = true; + this->lv_focused_overlay_selection = 0_vl; + } + } + } else { + this->lv_overlay_focused = false; + this->lv_focused_overlay_top = 0_vl; + this->lv_focused_overlay_selection = 0_vl; + } + this->set_needs_update(); +} diff --git a/src/listview_curses.hh b/src/listview_curses.hh index 5cbe94a3..c0e48733 100644 --- a/src/listview_curses.hh +++ b/src/listview_curses.hh @@ -247,6 +247,8 @@ public: return nonstd::nullopt; } + void set_overlay_selection(nonstd::optional sel); + void set_sync_selection_and_top(bool value) { this->lv_sync_selection_and_top = value;