2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Alexis Jeandet.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#pragma once
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <QColor>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QRegularExpression>
|
|
|
|
|
#include <QSyntaxHighlighter>
|
|
|
|
|
|
|
|
|
|
namespace MesonProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class RegexHighlighter : public QSyntaxHighlighter
|
|
|
|
|
{
|
|
|
|
|
const QRegularExpression m_regex{R"('([^']+)'+|([^', ]+)[, ]*)"};
|
|
|
|
|
QTextCharFormat m_format;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
RegexHighlighter(QWidget *parent);
|
|
|
|
|
void highlightBlock(const QString &text) override;
|
|
|
|
|
QStringList options(const QString &text);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ArrayOptionLineEdit : public QPlainTextEdit
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
RegexHighlighter *m_highLighter;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ArrayOptionLineEdit(QWidget *parent = nullptr);
|
|
|
|
|
QStringList options();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
|
};
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace MesonProjectManager
|