Do not set idle timers when running in a transient context
This commit is contained in:
parent
7ceb768a2e
commit
806d885eaf
|
@ -174,12 +174,15 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void on_enabled() override
|
void on_enabled() override
|
||||||
|
{
|
||||||
|
if (not (context().flags() & Context::Flags::Transient))
|
||||||
{
|
{
|
||||||
if (context().has_client())
|
if (context().has_client())
|
||||||
context().client().check_if_buffer_needs_reloading();
|
context().client().check_if_buffer_needs_reloading();
|
||||||
|
|
||||||
m_fs_check_timer.set_next_date(Clock::now() + get_fs_check_timeout(context()));
|
m_fs_check_timer.set_next_date(Clock::now() + get_fs_check_timeout(context()));
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
|
}
|
||||||
|
|
||||||
if (m_hooks_disabled and not m_in_on_key)
|
if (m_hooks_disabled and not m_in_on_key)
|
||||||
{
|
{
|
||||||
|
@ -220,10 +223,15 @@ public:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const bool transient = context().flags() & Context::Flags::Transient;
|
||||||
|
|
||||||
auto cp = key.codepoint();
|
auto cp = key.codepoint();
|
||||||
|
|
||||||
if (m_mouse_handler.handle_key(key, context()))
|
if (m_mouse_handler.handle_key(key, context()))
|
||||||
|
{
|
||||||
|
if (not transient)
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
|
}
|
||||||
else if (cp and isdigit(*cp))
|
else if (cp and isdigit(*cp))
|
||||||
{
|
{
|
||||||
int new_val = m_params.count * 10 + *cp - '0';
|
int new_val = m_params.count * 10 + *cp - '0';
|
||||||
|
@ -284,7 +292,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
context().hooks().run_hook("NormalKey", key_to_str(key), context());
|
context().hooks().run_hook("NormalKey", key_to_str(key), context());
|
||||||
if (enabled()) // The hook might have changed mode
|
if (enabled() and not transient) // The hook might have changed mode
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +881,7 @@ public:
|
||||||
|
|
||||||
display();
|
display();
|
||||||
m_line_changed = true;
|
m_line_changed = true;
|
||||||
if (enabled()) // The callback might have disabled us
|
if (enabled() and not (context().flags() & Context::Flags::Transient)) // The callback might have disabled us
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,6 +965,8 @@ private:
|
||||||
display();
|
display();
|
||||||
m_line_changed = false;
|
m_line_changed = false;
|
||||||
m_callback(m_line_editor.line(), PromptEvent::Change, context());
|
m_callback(m_line_editor.line(), PromptEvent::Change, context());
|
||||||
|
|
||||||
|
if (not (context().flags() & Context::Flags::Transient))
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,6 +1082,7 @@ public:
|
||||||
|
|
||||||
void on_enabled() override
|
void on_enabled() override
|
||||||
{
|
{
|
||||||
|
if (not (context().flags() & Context::Flags::Transient))
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,10 +1096,14 @@ public:
|
||||||
auto& buffer = context().buffer();
|
auto& buffer = context().buffer();
|
||||||
last_insert().keys.push_back(key);
|
last_insert().keys.push_back(key);
|
||||||
|
|
||||||
|
const bool transient = context().flags() & Context::Flags::Transient;
|
||||||
bool update_completions = true;
|
bool update_completions = true;
|
||||||
bool moved = false;
|
bool moved = false;
|
||||||
if (m_mouse_handler.handle_key(key, context()))
|
if (m_mouse_handler.handle_key(key, context()))
|
||||||
|
{
|
||||||
|
if (not transient)
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
|
}
|
||||||
else if (key == Key::Escape or key == ctrl('c'))
|
else if (key == Key::Escape or key == ctrl('c'))
|
||||||
{
|
{
|
||||||
if (m_in_end)
|
if (m_in_end)
|
||||||
|
@ -1215,12 +1230,12 @@ public:
|
||||||
else if (key == ctrl('v'))
|
else if (key == ctrl('v'))
|
||||||
{
|
{
|
||||||
on_next_key_with_autoinfo(context(), KeymapMode::None,
|
on_next_key_with_autoinfo(context(), KeymapMode::None,
|
||||||
[this](Key key, Context&) {
|
[this, transient](Key key, Context&) {
|
||||||
if (auto cp = get_raw_codepoint(key))
|
if (auto cp = get_raw_codepoint(key))
|
||||||
{
|
{
|
||||||
insert(*cp);
|
insert(*cp);
|
||||||
context().hooks().run_hook("InsertKey", key_to_str(key), context());
|
context().hooks().run_hook("InsertKey", key_to_str(key), context());
|
||||||
if (enabled())
|
if (enabled() and not transient)
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
}
|
}
|
||||||
}, "raw insert", "enter key to insert");
|
}, "raw insert", "enter key to insert");
|
||||||
|
@ -1236,7 +1251,7 @@ public:
|
||||||
if (moved)
|
if (moved)
|
||||||
context().hooks().run_hook("InsertMove", key_to_str(key), context());
|
context().hooks().run_hook("InsertMove", key_to_str(key), context());
|
||||||
|
|
||||||
if (update_completions and enabled()) // Hooks might have disabled us
|
if (update_completions and enabled() and not transient) // Hooks might have disabled us
|
||||||
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user