Window: add multi_select method
multi_select provides Selection -> SelectionList operations
This commit is contained in:
parent
7423677236
commit
0203b904e1
|
@ -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();
|
||||
|
|
|
@ -39,6 +39,7 @@ class Window
|
|||
public:
|
||||
typedef BufferString String;
|
||||
typedef std::function<Selection (const BufferIterator&)> Selector;
|
||||
typedef std::function<SelectionList (const Selection&)> 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; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user