Move client drawing responsiblity to the ClientManager
This commit is contained in:
parent
a41bb34b21
commit
3daac4883e
|
@ -16,6 +16,7 @@ void ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
input_handler->handle_available_inputs(*context);
|
input_handler->handle_available_inputs(*context);
|
||||||
|
context->window().forget_timestamp();
|
||||||
}
|
}
|
||||||
catch (Kakoune::runtime_error& error)
|
catch (Kakoune::runtime_error& error)
|
||||||
{
|
{
|
||||||
|
@ -26,8 +27,9 @@ void ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
|
||||||
EventManager::instance().unwatch(event_fd);
|
EventManager::instance().unwatch(event_fd);
|
||||||
close(event_fd);
|
close(event_fd);
|
||||||
}
|
}
|
||||||
|
ClientManager::instance().redraw_clients();
|
||||||
});
|
});
|
||||||
context->draw_ifn();
|
redraw_clients();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientManager::remove_client_by_context(Context& context)
|
void ClientManager::remove_client_by_context(Context& context)
|
||||||
|
@ -52,9 +54,30 @@ Window& ClientManager::get_unused_window_for_buffer(Buffer& buffer) const
|
||||||
return &client.context->window() == w.get();
|
return &client.context->window() == w.get();
|
||||||
});
|
});
|
||||||
if (it == m_clients.end())
|
if (it == m_clients.end())
|
||||||
|
{
|
||||||
|
w->forget_timestamp();
|
||||||
return *w;
|
return *w;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return buffer.new_window();
|
return buffer.new_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientManager::redraw_clients() const
|
||||||
|
{
|
||||||
|
for (auto& client : m_clients)
|
||||||
|
{
|
||||||
|
Context& context = *client.context;
|
||||||
|
if (context.window().timestamp() != context.buffer().timestamp())
|
||||||
|
{
|
||||||
|
DisplayCoord dimensions = context.ui().dimensions();
|
||||||
|
if (dimensions == DisplayCoord{0,0})
|
||||||
|
return;
|
||||||
|
context.window().set_dimensions(dimensions);
|
||||||
|
context.window().update_display_buffer();;
|
||||||
|
context.ui().draw(context.window().display_buffer(),
|
||||||
|
context.window().status_line());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
|
|
||||||
Window& get_unused_window_for_buffer(Buffer& buffer) const;
|
Window& get_unused_window_for_buffer(Buffer& buffer) const;
|
||||||
|
|
||||||
|
void redraw_clients() const;
|
||||||
private:
|
private:
|
||||||
struct Client
|
struct Client
|
||||||
{
|
{
|
||||||
|
|
|
@ -238,14 +238,14 @@ Buffer* open_fifo(const String& name , const String& filename, Context& context)
|
||||||
{ EventManager::instance().unwatch(fd); close(fd); }
|
{ EventManager::instance().unwatch(fd); close(fd); }
|
||||||
);
|
);
|
||||||
|
|
||||||
EventManager::instance().watch(fd, [buffer, &context](int fd) {
|
EventManager::instance().watch(fd, [buffer](int fd) {
|
||||||
char data[4096];
|
char data[4096];
|
||||||
ssize_t count = read(fd, data, 4096);
|
ssize_t count = read(fd, data, 4096);
|
||||||
buffer->insert(buffer->end()-1,
|
buffer->insert(buffer->end()-1,
|
||||||
count > 0 ? String(data, data+count)
|
count > 0 ? String(data, data+count)
|
||||||
: "*** kak: fifo closed ***\n");
|
: "*** kak: fifo closed ***\n");
|
||||||
buffer->reset_undo_data();
|
buffer->reset_undo_data();
|
||||||
context.draw_ifn();
|
ClientManager::instance().redraw_clients();
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -91,20 +91,6 @@ struct Context
|
||||||
return GlobalOptionManager::instance();
|
return GlobalOptionManager::instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_ifn() const
|
|
||||||
{
|
|
||||||
if (has_ui() and has_window())
|
|
||||||
{
|
|
||||||
DisplayCoord dimensions = ui().dimensions();
|
|
||||||
if (dimensions == DisplayCoord{0,0})
|
|
||||||
return;
|
|
||||||
window().set_dimensions(dimensions);
|
|
||||||
window().update_display_buffer();;
|
|
||||||
ui().draw(window().display_buffer(), window().status_line());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_status(const String& status) const
|
void print_status(const String& status) const
|
||||||
{
|
{
|
||||||
if (has_ui())
|
if (has_ui())
|
||||||
|
|
|
@ -635,7 +635,6 @@ void InputHandler::handle_available_inputs(Context& context)
|
||||||
if (is_valid(key))
|
if (is_valid(key))
|
||||||
m_mode->on_key(key, context);
|
m_mode->on_key(key, context);
|
||||||
}
|
}
|
||||||
context.draw_ifn();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user