Rename Context::Flags::Transient to Context::Flags::Draft

Draft is well establish and all draft context are transient.
This commit is contained in:
Maxime Coste 2018-05-13 17:59:01 +10:00
parent b204e773d4
commit 75eb293f98
6 changed files with 19 additions and 19 deletions

View File

@ -695,7 +695,7 @@ void Buffer::run_hook_in_own_context(StringView hook_name, StringView param, Str
return; return;
InputHandler hook_handler{{ *this, Selection{} }, InputHandler hook_handler{{ *this, Selection{} },
Context::Flags::Transient, Context::Flags::Draft,
std::move(client_name)}; std::move(client_name)};
hooks().run_hook(hook_name, param, hook_handler.context()); hooks().run_hook(hook_name, param, hook_handler.context());
} }

View File

@ -1581,7 +1581,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
{ {
auto context_wrap_for_buffer = [&](Buffer& buffer) { auto context_wrap_for_buffer = [&](Buffer& buffer) {
InputHandler input_handler{{ buffer, Selection{} }, InputHandler input_handler{{ buffer, Selection{} },
Context::Flags::Transient}; Context::Flags::Draft};
Context& c = input_handler.context(); Context& c = input_handler.context();
ScopedSetBool disable_hooks(c.hooks_disabled(), no_hooks); ScopedSetBool disable_hooks(c.hooks_disabled(), no_hooks);
@ -1621,7 +1621,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
if (draft) if (draft)
{ {
input_handler.emplace(base_context->selections(), input_handler.emplace(base_context->selections(),
Context::Flags::Transient, Context::Flags::Draft,
base_context->name()); base_context->name());
effective_context = &input_handler->context(); effective_context = &input_handler->context();
@ -1675,7 +1675,7 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
} }
else else
{ {
const bool transient = c.flags() & Context::Flags::Transient; const bool transient = c.flags() & Context::Flags::Draft;
auto original_jump_list = transient ? Optional<JumpList>{} : c.jump_list(); auto original_jump_list = transient ? Optional<JumpList>{} : c.jump_list();
auto jump = transient ? Optional<SelectionList>{} : c.selections(); auto jump = transient ? Optional<SelectionList>{} : c.selections();

View File

@ -50,8 +50,8 @@ class Context
public: public:
enum class Flags enum class Flags
{ {
None = 0, None = 0,
Transient = 1, Draft = 1,
}; };
friend constexpr bool with_bit_ops(Meta::Type<Flags>) { return true; } friend constexpr bool with_bit_ops(Meta::Type<Flags>) { return true; }
@ -121,7 +121,7 @@ public:
JumpList& jump_list() { return m_jump_list; } JumpList& jump_list() { return m_jump_list; }
void push_jump(bool force = false) void push_jump(bool force = false)
{ {
if (force or not (m_flags & Flags::Transient)) if (force or not (m_flags & Flags::Draft))
m_jump_list.push(selections()); m_jump_list.push(selections());
} }

View File

@ -163,12 +163,12 @@ public:
Normal(InputHandler& input_handler, bool single_command = false) Normal(InputHandler& input_handler, bool single_command = false)
: InputMode(input_handler), : InputMode(input_handler),
m_idle_timer{TimePoint::max(), m_idle_timer{TimePoint::max(),
context().flags() & Context::Flags::Transient ? context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) { Timer::Callback{} : [this](Timer&) {
context().hooks().run_hook("NormalIdle", "", context()); context().hooks().run_hook("NormalIdle", "", context());
}}, }},
m_fs_check_timer{TimePoint::max(), m_fs_check_timer{TimePoint::max(),
context().flags() & Context::Flags::Transient ? context().flags() & Context::Flags::Draft ?
Timer::Callback{} : Timer::Callback{[this](Timer& timer) { Timer::Callback{} : Timer::Callback{[this](Timer& timer) {
if (context().has_client()) if (context().has_client())
context().client().check_if_buffer_needs_reloading(); context().client().check_if_buffer_needs_reloading();
@ -179,7 +179,7 @@ public:
void on_enabled() override void on_enabled() override
{ {
if (not (context().flags() & Context::Flags::Transient)) if (not (context().flags() & Context::Flags::Draft))
{ {
if (context().has_client()) if (context().has_client())
context().client().check_if_buffer_needs_reloading(); context().client().check_if_buffer_needs_reloading();
@ -234,7 +234,7 @@ public:
} }
}); });
const bool transient = context().flags() & Context::Flags::Transient; const bool transient = context().flags() & Context::Flags::Draft;
auto cp = key.codepoint(); auto cp = key.codepoint();
@ -709,7 +709,7 @@ public:
m_empty_text{std::move(emptystr)}, m_empty_text{std::move(emptystr)},
m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)), m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)),
m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()}, m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Transient ? m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) { Timer::Callback{} : [this](Timer&) {
if (m_autoshowcompl and m_refresh_completion_pending) if (m_autoshowcompl and m_refresh_completion_pending)
refresh_completions(CompletionFlags::Fast); refresh_completions(CompletionFlags::Fast);
@ -905,7 +905,7 @@ public:
display(); display();
m_line_changed = true; m_line_changed = true;
if (enabled() and not (context().flags() & Context::Flags::Transient)) // The callback might have disabled us if (enabled() and not (context().flags() & Context::Flags::Draft)) // 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()));
} }
@ -991,7 +991,7 @@ private:
display(); display();
m_line_changed = true; m_line_changed = true;
if (not (context().flags() & Context::Flags::Transient)) if (not (context().flags() & Context::Flags::Draft))
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context())); m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
} }
@ -1076,7 +1076,7 @@ public:
m_completer(context()), m_completer(context()),
m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()}, m_autoshowcompl{context().options()["autoshowcompl"].get<bool>()},
m_disable_hooks{context().hooks_disabled(), context().hooks_disabled()}, m_disable_hooks{context().hooks_disabled(), context().hooks_disabled()},
m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Transient ? m_idle_timer{TimePoint::max(), context().flags() & Context::Flags::Draft ?
Timer::Callback{} : [this](Timer&) { Timer::Callback{} : [this](Timer&) {
if (m_autoshowcompl) if (m_autoshowcompl)
m_completer.update(); m_completer.update();
@ -1096,7 +1096,7 @@ public:
void on_enabled() override void on_enabled() override
{ {
if (not (context().flags() & Context::Flags::Transient)) if (not (context().flags() & Context::Flags::Draft))
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context())); m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));
} }
@ -1124,7 +1124,7 @@ public:
{ {
auto& buffer = context().buffer(); auto& buffer = context().buffer();
const bool transient = context().flags() & Context::Flags::Transient; const bool transient = context().flags() & Context::Flags::Draft;
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()))

View File

@ -748,7 +748,7 @@ int run_filter(StringView keystr, ConstArrayView<StringView> files, bool quiet,
{ {
InputHandler input_handler{ InputHandler input_handler{
{ buffer, Selection{{0,0}, buffer.back_coord()} }, { buffer, Selection{{0,0}, buffer.back_coord()} },
Context::Flags::Transient Context::Flags::Draft
}; };
for (auto& key : keys) for (auto& key : keys)

View File

@ -333,7 +333,7 @@ void Window::run_hook_in_own_context(StringView hook_name, StringView param,
return; return;
InputHandler hook_handler{{ *m_buffer, Selection{} }, InputHandler hook_handler{{ *m_buffer, Selection{} },
Context::Flags::Transient, Context::Flags::Draft,
std::move(client_name)}; std::move(client_name)};
hook_handler.context().set_window(*this); hook_handler.context().set_window(*this);
if (m_client) if (m_client)