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();
|
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
|
BufferString Window::selection_content() const
|
||||||
{
|
{
|
||||||
check_invariant();
|
check_invariant();
|
||||||
|
|
|
@ -39,6 +39,7 @@ class Window
|
||||||
public:
|
public:
|
||||||
typedef BufferString String;
|
typedef BufferString String;
|
||||||
typedef std::function<Selection (const BufferIterator&)> Selector;
|
typedef std::function<Selection (const BufferIterator&)> Selector;
|
||||||
|
typedef std::function<SelectionList (const Selection&)> MultiSelector;
|
||||||
|
|
||||||
void erase();
|
void erase();
|
||||||
void insert(const String& string);
|
void insert(const String& string);
|
||||||
|
@ -58,6 +59,7 @@ public:
|
||||||
|
|
||||||
void clear_selections();
|
void clear_selections();
|
||||||
void select(const Selector& selector, bool append = false);
|
void select(const Selector& selector, bool append = false);
|
||||||
|
void multi_select(const MultiSelector& selector);
|
||||||
BufferString selection_content() const;
|
BufferString selection_content() const;
|
||||||
const SelectionList selections() const { return m_selections; }
|
const SelectionList selections() const { return m_selections; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user