From 62fdacb757cee6bb4d859f49b8ca7a2e476b8379 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 24 Jul 2013 01:38:30 +0200 Subject: [PATCH] Add scroll left/right support --- README.asciidoc | 2 ++ src/normal.cc | 6 ++++++ src/window.cc | 5 +++++ src/window.hh | 1 + 4 files changed, 14 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index 15db7b81..60393a76 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -161,6 +161,8 @@ view. * _vb_: scroll to put the main selection on the bottom line of the window * _vj_: scroll the window count line downward * _vk_: scroll the window count line upward + * _vh_: scroll the window count columns left + * _vl_: scroll the window count columns right Multi Selection --------------- diff --git a/src/normal.cc b/src/normal.cc index 81526b9c..4c50bc03 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -194,6 +194,12 @@ void view_commands(Context& context) case 'k': context.window().scroll(-std::max(1, context.numeric_param())); break; + case 'l': + context.window().scroll( std::max(1, context.numeric_param())); + break; + case 'h': + context.window().scroll(-std::max(1, context.numeric_param())); + break; } }); } diff --git a/src/window.cc b/src/window.cc index 1ab42982..72a69984 100644 --- a/src/window.cc +++ b/src/window.cc @@ -57,6 +57,11 @@ void Window::scroll(LineCount offset) m_position.line = std::max(0_line, m_position.line + offset); } +void Window::scroll(CharCount offset) +{ + m_position.column = std::max(0_char, m_position.column + offset); +} + void Window::update_display_buffer() { scroll_to_keep_cursor_visible_ifn(); diff --git a/src/window.hh b/src/window.hh index 08ee23f0..a9ea0c8c 100644 --- a/src/window.hh +++ b/src/window.hh @@ -35,6 +35,7 @@ public: void center_selection(); void display_selection_at(LineCount line); void scroll(LineCount offset); + void scroll(CharCount offset); void update_display_buffer(); DisplayCoord display_position(const BufferCoord& coord);