summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-10-16 20:19:43 +1100
committerMaxime Coste <mawww@kakoune.org>2019-10-16 20:45:53 +1100
commite4fb70ebec80edcd17f0e00823780e4798a3fb1a (patch)
tree8e45c2e340a63ca05aa73f8a44bf3c9d59494c0b /src
parent3a36a2486e12be9150e28fa81ac707d65c425d45 (diff)
Replace ModeChange hooks by ModePush and ModePop
Remove deprecated InsertBegin, InsertEnd, NormalBegin, NormalEnd hooks. Closes #2545
Diffstat (limited to 'src')
-rw-r--r--src/hook_manager.hh10
-rw-r--r--src/input_handler.cc23
-rw-r--r--src/main.cc4
3 files changed, 9 insertions, 28 deletions
diff --git a/src/hook_manager.hh b/src/hook_manager.hh
index 71e9e2d1..302e3e14 100644
--- a/src/hook_manager.hh
+++ b/src/hook_manager.hh
@@ -30,10 +30,8 @@ enum class Hook
BufSetOption,
ClientCreate,
ClientClose,
- InsertBegin,
InsertChar,
InsertDelete,
- InsertEnd,
InsertIdle,
InsertKey,
InsertMove,
@@ -46,8 +44,6 @@ enum class Hook
GlobalSetOption,
RuntimeError,
PromptIdle,
- NormalBegin,
- NormalEnd,
NormalIdle,
NormalKey,
ModeChange,
@@ -62,7 +58,7 @@ enum class Hook
constexpr auto enum_desc(Meta::Type<Hook>)
{
- return make_array<EnumDesc<Hook>, 41>({
+ return make_array<EnumDesc<Hook>, 38>({
{Hook::BufCreate, "BufCreate"},
{Hook::BufNewFile, "BufNewFile"},
{Hook::BufOpenFile, "BufOpenFile"},
@@ -76,10 +72,8 @@ constexpr auto enum_desc(Meta::Type<Hook>)
{Hook::BufSetOption, "BufSetOption"},
{Hook::ClientCreate, "ClientCreate"},
{Hook::ClientClose, "ClientClose"},
- {Hook::InsertBegin, "InsertBegin"},
{Hook::InsertChar, "InsertChar"},
{Hook::InsertDelete, "InsertDelete"},
- {Hook::InsertEnd, "InsertEnd"},
{Hook::InsertIdle, "InsertIdle"},
{Hook::InsertKey, "InsertKey"},
{Hook::InsertMove, "InsertMove"},
@@ -92,8 +86,6 @@ constexpr auto enum_desc(Meta::Type<Hook>)
{Hook::GlobalSetOption, "GlobalSetOption"},
{Hook::RuntimeError, "RuntimeError"},
{Hook::PromptIdle, "PromptIdle"},
- {Hook::NormalBegin, "NormalBegin"},
- {Hook::NormalEnd, "NormalEnd"},
{Hook::NormalIdle, "NormalIdle"},
{Hook::NormalKey, "NormalKey"},
{Hook::ModeChange, "ModeChange"},
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 56de0bd1..5cb780ee 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -203,8 +203,6 @@ public:
context().hooks_disabled().unset();
m_hooks_disabled = false;
}
-
- context().hooks().run_hook(Hook::NormalBegin, "", context());
}
void on_disabled(bool temporary) override
@@ -217,8 +215,6 @@ public:
context().hooks_disabled().unset();
m_hooks_disabled = false;
}
-
- context().hooks().run_hook(Hook::NormalEnd, "", context());
}
void on_key(Key key) override
@@ -1153,7 +1149,6 @@ public:
last_insert().keys.clear();
last_insert().disable_hooks = context().hooks_disabled();
last_insert().count = count;
- context().hooks().run_hook(Hook::InsertBegin, "", context());
prepare(mode, count);
}
@@ -1197,11 +1192,6 @@ public:
}
else if (key == Key::Escape or key == ctrl('c'))
{
- if (m_in_end)
- throw runtime_error("asked to exit insert mode while running InsertEnd hook");
- m_in_end = true;
- context().hooks().run_hook(Hook::InsertEnd, "", context());
-
m_completer.reset();
pop_mode();
}
@@ -1496,7 +1486,6 @@ private:
const bool m_restore_cursor;
bool m_auto_complete;
Timer m_idle_timer;
- bool m_in_end = false;
MouseHandler m_mouse_handler;
ScopedSetBool m_disable_hooks;
};
@@ -1520,7 +1509,7 @@ void InputHandler::push_mode(InputMode* new_mode)
m_mode_stack.emplace_back(new_mode);
new_mode->on_enabled();
- context().hooks().run_hook(Hook::ModeChange, format("{}:{}", prev_name, new_mode->name()), context());
+ context().hooks().run_hook(Hook::ModeChange, format("push:{}:{}", prev_name, new_mode->name()), context());
}
void InputHandler::pop_mode(InputMode* mode)
@@ -1534,7 +1523,7 @@ void InputHandler::pop_mode(InputMode* mode)
m_mode_stack.pop_back();
current_mode().on_enabled();
- context().hooks().run_hook(Hook::ModeChange, format("{}:{}", prev_name, current_mode().name()), context());
+ context().hooks().run_hook(Hook::ModeChange, format("pop:{}:{}", prev_name, current_mode().name()), context());
}
void InputHandler::reset_normal_mode()
@@ -1543,12 +1532,8 @@ void InputHandler::reset_normal_mode()
if (m_mode_stack.size() == 1)
return;
- StringView prev_name = current_mode().name();
- current_mode().on_disabled(false);
- m_mode_stack.resize(1);
- current_mode().on_enabled();
-
- context().hooks().run_hook(Hook::ModeChange, format("{}:{}", prev_name, current_mode().name()), context());
+ while (m_mode_stack.size() > 1)
+ pop_mode(m_mode_stack.back().get());
}
void InputHandler::insert(InsertMode mode, int count)
diff --git a/src/main.cc b/src/main.cc
index de2dba2d..5cc39286 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -44,6 +44,10 @@ struct {
unsigned int version;
const char* notes;
} constexpr version_notes[] = { {
+ 0,
+ "» ModeChange parameter has changed to contain push/pop\n"
+ " ${Mode}Begin/${Mode}End hooks were removed\n"
+ }, {
20190701,
"» %file{...} expansions to read files\n"
"» echo -to-file <filename> to write to file\n"