editor: support select mode on select(BufferIterator)

This commit is contained in:
Maxime Coste 2012-12-18 19:12:15 +01:00
parent cf7e6bdd07
commit 6cc4ec796e
2 changed files with 13 additions and 3 deletions

View File

@ -200,9 +200,18 @@ void Editor::remove_selection(int index)
m_selections.erase(m_selections.begin() + index);
}
void Editor::select(const BufferIterator& iterator)
void Editor::select(const BufferIterator& iterator, SelectMode mode)
{
if (mode == SelectMode::Replace)
m_selections = SelectionList{ {iterator, iterator} };
else if (mode == SelectMode::Extend)
{
for (auto& sel : m_selections)
sel.last() = iterator;
merge_overlapping(m_selections);
}
else if (mode == SelectMode::Append)
assert(false);
}
void Editor::select(SelectionList selections)

View File

@ -62,7 +62,8 @@ public:
void flip_selections();
void keep_selection(int index);
void remove_selection(int index);
void select(const BufferIterator& iterator);
void select(const BufferIterator& iterator,
SelectMode mode = SelectMode::Replace);
void select(const Selector& selector,
SelectMode mode = SelectMode::Replace);
void select(SelectionList selections);