Add InsertCompletionShow/InsertCompletionHide hooks
This commit is contained in:
parent
12f2815159
commit
532e3758fe
|
@ -1383,6 +1383,10 @@ existing hooks are:
|
|||
the filtering text is the client name.
|
||||
* `FocusOut`: On supported clients, triggered when the client gets unfocused.
|
||||
the filtering text is the client name.
|
||||
* `InsertCompletionShow`: Triggered when the insert completion menu gets
|
||||
displayed.
|
||||
* `InsertCompletionHide`: Triggered when the insert completion menu gets
|
||||
hidden.
|
||||
|
||||
When not specified, the filtering text is an empty string.
|
||||
|
||||
|
|
|
@ -143,4 +143,10 @@ Default hooks
|
|||
on supported clients, triggered when the client gets unfocused. the
|
||||
filtering text is the client name
|
||||
|
||||
*InsertCompletionShow*::
|
||||
Triggered when the insert completion menu gets displayed.
|
||||
|
||||
*InsertCompletionHide*::
|
||||
Triggered when the insert completion menu gets hidden.
|
||||
|
||||
When not specified, the filtering text is an empty string.
|
||||
|
|
|
@ -346,7 +346,7 @@ InsertCompletion complete_line(const SelectionList& sels, const OptionManager& o
|
|||
|
||||
}
|
||||
|
||||
InsertCompleter::InsertCompleter(const Context& context)
|
||||
InsertCompleter::InsertCompleter(Context& context)
|
||||
: m_context(context), m_options(context.options())
|
||||
{
|
||||
m_options.register_watcher(*this);
|
||||
|
@ -382,7 +382,7 @@ void InsertCompleter::select(int offset, Vector<Key>& keystrokes)
|
|||
{
|
||||
buffer.replace((pos - prefix_len).coord(),
|
||||
(pos + suffix_len).coord(), candidate.completion);
|
||||
const_cast<SelectionList&>(selections).update();
|
||||
selections.update();
|
||||
}
|
||||
}
|
||||
m_completions.end = cursor_pos;
|
||||
|
@ -423,6 +423,7 @@ void InsertCompleter::reset()
|
|||
{
|
||||
m_context.client().menu_hide();
|
||||
m_context.client().info_hide();
|
||||
m_context.hooks().run_hook("InsertCompletionHide", "", m_context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,6 +469,7 @@ void InsertCompleter::menu_show()
|
|||
m_context.client().menu_show(std::move(menu_entries), m_completions.begin,
|
||||
MenuStyle::Inline);
|
||||
m_context.client().menu_select(m_current_candidate);
|
||||
m_context.hooks().run_hook("InsertCompletionShow", "", m_context);
|
||||
}
|
||||
|
||||
void InsertCompleter::on_option_changed(const Option& opt)
|
||||
|
|
|
@ -75,7 +75,7 @@ struct InsertCompletion
|
|||
class InsertCompleter : public OptionManagerWatcher
|
||||
{
|
||||
public:
|
||||
InsertCompleter(const Context& context);
|
||||
InsertCompleter(Context& context);
|
||||
InsertCompleter(const InsertCompleter&) = delete;
|
||||
InsertCompleter& operator=(const InsertCompleter&) = delete;
|
||||
~InsertCompleter();
|
||||
|
@ -97,7 +97,7 @@ private:
|
|||
|
||||
void menu_show();
|
||||
|
||||
const Context& m_context;
|
||||
Context& m_context;
|
||||
OptionManager& m_options;
|
||||
InsertCompletion m_completions;
|
||||
int m_current_candidate = -1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user