Factorize some duplicated completer code in register_commands
This commit is contained in:
parent
30d9e10ac6
commit
e57ddd3bab
|
@ -719,29 +719,27 @@ void register_commands()
|
||||||
{
|
{
|
||||||
CommandManager& cm = CommandManager::instance();
|
CommandManager& cm = CommandManager::instance();
|
||||||
|
|
||||||
cm.register_commands({ "e", "edit" }, edit<false>, CommandManager::None,
|
PerArgumentCommandCompleter filename_completer({ complete_filename });
|
||||||
PerArgumentCommandCompleter({ complete_filename }));
|
cm.register_commands({ "e", "edit" }, edit<false>,
|
||||||
cm.register_commands({ "e!", "edit!" }, edit<true>, CommandManager::None,
|
CommandManager::None, filename_completer);
|
||||||
PerArgumentCommandCompleter({ complete_filename }));
|
cm.register_commands({ "e!", "edit!" }, edit<true>,
|
||||||
|
CommandManager::None, filename_completer);
|
||||||
|
cm.register_commands({ "w", "write" }, write_buffer,
|
||||||
|
CommandManager::None, filename_completer);
|
||||||
cm.register_commands({ "q", "quit" }, quit<false>);
|
cm.register_commands({ "q", "quit" }, quit<false>);
|
||||||
cm.register_commands({ "q!", "quit!" }, quit<true>);
|
cm.register_commands({ "q!", "quit!" }, quit<true>);
|
||||||
cm.register_commands({ "w", "write" }, write_buffer,
|
|
||||||
CommandManager::None,
|
|
||||||
PerArgumentCommandCompleter({ complete_filename }));
|
|
||||||
cm.register_command("wq", write_and_quit<false>);
|
cm.register_command("wq", write_and_quit<false>);
|
||||||
cm.register_command("wq!", write_and_quit<true>);
|
cm.register_command("wq!", write_and_quit<true>);
|
||||||
|
|
||||||
|
PerArgumentCommandCompleter buffer_completer({
|
||||||
|
[](const String& prefix, size_t cursor_pos)
|
||||||
|
{ return BufferManager::instance().complete_buffername(prefix, cursor_pos); }
|
||||||
|
});
|
||||||
cm.register_commands({ "b", "buffer" }, show_buffer,
|
cm.register_commands({ "b", "buffer" }, show_buffer,
|
||||||
CommandManager::None,
|
CommandManager::None, buffer_completer);
|
||||||
PerArgumentCommandCompleter({
|
|
||||||
[](const String& prefix, size_t cursor_pos)
|
|
||||||
{ return BufferManager::instance().complete_buffername(prefix, cursor_pos); }
|
|
||||||
}));
|
|
||||||
cm.register_commands({ "db", "delbuf" }, delete_buffer,
|
cm.register_commands({ "db", "delbuf" }, delete_buffer,
|
||||||
CommandManager::None,
|
CommandManager::None, buffer_completer);
|
||||||
PerArgumentCommandCompleter({
|
|
||||||
[](const String& prefix, size_t cursor_pos)
|
|
||||||
{ return BufferManager::instance().complete_buffername(prefix, cursor_pos); }
|
|
||||||
}));
|
|
||||||
cm.register_commands({ "ah", "addhl" }, add_highlighter,
|
cm.register_commands({ "ah", "addhl" }, add_highlighter,
|
||||||
CommandManager::None,
|
CommandManager::None,
|
||||||
[](const CommandParameters& params, size_t token_to_complete, size_t pos_in_token)
|
[](const CommandParameters& params, size_t token_to_complete, size_t pos_in_token)
|
||||||
|
@ -770,23 +768,20 @@ void register_commands()
|
||||||
else
|
else
|
||||||
return w.highlighters().complete_id(arg, pos_in_token);
|
return w.highlighters().complete_id(arg, pos_in_token);
|
||||||
});
|
});
|
||||||
cm.register_commands({ "af", "addfilter" }, add_filter,
|
|
||||||
CommandManager::None,
|
PerArgumentCommandCompleter filter_completer({
|
||||||
PerArgumentCommandCompleter({
|
|
||||||
[](const String& prefix, size_t cursor_pos)
|
[](const String& prefix, size_t cursor_pos)
|
||||||
{ return FilterRegistry::instance().complete_filter(prefix, cursor_pos); }
|
{ return FilterRegistry::instance().complete_filter(prefix, cursor_pos); }
|
||||||
}));
|
});
|
||||||
|
cm.register_commands({ "af", "addfilter" }, add_filter,
|
||||||
|
CommandManager::None, filter_completer);
|
||||||
cm.register_commands({ "rf", "rmfilter" }, rm_filter,
|
cm.register_commands({ "rf", "rmfilter" }, rm_filter,
|
||||||
CommandManager::None,
|
CommandManager::None, filter_completer);
|
||||||
PerArgumentCommandCompleter({
|
|
||||||
[](const String& prefix, size_t cursor_pos)
|
|
||||||
{ return main_context.window().complete_filterid(prefix, cursor_pos); }
|
|
||||||
}));
|
|
||||||
cm.register_command("hook", add_hook, CommandManager::IgnoreSemiColons | CommandManager::DeferredShellEval);
|
cm.register_command("hook", add_hook, CommandManager::IgnoreSemiColons | CommandManager::DeferredShellEval);
|
||||||
|
|
||||||
cm.register_command("source", exec_commands_in_file,
|
cm.register_command("source", exec_commands_in_file,
|
||||||
CommandManager::None,
|
CommandManager::None, filename_completer);
|
||||||
PerArgumentCommandCompleter({ complete_filename }));
|
|
||||||
cm.register_command("runtime", exec_commands_in_runtime_file);
|
cm.register_command("runtime", exec_commands_in_runtime_file);
|
||||||
|
|
||||||
cm.register_command("exec", exec_string);
|
cm.register_command("exec", exec_string);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user