diff --git a/README.asciidoc b/README.asciidoc index 2e127dcb..8e8762f3 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -148,6 +148,8 @@ window. * _zz_ or _zc_: center the main selection in the window * _zt_: scroll to put the main selection on the top line of the window * _zb_: scroll to put the main selection on the bottom line of the window + * _zj_: scroll the window count line downward + * _zk_: scroll the window count line upward Multi Selection --------------- diff --git a/src/main.cc b/src/main.cc index 81cabb17..1d7d7c28 100644 --- a/src/main.cc +++ b/src/main.cc @@ -167,6 +167,12 @@ void do_disp_cmd(Context& context) case 'b': context.window().display_selection_at(window.dimensions().line-1); break; + case 'j': + context.window().scroll( std::max(1, context.numeric_param())); + break; + case 'k': + context.window().scroll(-std::max(1, context.numeric_param())); + break; } }); } diff --git a/src/window.cc b/src/window.cc index 132c48fe..f77a200f 100644 --- a/src/window.cc +++ b/src/window.cc @@ -52,6 +52,11 @@ void Window::center_selection() display_selection_at(m_dimensions.line/2_line); } +void Window::scroll(LineCount offset) +{ + m_position.line = std::max(0_line, m_position.line + offset); +} + void Window::update_display_buffer() { scroll_to_keep_cursor_visible_ifn(); diff --git a/src/window.hh b/src/window.hh index b8cf0ddc..8f842f06 100644 --- a/src/window.hh +++ b/src/window.hh @@ -34,6 +34,7 @@ public: void center_selection(); void display_selection_at(LineCount line); + void scroll(LineCount offset); void update_display_buffer(); DisplayCoord display_position(const BufferIterator& it);