| 1 | // QCodeEditorcxx . . $ `<file>/src/internal/QSyntaxStyle.cpp`/ |
| 2 | #include <QSyntaxStyle>cxx . . $ `<file>/include/QSyntaxStyle`/ |
| 3 | |
| 4 | // Qt |
| 5 | #include <QDebug> |
| 6 | #include <QXmlStreamReader> |
| 7 | #include <QFile> |
| 8 | |
| 9 | QSyntaxStylecxx . . $ QSyntaxStyle#::QSyntaxStylecxx . . $ QSyntaxStyle#QSyntaxStyle(749de1b6ae65bddd).(QObjectcxx . . $ QObject#* parent) : |
| 10 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), |
| 11 | m_namecxx . . $ QSyntaxStyle#m_name.(), |
| 12 | m_datacxx . . $ QSyntaxStyle#m_data.(), |
| 13 | m_loadedcxx . . $ QSyntaxStyle#m_loaded.(false) |
| 14 | { |
| 15 | |
| 16 | } |
| 17 | |
| 18 | bool QSyntaxStylecxx . . $ QSyntaxStyle#::loadcxx . . $ QSyntaxStyle#load(7dc6c9a0b6a7270f).(QStringcxx . . $ QString# fl) |
| 19 | { |
| 20 | QXmlStreamReadercxx . . $ QXmlStreamReader# readercxx . . $ QXmlStreamReader#QXmlStreamReader(3520e46b33348bf6).(fl); |
| 21 | |
| 22 | while (!reader.atEndcxx . . $ QXmlStreamReader#atEnd(50ce9a9e25b4a850).() && !reader.hasErrorcxx . . $ QXmlStreamReader#hasError(50ce9a9e25b4a850).()) |
| 23 | { |
| 24 | auto token = reader.readNextcxx . . $ QXmlStreamReader#readNext(b7ff4e19d2a802cc).(); |
| 25 | |
| 26 | if(token == QXmlStreamReadercxx . . $ QXmlStreamReader#::StartElementcxx . . $ QXmlStreamReader#StartElement.) |
| 27 | { |
| 28 | if (reader.namecxx . . $ QXmlStreamReader#name(d2d1e01c834b11a).() ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "style-scheme") |
| 29 | { |
| 30 | if (reader.attributescxx . . $ QXmlStreamReader#attributes(67475bfd56333fa4).().hasAttributecxx . . $ QXmlStreamAttributes#hasAttribute(f3b39adf77d9c36c).("name"cxx . . $ QString#QString(85c52e162fed56f9).)) |
| 31 | { |
| 32 | m_namecxx . . $ QSyntaxStyle#m_name. =cxx . . $ QString#`operator=`(7b76e6691bca1027). reader.attributescxx . . $ QXmlStreamReader#attributes(67475bfd56333fa4).().valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("name"cxx . . $ QString#QString(85c52e162fed56f9).).toStringcxx . . $ QStringRef#toString(6ef7b6c27b00b43d).(); |
| 33 | } |
| 34 | } |
| 35 | else if (reader.namecxx . . $ QXmlStreamReader#name(d2d1e01c834b11a).() ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "style") |
| 36 | { |
| 37 | auto attributes = reader.attributescxx . . $ QXmlStreamReader#attributes(67475bfd56333fa4).(); |
| 38 | |
| 39 | auto name = attributescxx . . $ QStringRef#QStringRef(798cd4a784e54499)..valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("name"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 40 | |
| 41 | QTextCharFormatcxx . . $ QTextCharFormat# formatcxx . . $ QTextCharFormat#QTextCharFormat(49f6e7a06ebc5aa8).; |
| 42 | |
| 43 | if (attributes.hasAttributecxx . . $ QXmlStreamAttributes#hasAttribute(f3b39adf77d9c36c).("background"cxx . . $ QString#QString(85c52e162fed56f9).)) |
| 44 | { |
| 45 | format.setBackgroundcxx . . $ QTextFormat#setBackground(ffc9f5d0bda78261).(QColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).(attributes.valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("background"cxx . . $ QString#QString(85c52e162fed56f9).).toStringcxx . . $ QStringRef#toString(6ef7b6c27b00b43d).())); |
| 46 | } |
| 47 | |
| 48 | if (attributes.hasAttributecxx . . $ QXmlStreamAttributes#hasAttribute(f3b39adf77d9c36c).("foreground"cxx . . $ QString#QString(85c52e162fed56f9).)) |
| 49 | { |
| 50 | format.setForegroundcxx . . $ QTextFormat#setForeground(ffc9f5d0bda78261).(QColorcxx . . $ QBrush#QBrush(b50947b0752ea6ac).(attributes.valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("foreground"cxx . . $ QString#QString(85c52e162fed56f9).).toStringcxx . . $ QStringRef#toString(6ef7b6c27b00b43d).())); |
| 51 | } |
| 52 | |
| 53 | if (attributes.hasAttributecxx . . $ QXmlStreamAttributes#hasAttribute(f3b39adf77d9c36c).("bold"cxx . . $ QString#QString(85c52e162fed56f9).) && |
| 54 | attributes.valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("bold"cxx . . $ QString#QString(85c52e162fed56f9).) ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "true") |
| 55 | { |
| 56 | format.setFontWeightcxx . . $ QTextCharFormat#setFontWeight(d4f767463ce0a6b3).(QFontcxx . . $ QFont#::Weightcxx . . $ QFont#Weight#::Boldcxx . . $ QFont#Bold.); |
| 57 | } |
| 58 | |
| 59 | if (attributes.hasAttributecxx . . $ QXmlStreamAttributes#hasAttribute(f3b39adf77d9c36c).("italic"cxx . . $ QString#QString(85c52e162fed56f9).) && |
| 60 | attributes.valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("italic"cxx . . $ QString#QString(85c52e162fed56f9).) ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "true") |
| 61 | { |
| 62 | format.setFontItaliccxx . . $ QTextCharFormat#setFontItalic(b45ddcbc8423892c).(true); |
| 63 | } |
| 64 | |
| 65 | if (attributes.hasAttributecxx . . $ QXmlStreamAttributes#hasAttribute(f3b39adf77d9c36c).("underlineStyle"cxx . . $ QString#QString(85c52e162fed56f9).)) |
| 66 | { |
| 67 | auto underline = attributescxx . . $ QStringRef#QStringRef(798cd4a784e54499)..valuecxx . . $ QXmlStreamAttributes#value(d1818b7318ce2ed4).("underlineStyle"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 68 | |
| 69 | auto s = QTextCharFormatcxx . . $ QTextCharFormat#::UnderlineStylecxx . . $ QTextCharFormat#UnderlineStyle#::NoUnderlinecxx . . $ QTextCharFormat#NoUnderline.; |
| 70 | |
| 71 | if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "SingleUnderline") |
| 72 | { |
| 73 | s = QTextCharFormatcxx . . $ QTextCharFormat#::UnderlineStylecxx . . $ QTextCharFormat#UnderlineStyle#::SingleUnderlinecxx . . $ QTextCharFormat#SingleUnderline.; |
| 74 | } |
| 75 | else if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "DashUnderline") |
| 76 | { |
| 77 | s = QTextCharFormatcxx . . $ QTextCharFormat#::UnderlineStylecxx . . $ QTextCharFormat#UnderlineStyle#::DashUnderlinecxx . . $ QTextCharFormat#DashUnderline.; |
| 78 | } |
| 79 | else if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "DotLine") |
| 80 | { |
| 81 | s = QTextCharFormatcxx . . $ QTextCharFormat#::UnderlineStylecxx . . $ QTextCharFormat#UnderlineStyle#::DotLinecxx . . $ QTextCharFormat#DotLine.; |
| 82 | } |
| 83 | else if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "DashDotLine") |
| 84 | { |
| 85 | s = QTextCharFormatcxx . . $ QTextCharFormat#::DashDotLinecxx . . $ QTextCharFormat#DashDotLine.; |
| 86 | } |
| 87 | else if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "DashDotDotLine") |
| 88 | { |
| 89 | s = QTextCharFormatcxx . . $ QTextCharFormat#::DashDotDotLinecxx . . $ QTextCharFormat#DashDotDotLine.; |
| 90 | } |
| 91 | else if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "WaveUnderline") |
| 92 | { |
| 93 | s = QTextCharFormatcxx . . $ QTextCharFormat#::WaveUnderlinecxx . . $ QTextCharFormat#WaveUnderline.; |
| 94 | } |
| 95 | else if (underline ==cxx . . $ QStringRef#`operator==`(7d4bdb1abc417636). "SpellCheckUnderline") |
| 96 | { |
| 97 | s = QTextCharFormatcxx . . $ QTextCharFormat#::SpellCheckUnderlinecxx . . $ QTextCharFormat#SpellCheckUnderline.; |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Unknown underline value " <<cxx . . $ QDebug#`operator<<`(957eb071131d8951). underline; |
| 102 | } |
| 103 | |
| 104 | format.setUnderlineStylecxx . . $ QTextCharFormat#setUnderlineStyle(2bd1f08ca4af7b71).(s); |
| 105 | } |
| 106 | |
| 107 | m_datacxx . . $ QSyntaxStyle#m_data.[cxx . . $ QMap#`operator[]`(bbd415b616967878).name.toStringcxx . . $ QStringRef#toString(6ef7b6c27b00b43d).()] =cxx . . $ QTextCharFormat#`operator=`(74fb0fd9fc0c28a7). format; |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | m_loadedcxx . . $ QSyntaxStyle#m_loaded. = !reader.hasErrorcxx . . $ QXmlStreamReader#hasError(50ce9a9e25b4a850).(); |
| 113 | |
| 114 | return m_loadedcxx . . $ QSyntaxStyle#m_loaded.; |
| 115 | } |
| 116 | |
| 117 | QStringcxx . . $ QString# QSyntaxStylecxx . . $ QSyntaxStyle#::namecxx . . $ QSyntaxStyle#name(6ef7b6c27b00b43d).() const |
| 118 | { |
| 119 | return m_namecxx . . $ QString#QString(3520e46b33348bf6).; |
| 120 | } |
| 121 | |
| 122 | QTextCharFormatcxx . . $ QTextCharFormat# QSyntaxStylecxx . . $ QSyntaxStyle#::getFormatcxx . . $ QSyntaxStyle#getFormat(5b7fd501ba56a402).(QStringcxx . . $ QString# name) const |
| 123 | { |
| 124 | auto result = m_datacxx . . $ QSyntaxStyle#m_data..findcxx . . $ QMap#find(fcb93a6f9e7070f5).(name); |
| 125 | |
| 126 | if (result ==cxx . . $ QMap#const_iterator#`operator==`(afb29c289d8ce2db). m_datacxx . . $ QSyntaxStyle#m_data..endcxx . . $ QMap#end(81a977e5fd18ea74).()) |
| 127 | { |
| 128 | return QTextCharFormatcxx . . $ QTextCharFormat#QTextCharFormat(49f6e7a06ebc5aa8).(); |
| 129 | } |
| 130 | |
| 131 | return result.valuecxx . . $ QMap#const_iterator#value(bdbd05d619d62250).(); |
| 132 | } |
| 133 | |
| 134 | bool QSyntaxStylecxx . . $ QSyntaxStyle#::isLoadedcxx . . $ QSyntaxStyle#isLoaded(50ce9a9e25b4a850).() const |
| 135 | { |
| 136 | return m_loadedcxx . . $ QSyntaxStyle#m_loaded.; |
| 137 | } |
| 138 | |
| 139 | QSyntaxStylecxx . . $ QSyntaxStyle#* QSyntaxStylecxx . . $ QSyntaxStyle#::defaultStylecxx . . $ QSyntaxStyle#defaultStyle(4772fd1b605239d8).() |
| 140 | { |
| 141 | static QSyntaxStylecxx . . $ QSyntaxStyle# stylecxx . . $ QSyntaxStyle#QSyntaxStyle(749de1b6ae65bddd).; |
| 142 | |
| 143 | if (!style.isLoadedcxx . . $ QSyntaxStyle#isLoaded(50ce9a9e25b4a850).()) |
| 144 | { |
| 145 | Q_INIT_RESOURCEcxx . . $ `<external>/15045578679651060896/qglobal.h:469:9`!(qcodeeditor_resources); |
| 146 | QFilecxx . . $ QFile# flcxx . . $ QFile#QFile(3520e46b33348bf6).(":/default_style.xml"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 147 | |
| 148 | if (!fl.opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QFlags#QFlags(9b289cee16747614).::ReadOnlycxx . . $ QIODevice#ReadOnly.)) |
| 149 | { |
| 150 | return &style; |
| 151 | } |
| 152 | |
| 153 | if (!style.loadcxx . . $ QSyntaxStyle#load(7dc6c9a0b6a7270f).(flcxx . . $ QString#QString(e1217c004a86c950)..readAllcxx . . $ QIODevice#readAll(b3c286cec66e09f4).())) |
| 154 | { |
| 155 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Can't load default style."; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | return &style; |
| 160 | } |