13 const QFont::Style style = QFont::Style::StyleNormal,
14 const QFont::Weight weight = QFont::Weight::Normal)
16 QTextCharFormat charFormat;
18 charFormat.setForeground(
color);
19 charFormat.setFontWeight(weight);
20 if (style == QFont::Style::StyleItalic)
22 charFormat.setFontItalic(
true);
33 ColorScheme::ColorScheme(QString
name,
34 QVector<QTextCharFormat> &&formats,
35 const QTextFormat &defaultFormat,
36 QColor backgroundColor,
37 QColor currentLineHighlightColor)
40 m_defaultFormat(defaultFormat),
41 m_backgroundColor(
std::move(backgroundColor)),
42 m_currentLineHighlightColor(
std::move(currentLineHighlightColor))
49 return m_defaultFormat.foreground().color();
54 return m_backgroundColor;
59 return m_currentLineHighlightColor;
64 const auto index =
static_cast<int>(e);
65 Q_ASSERT(index < m_formats.size());
66 return m_formats[index];
90 QVector<QTextCharFormat> formats{
FormatHelper(QColor(255, 121, 198)),
128 [
name](
const ColorScheme &colorScheme) { return colorScheme.name() == name; });
static ColorScheme::Vector s_AvailableColorSchemes
static QTextCharFormat FormatHelper(const QColor &color, const QFont::Style style=QFont::Style::StyleNormal, const QFont::Weight weight=QFont::Weight::Normal)
ColorScheme to be used by the PythonHighlighter & Editor.
static ColorScheme Dracula()
QColor foregroundColor() const
Color to be used for regular text.
const QString & name() const
The name of the color scheme.
QColor currentLineHighlightColor() const
Color to be used if a highlight of the current line is shown.
static const Vector & AvailableColorSchemes()
Returns the vector of available color schemes.
const QTextCharFormat & operator[](PythonHighlighter::CodeElement e) const
Returns the format to be used for the given code element.
static ColorScheme Default()
Default color scheme.
std::vector< ColorScheme > Vector
static const ColorScheme * ColorSchemeByName(const QString &name)
QColor backgroundColor() const
Color to be used as the background for the displayed text.
constexpr Rgb black(0, 0, 0)
constexpr Rgb magenta(MAX, 0, MAX)
constexpr Rgb white(MAX, MAX, MAX)
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
constexpr Rgb yellow(MAX, MAX, 0)