Move status/mode line drawing as a separate ui method
This commit is contained in:
parent
7417c5e9e2
commit
bf46870ff2
|
@ -146,25 +146,29 @@ void Client::change_buffer(Buffer& buffer)
|
||||||
|
|
||||||
void Client::redraw_ifn()
|
void Client::redraw_ifn()
|
||||||
{
|
{
|
||||||
DisplayLine mode_line = generate_mode_line();
|
Face default_face = get_face("Default");
|
||||||
const bool buffer_changed = context().window().timestamp() != context().buffer().timestamp();
|
|
||||||
const bool mode_line_changed = mode_line.atoms() != m_mode_line.atoms();
|
if (context().window().timestamp() != context().buffer().timestamp())
|
||||||
const bool status_line_changed = m_status_line.atoms() != m_pending_status_line.atoms();
|
{
|
||||||
if (buffer_changed or status_line_changed or mode_line_changed)
|
CharCoord dimensions = context().ui().dimensions();
|
||||||
|
if (dimensions == CharCoord{0,0})
|
||||||
|
return;
|
||||||
|
context().window().set_dimensions(dimensions);
|
||||||
|
context().window().update_display_buffer(context());
|
||||||
|
|
||||||
|
context().ui().draw(context().window().display_buffer(), default_face);
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayLine mode_line = generate_mode_line();
|
||||||
|
if (m_status_line.atoms() != m_pending_status_line.atoms() or
|
||||||
|
mode_line.atoms() != m_mode_line.atoms())
|
||||||
{
|
{
|
||||||
if (buffer_changed)
|
|
||||||
{
|
|
||||||
CharCoord dimensions = context().ui().dimensions();
|
|
||||||
if (dimensions == CharCoord{0,0})
|
|
||||||
return;
|
|
||||||
context().window().set_dimensions(dimensions);
|
|
||||||
context().window().update_display_buffer(context());
|
|
||||||
}
|
|
||||||
m_mode_line = std::move(mode_line);
|
m_mode_line = std::move(mode_line);
|
||||||
m_status_line = m_pending_status_line;
|
m_status_line = m_pending_status_line;
|
||||||
context().ui().draw(context().window().display_buffer(),
|
|
||||||
m_status_line, m_mode_line);
|
context().ui().draw_status(m_status_line, m_mode_line, default_face);
|
||||||
}
|
}
|
||||||
|
|
||||||
context().ui().refresh();
|
context().ui().refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,13 +149,9 @@ public:
|
||||||
void optimize();
|
void optimize();
|
||||||
void compute_range();
|
void compute_range();
|
||||||
|
|
||||||
void set_default_face(const Face& face) { m_default_face = face; }
|
|
||||||
const Face& default_face() const { return m_default_face; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LineList m_lines;
|
LineList m_lines;
|
||||||
BufferRange m_range;
|
BufferRange m_range;
|
||||||
Face m_default_face;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,8 @@ public:
|
||||||
void info_show(StringView, StringView, CharCoord, Face, InfoStyle) override {}
|
void info_show(StringView, StringView, CharCoord, Face, InfoStyle) override {}
|
||||||
void info_hide() override {}
|
void info_hide() override {}
|
||||||
|
|
||||||
void draw(const DisplayBuffer&, const DisplayLine&, const DisplayLine&) override {}
|
void draw(const DisplayBuffer&, const Face&) override {}
|
||||||
|
void draw_status(const DisplayLine&, const DisplayLine&, const Face&) override {}
|
||||||
CharCoord dimensions() override { return {24,80}; }
|
CharCoord dimensions() override { return {24,80}; }
|
||||||
bool is_key_available() override { return false; }
|
bool is_key_available() override { return false; }
|
||||||
Key get_key() override { return Key::Invalid; }
|
Key get_key() override { return Key::Invalid; }
|
||||||
|
|
|
@ -368,10 +368,8 @@ void NCursesUI::draw_line(const DisplayLine& line, CharCount col_index,
|
||||||
}
|
}
|
||||||
|
|
||||||
void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
||||||
const DisplayLine& status_line,
|
const Face& default_face)
|
||||||
const DisplayLine& mode_line)
|
|
||||||
{
|
{
|
||||||
const Face& default_face = display_buffer.default_face();
|
|
||||||
wbkgdset(m_window, COLOR_PAIR(get_color_pair(default_face)));
|
wbkgdset(m_window, COLOR_PAIR(get_color_pair(default_face)));
|
||||||
|
|
||||||
check_resize();
|
check_resize();
|
||||||
|
@ -393,6 +391,13 @@ void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
||||||
waddch(m_window, '~');
|
waddch(m_window, '~');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NCursesUI::draw_status(const DisplayLine& status_line,
|
||||||
|
const DisplayLine& mode_line,
|
||||||
|
const Face& default_face)
|
||||||
|
{
|
||||||
int status_line_pos = m_status_on_top ? 0 : (int)m_dimensions.line;
|
int status_line_pos = m_status_on_top ? 0 : (int)m_dimensions.line;
|
||||||
wmove(m_window, status_line_pos, 0);
|
wmove(m_window, status_line_pos, 0);
|
||||||
wclrtoeol(m_window);
|
wclrtoeol(m_window);
|
||||||
|
|
|
@ -22,11 +22,14 @@ public:
|
||||||
NCursesUI& operator=(const NCursesUI&) = delete;
|
NCursesUI& operator=(const NCursesUI&) = delete;
|
||||||
|
|
||||||
void draw(const DisplayBuffer& display_buffer,
|
void draw(const DisplayBuffer& display_buffer,
|
||||||
const DisplayLine& status_line,
|
const Face& default_face) override;
|
||||||
const DisplayLine& mode_line) override;
|
|
||||||
|
|
||||||
bool is_key_available() override;
|
void draw_status(const DisplayLine& status_line,
|
||||||
Key get_key() override;
|
const DisplayLine& mode_line,
|
||||||
|
const Face& default_face) override;
|
||||||
|
|
||||||
|
bool is_key_available() override;
|
||||||
|
Key get_key() override;
|
||||||
|
|
||||||
void menu_show(ConstArrayView<String> items,
|
void menu_show(ConstArrayView<String> items,
|
||||||
CharCoord anchor, Face fg, Face bg,
|
CharCoord anchor, Face fg, Face bg,
|
||||||
|
|
|
@ -26,6 +26,7 @@ enum class RemoteUIMsg
|
||||||
InfoShow,
|
InfoShow,
|
||||||
InfoHide,
|
InfoHide,
|
||||||
Draw,
|
Draw,
|
||||||
|
DrawStatus,
|
||||||
Refresh,
|
Refresh,
|
||||||
SetOptions
|
SetOptions
|
||||||
};
|
};
|
||||||
|
@ -123,7 +124,6 @@ public:
|
||||||
|
|
||||||
void write(const DisplayBuffer& display_buffer)
|
void write(const DisplayBuffer& display_buffer)
|
||||||
{
|
{
|
||||||
write(display_buffer.default_face());
|
|
||||||
write(display_buffer.lines());
|
write(display_buffer.lines());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,6 @@ template<>
|
||||||
DisplayBuffer read<DisplayBuffer>(int socket)
|
DisplayBuffer read<DisplayBuffer>(int socket)
|
||||||
{
|
{
|
||||||
DisplayBuffer db;
|
DisplayBuffer db;
|
||||||
db.set_default_face(read<Face>(socket));
|
|
||||||
db.lines() = read_vector<DisplayLine>(socket);
|
db.lines() = read_vector<DisplayLine>(socket);
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
@ -263,8 +262,11 @@ public:
|
||||||
void info_hide() override;
|
void info_hide() override;
|
||||||
|
|
||||||
void draw(const DisplayBuffer& display_buffer,
|
void draw(const DisplayBuffer& display_buffer,
|
||||||
const DisplayLine& status_line,
|
const Face& default_face) override;
|
||||||
const DisplayLine& mode_line) override;
|
|
||||||
|
void draw_status(const DisplayLine& status_line,
|
||||||
|
const DisplayLine& mode_line,
|
||||||
|
const Face& default_face) override;
|
||||||
|
|
||||||
void refresh() override;
|
void refresh() override;
|
||||||
|
|
||||||
|
@ -344,14 +346,23 @@ void RemoteUI::info_hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteUI::draw(const DisplayBuffer& display_buffer,
|
void RemoteUI::draw(const DisplayBuffer& display_buffer,
|
||||||
const DisplayLine& status_line,
|
const Face& default_face)
|
||||||
const DisplayLine& mode_line)
|
|
||||||
{
|
{
|
||||||
Message msg(m_socket_watcher.fd());
|
Message msg(m_socket_watcher.fd());
|
||||||
msg.write(RemoteUIMsg::Draw);
|
msg.write(RemoteUIMsg::Draw);
|
||||||
msg.write(display_buffer);
|
msg.write(display_buffer);
|
||||||
|
msg.write(default_face);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteUI::draw_status(const DisplayLine& status_line,
|
||||||
|
const DisplayLine& mode_line,
|
||||||
|
const Face& default_face)
|
||||||
|
{
|
||||||
|
Message msg(m_socket_watcher.fd());
|
||||||
|
msg.write(RemoteUIMsg::DrawStatus);
|
||||||
msg.write(status_line);
|
msg.write(status_line);
|
||||||
msg.write(mode_line);
|
msg.write(mode_line);
|
||||||
|
msg.write(default_face);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteUI::refresh()
|
void RemoteUI::refresh()
|
||||||
|
@ -510,9 +521,16 @@ void RemoteClient::process_next_message()
|
||||||
case RemoteUIMsg::Draw:
|
case RemoteUIMsg::Draw:
|
||||||
{
|
{
|
||||||
auto display_buffer = read<DisplayBuffer>(socket);
|
auto display_buffer = read<DisplayBuffer>(socket);
|
||||||
|
auto default_face = read<Face>(socket);
|
||||||
|
m_ui->draw(display_buffer, default_face);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RemoteUIMsg::DrawStatus:
|
||||||
|
{
|
||||||
auto status_line = read<DisplayLine>(socket);
|
auto status_line = read<DisplayLine>(socket);
|
||||||
auto mode_line = read<DisplayLine>(socket);
|
auto mode_line = read<DisplayLine>(socket);
|
||||||
m_ui->draw(display_buffer, status_line, mode_line);
|
auto default_face = read<Face>(socket);
|
||||||
|
m_ui->draw_status(status_line, mode_line, default_face);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RemoteUIMsg::Refresh:
|
case RemoteUIMsg::Refresh:
|
||||||
|
|
|
@ -53,8 +53,12 @@ public:
|
||||||
virtual void info_hide() = 0;
|
virtual void info_hide() = 0;
|
||||||
|
|
||||||
virtual void draw(const DisplayBuffer& display_buffer,
|
virtual void draw(const DisplayBuffer& display_buffer,
|
||||||
const DisplayLine& status_line,
|
const Face& default_face) = 0;
|
||||||
const DisplayLine& mode_line) = 0;
|
|
||||||
|
virtual void draw_status(const DisplayLine& status_line,
|
||||||
|
const DisplayLine& mode_line,
|
||||||
|
const Face& default_face) = 0;
|
||||||
|
|
||||||
virtual CharCoord dimensions() = 0;
|
virtual CharCoord dimensions() = 0;
|
||||||
virtual bool is_key_available() = 0;
|
virtual bool is_key_available() = 0;
|
||||||
virtual Key get_key() = 0;
|
virtual Key get_key() = 0;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "assert.hh"
|
#include "assert.hh"
|
||||||
#include "context.hh"
|
#include "context.hh"
|
||||||
#include "face_registry.hh"
|
|
||||||
#include "highlighter.hh"
|
#include "highlighter.hh"
|
||||||
#include "hook_manager.hh"
|
#include "hook_manager.hh"
|
||||||
#include "client.hh"
|
#include "client.hh"
|
||||||
|
@ -66,7 +65,6 @@ void Window::update_display_buffer(const Context& context)
|
||||||
kak_assert(&buffer() == &context.buffer());
|
kak_assert(&buffer() == &context.buffer());
|
||||||
scroll_to_keep_selection_visible_ifn(context);
|
scroll_to_keep_selection_visible_ifn(context);
|
||||||
|
|
||||||
m_display_buffer.set_default_face(get_face("Default"));
|
|
||||||
DisplayBuffer::LineList& lines = m_display_buffer.lines();
|
DisplayBuffer::LineList& lines = m_display_buffer.lines();
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user