Add zj and zk command for scrolling the window

This commit is contained in:
Maxime Coste 2013-04-12 01:31:21 +02:00
parent e4d87ee1f1
commit 46deca4f3f
4 changed files with 14 additions and 0 deletions

View File

@ -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
---------------

View File

@ -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;
}
});
}

View File

@ -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();

View File

@ -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);