From 5a46ad49ea0f5fe01521437a9776f8383820bb24 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 22 Sep 2011 14:00:04 +0000 Subject: [PATCH] Window: add move_cursor_to method --- src/window.cc | 7 ++++++- src/window.hh | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/window.cc b/src/window.cc index 0544031e..1448dc68 100644 --- a/src/window.cc +++ b/src/window.cc @@ -142,7 +142,12 @@ void Window::select(bool append, const Selector& selector) 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)); diff --git a/src/window.hh b/src/window.hh index c16586ee..2506025b 100644 --- a/src/window.hh +++ b/src/window.hh @@ -68,6 +68,7 @@ public: WindowCoord line_and_column_at(const BufferIterator& iterator) const; void move_cursor(const WindowCoord& offset); + void move_cursor_to(const WindowCoord& new_pos); void empty_selections(); void select(bool append, const Selector& selector);