diff --git a/src/window.cc b/src/window.cc index c1792d2d..6fd4c541 100644 --- a/src/window.cc +++ b/src/window.cc @@ -213,6 +213,21 @@ void Window::select(const Selector& selector, bool append) scroll_to_keep_cursor_visible_ifn(); } +void Window::multi_select(const MultiSelector& selector) +{ + check_invariant(); + + SelectionList new_selections; + for (auto& sel : m_selections) + { + SelectionList selections = selector(sel); + std::copy(selections.begin(), selections.end(), + std::back_inserter(new_selections)); + } + m_selections = std::move(new_selections); + scroll_to_keep_cursor_visible_ifn(); +} + BufferString Window::selection_content() const { check_invariant(); diff --git a/src/window.hh b/src/window.hh index 133d44d1..a3d1c4ab 100644 --- a/src/window.hh +++ b/src/window.hh @@ -39,6 +39,7 @@ class Window public: typedef BufferString String; typedef std::function Selector; + typedef std::function MultiSelector; void erase(); void insert(const String& string); @@ -58,6 +59,7 @@ public: void clear_selections(); void select(const Selector& selector, bool append = false); + void multi_select(const MultiSelector& selector); BufferString selection_content() const; const SelectionList selections() const { return m_selections; }