summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-03-30 10:38:56 +0100
committerMaxime Coste <mawww@kakoune.org>2017-03-30 10:38:56 +0100
commit2cfe3cae36cb9054b37a351de0d7b60a0e5bd4ca (patch)
treeab807ceffc30c6bc045c30668e519a4834c600d6 /src
parentfa7f29a1205d8dcbce1e10a171eb64a11774f7d8 (diff)
Add an InsertDelete hook
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc2
-rw-r--r--src/input_handler.cc6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/commands.cc b/src/commands.cc
index ec8cd6ca..2c21c78d 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -761,7 +761,7 @@ const CommandDesc remove_highlighter_cmd = {
static constexpr auto hooks = {
"BufCreate", "BufNewFile", "BufOpenFile", "BufClose", "BufWritePost",
"BufWritePre", "BufOpenFifo", "BufCloseFifo", "BufReadFifo", "BufSetOption",
- "InsertBegin", "InsertChar", "InsertEnd", "InsertIdle", "InsertKey",
+ "InsertBegin", "InsertChar", "InsertDelete", "InsertEnd", "InsertIdle", "InsertKey",
"InsertMove", "InsertCompletionHide", "InsertCompletionShow",
"KakBegin", "KakEnd", "FocusIn", "FocusOut", "RuntimeError",
"NormalBegin", "NormalEnd", "NormalIdle", "NormalKey", "RawKey",
diff --git a/src/input_handler.cc b/src/input_handler.cc
index b25e4174..b9a1653c 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1067,8 +1067,14 @@ public:
auto pos = sel.cursor();
sels.emplace_back(buffer.char_prev(pos));
}
+ auto& main = context().selections().main();
+ String main_char = buffer.string(buffer.char_prev(main.cursor()),
+ main.cursor());
if (not sels.empty())
SelectionList{buffer, std::move(sels)}.erase();
+
+ if (not main_char.empty())
+ context().hooks().run_hook("InsertDelete", main_char, context());
}
else if (key == Key::Delete)
{