Skip to content

Commit

Permalink
[mouse] breathe some life back into mouse support
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed Apr 11, 2024
1 parent 7fa4e25 commit 7341dc1
Show file tree
Hide file tree
Showing 21 changed files with 430 additions and 311 deletions.
10 changes: 7 additions & 3 deletions src/breadcrumb_curses.cc
Expand Up @@ -38,6 +38,7 @@ breadcrumb_curses::breadcrumb_curses()
{
this->bc_match_search_overlay.sos_parent = this;
this->bc_match_source.set_reverse_selection(true);
this->bc_match_view.set_title("breadcrumb popup");
this->bc_match_view.set_selectable(true);
this->bc_match_view.set_overlay_source(&this->bc_match_search_overlay);
this->bc_match_view.set_sub_source(&this->bc_match_source);
Expand All @@ -47,11 +48,11 @@ breadcrumb_curses::breadcrumb_curses()
this->add_child_view(&this->bc_match_view);
}

void
bool
breadcrumb_curses::do_update()
{
if (!this->bc_line_source) {
return;
return false;
}

size_t crumb_index = 0;
Expand Down Expand Up @@ -94,12 +95,14 @@ breadcrumb_curses::do_update()

line_range lr{0, static_cast<int>(width)};
view_curses::mvwattrline(
this->bc_window, this->bc_y, 0, crumbs_line, lr, role_t::VCR_STATUS);
this->bc_window, this->vc_y, 0, crumbs_line, lr, role_t::VCR_STATUS);

if (this->bc_selected_crumb) {
this->bc_match_view.set_x(sel_crumb_offset);
}
view_curses::do_update();

return true;
}

void
Expand Down Expand Up @@ -172,6 +175,7 @@ breadcrumb_curses::reload_data()
void
breadcrumb_curses::focus()
{
this->bc_match_view.set_y(this->vc_y + 1);
this->bc_focused_crumbs = this->bc_line_source();
if (this->bc_focused_crumbs.empty()) {
return;
Expand Down
11 changes: 1 addition & 10 deletions src/breadcrumb_curses.hh
Expand Up @@ -42,14 +42,6 @@ class breadcrumb_curses : public view_curses {
public:
breadcrumb_curses();

void set_y(int y)
{
this->bc_y = y;
this->bc_match_view.set_y(y + 1);
}

int get_y() const { return this->bc_y; }

void set_window(WINDOW* win)
{
this->bc_window = win;
Expand All @@ -66,7 +58,7 @@ public:

bool handle_key(int ch);

void do_update() override;
bool do_update() override;

void reload_data();

Expand All @@ -90,7 +82,6 @@ private:

WINDOW* bc_window{nullptr};
std::function<std::vector<breadcrumb::crumb>()> bc_line_source;
int bc_y{0};
std::vector<breadcrumb::crumb> bc_focused_crumbs;
nonstd::optional<size_t> bc_selected_crumb;
nonstd::optional<size_t> bc_last_selected_crumb;
Expand Down
4 changes: 2 additions & 2 deletions src/filter_sub_source.cc
Expand Up @@ -44,7 +44,7 @@ using namespace lnav::roles::literals;
filter_sub_source::filter_sub_source(std::shared_ptr<readline_curses> editor)
: fss_editor(editor)
{
this->fss_editor->set_left(25);
this->fss_editor->set_x(25);
this->fss_editor->set_width(-1);
this->fss_editor->set_save_history(!(lnav_data.ld_flags & LNF_SECURE_MODE));
this->fss_regex_context.set_highlighter(readline_regex_highlighter)
Expand Down Expand Up @@ -656,7 +656,7 @@ filter_sub_source::rl_display_matches(readline_curses* rc)

this->fss_match_view.set_window(this->tss_view->get_window());
this->fss_match_view.set_y(rc->get_y() + 1);
this->fss_match_view.set_x(rc->get_left() + rc->get_match_start());
this->fss_match_view.set_x(rc->get_x() + rc->get_match_start());
this->fss_match_view.set_width(width + 3);
this->fss_match_view.set_needs_update();
this->fss_match_view.reload_data();
Expand Down
3 changes: 1 addition & 2 deletions src/hotkeys.cc
Expand Up @@ -275,8 +275,7 @@ handle_paging_key(int ch)
} else {
lnav_data.ld_rl_view->set_value(
"error: mouse support is not available, make sure your "
"TERM is set to "
"xterm or xterm-256color");
"TERM is set to xterm or xterm-256color");
}
break;

Expand Down

0 comments on commit 7341dc1

Please sign in to comment.