summaryrefslogtreecommitdiff
path: root/src/editor.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-12-14 14:08:26 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-12-14 14:38:17 +0000
commit77590fe2e864fbde37067f341b6767c4f043dbed (patch)
treef0a95aae43195b7150d4a4eb8f8ddddfb7c11c33 /src/editor.cc
parentdad27fe1a0d3cf7382675e9fb2c64a0a4f874a59 (diff)
Move (keep|flip|remove|clear)_selections from editor method to free selectors
Diffstat (limited to 'src/editor.cc')
-rw-r--r--src/editor.cc56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/editor.cc b/src/editor.cc
index 4f925374..95b4c0f5 100644
--- a/src/editor.cc
+++ b/src/editor.cc
@@ -17,20 +17,6 @@ Editor::Editor(Buffer& buffer)
m_selections(buffer, { {{},{}} })
{}
-void avoid_eol(const Buffer& buffer, BufferCoord& coord)
-{
- const auto column = coord.column;
- const auto& line = buffer[coord.line];
- if (column != 0 and column == line.length() - 1)
- coord.column = line.byte_count_to(line.char_length() - 2);
-}
-
-void avoid_eol(const Buffer& buffer, Range& sel)
-{
- avoid_eol(buffer, sel.first());
- avoid_eol(buffer, sel.last());
-}
-
void Editor::erase()
{
scoped_edition edition(*this);
@@ -165,48 +151,6 @@ void Editor::move_selections(LineCount offset, SelectMode mode)
m_selections.sort_and_merge_overlapping();
}
-void Editor::clear_selections()
-{
- auto& sel = m_selections.main();
- auto& pos = sel.last();
- avoid_eol(*m_buffer, pos);
- sel.first() = pos;
-
- m_selections = SelectionList{ std::move(sel) };
- check_invariant();
-}
-
-void Editor::flip_selections()
-{
- for (auto& sel : m_selections)
- std::swap(sel.first(), sel.last());
- check_invariant();
-}
-
-void Editor::keep_selection(int index)
-{
- if (index < m_selections.size())
- {
- size_t real_index = (index + m_selections.main_index() + 1) % m_selections.size();
- m_selections = SelectionList{ std::move(m_selections[real_index]) };
- }
- check_invariant();
-}
-
-void Editor::remove_selection(int index)
-{
- if (m_selections.size() > 1 and index < m_selections.size())
- {
- size_t real_index = (index + m_selections.main_index() + 1) % m_selections.size();
- m_selections.erase(m_selections.begin() + real_index);
- size_t main_index = m_selections.main_index();
- if (real_index <= main_index)
- m_selections.set_main_index((main_index > 0 ? main_index
- : m_selections.size()) - 1);
- }
- check_invariant();
-}
-
void Editor::select(const Selection& selection, SelectMode mode)
{
if (mode == SelectMode::Replace)