Commit 5578e2ef authored by Giovana Vitor Dionisio Santana's avatar Giovana Vitor Dionisio Santana ✍🏾 Committed by Christoph Cullmann
Browse files

replacing the numberOfColors macro with a constexpr

parent 230460ec
Pipeline #167441 passed with stage
in 15 minutes and 35 seconds
......@@ -15,7 +15,7 @@
#include <array>
#define NUMBER_OF_COLORS 5
constexpr int numberOfColors = 5;
K_PLUGIN_FACTORY_WITH_JSON(RainbowParenPluginFactory, "rainbowparens_plugin.json", registerPlugin<RainbowParenPlugin>();)
......@@ -50,7 +50,7 @@ void RainbowParenPluginView::updateColors(KTextEditor::Editor *editor)
QColor bg = editor->theme().editorColor(KSyntaxHighlighting::Theme::BackgroundColor);
if (attrs.empty()) {
attrs.resize(NUMBER_OF_COLORS);
attrs.resize(numberOfColors);
}
if (bg.lightness() < 127) {
......@@ -62,7 +62,7 @@ void RainbowParenPluginView::updateColors(KTextEditor::Editor *editor)
QColor("#FC834A"), // Orange
QColor("#3A86FF"), // Blue
};
for (int i = 0; i < NUMBER_OF_COLORS; ++i) {
for (int i = 0; i < numberOfColors; ++i) {
attrs[i] = new KTextEditor::Attribute;
attrs[i]->setForeground(colors[i]);
}
......@@ -75,7 +75,7 @@ void RainbowParenPluginView::updateColors(KTextEditor::Editor *editor)
QColor("#DD4803"), // Orange
QColor("#004ECC"), // Blue
};
for (int i = 0; i < NUMBER_OF_COLORS; ++i) {
for (int i = 0; i < numberOfColors; ++i) {
attrs[i] = new KTextEditor::Attribute;
attrs[i]->setForeground(colors[i]);
}
......@@ -378,12 +378,12 @@ void RainbowParenPluginView::rehighlight(KTextEditor::View *view)
}
std::unique_ptr<KTextEditor::MovingRange> r(miface->newMovingRange({p.opener, cur1}));
r->setAttribute(attrs[color % NUMBER_OF_COLORS]);
r->setAttribute(attrs[color % numberOfColors]);
auto cur2 = p.closer;
cur2.setColumn(cur2.column() + 1);
std::unique_ptr<KTextEditor::MovingRange> r2(miface->newMovingRange({p.closer, cur2}));
r2->setAttribute(attrs[color % NUMBER_OF_COLORS]);
r2->setAttribute(attrs[color % numberOfColors]);
ranges.push_back(std::move(r));
ranges.push_back(std::move(r2));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment