Refactor slightly window redrawing

This commit is contained in:
Maxime Coste 2015-06-22 13:34:22 +01:00
parent 3834440298
commit 7e6b02f26a
3 changed files with 12 additions and 12 deletions

View File

@ -145,12 +145,11 @@ void Client::redraw_ifn()
{ {
Face default_face = get_face("Default"); Face default_face = get_face("Default");
if (context().window().needs_redraw(context())) Window& window = context().window();
{ UserInterface& ui = context().ui();
context().window().update_display_buffer(context());
context().ui().draw(context().window().display_buffer(), default_face); if (window.needs_redraw(context()))
} ui.draw(window.update_display_buffer(context()), default_face);
DisplayLine mode_line = generate_mode_line(); DisplayLine mode_line = generate_mode_line();
if (m_status_line.atoms() != m_pending_status_line.atoms() or if (m_status_line.atoms() != m_pending_status_line.atoms() or
@ -159,10 +158,10 @@ void Client::redraw_ifn()
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_status(m_status_line, m_mode_line, default_face); ui.draw_status(m_status_line, m_mode_line, default_face);
} }
context().ui().refresh(); ui.refresh();
} }
void Client::reload_buffer() void Client::reload_buffer()

View File

@ -79,14 +79,14 @@ bool Window::needs_redraw(const Context& context) const
return hash != m_hash; return hash != m_hash;
} }
void Window::update_display_buffer(const Context& context) const DisplayBuffer& Window::update_display_buffer(const Context& context)
{ {
DisplayBuffer::LineList& lines = m_display_buffer.lines(); DisplayBuffer::LineList& lines = m_display_buffer.lines();
lines.clear(); lines.clear();
m_dimensions = context.ui().dimensions(); m_dimensions = context.ui().dimensions();
if (m_dimensions == CharCoord{0,0}) if (m_dimensions == CharCoord{0,0})
return; return m_display_buffer;
kak_assert(&buffer() == &context.buffer()); kak_assert(&buffer() == &context.buffer());
scroll_to_keep_selection_visible_ifn(context); scroll_to_keep_selection_visible_ifn(context);
@ -110,6 +110,8 @@ void Window::update_display_buffer(const Context& context)
m_display_buffer.optimize(); m_display_buffer.optimize();
m_hash = compute_hash(context); m_hash = compute_hash(context);
return m_display_buffer;
} }
void Window::set_position(CharCoord position) void Window::set_position(CharCoord position)

View File

@ -23,13 +23,12 @@ public:
const CharCoord& dimensions() const { return m_dimensions; } const CharCoord& dimensions() const { return m_dimensions; }
void set_dimensions(CharCoord dimensions); void set_dimensions(CharCoord dimensions);
const DisplayBuffer& display_buffer() const { return m_display_buffer; }
void center_line(LineCount buffer_line); void center_line(LineCount buffer_line);
void display_line_at(LineCount buffer_line, LineCount display_line); void display_line_at(LineCount buffer_line, LineCount display_line);
void scroll(LineCount offset); void scroll(LineCount offset);
void scroll(CharCount offset); void scroll(CharCount offset);
void update_display_buffer(const Context& context);
const DisplayBuffer& update_display_buffer(const Context& context);
CharCoord display_position(ByteCoord coord) const; CharCoord display_position(ByteCoord coord) const;
ByteCoord buffer_coord(CharCoord coord) const; ByteCoord buffer_coord(CharCoord coord) const;