2013-09-13 01:47:23 +04:00
|
|
|
#include "client.hh"
|
2012-09-03 16:22:02 +04:00
|
|
|
|
2014-07-11 03:27:04 +04:00
|
|
|
#include "face_registry.hh"
|
2012-09-03 16:22:02 +04:00
|
|
|
#include "context.hh"
|
2013-05-20 16:10:53 +04:00
|
|
|
#include "buffer_manager.hh"
|
2015-09-19 14:43:39 +03:00
|
|
|
#include "buffer_utils.hh"
|
2013-08-02 20:58:37 +04:00
|
|
|
#include "file.hh"
|
2013-10-11 21:43:23 +04:00
|
|
|
#include "remote.hh"
|
2013-10-15 21:51:31 +04:00
|
|
|
#include "client_manager.hh"
|
2015-09-19 14:43:39 +03:00
|
|
|
#include "command_manager.hh"
|
2014-11-25 04:00:18 +03:00
|
|
|
#include "event_manager.hh"
|
2016-02-27 20:23:13 +03:00
|
|
|
#include "user_interface.hh"
|
2013-11-15 01:12:59 +04:00
|
|
|
#include "window.hh"
|
2012-09-03 16:22:02 +04:00
|
|
|
|
2014-11-25 04:00:18 +03:00
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2012-09-03 16:22:02 +04:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
Client::Client(std::unique_ptr<UserInterface>&& ui,
|
|
|
|
std::unique_ptr<Window>&& window,
|
2014-04-08 00:25:44 +04:00
|
|
|
SelectionList selections,
|
|
|
|
EnvVarMap env_vars,
|
|
|
|
String name)
|
2013-12-21 00:10:08 +04:00
|
|
|
: m_ui{std::move(ui)}, m_window{std::move(window)},
|
2014-12-19 02:12:58 +03:00
|
|
|
m_input_handler{std::move(selections), Context::Flags::None,
|
2014-04-08 00:25:44 +04:00
|
|
|
std::move(name)},
|
|
|
|
m_env_vars(env_vars)
|
2013-11-14 22:09:15 +04:00
|
|
|
{
|
2016-05-09 15:48:48 +03:00
|
|
|
m_window->set_client(this);
|
|
|
|
|
2013-11-14 22:09:15 +04:00
|
|
|
context().set_client(*this);
|
2013-12-21 00:10:08 +04:00
|
|
|
context().set_window(*m_window);
|
2014-11-11 02:29:16 +03:00
|
|
|
|
2016-02-27 20:23:13 +03:00
|
|
|
m_window->set_dimensions(m_ui->dimensions());
|
2014-11-11 02:29:16 +03:00
|
|
|
m_window->options().register_watcher(*this);
|
2016-02-27 20:23:13 +03:00
|
|
|
|
2014-11-11 02:29:16 +03:00
|
|
|
m_ui->set_ui_options(m_window->options()["ui_options"].get<UserInterface::Options>());
|
2016-02-27 20:23:13 +03:00
|
|
|
m_ui->set_input_callback([this](EventMode mode) { handle_available_input(mode); });
|
2016-11-03 22:09:52 +03:00
|
|
|
|
|
|
|
m_window->hooks().run_hook("WinDisplay", m_window->buffer().name(), context());
|
|
|
|
|
2016-03-08 02:11:59 +03:00
|
|
|
force_redraw();
|
2013-11-14 22:09:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Client::~Client()
|
|
|
|
{
|
2014-11-11 02:29:16 +03:00
|
|
|
m_window->options().unregister_watcher(*this);
|
2016-05-09 15:48:48 +03:00
|
|
|
m_window->set_client(nullptr);
|
2013-11-14 22:09:15 +04:00
|
|
|
}
|
|
|
|
|
2014-11-29 23:14:52 +03:00
|
|
|
Optional<Key> Client::get_next_key(EventMode mode)
|
|
|
|
{
|
|
|
|
if (not m_pending_keys.empty())
|
|
|
|
{
|
|
|
|
Key key = m_pending_keys.front();
|
|
|
|
m_pending_keys.erase(m_pending_keys.begin());
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
if (mode != EventMode::Pending and m_ui->is_key_available())
|
|
|
|
return m_ui->get_key();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2014-11-25 04:00:18 +03:00
|
|
|
void Client::handle_available_input(EventMode mode)
|
2013-11-14 22:09:15 +04:00
|
|
|
{
|
2014-11-29 23:14:52 +03:00
|
|
|
if (mode == EventMode::Urgent)
|
|
|
|
{
|
|
|
|
Key key = m_ui->get_key();
|
|
|
|
if (key == ctrl('c'))
|
|
|
|
killpg(getpgrp(), SIGINT);
|
|
|
|
else
|
|
|
|
m_pending_keys.push_back(key);
|
2015-07-22 15:30:03 +03:00
|
|
|
return;
|
2014-11-29 23:14:52 +03:00
|
|
|
}
|
2015-07-22 15:30:03 +03:00
|
|
|
|
|
|
|
try
|
2014-11-25 04:00:18 +03:00
|
|
|
{
|
2016-11-26 16:29:17 +03:00
|
|
|
const bool debug_keys = (bool)(context().options()["debug"].get<DebugFlags>() & DebugFlags::Keys);
|
|
|
|
|
2016-09-04 19:54:07 +03:00
|
|
|
while (Optional<Key> key = get_next_key(mode))
|
2014-11-25 04:00:18 +03:00
|
|
|
{
|
2016-11-26 16:29:17 +03:00
|
|
|
if (debug_keys)
|
|
|
|
write_to_debug_buffer(format("Client '{}' got key '{}'",
|
|
|
|
context().name(), key_to_str(*key)));
|
|
|
|
|
2016-09-04 19:54:07 +03:00
|
|
|
if (*key == ctrl('c'))
|
|
|
|
killpg(getpgrp(), SIGINT);
|
|
|
|
else if (*key == Key::FocusIn)
|
|
|
|
context().hooks().run_hook("FocusIn", context().name(), context());
|
|
|
|
else if (*key == Key::FocusOut)
|
|
|
|
context().hooks().run_hook("FocusOut", context().name(), context());
|
|
|
|
else if (key->modifiers == Key::Modifiers::Resize)
|
2015-12-14 22:06:30 +03:00
|
|
|
{
|
2016-09-04 19:54:07 +03:00
|
|
|
m_window->set_dimensions(m_ui->dimensions());
|
|
|
|
force_redraw();
|
2015-12-14 22:06:30 +03:00
|
|
|
}
|
2016-09-04 19:54:07 +03:00
|
|
|
else
|
|
|
|
m_input_handler.handle_key(*key);
|
2014-11-25 04:00:18 +03:00
|
|
|
}
|
2015-07-22 15:30:03 +03:00
|
|
|
}
|
2016-09-04 19:54:07 +03:00
|
|
|
catch (Kakoune::runtime_error& error)
|
2015-07-22 15:30:03 +03:00
|
|
|
{
|
2016-09-04 19:54:07 +03:00
|
|
|
context().print_status({ error.what().str(), get_face("Error") });
|
|
|
|
context().hooks().run_hook("RuntimeError", error.what(), context());
|
2015-07-22 15:30:03 +03:00
|
|
|
}
|
2013-11-14 22:09:15 +04:00
|
|
|
}
|
|
|
|
|
2016-10-29 13:25:58 +03:00
|
|
|
void Client::print_status(DisplayLine status_line, bool immediate)
|
2013-09-16 22:15:13 +04:00
|
|
|
{
|
2016-03-08 02:11:59 +03:00
|
|
|
m_status_line = std::move(status_line);
|
2016-10-29 13:25:58 +03:00
|
|
|
if (immediate)
|
|
|
|
{
|
|
|
|
m_ui->draw_status(m_status_line, m_mode_line, get_face("StatusLine"));
|
|
|
|
m_ui->refresh(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ui_pending |= StatusLine;
|
|
|
|
}
|
2013-09-16 22:15:13 +04:00
|
|
|
}
|
|
|
|
|
2016-11-29 22:53:11 +03:00
|
|
|
|
|
|
|
DisplayCoord Client::dimensions() const
|
|
|
|
{
|
|
|
|
return m_ui->dimensions();
|
|
|
|
}
|
|
|
|
|
2013-10-11 00:34:19 +04:00
|
|
|
DisplayLine Client::generate_mode_line() const
|
2013-09-16 22:15:13 +04:00
|
|
|
{
|
2015-09-19 14:43:39 +03:00
|
|
|
DisplayLine modeline;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const String& modelinefmt = context().options()["modelinefmt"].get<String>();
|
|
|
|
|
2015-09-20 13:34:13 +03:00
|
|
|
modeline = parse_display_line(expand(modelinefmt, context()));
|
2015-09-19 14:43:39 +03:00
|
|
|
}
|
|
|
|
catch (runtime_error& err)
|
|
|
|
{
|
|
|
|
write_to_debug_buffer(format("Error while parsing modelinefmt: {}", err.what()));
|
|
|
|
modeline.push_back({ "modelinefmt error, see *debug* buffer", get_face("Error") });
|
|
|
|
}
|
2013-09-16 22:15:13 +04:00
|
|
|
|
2014-07-11 03:27:04 +04:00
|
|
|
Face info_face = get_face("Information");
|
2014-07-07 22:57:03 +04:00
|
|
|
|
2013-10-11 00:34:19 +04:00
|
|
|
if (context().buffer().is_modified())
|
2015-09-19 14:43:39 +03:00
|
|
|
modeline.push_back({ "[+]", info_face });
|
2013-11-14 22:09:15 +04:00
|
|
|
if (m_input_handler.is_recording())
|
2015-09-19 14:43:39 +03:00
|
|
|
modeline.push_back({ format("[recording ({})]", m_input_handler.recording_reg()), info_face });
|
2013-10-11 00:34:19 +04:00
|
|
|
if (context().buffer().flags() & Buffer::Flags::New)
|
2015-09-19 14:43:39 +03:00
|
|
|
modeline.push_back({ "[new file]", info_face });
|
2016-09-27 01:43:05 +03:00
|
|
|
if (context().hooks_disabled())
|
2015-09-19 14:43:39 +03:00
|
|
|
modeline.push_back({ "[no-hooks]", info_face });
|
2014-07-07 22:57:03 +04:00
|
|
|
if (context().buffer().flags() & Buffer::Flags::Fifo)
|
2015-09-19 14:43:39 +03:00
|
|
|
modeline.push_back({ "[fifo]", info_face });
|
|
|
|
modeline.push_back({ " " });
|
2014-09-10 22:06:53 +04:00
|
|
|
for (auto& atom : m_input_handler.mode_line())
|
2015-09-19 14:43:39 +03:00
|
|
|
modeline.push_back(std::move(atom));
|
|
|
|
modeline.push_back({ format(" - {}@[{}]", context().name(), Server::instance().session()) });
|
2014-07-07 22:57:03 +04:00
|
|
|
|
2015-09-19 14:43:39 +03:00
|
|
|
return modeline;
|
2013-09-16 22:15:13 +04:00
|
|
|
}
|
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
void Client::change_buffer(Buffer& buffer)
|
|
|
|
{
|
2015-02-12 17:55:02 +03:00
|
|
|
if (m_buffer_reload_dialog_opened)
|
|
|
|
close_buffer_reload_dialog();
|
|
|
|
|
2016-10-13 23:37:44 +03:00
|
|
|
auto* current = &m_window->buffer();
|
|
|
|
m_last_buffer = contains(BufferManager::instance(), current) ? current : nullptr;
|
2015-11-07 21:24:08 +03:00
|
|
|
|
2014-04-01 21:54:46 +04:00
|
|
|
auto& client_manager = ClientManager::instance();
|
2014-11-11 02:29:16 +03:00
|
|
|
m_window->options().unregister_watcher(*this);
|
2016-05-09 15:48:48 +03:00
|
|
|
m_window->set_client(nullptr);
|
2014-04-01 21:54:46 +04:00
|
|
|
client_manager.add_free_window(std::move(m_window),
|
|
|
|
std::move(context().selections()));
|
|
|
|
WindowAndSelections ws = client_manager.get_free_window(buffer);
|
2014-11-11 02:29:16 +03:00
|
|
|
|
2014-01-28 00:28:38 +04:00
|
|
|
m_window = std::move(ws.window);
|
2016-05-09 15:48:48 +03:00
|
|
|
m_window->set_client(this);
|
2014-11-11 02:29:16 +03:00
|
|
|
m_window->options().register_watcher(*this);
|
|
|
|
m_ui->set_ui_options(m_window->options()["ui_options"].get<UserInterface::Options>());
|
|
|
|
|
2015-04-19 17:12:16 +03:00
|
|
|
context().selections_write_only() = std::move(ws.selections);
|
2013-12-21 00:10:08 +04:00
|
|
|
context().set_window(*m_window);
|
2016-02-27 20:23:13 +03:00
|
|
|
m_window->set_dimensions(m_ui->dimensions());
|
2016-03-08 02:11:59 +03:00
|
|
|
force_redraw();
|
2014-11-11 02:29:16 +03:00
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
m_window->hooks().run_hook("WinDisplay", buffer.name(), context());
|
|
|
|
}
|
|
|
|
|
2016-02-27 20:23:13 +03:00
|
|
|
static bool is_inline(InfoStyle style)
|
|
|
|
{
|
|
|
|
return style == InfoStyle::Inline or
|
|
|
|
style == InfoStyle::InlineAbove or
|
|
|
|
style == InfoStyle::InlineBelow;
|
|
|
|
}
|
|
|
|
|
2016-03-08 02:11:59 +03:00
|
|
|
void Client::redraw_ifn()
|
2013-09-16 22:15:13 +04:00
|
|
|
{
|
2015-06-22 15:34:22 +03:00
|
|
|
Window& window = context().window();
|
2016-03-08 02:11:59 +03:00
|
|
|
if (window.needs_redraw(context()))
|
|
|
|
m_ui_pending |= Draw;
|
2015-06-17 23:28:02 +03:00
|
|
|
|
2016-03-08 02:11:59 +03:00
|
|
|
DisplayLine mode_line = generate_mode_line();
|
|
|
|
if (mode_line.atoms() != m_mode_line.atoms())
|
|
|
|
{
|
|
|
|
m_ui_pending |= StatusLine;
|
|
|
|
m_mode_line = std::move(mode_line);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_ui_pending == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_ui_pending & Draw)
|
2016-02-27 20:23:13 +03:00
|
|
|
{
|
2016-04-11 15:44:10 +03:00
|
|
|
m_ui->draw(window.update_display_buffer(context()),
|
|
|
|
get_face("Default"), get_face("BufferPadding"));
|
2016-02-27 20:23:13 +03:00
|
|
|
|
2016-03-30 21:46:43 +03:00
|
|
|
if (not m_menu.items.empty() and m_menu.style == MenuStyle::Inline and
|
|
|
|
m_menu.ui_anchor != window.display_position(m_menu.anchor))
|
|
|
|
m_ui_pending |= (MenuShow | MenuSelect);
|
|
|
|
if (not m_info.content.empty() and is_inline(m_info.style) and
|
|
|
|
m_info.ui_anchor != window.display_position(m_info.anchor))
|
|
|
|
m_ui_pending |= InfoShow;
|
2016-02-27 20:23:13 +03:00
|
|
|
}
|
2015-06-17 23:28:02 +03:00
|
|
|
|
2016-03-08 02:11:59 +03:00
|
|
|
if (m_ui_pending & MenuShow)
|
2013-09-16 22:15:13 +04:00
|
|
|
{
|
2016-03-30 21:46:43 +03:00
|
|
|
m_menu.ui_anchor = m_menu.style == MenuStyle::Inline ?
|
2016-09-22 22:36:26 +03:00
|
|
|
window.display_position(m_menu.anchor) : DisplayCoord{};
|
2016-03-30 21:46:43 +03:00
|
|
|
m_ui->menu_show(m_menu.items, m_menu.ui_anchor,
|
2016-03-08 02:11:59 +03:00
|
|
|
get_face("MenuForeground"), get_face("MenuBackground"),
|
|
|
|
m_menu.style);
|
2013-09-16 22:15:13 +04:00
|
|
|
}
|
2016-03-08 02:11:59 +03:00
|
|
|
if (m_ui_pending & MenuSelect)
|
|
|
|
m_ui->menu_select(m_menu.selected);
|
|
|
|
if (m_ui_pending & MenuHide)
|
|
|
|
m_ui->menu_hide();
|
2015-06-17 23:28:02 +03:00
|
|
|
|
2016-03-08 02:11:59 +03:00
|
|
|
if (m_ui_pending & InfoShow)
|
2016-03-05 16:53:21 +03:00
|
|
|
{
|
2016-03-30 21:46:43 +03:00
|
|
|
m_info.ui_anchor = is_inline(m_info.style) ?
|
2016-09-22 22:36:26 +03:00
|
|
|
window.display_position(m_info.anchor) : DisplayCoord{};
|
2016-03-30 21:46:43 +03:00
|
|
|
m_ui->info_show(m_info.title, m_info.content, m_info.ui_anchor,
|
2016-03-08 02:11:59 +03:00
|
|
|
get_face("Information"), m_info.style);
|
2016-03-05 16:53:21 +03:00
|
|
|
}
|
2016-03-08 02:11:59 +03:00
|
|
|
if (m_ui_pending & InfoHide)
|
|
|
|
m_ui->info_hide();
|
|
|
|
|
|
|
|
if (m_ui_pending & StatusLine)
|
|
|
|
m_ui->draw_status(m_status_line, m_mode_line, get_face("StatusLine"));
|
|
|
|
|
|
|
|
m_ui->refresh(m_ui_pending | Refresh);
|
|
|
|
m_ui_pending = 0;
|
2013-09-16 22:15:13 +04:00
|
|
|
}
|
|
|
|
|
2015-08-23 15:29:24 +03:00
|
|
|
void Client::force_redraw()
|
|
|
|
{
|
2016-03-09 00:35:56 +03:00
|
|
|
m_ui_pending |= Refresh | Draw | StatusLine |
|
2016-03-08 16:42:00 +03:00
|
|
|
(m_menu.items.empty() ? MenuHide : MenuShow | MenuSelect) |
|
|
|
|
(m_info.content.empty() ? InfoHide : InfoShow);
|
2015-08-23 15:29:24 +03:00
|
|
|
}
|
|
|
|
|
2015-02-12 17:55:02 +03:00
|
|
|
void Client::reload_buffer()
|
|
|
|
{
|
2015-10-16 03:33:17 +03:00
|
|
|
Buffer& buffer = context().buffer();
|
2015-10-16 15:58:56 +03:00
|
|
|
reload_file_buffer(buffer);
|
|
|
|
context().print_status({ format("'{}' reloaded", buffer.display_name()),
|
|
|
|
get_face("Information") });
|
2015-02-12 17:55:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::on_buffer_reload_key(Key key)
|
2013-10-21 21:58:11 +04:00
|
|
|
{
|
2015-02-12 17:55:02 +03:00
|
|
|
auto& buffer = context().buffer();
|
|
|
|
|
2016-07-05 21:21:15 +03:00
|
|
|
if (key == 'y' or key == Key::Return)
|
2015-02-12 17:55:02 +03:00
|
|
|
reload_buffer();
|
|
|
|
else if (key == 'n' or key == Key::Escape)
|
|
|
|
{
|
|
|
|
// reread timestamp in case the file was modified again
|
|
|
|
buffer.set_fs_timestamp(get_fs_timestamp(buffer.name()));
|
2015-06-01 23:15:59 +03:00
|
|
|
print_status({ format("'{}' kept", buffer.display_name()),
|
2015-02-12 17:55:02 +03:00
|
|
|
get_face("Information") });
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-01 23:15:59 +03:00
|
|
|
print_status({ format("'{}' is not a valid choice", key_to_str(key)),
|
2015-02-12 17:55:02 +03:00
|
|
|
get_face("Error") });
|
|
|
|
m_input_handler.on_next_key(KeymapMode::None, [this](Key key, Context&){ on_buffer_reload_key(key); });
|
2013-10-21 21:58:11 +04:00
|
|
|
return;
|
2015-02-12 17:55:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& client : ClientManager::instance())
|
|
|
|
{
|
|
|
|
if (&client->context().buffer() == &buffer and
|
|
|
|
client->m_buffer_reload_dialog_opened)
|
|
|
|
client->close_buffer_reload_dialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::close_buffer_reload_dialog()
|
|
|
|
{
|
|
|
|
kak_assert(m_buffer_reload_dialog_opened);
|
|
|
|
m_buffer_reload_dialog_opened = false;
|
2016-06-16 21:35:43 +03:00
|
|
|
info_hide();
|
2015-02-12 17:55:02 +03:00
|
|
|
m_input_handler.reset_normal_mode();
|
2013-10-21 21:58:11 +04:00
|
|
|
}
|
|
|
|
|
2015-02-12 17:55:02 +03:00
|
|
|
void Client::check_if_buffer_needs_reloading()
|
2013-10-15 21:51:31 +04:00
|
|
|
{
|
2015-03-04 23:46:26 +03:00
|
|
|
if (m_buffer_reload_dialog_opened)
|
|
|
|
return;
|
|
|
|
|
2013-11-14 22:09:15 +04:00
|
|
|
Buffer& buffer = context().buffer();
|
2015-11-20 11:50:53 +03:00
|
|
|
auto reload = context().options()["autoreload"].get<Autoreload>();
|
|
|
|
if (not (buffer.flags() & Buffer::Flags::File) or reload == Autoreload::No)
|
2013-10-15 21:51:31 +04:00
|
|
|
return;
|
2013-10-21 21:58:11 +04:00
|
|
|
|
|
|
|
const String& filename = buffer.name();
|
2015-09-27 13:55:34 +03:00
|
|
|
timespec ts = get_fs_timestamp(filename);
|
2014-06-22 14:09:44 +04:00
|
|
|
if (ts == InvalidTime or ts == buffer.fs_timestamp())
|
2013-10-21 21:58:11 +04:00
|
|
|
return;
|
2015-11-20 11:50:53 +03:00
|
|
|
if (reload == Autoreload::Ask)
|
2013-10-15 21:51:31 +04:00
|
|
|
{
|
2016-03-02 16:14:21 +03:00
|
|
|
StringView bufname = buffer.display_name();
|
|
|
|
info_show(format("reload '{}' ?", bufname),
|
|
|
|
format("'{}' was modified externally\n"
|
|
|
|
"press <ret> or y to reload, <esc> or n to keep",
|
|
|
|
bufname), {}, InfoStyle::Prompt);
|
2014-03-24 23:31:40 +04:00
|
|
|
|
2015-02-12 17:55:02 +03:00
|
|
|
m_buffer_reload_dialog_opened = true;
|
|
|
|
m_input_handler.on_next_key(KeymapMode::None, [this](Key key, Context&){ on_buffer_reload_key(key); });
|
2013-10-15 21:51:31 +04:00
|
|
|
}
|
2013-10-21 21:58:11 +04:00
|
|
|
else
|
2015-02-12 17:55:02 +03:00
|
|
|
reload_buffer();
|
2013-10-15 21:51:31 +04:00
|
|
|
}
|
|
|
|
|
2015-09-16 21:57:57 +03:00
|
|
|
StringView Client::get_env_var(StringView name) const
|
2014-04-08 00:25:44 +04:00
|
|
|
{
|
|
|
|
auto it = m_env_vars.find(name);
|
|
|
|
if (it == m_env_vars.end())
|
2014-12-20 21:40:17 +03:00
|
|
|
return {};
|
2015-09-16 21:57:57 +03:00
|
|
|
return it->value;
|
2015-03-10 22:33:46 +03:00
|
|
|
}
|
|
|
|
|
2014-11-11 02:29:16 +03:00
|
|
|
void Client::on_option_changed(const Option& option)
|
|
|
|
{
|
|
|
|
if (option.name() == "ui_options")
|
2016-03-05 16:53:21 +03:00
|
|
|
{
|
2014-11-11 02:29:16 +03:00
|
|
|
m_ui->set_ui_options(option.get<UserInterface::Options>());
|
2016-03-08 02:11:59 +03:00
|
|
|
m_ui_pending |= Draw;
|
2016-03-05 16:53:21 +03:00
|
|
|
}
|
2014-11-11 02:29:16 +03:00
|
|
|
}
|
|
|
|
|
2016-09-22 22:36:26 +03:00
|
|
|
void Client::menu_show(Vector<DisplayLine> choices, BufferCoord anchor, MenuStyle style)
|
2016-02-27 20:23:13 +03:00
|
|
|
{
|
2016-03-30 21:46:43 +03:00
|
|
|
m_menu = Menu{ std::move(choices), anchor, {}, style, -1 };
|
2016-03-08 02:11:59 +03:00
|
|
|
m_ui_pending |= MenuShow;
|
|
|
|
m_ui_pending &= ~MenuHide;
|
2016-02-27 20:23:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::menu_select(int selected)
|
|
|
|
{
|
|
|
|
m_menu.selected = selected;
|
2016-03-08 02:11:59 +03:00
|
|
|
m_ui_pending |= MenuSelect;
|
|
|
|
m_ui_pending &= ~MenuHide;
|
2016-02-27 20:23:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::menu_hide()
|
|
|
|
{
|
|
|
|
m_menu = Menu{};
|
2016-03-08 02:11:59 +03:00
|
|
|
m_ui_pending |= MenuHide;
|
|
|
|
m_ui_pending &= ~(MenuShow | MenuSelect);
|
2016-02-27 20:23:13 +03:00
|
|
|
}
|
|
|
|
|
2016-09-22 22:36:26 +03:00
|
|
|
void Client::info_show(String title, String content, BufferCoord anchor, InfoStyle style)
|
2016-02-27 20:23:13 +03:00
|
|
|
{
|
2016-03-30 21:46:43 +03:00
|
|
|
m_info = Info{ std::move(title), std::move(content), anchor, {}, style };
|
2016-03-08 02:11:59 +03:00
|
|
|
m_ui_pending |= InfoShow;
|
|
|
|
m_ui_pending &= ~InfoHide;
|
2016-02-27 20:23:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::info_hide()
|
|
|
|
{
|
|
|
|
m_info = Info{};
|
2016-03-08 02:11:59 +03:00
|
|
|
m_ui_pending |= InfoHide;
|
|
|
|
m_ui_pending &= ~InfoShow;
|
2016-02-27 20:23:13 +03:00
|
|
|
}
|
|
|
|
|
2012-09-03 16:22:02 +04:00
|
|
|
}
|