add Window::center_selection method

This commit is contained in:
Maxime Coste 2012-08-21 20:05:56 +02:00
parent 45b9ac6087
commit c9a7cf50f3
2 changed files with 7 additions and 0 deletions

View File

@ -35,6 +35,12 @@ Window::~Window()
m_option_manager.unregister_watcher(*this); m_option_manager.unregister_watcher(*this);
} }
void Window::center_selection()
{
BufferIterator cursor = selections().back().last();
m_position.line = std::max(0, cursor.line() - m_dimensions.line/2);
}
void Window::update_display_buffer() void Window::update_display_buffer()
{ {
scroll_to_keep_cursor_visible_ifn(); scroll_to_keep_cursor_visible_ifn();

View File

@ -30,6 +30,7 @@ public:
const DisplayBuffer& display_buffer() const { return m_display_buffer; } const DisplayBuffer& display_buffer() const { return m_display_buffer; }
void center_selection();
void update_display_buffer(); void update_display_buffer();
String status_line() const; String status_line() const;