Skip to content

Commit

Permalink
[mouse] treat ctrl+click the same as shift+click
Browse files Browse the repository at this point in the history
Some terminals capture shift+click so add ctrl+click as
an alternate way to highlight/mark lines.
  • Loading branch information
tstack committed May 14, 2024
1 parent fdecf28 commit 77b9829
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Interface Changes:
* In the Gantt chart view, pressing `ENTER` will focus on
the preview pane so you can scroll through messages
with the selected Op ID.
* With mouse mode enabled, `CTRL` can be used as an alternate
to `SHIFT` when clicking/dragging in the main view to
highlight lines. A few terminals capture shift+clicks as a
way to select text and do not pass them to the application.

Bug Fixes:
* Log messages in formats with custom timestamp formats were
Expand Down
3 changes: 3 additions & 0 deletions docs/source/ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ elements will respond to mouse inputs:

* clicking on the main view will move the cursor to the given
row and dragging will scroll the view as needed;
* :bkd:`Shift` (or :kbd:`CTRL`) clicking/dragging in the main
view will highlight lines and then toggle their bookmark
status on release;
* double-clicking in the main view will select the underlying
text and drag-selecting within a line will select the given
text;
Expand Down
15 changes: 10 additions & 5 deletions src/textview_curses.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ const bookmark_type_t textview_curses::BM_SEARCH("search");
const bookmark_type_t textview_curses::BM_META("meta");
const bookmark_type_t textview_curses::BM_PARTITION("partition");

textview_curses::textview_curses()
textview_curses::
textview_curses()
: lnav_config_listener(__FILE__), tc_search_action(noop_func{})
{
this->set_data_source(this);
}

textview_curses::~textview_curses()
textview_curses::~
textview_curses()
{
this->tc_search_action = noop_func{};
}
Expand Down Expand Up @@ -471,8 +473,10 @@ textview_curses::handle_mouse(mouse_event& me)
if (this->vc_enabled) {
if (this->tc_supports_marks
&& me.me_button == mouse_button_t::BUTTON_LEFT
&& me.is_modifier_pressed(
mouse_event::modifier_t::shift))
&& (me.is_modifier_pressed(
mouse_event::modifier_t::shift)
|| me.is_modifier_pressed(
mouse_event::modifier_t::ctrl)))
{
this->tc_selection_start = mc.mc_line;
}
Expand Down Expand Up @@ -1296,7 +1300,8 @@ text_sub_source::text_crumbs_for_line(int line,
{
}

logfile_filter_state::logfile_filter_state(std::shared_ptr<logfile> lf)
logfile_filter_state::
logfile_filter_state(std::shared_ptr<logfile> lf)
: tfs_logfile(std::move(lf))
{
memset(this->tfs_filter_count, 0, sizeof(this->tfs_filter_count));
Expand Down

0 comments on commit 77b9829

Please sign in to comment.