[overlay] try to fix issues between overlay and selection (related to #1088)

pull/1084/head
Tim Stack 1 year ago
parent fe50ba8f9b
commit df80e75586

@ -1,3 +1,11 @@
## lnav v0.11.2
Features:
* A "cursor" mode has been added to the main view that can
be toggled by pressing CTRL-X. While in cursor mode, any
operations that would normally work on the "top" line now
operate on the selected line instead.
## lnav v0.11.1
Features:

@ -175,7 +175,6 @@ breadcrumb_curses::reload_data()
this->bc_match_view.set_needs_update();
this->bc_match_view.set_selection(
vis_line_t(selected_value.value_or(-1_vl)));
this->bc_match_view.scroll_selection_into_view();
this->bc_match_view.reload_data();
this->set_needs_update();
}
@ -257,7 +256,8 @@ breadcrumb_curses::handle_key(int ch)
this->focus();
this->reload_data();
if (this->bc_selected_crumb.value()
< this->bc_focused_crumbs.size() - 1) {
< this->bc_focused_crumbs.size() - 1)
{
this->bc_selected_crumb
= this->bc_selected_crumb.value() + 1;
retval = true;
@ -333,13 +333,15 @@ breadcrumb_curses::perform_selection(
= this->bc_focused_crumbs[this->bc_selected_crumb.value()];
auto match_sel = this->bc_match_view.get_selection();
if (match_sel >= 0
&& match_sel < vis_line_t(this->bc_similar_values.size())) {
&& match_sel < vis_line_t(this->bc_similar_values.size()))
{
const auto& new_value = this->bc_similar_values[match_sel].p_key;
switch (behavior) {
case perform_behavior_t::if_different:
if (breadcrumb::crumb::key_t{new_value}
== selected_crumb_ref.c_key) {
== selected_crumb_ref.c_key)
{
return;
}
break;
@ -418,7 +420,8 @@ breadcrumb_curses::search_overlay_source::list_value_for_overlay(
size_t index;
if (sscanf(parent->bc_current_search.c_str(), "%zu", &index)
== 1) {
== 1)
{
if (index < 0
|| (index
>= (sel_opt

@ -646,7 +646,6 @@ filter_sub_source::rl_display_matches(readline_curses* rc)
this->fss_match_view.set_x(rc->get_left() + rc->get_match_start());
this->fss_match_view.set_width(width + 3);
this->fss_match_view.set_needs_update();
this->fss_match_view.scroll_selection_into_view();
this->fss_match_view.reload_data();
}

@ -190,16 +190,36 @@ listview_curses::do_update()
return;
}
if (this->vc_needs_update) {
view_colors& vc = view_colors::singleton();
vis_line_t height, row, start_row;
vis_line_t height;
unsigned long width;
this->get_dimensions(height, width);
if (this->lv_selectable) {
if (this->lv_selection < 0_vl) {
this->set_top(0_vl);
} else if (this->lv_selection
>= (this->lv_top + height - this->lv_tail_space - 1_vl))
{
this->set_top(
this->lv_selection - height + 1_vl + this->lv_tail_space, true);
} else if (this->lv_selection < this->lv_top) {
this->set_top(this->lv_selection, true);
}
}
while (this->vc_needs_update) {
auto& vc = view_colors::singleton();
vis_line_t row;
attr_line_t overlay_line;
struct line_range lr;
unsigned long width, wrap_width;
unsigned long wrap_width;
int y = this->lv_y, bottom;
auto role_attrs = vc.attrs_for_role(this->vc_default_role);
this->get_dimensions(height, width);
if (height <= 0) {
return;
}
if (this->vc_width > 0) {
width = std::min((unsigned long) this->vc_width, width);
@ -211,20 +231,19 @@ listview_curses::do_update()
}
size_t row_count = this->get_inner_height();
size_t blank_rows = 0;
row = this->lv_top;
start_row = row;
bottom = y + height;
std::vector<attr_line_t> rows(
std::min((size_t) height, row_count - (int) this->lv_top));
this->lv_source->listview_value_for_rows(*this, row, rows);
vis_line_t selected_in_view = this->get_selection() - this->get_top();
while (y < bottom) {
lr.lr_start = this->lv_left;
lr.lr_end = this->lv_left + wrap_width;
if (this->lv_overlay_source != nullptr
&& this->lv_overlay_source->list_value_for_overlay(
*this,
y - selected_in_view - this->lv_y,
y - this->lv_y,
bottom - this->lv_y,
row,
overlay_line))
@ -263,9 +282,18 @@ listview_curses::do_update()
nullptr);
mvwhline(this->lv_window, y, this->lv_x, ' ', width);
++y;
blank_rows += 1;
}
}
if (this->lv_selectable && this->lv_selection >= 0
&& (row > this->lv_tail_space) && (blank_rows < this->lv_tail_space)
&& ((row - this->lv_tail_space) < this->lv_selection))
{
this->shift_top(this->lv_selection - row + this->lv_tail_space);
continue;
}
if (this->lv_show_scrollbar) {
double progress = 1.0;
double coverage = 1.0;
@ -367,7 +395,6 @@ listview_curses::shift_selection(int offset)
if (new_selection >= 0_vl && new_selection < this->get_inner_height()) {
this->set_selection(new_selection);
this->scroll_selection_into_view();
}
}
@ -563,28 +590,6 @@ listview_curses::rows_available(vis_line_t line,
return retval;
}
void
listview_curses::scroll_selection_into_view()
{
unsigned long width;
vis_line_t height;
this->get_dimensions(height, width);
if (height <= 0) {
return;
}
if (this->lv_selection < 0_vl) {
this->set_top(0_vl);
} else if (this->lv_selection
>= (this->lv_top + height - this->lv_tail_space - 1_vl))
{
this->set_top(this->lv_selection - height + 1_vl + this->lv_tail_space,
true);
} else if (this->lv_selection < this->lv_top) {
this->set_top(this->lv_selection, true);
}
}
void
listview_curses::set_selection(vis_line_t sel)
{
@ -623,7 +628,6 @@ listview_curses::set_selection(vis_line_t sel)
}
if (found) {
this->lv_selection = sel;
this->scroll_selection_into_view();
this->lv_source->listview_selection_changed(*this);
this->set_needs_update();
this->invoke_scroll();

@ -207,8 +207,6 @@ public:
void set_selection(vis_line_t sel);
void scroll_selection_into_view();
void shift_selection(int offset);
vis_line_t get_selection() const

Loading…
Cancel
Save