summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2021-10-10 10:28:34 +1100
committerMaxime Coste <mawww@kakoune.org>2021-10-10 11:02:09 +1100
commit689553c2e9b953a9d3822528d4ad858af95fb6a2 (patch)
tree1415eb0f4a733f278caf2c717340859f269c0989 /src/input_handler.cc
parentb609adc84c1bb3251d3e410a3555aa9f94cc769f (diff)
Split InsertMode into InsertMode and PasteMode
They are quite different use cases, and this allow moving InsertMode to input_handler.hh which is what uses it. This also cleans up the code as we can get rid of get_insert_pos and rely more on SelectionList::for_each.
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 85904e7f..fbfadf81 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1467,13 +1467,19 @@ private:
void insert(ConstArrayView<String> strings)
{
- context().selections().insert(strings, InsertMode::InsertCursor);
+ context().selections().for_each([strings, &buffer=context().buffer()]
+ (size_t index, Selection& sel) {
+ Kakoune::insert(buffer, sel, sel.cursor(), strings[std::min(strings.size()-1, index)]);
+ });
}
void insert(Codepoint key)
{
String str{key};
- context().selections().insert(str, InsertMode::InsertCursor);
+ context().selections().for_each([&buffer=context().buffer(), &str]
+ (size_t index, Selection& sel) {
+ Kakoune::insert(buffer, sel, sel.cursor(), str);
+ });
context().hooks().run_hook(Hook::InsertChar, str, context());
}
@@ -1551,10 +1557,6 @@ private:
sel.set(pos);
}
break;
- case InsertMode::InsertAtNextLineBegin:
- case InsertMode::InsertCursor:
- kak_assert(false); // invalid for interactive insert
- break;
}
selections.check_invariant();
buffer.check_invariant();