diff options
Diffstat (limited to 'src/editor.cc')
| -rw-r--r-- | src/editor.cc | 56 |
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) |
