mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#ifndef VSTYLEPARSER_H
|
|
#define VSTYLEPARSER_H
|
|
|
|
#include <QPalette>
|
|
#include <QVector>
|
|
#include <QString>
|
|
#include <QHash>
|
|
#include "pegmarkdownhighlighter.h"
|
|
|
|
extern "C" {
|
|
#include <pmh_definitions.h>
|
|
#include <pmh_styleparser.h>
|
|
}
|
|
|
|
class QColor;
|
|
class QBrush;
|
|
|
|
class VStyleParser
|
|
{
|
|
public:
|
|
VStyleParser();
|
|
~VStyleParser();
|
|
|
|
void parseMarkdownStyle(const QString &styleStr);
|
|
QVector<HighlightingStyle> fetchMarkdownStyles(const QFont &baseFont) const;
|
|
|
|
// Fetch style sections: editor, editor-selection, editor-current-line.
|
|
// @styles: [rule] -> ([attr] -> value).
|
|
void fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
|
|
QMap<QString, QMap<QString, QString>> &styles) const;
|
|
|
|
QHash<QString, QTextCharFormat> fetchCodeBlockStyles(const QFont &p_baseFont) const;
|
|
|
|
private:
|
|
QColor QColorFromPmhAttr(pmh_attr_argb_color *attr) const;
|
|
QBrush QBrushFromPmhAttr(pmh_attr_argb_color *attr) const;
|
|
QTextCharFormat QTextCharFormatFromAttrs(pmh_style_attribute *attrs,
|
|
const QFont &baseFont) const;
|
|
pmh_style_collection *markdownStyles;
|
|
};
|
|
|
|
#endif // VSTYLEPARSER_H
|