Window: add move_cursor_to method

This commit is contained in:
Maxime Coste 2011-09-22 14:00:04 +00:00
parent 3012f69c4d
commit 5a46ad49ea
2 changed files with 7 additions and 1 deletions

View File

@ -142,7 +142,12 @@ void Window::select(bool append, const Selector& selector)
void Window::move_cursor(const WindowCoord& offset) void Window::move_cursor(const WindowCoord& offset)
{ {
BufferCoord target_position = window_to_buffer(m_cursor + offset); move_cursor_to(m_cursor + offset);
}
void Window::move_cursor_to(const WindowCoord& new_pos)
{
BufferCoord target_position = window_to_buffer(new_pos);
m_cursor = buffer_to_window(m_buffer.clamp(target_position)); m_cursor = buffer_to_window(m_buffer.clamp(target_position));

View File

@ -68,6 +68,7 @@ public:
WindowCoord line_and_column_at(const BufferIterator& iterator) const; WindowCoord line_and_column_at(const BufferIterator& iterator) const;
void move_cursor(const WindowCoord& offset); void move_cursor(const WindowCoord& offset);
void move_cursor_to(const WindowCoord& new_pos);
void empty_selections(); void empty_selections();
void select(bool append, const Selector& selector); void select(bool append, const Selector& selector);