summaryrefslogtreecommitdiff
path: root/src/commands.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-09-12 23:39:34 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-09-12 23:39:34 +0200
commitac7e437730ecbe32f9e4e168a3ee4a7b7f3cd761 (patch)
treecb5b0e413373ed209d092d476f0abf4a0eeb8209 /src/commands.cc
parent916a0cb52e8637d0e6ec456363ef6412142945da (diff)
Move Client responsibilities to InputHandler
InputHandler owns it's UserInterface, and is directly stored by the ClientManager.
Diffstat (limited to 'src/commands.cc')
-rw-r--r--src/commands.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 1dc7ba1c..7ec8c1f2 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -537,6 +537,26 @@ void declare_option(CommandParameters params, Context& context)
opt->set_from_string(params[2]);
}
+class DraftUI : public UserInterface
+{
+public:
+ void print_status(const DisplayLine&) override {}
+
+ void menu_show(memoryview<String>, DisplayCoord, ColorPair, ColorPair, MenuStyle) override {}
+ void menu_select(int) override {}
+ void menu_hide() override {}
+
+ void info_show(const String&, DisplayCoord, ColorPair, MenuStyle) override {}
+ void info_hide() override {}
+
+ void draw(const DisplayBuffer&, const DisplayLine&) override {}
+ DisplayCoord dimensions() override { return {0,0}; }
+ bool is_key_available() override { return false; }
+ Key get_key() override { return 'a'; }
+
+ void set_input_callback(InputCallback) override {}
+};
+
template<typename Func>
void context_wrap(CommandParameters params, Context& context, Func func)
{
@@ -549,9 +569,10 @@ void context_wrap(CommandParameters params, Context& context, Func func)
if (parser.has_option("draft"))
{
- InputHandler input_handler(real_context.ui());
Editor& editor = real_context.editor();
- input_handler.context().change_editor(editor);
+ InputHandler input_handler(std::unique_ptr<UserInterface>(new DraftUI()), editor,
+ real_context.has_input_handler() ?
+ real_context.input_handler().name() : "");
DynamicSelectionList sels{editor.buffer(), editor.selections()};
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
func(parser, input_handler.context());