From 60cf71bc2435762467dc9b43d99ee687a7306480 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 11 Jun 2018 15:10:05 +1000 Subject: [PATCH] Pass DisplaySetup through the HighlightContext --- src/highlighter.hh | 1 + src/highlighter_group.cc | 4 ++-- src/highlighters.cc | 8 ++++---- src/window.cc | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/highlighter.hh b/src/highlighter.hh index f3b7e3fd..033116a9 100644 --- a/src/highlighter.hh +++ b/src/highlighter.hh @@ -56,6 +56,7 @@ using HighlighterIdList = ConstArrayView; struct HighlightContext { const Context& context; + const DisplaySetup& setup; HighlightPass pass; HighlighterIdList disabled_ids; }; diff --git a/src/highlighter_group.cc b/src/highlighter_group.cc index f7758be0..173d8348 100644 --- a/src/highlighter_group.cc +++ b/src/highlighter_group.cc @@ -80,7 +80,7 @@ void Highlighters::highlight(HighlightContext context, DisplayBuffer& display_bu m_group.fill_unique_ids(disabled_ids); if (m_parent) - m_parent->highlight({context.context, context.pass, disabled_ids}, display_buffer, range); + m_parent->highlight({context.context, context.setup, context.pass, disabled_ids}, display_buffer, range); m_group.highlight(context, display_buffer, range); } @@ -90,7 +90,7 @@ void Highlighters::compute_display_setup(HighlightContext context, DisplaySetup& m_group.fill_unique_ids(disabled_ids); if (m_parent) - m_parent->compute_display_setup({context.context, context.pass, disabled_ids}, setup); + m_parent->compute_display_setup({context.context, context.setup, context.pass, disabled_ids}, setup); m_group.compute_display_setup(context, setup); } diff --git a/src/highlighters.cc b/src/highlighters.cc index 38745a9c..bd5ad191 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -601,7 +601,7 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params) return; auto face = context.context.faces()[facespec]; - auto win_column = context.context.window().position().column; + auto win_column = context.setup.window_pos.column; for (auto& line : display_buffer.lines()) { auto target_col = column - win_column; @@ -651,7 +651,7 @@ struct WrapHighlighter : Highlighter if (contains(context.disabled_ids, ms_id)) return; - const ColumnCount wrap_column = std::min(m_max_width, context.context.window().range().column); + const ColumnCount wrap_column = std::min(m_max_width, context.setup.window_range.column); if (wrap_column <= 0) return; @@ -889,7 +889,7 @@ struct TabulationHighlighter : Highlighter { const ColumnCount tabstop = context.context.options()["tabstop"].get(); auto& buffer = context.context.buffer(); - auto win_column = context.context.window().position().column; + auto win_column = context.setup.window_pos.column; for (auto& line : display_buffer.lines()) { for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it) @@ -945,7 +945,7 @@ void show_whitespaces(HighlightContext context, DisplayBuffer& display_buffer, B const int tabstop = context.context.options()["tabstop"].get(); auto whitespaceface = context.context.faces()["Whitespace"]; auto& buffer = context.context.buffer(); - auto win_column = context.context.window().position().column; + auto win_column = context.setup.window_pos.column; for (auto& line : display_buffer.lines()) { for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it) diff --git a/src/window.cc b/src/window.cc index e8d99f33..f9c47e3d 100644 --- a/src/window.cc +++ b/src/window.cc @@ -158,7 +158,7 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context) m_display_buffer.compute_range(); BufferRange range{{0,0}, buffer().end_coord()}; for (auto pass : { HighlightPass::Wrap, HighlightPass::Move, HighlightPass::Colorize }) - m_builtin_highlighters.highlight({context, pass, {}}, m_display_buffer, range); + m_builtin_highlighters.highlight({context, setup, pass, {}}, m_display_buffer, range); m_display_buffer.optimize(); @@ -225,7 +225,7 @@ DisplaySetup Window::compute_display_setup(const Context& context) const false }; for (auto pass : { HighlightPass::Move, HighlightPass::Wrap }) - m_builtin_highlighters.compute_display_setup({context, pass, {}}, setup); + m_builtin_highlighters.compute_display_setup({context, setup, pass, {}}, setup); check_display_setup(setup, *this); // now ensure the cursor column is visible