diff --git a/src/window.cc b/src/window.cc index fad8859ea..c5ee5c1a8 100644 --- a/src/window.cc +++ b/src/window.cc @@ -35,6 +35,12 @@ Window::~Window() 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() { scroll_to_keep_cursor_visible_ifn(); diff --git a/src/window.hh b/src/window.hh index 455830e5d..119cf962e 100644 --- a/src/window.hh +++ b/src/window.hh @@ -30,6 +30,7 @@ public: const DisplayBuffer& display_buffer() const { return m_display_buffer; } + void center_selection(); void update_display_buffer(); String status_line() const;