From c9a7cf50f37ad78679fe2935b9ca70d7ef413c45 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 21 Aug 2012 20:05:56 +0200 Subject: [PATCH] add Window::center_selection method --- src/window.cc | 6 ++++++ src/window.hh | 1 + 2 files changed, 7 insertions(+) diff --git a/src/window.cc b/src/window.cc index fad8859e..c5ee5c1a 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 455830e5..119cf962 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;