Add Editor::select(const Selection&, SelectMode)

This commit is contained in:
Maxime Coste 2012-12-31 14:06:20 +01:00
parent 4e69ec078d
commit 76c3246642
2 changed files with 11 additions and 5 deletions

View File

@ -211,18 +211,21 @@ void Editor::remove_selection(int 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)
m_selections = SelectionList{ {iterator, iterator} };
m_selections = SelectionList{ selection };
else if (mode == SelectMode::Extend)
{
for (auto& sel : m_selections)
sel.last() = iterator;
sel.merge_with(selection);
sort_and_merge_overlapping(m_selections);
}
else if (mode == SelectMode::Append)
assert(false);
{
m_selections.push_back(selection);
sort_and_merge_overlapping(m_selections);
}
}
void Editor::select(SelectionList selections)

View File

@ -62,7 +62,10 @@ public:
void flip_selections();
void keep_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);
void select(const Selector& selector,
SelectMode mode = SelectMode::Replace);