rename InputHandler to Client
This commit is contained in:
parent
ac7e437730
commit
823812fd1a
|
@ -1,4 +1,4 @@
|
|||
#include "input_handler.hh"
|
||||
#include "client.hh"
|
||||
|
||||
#include "color_registry.hh"
|
||||
#include "context.hh"
|
||||
|
@ -20,21 +20,21 @@ namespace Kakoune
|
|||
class InputMode
|
||||
{
|
||||
public:
|
||||
InputMode(InputHandler& input_handler) : m_input_handler(input_handler) {}
|
||||
InputMode(Client& client) : m_client(client) {}
|
||||
virtual ~InputMode() {}
|
||||
InputMode(const InputMode&) = delete;
|
||||
InputMode& operator=(const InputMode&) = delete;
|
||||
|
||||
virtual void on_key(Key key) = 0;
|
||||
Context& context() const { return m_input_handler.context(); }
|
||||
Context& context() const { return m_client.context(); }
|
||||
|
||||
using Insertion = InputHandler::Insertion;
|
||||
Insertion& last_insert() { return m_input_handler.m_last_insert; }
|
||||
using Insertion = Client::Insertion;
|
||||
Insertion& last_insert() { return m_client.m_last_insert; }
|
||||
|
||||
protected:
|
||||
InputMode& reset_normal_mode();
|
||||
private:
|
||||
InputHandler& m_input_handler;
|
||||
Client& m_client;
|
||||
};
|
||||
|
||||
namespace InputModes
|
||||
|
@ -45,8 +45,8 @@ static constexpr std::chrono::milliseconds idle_timeout{100};
|
|||
class Normal : public InputMode
|
||||
{
|
||||
public:
|
||||
Normal(InputHandler& input_handler)
|
||||
: InputMode(input_handler),
|
||||
Normal(Client& client)
|
||||
: InputMode(client),
|
||||
m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) {
|
||||
context().hooks().run_hook("NormalIdle", "", context());
|
||||
}}
|
||||
|
@ -162,9 +162,9 @@ private:
|
|||
class Menu : public InputMode
|
||||
{
|
||||
public:
|
||||
Menu(InputHandler& input_handler, memoryview<String> choices,
|
||||
Menu(Client& client, memoryview<String> choices,
|
||||
MenuCallback callback)
|
||||
: InputMode(input_handler),
|
||||
: InputMode(client),
|
||||
m_callback(callback), m_choices(choices.begin(), choices.end()),
|
||||
m_selected(m_choices.begin())
|
||||
{
|
||||
|
@ -291,9 +291,9 @@ String common_prefix(memoryview<String> strings)
|
|||
class Prompt : public InputMode
|
||||
{
|
||||
public:
|
||||
Prompt(InputHandler& input_handler, const String& prompt,
|
||||
Prompt(Client& client, const String& prompt,
|
||||
ColorPair colors, Completer completer, PromptCallback callback)
|
||||
: InputMode(input_handler), m_prompt(prompt), m_prompt_colors(colors),
|
||||
: InputMode(client), m_prompt(prompt), m_prompt_colors(colors),
|
||||
m_completer(completer), m_callback(callback)
|
||||
{
|
||||
m_history_it = ms_history[m_prompt].end();
|
||||
|
@ -474,8 +474,8 @@ std::unordered_map<String, std::vector<String>> Prompt::ms_history;
|
|||
class NextKey : public InputMode
|
||||
{
|
||||
public:
|
||||
NextKey(InputHandler& input_handler, KeyCallback callback)
|
||||
: InputMode(input_handler), m_callback(callback) {}
|
||||
NextKey(Client& client, KeyCallback callback)
|
||||
: InputMode(client), m_callback(callback) {}
|
||||
|
||||
void on_key(Key key) override
|
||||
{
|
||||
|
@ -795,8 +795,8 @@ private:
|
|||
class Insert : public InputMode
|
||||
{
|
||||
public:
|
||||
Insert(InputHandler& input_handler, InsertMode mode)
|
||||
: InputMode(input_handler),
|
||||
Insert(Client& client, InsertMode mode)
|
||||
: InputMode(client),
|
||||
m_inserter(context().editor(), mode),
|
||||
m_completer(context()),
|
||||
m_idle_timer{Clock::now() + idle_timeout,
|
||||
|
@ -908,28 +908,28 @@ private:
|
|||
|
||||
InputMode& InputMode::reset_normal_mode()
|
||||
{
|
||||
m_input_handler.m_mode_trash.emplace_back(std::move(m_input_handler.m_mode));
|
||||
m_input_handler.m_mode.reset(new InputModes::Normal(m_input_handler));
|
||||
return *m_input_handler.m_mode;
|
||||
m_client.m_mode_trash.emplace_back(std::move(m_client.m_mode));
|
||||
m_client.m_mode.reset(new InputModes::Normal(m_client));
|
||||
return *m_client.m_mode;
|
||||
}
|
||||
|
||||
|
||||
InputHandler::InputHandler(std::unique_ptr<UserInterface>&& ui, Editor& editor, String name)
|
||||
Client::Client(std::unique_ptr<UserInterface>&& ui, Editor& editor, String name)
|
||||
: m_ui(std::move(ui)), m_context(*this, editor), m_mode(new InputModes::Normal(*this)), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
InputHandler::~InputHandler()
|
||||
Client::~Client()
|
||||
{
|
||||
}
|
||||
|
||||
void InputHandler::insert(InsertMode mode)
|
||||
void Client::insert(InsertMode mode)
|
||||
{
|
||||
m_mode_trash.emplace_back(std::move(m_mode));
|
||||
m_mode.reset(new InputModes::Insert(*this, mode));
|
||||
}
|
||||
|
||||
void InputHandler::repeat_last_insert()
|
||||
void Client::repeat_last_insert()
|
||||
{
|
||||
if (m_last_insert.second.empty())
|
||||
return;
|
||||
|
@ -945,7 +945,7 @@ void InputHandler::repeat_last_insert()
|
|||
kak_assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr);
|
||||
}
|
||||
|
||||
void InputHandler::prompt(const String& prompt, ColorPair prompt_colors,
|
||||
void Client::prompt(const String& prompt, ColorPair prompt_colors,
|
||||
Completer completer, PromptCallback callback)
|
||||
{
|
||||
m_mode_trash.emplace_back(std::move(m_mode));
|
||||
|
@ -953,21 +953,21 @@ void InputHandler::prompt(const String& prompt, ColorPair prompt_colors,
|
|||
completer, callback));
|
||||
}
|
||||
|
||||
void InputHandler::set_prompt_colors(ColorPair prompt_colors)
|
||||
void Client::set_prompt_colors(ColorPair prompt_colors)
|
||||
{
|
||||
InputModes::Prompt* prompt = dynamic_cast<InputModes::Prompt*>(m_mode.get());
|
||||
if (prompt)
|
||||
prompt->set_prompt_colors(prompt_colors);
|
||||
}
|
||||
|
||||
void InputHandler::menu(memoryview<String> choices,
|
||||
void Client::menu(memoryview<String> choices,
|
||||
MenuCallback callback)
|
||||
{
|
||||
m_mode_trash.emplace_back(std::move(m_mode));
|
||||
m_mode.reset(new InputModes::Menu(*this, choices, callback));
|
||||
}
|
||||
|
||||
void InputHandler::on_next_key(KeyCallback callback)
|
||||
void Client::on_next_key(KeyCallback callback)
|
||||
{
|
||||
m_mode_trash.emplace_back(std::move(m_mode));
|
||||
m_mode.reset(new InputModes::NextKey(*this, callback));
|
||||
|
@ -978,7 +978,7 @@ bool is_valid(Key key)
|
|||
return key != Key::Invalid and key.key <= 0x10FFFF;
|
||||
}
|
||||
|
||||
void InputHandler::handle_key(Key key)
|
||||
void Client::handle_key(Key key)
|
||||
{
|
||||
if (is_valid(key))
|
||||
{
|
||||
|
@ -993,19 +993,19 @@ void InputHandler::handle_key(Key key)
|
|||
m_mode_trash.clear();
|
||||
}
|
||||
|
||||
void InputHandler::start_recording(char reg)
|
||||
void Client::start_recording(char reg)
|
||||
{
|
||||
kak_assert(m_recording_reg == 0);
|
||||
m_recorded_keys = "";
|
||||
m_recording_reg = reg;
|
||||
}
|
||||
|
||||
bool InputHandler::is_recording() const
|
||||
bool Client::is_recording() const
|
||||
{
|
||||
return m_recording_reg != 0;
|
||||
}
|
||||
|
||||
void InputHandler::stop_recording()
|
||||
void Client::stop_recording()
|
||||
{
|
||||
kak_assert(m_recording_reg != 0);
|
||||
RegisterManager::instance()[m_recording_reg] = memoryview<String>(m_recorded_keys);
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef input_handler_hh_INCLUDED
|
||||
#define input_handler_hh_INCLUDED
|
||||
#ifndef client_hh_INCLUDED
|
||||
#define client_hh_INCLUDED
|
||||
|
||||
#include "color.hh"
|
||||
#include "completion.hh"
|
||||
|
@ -34,11 +34,11 @@ using KeyCallback = std::function<void (Key, Context&)>;
|
|||
class InputMode;
|
||||
enum class InsertMode : unsigned;
|
||||
|
||||
class InputHandler : public SafeCountable
|
||||
class Client : public SafeCountable
|
||||
{
|
||||
public:
|
||||
InputHandler(std::unique_ptr<UserInterface>&& ui, Editor& editor, String name);
|
||||
~InputHandler();
|
||||
Client(std::unique_ptr<UserInterface>&& ui, Editor& editor, String name);
|
||||
~Client();
|
||||
|
||||
// switch to insert mode
|
||||
void insert(InsertMode mode);
|
||||
|
@ -96,4 +96,4 @@ struct prompt_aborted {};
|
|||
|
||||
}
|
||||
|
||||
#endif // input_handler_hh_INCLUDED
|
||||
#endif // client_hh_INCLUDED
|
|
@ -33,11 +33,11 @@ String ClientManager::generate_name() const
|
|||
}
|
||||
}
|
||||
|
||||
InputHandler* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
||||
Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
||||
const String& init_commands)
|
||||
{
|
||||
Buffer& buffer = **BufferManager::instance().begin();
|
||||
InputHandler* client = new InputHandler{std::move(ui), get_unused_window_for_buffer(buffer),
|
||||
Client* client = new Client{std::move(ui), get_unused_window_for_buffer(buffer),
|
||||
generate_name()};
|
||||
m_clients.emplace_back(client);
|
||||
try
|
||||
|
@ -80,7 +80,7 @@ InputHandler* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
|||
return client;
|
||||
}
|
||||
|
||||
void ClientManager::remove_client(InputHandler& client)
|
||||
void ClientManager::remove_client(Client& client)
|
||||
{
|
||||
for (auto it = m_clients.begin(); it != m_clients.end(); ++it)
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ Window& ClientManager::get_unused_window_for_buffer(Buffer& buffer)
|
|||
continue;
|
||||
|
||||
auto it = std::find_if(m_clients.begin(), m_clients.end(),
|
||||
[&](const std::unique_ptr<InputHandler>& client)
|
||||
[&](const std::unique_ptr<Client>& client)
|
||||
{ return &client->context().window() == w.get(); });
|
||||
if (it == m_clients.end())
|
||||
{
|
||||
|
@ -145,16 +145,16 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer)
|
|||
m_windows.erase(end, m_windows.end());
|
||||
}
|
||||
|
||||
void ClientManager::set_client_name(InputHandler& client, String name)
|
||||
void ClientManager::set_client_name(Client& client, String name)
|
||||
{
|
||||
auto it = find_if(m_clients, [&name](std::unique_ptr<InputHandler>& client)
|
||||
auto it = find_if(m_clients, [&name](std::unique_ptr<Client>& client)
|
||||
{ return client->m_name == name; });
|
||||
if (it != m_clients.end() and it->get() != &client)
|
||||
throw runtime_error("name not unique: " + name);
|
||||
client.m_name = std::move(name);
|
||||
}
|
||||
|
||||
InputHandler& ClientManager::get_client(const Context& context)
|
||||
Client& ClientManager::get_client(const Context& context)
|
||||
{
|
||||
for (auto& client : m_clients)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ InputHandler& ClientManager::get_client(const Context& context)
|
|||
throw runtime_error("no client for current context");
|
||||
}
|
||||
|
||||
InputHandler& ClientManager::get_client(const String& name)
|
||||
Client& ClientManager::get_client(const String& name)
|
||||
{
|
||||
for (auto& client : m_clients)
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ InputHandler& ClientManager::get_client(const String& name)
|
|||
throw runtime_error("no client named: " + name);
|
||||
}
|
||||
|
||||
static DisplayLine generate_status_line(InputHandler& client)
|
||||
static DisplayLine generate_status_line(Client& client)
|
||||
{
|
||||
auto& context = client.context();
|
||||
auto pos = context.editor().main_selection().last();
|
||||
|
@ -185,7 +185,7 @@ static DisplayLine generate_status_line(InputHandler& client)
|
|||
<< " " << (int)pos.line+1 << ":" << (int)col+1;
|
||||
if (context.buffer().is_modified())
|
||||
oss << " [+]";
|
||||
if (context.input_handler().is_recording())
|
||||
if (context.client().is_recording())
|
||||
oss << " [recording]";
|
||||
if (context.buffer().flags() & Buffer::Flags::New)
|
||||
oss << " [new file]";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define client_manager_hh_INCLUDED
|
||||
|
||||
#include "context.hh"
|
||||
#include "input_handler.hh"
|
||||
#include "client.hh"
|
||||
|
||||
namespace Kakoune
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ public:
|
|||
ClientManager();
|
||||
~ClientManager();
|
||||
|
||||
InputHandler* create_client(std::unique_ptr<UserInterface>&& ui,
|
||||
Client* create_client(std::unique_ptr<UserInterface>&& ui,
|
||||
const String& init_cmd);
|
||||
|
||||
bool empty() const { return m_clients.empty(); }
|
||||
|
@ -26,15 +26,15 @@ public:
|
|||
|
||||
void redraw_clients() const;
|
||||
|
||||
InputHandler& get_client(const Context& context);
|
||||
InputHandler& get_client(const String& name);
|
||||
void set_client_name(InputHandler& client, String name);
|
||||
void remove_client(InputHandler& client);
|
||||
Client& get_client(const Context& context);
|
||||
Client& get_client(const String& name);
|
||||
void set_client_name(Client& client, String name);
|
||||
void remove_client(Client& client);
|
||||
|
||||
private:
|
||||
String generate_name() const;
|
||||
|
||||
std::vector<std::unique_ptr<InputHandler>> m_clients;
|
||||
std::vector<std::unique_ptr<Client>> m_clients;
|
||||
std::vector<std::unique_ptr<Window>> m_windows;
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "filter.hh"
|
||||
#include "highlighter.hh"
|
||||
#include "highlighters.hh"
|
||||
#include "input_handler.hh"
|
||||
#include "client.hh"
|
||||
#include "option_manager.hh"
|
||||
#include "option_types.hh"
|
||||
#include "parameters_parser.hh"
|
||||
|
@ -570,12 +570,12 @@ void context_wrap(CommandParameters params, Context& context, Func func)
|
|||
if (parser.has_option("draft"))
|
||||
{
|
||||
Editor& editor = real_context.editor();
|
||||
InputHandler input_handler(std::unique_ptr<UserInterface>(new DraftUI()), editor,
|
||||
real_context.has_input_handler() ?
|
||||
real_context.input_handler().name() : "");
|
||||
Client client(std::unique_ptr<UserInterface>(new DraftUI()), editor,
|
||||
real_context.has_client() ?
|
||||
real_context.client().name() : "");
|
||||
DynamicSelectionList sels{editor.buffer(), editor.selections()};
|
||||
auto restore_sels = on_scope_end([&]{ editor.select(sels); });
|
||||
func(parser, input_handler.context());
|
||||
func(parser, client.context());
|
||||
}
|
||||
else
|
||||
func(parser, real_context);
|
||||
|
@ -637,7 +637,7 @@ void menu(CommandParameters params, Context& context)
|
|||
select_cmds.push_back(parser[i+2]);
|
||||
}
|
||||
|
||||
context.input_handler().menu(choices,
|
||||
context.client().menu(choices,
|
||||
[=](int choice, MenuEvent event, Context& context) {
|
||||
if (event == MenuEvent::Validate and choice >= 0 and choice < commands.size())
|
||||
CommandManager::instance().execute(commands[choice], context);
|
||||
|
@ -860,7 +860,7 @@ void exec_keys(const KeyList& keys, Context& context)
|
|||
scoped_edition edition(context.editor());
|
||||
|
||||
for (auto& key : keys)
|
||||
context.input_handler().handle_key(key);
|
||||
context.client().handle_key(key);
|
||||
}
|
||||
|
||||
void register_commands()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "context.hh"
|
||||
|
||||
#include "input_handler.hh"
|
||||
#include "client.hh"
|
||||
#include "user_interface.hh"
|
||||
#include "window.hh"
|
||||
|
||||
|
@ -12,8 +12,8 @@ Context::Context() = default;
|
|||
Context::Context(Editor& editor)
|
||||
: m_editor(&editor) {}
|
||||
|
||||
Context::Context(InputHandler& input_handler, Editor& editor)
|
||||
: m_input_handler(&input_handler), m_editor(&editor) {}
|
||||
Context::Context(Client& client, Editor& editor)
|
||||
: m_client(&client), m_editor(&editor) {}
|
||||
|
||||
Context::~Context() = default;
|
||||
|
||||
|
@ -43,18 +43,18 @@ bool Context::has_window() const
|
|||
return (bool)m_editor and dynamic_cast<Window*>(m_editor.get());
|
||||
}
|
||||
|
||||
InputHandler& Context::input_handler() const
|
||||
Client& Context::client() const
|
||||
{
|
||||
if (not has_input_handler())
|
||||
if (not has_client())
|
||||
throw runtime_error("no input handler in context");
|
||||
return *m_input_handler;
|
||||
return *m_client;
|
||||
}
|
||||
|
||||
UserInterface& Context::ui() const
|
||||
{
|
||||
if (not has_ui())
|
||||
throw runtime_error("no user interface in context");
|
||||
return m_input_handler->ui();
|
||||
return m_client->ui();
|
||||
}
|
||||
|
||||
OptionManager& Context::options() const
|
||||
|
|
|
@ -9,21 +9,21 @@ namespace Kakoune
|
|||
class Editor;
|
||||
class Window;
|
||||
class Buffer;
|
||||
class InputHandler;
|
||||
class Client;
|
||||
class UserInterface;
|
||||
class DisplayLine;
|
||||
|
||||
// A Context is used to access non singleton objects for various services
|
||||
// in commands.
|
||||
//
|
||||
// The Context object links an InputHandler, an Editor (which may be a Window),
|
||||
// The Context object links an Client, an Editor (which may be a Window),
|
||||
// and a UserInterface. It may represent an interactive user window, or
|
||||
// a hook execution or a macro replay.
|
||||
struct Context
|
||||
{
|
||||
Context();
|
||||
explicit Context(Editor& editor);
|
||||
Context(InputHandler& input_handler, Editor& editor);
|
||||
Context(Client& client, Editor& editor);
|
||||
~Context();
|
||||
|
||||
Context(const Context&) = delete;
|
||||
|
@ -38,11 +38,11 @@ struct Context
|
|||
Window& window() const;
|
||||
bool has_window() const;
|
||||
|
||||
InputHandler& input_handler() const;
|
||||
bool has_input_handler() const { return (bool)m_input_handler; }
|
||||
Client& client() const;
|
||||
bool has_client() const { return (bool)m_client; }
|
||||
|
||||
UserInterface& ui() const;
|
||||
bool has_ui() const { return (bool)m_input_handler; }
|
||||
bool has_ui() const { return (bool)m_client; }
|
||||
|
||||
void change_editor(Editor& editor);
|
||||
|
||||
|
@ -59,7 +59,7 @@ struct Context
|
|||
int& numeric_param() { return m_numeric_param; }
|
||||
private:
|
||||
safe_ptr<Editor> m_editor;
|
||||
safe_ptr<InputHandler> m_input_handler;
|
||||
safe_ptr<Client> m_client;
|
||||
|
||||
int m_numeric_param = 0;
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ void create_local_client(const String& init_command)
|
|||
};
|
||||
|
||||
UserInterface* ui = new LocalNCursesUI{};
|
||||
static InputHandler* client = ClientManager::instance().create_client(
|
||||
static Client* client = ClientManager::instance().create_client(
|
||||
std::unique_ptr<UserInterface>{ui}, init_command);
|
||||
signal(SIGHUP, [](int) {
|
||||
if (client)
|
||||
|
|
|
@ -25,12 +25,12 @@ using namespace std::placeholders;
|
|||
template<InsertMode mode>
|
||||
void insert(Context& context)
|
||||
{
|
||||
context.input_handler().insert(mode);
|
||||
context.client().insert(mode);
|
||||
}
|
||||
|
||||
void repeat_insert(Context& context)
|
||||
{
|
||||
context.input_handler().repeat_last_insert();
|
||||
context.client().repeat_last_insert();
|
||||
}
|
||||
|
||||
bool show_auto_info_ifn(const String& info, const Context& context)
|
||||
|
@ -48,7 +48,7 @@ template<typename Cmd>
|
|||
void on_next_key_with_autoinfo(const Context& context, Cmd cmd, const std::string& info)
|
||||
{
|
||||
const bool hide = show_auto_info_ifn(info, context);
|
||||
context.input_handler().on_next_key([hide,cmd](Key key, Context& context) mutable {
|
||||
context.client().on_next_key([hide,cmd](Key key, Context& context) mutable {
|
||||
if (hide)
|
||||
context.ui().info_hide();
|
||||
cmd(key, context);
|
||||
|
@ -253,7 +253,7 @@ void for_each_char(Context& context)
|
|||
|
||||
void command(Context& context)
|
||||
{
|
||||
context.input_handler().prompt(
|
||||
context.client().prompt(
|
||||
":", get_color("Prompt"),
|
||||
std::bind(&CommandManager::complete, &CommandManager::instance(), _1, _2, _3),
|
||||
[](const String& cmdline, PromptEvent event, Context& context) {
|
||||
|
@ -264,7 +264,7 @@ void command(Context& context)
|
|||
|
||||
void pipe(Context& context)
|
||||
{
|
||||
context.input_handler().prompt("pipe:", get_color("Prompt"), complete_nothing,
|
||||
context.client().prompt("pipe:", get_color("Prompt"), complete_nothing,
|
||||
[](const String& cmdline, PromptEvent event, Context& context)
|
||||
{
|
||||
if (event != PromptEvent::Validate)
|
||||
|
@ -293,7 +293,7 @@ void search(Context& context)
|
|||
{
|
||||
const char* prompt = direction == Forward ? "search:" : "reverse search:";
|
||||
DynamicSelectionList selections{context.buffer(), context.editor().selections()};
|
||||
context.input_handler().prompt(prompt, get_color("Prompt"), complete_nothing,
|
||||
context.client().prompt(prompt, get_color("Prompt"), complete_nothing,
|
||||
[selections](const String& str, PromptEvent event, Context& context) {
|
||||
try
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ void search(Context& context)
|
|||
return;
|
||||
|
||||
Regex ex{str};
|
||||
context.input_handler().set_prompt_colors(get_color("Prompt"));
|
||||
context.client().set_prompt_colors(get_color("Prompt"));
|
||||
if (event == PromptEvent::Validate)
|
||||
{
|
||||
if (str.empty())
|
||||
|
@ -322,7 +322,7 @@ void search(Context& context)
|
|||
if (event == PromptEvent::Validate)
|
||||
throw runtime_error("regex error: "_str + err.what());
|
||||
else
|
||||
context.input_handler().set_prompt_colors(get_color("Error"));
|
||||
context.client().set_prompt_colors(get_color("Error"));
|
||||
}
|
||||
catch (runtime_error&)
|
||||
{
|
||||
|
@ -446,7 +446,7 @@ void paste(Context& context)
|
|||
template<typename T>
|
||||
void regex_prompt(Context& context, const String prompt, T on_validate)
|
||||
{
|
||||
context.input_handler().prompt(prompt, get_color("Prompt"), complete_nothing,
|
||||
context.client().prompt(prompt, get_color("Prompt"), complete_nothing,
|
||||
[=](const String& str, PromptEvent event, Context& context) {
|
||||
if (event == PromptEvent::Validate)
|
||||
{
|
||||
|
@ -462,7 +462,7 @@ void regex_prompt(Context& context, const String prompt, T on_validate)
|
|||
else if (event == PromptEvent::Change)
|
||||
{
|
||||
const bool ok = Regex{str, boost::regex_constants::no_except}.status() == 0;
|
||||
context.input_handler().set_prompt_colors(get_color(ok ? "Prompt" : "Error"));
|
||||
context.client().set_prompt_colors(get_color(ok ? "Prompt" : "Error"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -693,12 +693,12 @@ void select_to_next_char(Context& context)
|
|||
|
||||
void start_or_end_macro_recording(Context& context)
|
||||
{
|
||||
if (context.input_handler().is_recording())
|
||||
context.input_handler().stop_recording();
|
||||
if (context.client().is_recording())
|
||||
context.client().stop_recording();
|
||||
else
|
||||
on_next_key_with_autoinfo(context, [](Key key, Context& context) {
|
||||
if (key.modifiers == Key::Modifiers::None)
|
||||
context.input_handler().start_recording(key.key);
|
||||
context.client().start_recording(key.key);
|
||||
},
|
||||
"╭──┤record macro├──╮\n"
|
||||
"│ enter macro name │\n"
|
||||
|
|
Loading…
Reference in New Issue
Block a user