diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-04-12 01:31:21 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-04-12 01:31:21 +0200 |
| commit | 46deca4f3f711753c839d441f55ff6e2a0d52798 (patch) | |
| tree | 1fa1de2892d2c95e6220e3df700ce0486631bf98 /src | |
| parent | e4d87ee1f1c4cbc4682a4310802b85cda8ef408f (diff) | |
Add zj and zk command for scrolling the window
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 6 | ||||
| -rw-r--r-- | src/window.cc | 5 | ||||
| -rw-r--r-- | src/window.hh | 1 |
3 files changed, 12 insertions, 0 deletions
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<LineCount>(1, context.numeric_param())); + break; + case 'k': + context.window().scroll(-std::max<LineCount>(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); |
