diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-09-15 10:05:44 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-09-15 10:27:00 +1000 |
| commit | 858ae14f766dc8b847a61cb59ce04f704d412ad3 (patch) | |
| tree | 2adf3f6cff7bff6c96391f3107052f8199404381 /src | |
| parent | 6ee71191af7af3c67491466e00cef24843a07c5e (diff) | |
Allow scrolling while dragging mouse
Closes #2052
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_handler.cc | 10 | ||||
| -rw-r--r-- | src/input_handler.hh | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index b48edce9..56de0bd1 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -138,8 +138,7 @@ struct MouseHandler return true; case Key::Modifiers::Scroll: - m_dragging = false; - scroll_window(context, static_cast<int32_t>(key.key)); + scroll_window(context, static_cast<int32_t>(key.key), not m_dragging); return true; default: return false; @@ -1737,7 +1736,7 @@ void hide_auto_info_ifn(const Context& context, bool hide) context.client().info_hide(); } -void scroll_window(Context& context, LineCount offset) +void scroll_window(Context& context, LineCount offset, bool adapt_cursor) { Window& window = context.window(); Buffer& buffer = context.buffer(); @@ -1751,6 +1750,10 @@ void scroll_window(Context& context, LineCount offset) const LineCount line_count = buffer.line_count(); win_pos.line = clamp(win_pos.line + offset, 0_line, line_count-1); + window.set_position(win_pos); + + if (not adapt_cursor) + return; SelectionList& selections = context.selections(); const BufferCoord cursor = selections.main().cursor(); @@ -1766,7 +1769,6 @@ void scroll_window(Context& context, LineCount offset) buffer[line].length()-1); selections = SelectionList{buffer, BufferCoord{line, col}}; - window.set_position(win_pos); } } diff --git a/src/input_handler.hh b/src/input_handler.hh index e9528a07..3304b67e 100644 --- a/src/input_handler.hh +++ b/src/input_handler.hh @@ -186,7 +186,7 @@ void on_next_key_with_autoinfo(const Context& context, KeymapMode keymap_mode, C }); } -void scroll_window(Context& context, LineCount offset); +void scroll_window(Context& context, LineCount offset, bool adapt_cursor = true); } |
