Add Editor::select(const Selection&, SelectMode)
This commit is contained in:
parent
4e69ec078d
commit
76c3246642
|
@ -211,18 +211,21 @@ void Editor::remove_selection(int index)
|
||||||
m_selections.erase(m_selections.begin() + index);
|
m_selections.erase(m_selections.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::select(const BufferIterator& iterator, SelectMode mode)
|
void Editor::select(const Selection& selection, SelectMode mode)
|
||||||
{
|
{
|
||||||
if (mode == SelectMode::Replace)
|
if (mode == SelectMode::Replace)
|
||||||
m_selections = SelectionList{ {iterator, iterator} };
|
m_selections = SelectionList{ selection };
|
||||||
else if (mode == SelectMode::Extend)
|
else if (mode == SelectMode::Extend)
|
||||||
{
|
{
|
||||||
for (auto& sel : m_selections)
|
for (auto& sel : m_selections)
|
||||||
sel.last() = iterator;
|
sel.merge_with(selection);
|
||||||
sort_and_merge_overlapping(m_selections);
|
sort_and_merge_overlapping(m_selections);
|
||||||
}
|
}
|
||||||
else if (mode == SelectMode::Append)
|
else if (mode == SelectMode::Append)
|
||||||
assert(false);
|
{
|
||||||
|
m_selections.push_back(selection);
|
||||||
|
sort_and_merge_overlapping(m_selections);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::select(SelectionList selections)
|
void Editor::select(SelectionList selections)
|
||||||
|
|
|
@ -62,7 +62,10 @@ public:
|
||||||
void flip_selections();
|
void flip_selections();
|
||||||
void keep_selection(int index);
|
void keep_selection(int index);
|
||||||
void remove_selection(int index);
|
void remove_selection(int index);
|
||||||
void select(const BufferIterator& iterator,
|
void select(const BufferIterator& it,
|
||||||
|
SelectMode mode = SelectMode::Replace)
|
||||||
|
{ select(Selection{ it, it }, mode); }
|
||||||
|
void select(const Selection& sel,
|
||||||
SelectMode mode = SelectMode::Replace);
|
SelectMode mode = SelectMode::Replace);
|
||||||
void select(const Selector& selector,
|
void select(const Selector& selector,
|
||||||
SelectMode mode = SelectMode::Replace);
|
SelectMode mode = SelectMode::Replace);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user