summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-05-25 22:59:29 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-05-25 22:59:29 +0100
commit51eae8026b5e7a596ad3ec787ade96e8e78d7c33 (patch)
treedbbe253a8433f26de5c19ce5d43c1351e29630f4 /src
parentb2621ca140701269056c75983a8c1220b8382684 (diff)
Use SelectionList::insert in InputModes::Insert
Diffstat (limited to 'src')
-rw-r--r--src/input_handler.cc18
-rw-r--r--src/selection.cc3
-rw-r--r--src/selection.hh1
3 files changed, 6 insertions, 16 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 4c718c21..60cfb618 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -759,26 +759,13 @@ private:
void insert(memoryview<String> strings)
{
- auto& buffer = context().buffer();
- auto& selections = context().selections();
- for (size_t i = 0; i < selections.size(); ++i)
- {
- size_t index = selections.size() - 1 - i;
- const String& str = strings[std::min(index, strings.size()-1)];
- buffer.insert(buffer.iterator_at(selections[index].cursor()),
- str);
- }
- selections.update();
+ context().selections().insert(strings, InsertMode::InsertCursor);
}
void insert(Codepoint key)
{
auto str = codepoint_to_str(key);
- auto& buffer = context().buffer();
- auto& selections = context().selections();
- for (auto& sel : reversed(selections))
- buffer.insert(buffer.iterator_at(sel.cursor()), str);
- selections.update();
+ context().selections().insert(str, InsertMode::InsertCursor);
context().hooks().run_hook("InsertChar", str, context());
}
@@ -828,6 +815,7 @@ private:
cursor = anchor;
break;
case InsertMode::InsertAtNextLineBegin:
+ case InsertMode::InsertCursor:
kak_assert(false); // not implemented
break;
}
diff --git a/src/selection.cc b/src/selection.cc
index 7b99cc6d..c37829c2 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -239,6 +239,8 @@ BufferIterator prepare_insert(Buffer& buffer, const Selection& sel, InsertMode m
{
case InsertMode::Insert:
return buffer.iterator_at(sel.min());
+ case InsertMode::InsertCursor:
+ return buffer.iterator_at(sel.cursor());
case InsertMode::Replace:
return erase(buffer, sel);
case InsertMode::Append:
@@ -295,7 +297,6 @@ void SelectionList::insert(memoryview<String> strings, InsertMode mode)
}
}
update();
- avoid_eol();
check_invariant();
m_buffer->check_invariant();
}
diff --git a/src/selection.hh b/src/selection.hh
index a1bf8e5c..75d26728 100644
--- a/src/selection.hh
+++ b/src/selection.hh
@@ -58,6 +58,7 @@ static bool compare_selections(const Selection& lhs, const Selection& rhs)
enum class InsertMode : unsigned
{
Insert,
+ InsertCursor,
Append,
Replace,
InsertAtLineBegin,