Small code cleanup in winow.cc/hh
This commit is contained in:
parent
9c0c6b8fd5
commit
6f9f32b4bb
|
@ -85,37 +85,24 @@ static uint32_t compute_faces_hash(const FaceRegistry& faces)
|
||||||
|
|
||||||
Window::Setup Window::build_setup(const Context& context) const
|
Window::Setup Window::build_setup(const Context& context) const
|
||||||
{
|
{
|
||||||
Vector<BufferRange, MemoryDomain::Display> selections;
|
return {m_position, m_dimensions,
|
||||||
for (auto& sel : context.selections())
|
context.buffer().timestamp(),
|
||||||
selections.push_back({sel.cursor(), sel.anchor()});
|
compute_faces_hash(context.faces()),
|
||||||
|
context.selections().main_index(),
|
||||||
return { m_position, m_dimensions,
|
context.selections() | gather<Vector<BasicSelection, MemoryDomain::Display>>()};
|
||||||
context.buffer().timestamp(),
|
|
||||||
compute_faces_hash(context.faces()),
|
|
||||||
context.selections().main_index(),
|
|
||||||
std::move(selections) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::needs_redraw(const Context& context) const
|
bool Window::needs_redraw(const Context& context) const
|
||||||
{
|
{
|
||||||
auto& selections = context.selections();
|
auto& selections = context.selections();
|
||||||
|
return m_position != m_last_setup.position or
|
||||||
if (m_position != m_last_setup.position or
|
|
||||||
m_dimensions != m_last_setup.dimensions or
|
m_dimensions != m_last_setup.dimensions or
|
||||||
context.buffer().timestamp() != m_last_setup.timestamp or
|
context.buffer().timestamp() != m_last_setup.timestamp or
|
||||||
selections.main_index() != m_last_setup.main_selection or
|
selections.main_index() != m_last_setup.main_selection or
|
||||||
selections.size() != m_last_setup.selections.size() or
|
selections.size() != m_last_setup.selections.size() or
|
||||||
compute_faces_hash(context.faces()) != m_last_setup.faces_hash)
|
compute_faces_hash(context.faces()) != m_last_setup.faces_hash or
|
||||||
return true;
|
not std::equal(selections.begin(), selections.end(),
|
||||||
|
m_last_setup.selections.begin(), m_last_setup.selections.end());
|
||||||
for (int i = 0; i < selections.size(); ++i)
|
|
||||||
{
|
|
||||||
if (selections[i].cursor() != m_last_setup.selections[i].begin or
|
|
||||||
selections[i].anchor() != m_last_setup.selections[i].end)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplayBuffer& Window::update_display_buffer(const Context& context)
|
const DisplayBuffer& Window::update_display_buffer(const Context& context)
|
||||||
|
|
|
@ -77,7 +77,7 @@ private:
|
||||||
size_t timestamp;
|
size_t timestamp;
|
||||||
size_t faces_hash;
|
size_t faces_hash;
|
||||||
size_t main_selection;
|
size_t main_selection;
|
||||||
Vector<BufferRange, MemoryDomain::Display> selections;
|
Vector<BasicSelection, MemoryDomain::Display> selections;
|
||||||
};
|
};
|
||||||
Setup build_setup(const Context& context) const;
|
Setup build_setup(const Context& context) const;
|
||||||
Setup m_last_setup;
|
Setup m_last_setup;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user