add Window::display_selection_at(LineCount)

This commit is contained in:
Maxime Coste 2013-04-11 21:01:00 +02:00
parent 301921cd45
commit fb87c7ac9f
2 changed files with 11 additions and 2 deletions

View File

@ -38,10 +38,18 @@ Window::~Window()
m_options.unregister_watcher(*this);
}
void Window::display_selection_at(LineCount line)
{
if (line >= 0 or line < m_dimensions.line)
{
auto cursor_line = main_selection().last().line();
m_position.line = std::max(0_line, cursor_line - line);
}
}
void Window::center_selection()
{
BufferIterator cursor = main_selection().last();
m_position.line = std::max(0_line, cursor.line() - m_dimensions.line/2_line);
display_selection_at(m_dimensions.line/2_line);
}
void Window::update_display_buffer()

View File

@ -33,6 +33,7 @@ public:
const DisplayBuffer& display_buffer() const { return m_display_buffer; }
void center_selection();
void display_selection_at(LineCount line);
void update_display_buffer();
DisplayCoord display_position(const BufferIterator& it);