From c780ddb9af53be7e2f1fc1cd754ed886845591ea Mon Sep 17 00:00:00 2001 From: Timothy Stack Date: Mon, 3 Mar 2014 21:02:59 -0800 Subject: [PATCH] [mouse] more small fixes for mouse support (dragging) --- src/lnav.cc | 4 +++- src/logfile_sub_source.cc | 7 +++++-- src/textview_curses.cc | 10 ++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/lnav.cc b/src/lnav.cc index 68d73a48..43438113 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -2973,7 +2973,6 @@ public: if (lv.lv_origin.contains(x_offset)) { this->ad_press_value = lpc; - retval = true; break; } } @@ -2981,6 +2980,9 @@ public: } break; case BUTTON_STATE_DRAGGED: + if (mouse_line != this->ad_press_line) { + this->ad_press_value = -1; + } if (this->ad_press_value != -1) { retval = true; } diff --git a/src/logfile_sub_source.cc b/src/logfile_sub_source.cc index a5a98bdd..b04a8fe4 100644 --- a/src/logfile_sub_source.cc +++ b/src/logfile_sub_source.cc @@ -587,7 +587,8 @@ void logfile_sub_source::text_update_marks(vis_bookmarks &bm) } for (; vl < (int)this->lss_index.size(); ++vl) { - content_line_t cl = this->lss_index[vl]; + const content_line_t orig_cl = this->lss_index[vl]; + content_line_t cl = orig_cl; logfile * lf; lf = this->find(cl); @@ -596,7 +597,9 @@ void logfile_sub_source::text_update_marks(vis_bookmarks &bm) this->lss_user_marks.begin(); iter != this->lss_user_marks.end(); ++iter) { - if (binary_search(iter->second.begin(), iter->second.end(), cl)) { + if (binary_search(iter->second.begin(), + iter->second.end(), + orig_cl)) { bm[iter->first].insert_once(vl); if (iter->first == &textview_curses::BM_USER) { diff --git a/src/textview_curses.cc b/src/textview_curses.cc index 65cd7032..26596c71 100644 --- a/src/textview_curses.cc +++ b/src/textview_curses.cc @@ -238,6 +238,9 @@ void textview_curses::listview_value_for_row(const listview_curses &lv, bool textview_curses::handle_mouse(mouse_event &me) { + unsigned long width; + vis_line_t height; + if (this->tc_selection_start == -1 && listview_curses::handle_mouse(me)) { return true; @@ -258,6 +261,8 @@ bool textview_curses::handle_mouse(mouse_event &me) mouse_line = this->get_bottom(); } + this->get_dimensions(height, width); + switch (me.me_state) { case BUTTON_STATE_PRESSED: this->tc_selection_start = mouse_line; @@ -270,6 +275,11 @@ bool textview_curses::handle_mouse(mouse_event &me) me.me_y = 0; mouse_line = this->get_top(); } + if (me.me_y >= height && this->get_top() < this->get_top_for_last_row()) { + this->shift_top(vis_line_t(1)); + me.me_y = height; + mouse_line = this->get_bottom(); + } if (this->tc_selection_last == mouse_line) break;