diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-07-28 09:51:49 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-07-28 09:51:49 +0100 |
| commit | d28e5031505774e64d33cd3f231a8383e01fcab9 (patch) | |
| tree | 60ccde00fcef069bd4c8dd0807f09da2761b08c9 /src/normal.cc | |
| parent | a7005ec74be9eef4595031bfe9191cc8bd5a08e3 (diff) | |
Use the same logic for mouse wheel and (half) page up/down
Fixes #749
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/normal.cc b/src/normal.cc index 6927c291..c22b47fc 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1027,25 +1027,9 @@ template<Direction direction, bool half = false> void scroll(Context& context, NormalParams) { Window& window = context.window(); - Buffer& buffer = context.buffer(); - CharCoord position = window.position(); - LineCount cursor_line = 0; + const LineCount offset = (window.dimensions().line - 2) / (half ? 2 : 1); - if (direction == Backward) - { - position.line -= (window.dimensions().line - 2) / (half ? 2 : 1); - cursor_line = position.line; - } - else if (direction == Forward) - { - position.line += (window.dimensions().line - 2) / (half ? 2 : 1); - cursor_line = position.line + window.dimensions().line - 1; - } - auto cursor_pos = utf8::advance(buffer.iterator_at(position.line), - buffer.iterator_at(position.line+1), - position.column); - select_coord(buffer, cursor_pos.coord(), context.selections()); - window.set_position(position); + scroll_window(context, direction == Direction::Forward ? offset : -offset); } template<Direction direction> |
