Make compute_display_setup methods const
This commit is contained in:
parent
21603983c5
commit
3c03129c46
|
@ -71,7 +71,7 @@ struct Highlighter
|
|||
do_highlight(context, display_buffer, range);
|
||||
}
|
||||
|
||||
void compute_display_setup(HighlightContext context, DisplaySetup& setup)
|
||||
void compute_display_setup(HighlightContext context, DisplaySetup& setup) const
|
||||
{
|
||||
if (context.pass & m_passes)
|
||||
do_compute_display_setup(context, setup);
|
||||
|
@ -89,7 +89,7 @@ struct Highlighter
|
|||
|
||||
private:
|
||||
virtual void do_highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range) = 0;
|
||||
virtual void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) {}
|
||||
virtual void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const {}
|
||||
|
||||
const HighlightPass m_passes;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ void HighlighterGroup::do_highlight(HighlightContext context, DisplayBuffer& dis
|
|||
hl.value->highlight(context, display_buffer, range);
|
||||
}
|
||||
|
||||
void HighlighterGroup::do_compute_display_setup(HighlightContext context, DisplaySetup& setup)
|
||||
void HighlighterGroup::do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const
|
||||
{
|
||||
for (auto& hl : m_highlighters)
|
||||
hl.value->compute_display_setup(context, setup);
|
||||
|
@ -84,7 +84,7 @@ void Highlighters::highlight(HighlightContext context, DisplayBuffer& display_bu
|
|||
m_group.highlight(context, display_buffer, range);
|
||||
}
|
||||
|
||||
void Highlighters::compute_display_setup(HighlightContext context, DisplaySetup& setup)
|
||||
void Highlighters::compute_display_setup(HighlightContext context, DisplaySetup& setup) const
|
||||
{
|
||||
Vector<StringView> disabled_ids(context.disabled_ids.begin(), context.disabled_ids.end());
|
||||
m_group.fill_unique_ids(disabled_ids);
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
protected:
|
||||
void do_highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range) override;
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) override;
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const override;
|
||||
|
||||
using HighlighterMap = HashMap<String, std::unique_ptr<Highlighter>, MemoryDomain::Highlight>;
|
||||
HighlighterMap m_highlighters;
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
const HighlighterGroup& group() const { return m_group; }
|
||||
|
||||
void highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range);
|
||||
void compute_display_setup(HighlightContext context, DisplaySetup& setup);
|
||||
void compute_display_setup(HighlightContext context, DisplaySetup& setup) const;
|
||||
|
||||
private:
|
||||
friend class Scope;
|
||||
|
|
|
@ -727,7 +727,7 @@ struct WrapHighlighter : Highlighter
|
|||
}
|
||||
}
|
||||
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) override
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const override
|
||||
{
|
||||
if (contains(context.disabled_ids, ms_id))
|
||||
return;
|
||||
|
@ -817,7 +817,7 @@ struct WrapHighlighter : Highlighter
|
|||
unique_ids.push_back(ms_id);
|
||||
}
|
||||
|
||||
BufferCoord next_split_coord(const Buffer& buffer, ColumnCount wrap_column, int tabstop, BufferCoord coord)
|
||||
BufferCoord next_split_coord(const Buffer& buffer, ColumnCount wrap_column, int tabstop, BufferCoord coord) const
|
||||
{
|
||||
auto column = get_column(buffer, tabstop, coord);
|
||||
auto col = get_byte_to_column(
|
||||
|
@ -913,7 +913,7 @@ struct TabulationHighlighter : Highlighter
|
|||
}
|
||||
}
|
||||
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) override
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const override
|
||||
{
|
||||
auto& buffer = context.context.buffer();
|
||||
// Ensure that a cursor on a tab character makes the full tab character visible
|
||||
|
@ -1069,7 +1069,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) override
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const override
|
||||
{
|
||||
if (contains(context.disabled_ids, ms_id))
|
||||
return;
|
||||
|
@ -1083,7 +1083,7 @@ private:
|
|||
unique_ids.push_back(ms_id);
|
||||
}
|
||||
|
||||
int compute_digit_count(const Context& context)
|
||||
int compute_digit_count(const Context& context) const
|
||||
{
|
||||
int digit_count = 0;
|
||||
LineCount last_line = context.buffer().line_count();
|
||||
|
@ -1340,7 +1340,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) override
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const override
|
||||
{
|
||||
auto& line_flags = context.context.options()[m_option_name].get_mutable<LineAndSpecList>();
|
||||
auto& buffer = context.context.buffer();
|
||||
|
@ -1597,7 +1597,7 @@ private:
|
|||
{}
|
||||
}
|
||||
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) override
|
||||
void do_compute_display_setup(HighlightContext context, DisplaySetup& setup) const override
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -179,8 +179,10 @@ void Window::set_dimensions(DisplayCoord dimensions)
|
|||
}
|
||||
}
|
||||
|
||||
DisplaySetup Window::compute_display_setup(const Context& context)
|
||||
DisplaySetup Window::compute_display_setup(const Context& context) const
|
||||
{
|
||||
auto win_pos = m_position;
|
||||
|
||||
DisplayCoord offset = options()["scrolloff"].get<DisplayCoord>();
|
||||
offset.line = std::min(offset.line, (m_dimensions.line + 1) / 2);
|
||||
offset.column = std::min(offset.column, (m_dimensions.column + 1) / 2);
|
||||
|
@ -189,16 +191,16 @@ DisplaySetup Window::compute_display_setup(const Context& context)
|
|||
const auto& cursor = context.selections().main().cursor();
|
||||
|
||||
// Ensure cursor line is visible
|
||||
if (cursor.line - offset.line < m_position.line)
|
||||
m_position.line = std::max(0_line, cursor.line - offset.line);
|
||||
if (cursor.line + offset.line >= m_position.line + m_dimensions.line)
|
||||
m_position.line = std::min(buffer().line_count()-1, cursor.line + offset.line - m_dimensions.line + 1);
|
||||
if (cursor.line - offset.line < win_pos.line)
|
||||
win_pos.line = std::max(0_line, cursor.line - offset.line);
|
||||
if (cursor.line + offset.line >= win_pos.line + m_dimensions.line)
|
||||
win_pos.line = std::min(buffer().line_count()-1, cursor.line + offset.line - m_dimensions.line + 1);
|
||||
|
||||
DisplaySetup setup{
|
||||
m_position,
|
||||
win_pos,
|
||||
m_dimensions,
|
||||
{cursor.line - m_position.line,
|
||||
get_column(buffer(), tabstop, cursor) - m_position.column},
|
||||
{cursor.line - win_pos.line,
|
||||
get_column(buffer(), tabstop, cursor) - win_pos.column},
|
||||
offset,
|
||||
false
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
Window(const Window&) = delete;
|
||||
|
||||
void on_option_changed(const Option& option) override;
|
||||
DisplaySetup compute_display_setup(const Context& context);
|
||||
DisplaySetup compute_display_setup(const Context& context) const;
|
||||
|
||||
void run_hook_in_own_context(StringView hook_name, StringView param,
|
||||
String client_name = "");
|
||||
|
|
Loading…
Reference in New Issue
Block a user