| 1 | // QCodeEditorcxx . . $ `<file>/src/internal/QCodeEditor.cpp`/ |
| 2 | #include <QLineNumberArea>cxx . . $ `<file>/include/QLineNumberArea`/ |
| 3 | #include <QSyntaxStyle>cxx . . $ `<file>/include/QSyntaxStyle`/ |
| 4 | #include <QCodeEditor>cxx . . $ `<file>/include/QCodeEditor`/ |
| 5 | #include <QStyleSyntaxHighlighter>cxx . . $ `<file>/include/QStyleSyntaxHighlighter`/ |
| 6 | #include <QFramedTextAttribute>cxx . . $ `<file>/include/QFramedTextAttribute`/ |
| 7 | #include <QCXXHighlighter>cxx . . $ `<file>/include/QCXXHighlighter`/ |
| 8 | |
| 9 | |
| 10 | // Qt |
| 11 | #include <QTextBlock> |
| 12 | #include <QPaintEvent> |
| 13 | #include <QFontDatabase> |
| 14 | #include <QScrollBar> |
| 15 | #include <QAbstractTextDocumentLayout> |
| 16 | #include <QTextCharFormat> |
| 17 | #include <QCursor> |
| 18 | #include <QCompleter> |
| 19 | #include <QAbstractItemView> |
| 20 | #include <QShortcut> |
| 21 | #include <QMimeData> |
| 22 | |
| 23 | static QVectorcxx . . $ QVector#<QPaircxx . . $ QPair#<QStringcxx . . $ QString#, QStringcxx . . $ QString#>> parenthesescxx . . $ parentheses. = {cxx . . $ QVector#QVector(b6da5b9a9f304025). |
| 24 | {"(", ")"}, |
| 25 | {"{", "}"}, |
| 26 | {"[", "]"}, |
| 27 | {"\"", "\""}, |
| 28 | {"'", "'"} |
| 29 | }; |
| 30 | |
| 31 | QCodeEditorcxx . . $ QCodeEditor#::QCodeEditorcxx . . $ QCodeEditor#QCodeEditor(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* widget) : |
| 32 | QTextEditcxx . . $ QTextEdit#(widget), |
| 33 | m_highlightercxx . . $ QCodeEditor#m_highlighter.(nullptr), |
| 34 | m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.(nullptr), |
| 35 | m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.(new QLineNumberAreacxx . . $ QLineNumberArea#(this)), |
| 36 | m_completercxx . . $ QCodeEditor#m_completer.(nullptr), |
| 37 | m_framedAttributecxx . . $ QCodeEditor#m_framedAttribute.(new QFramedTextAttributecxx . . $ QFramedTextAttribute#QFramedTextAttribute(749de1b6ae65bddd).(this)), |
| 38 | m_autoIndentationcxx . . $ QCodeEditor#m_autoIndentation.(true), |
| 39 | m_autoParenthesescxx . . $ QCodeEditor#m_autoParentheses.(true), |
| 40 | m_replaceTabcxx . . $ QCodeEditor#m_replaceTab.(true), |
| 41 | m_tabReplacecxx . . $ QCodeEditor#m_tabReplace.(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(4, ' 'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)) |
| 42 | { |
| 43 | initDocumentLayoutHandlerscxx . . $ QCodeEditor#initDocumentLayoutHandlers(49f6e7a06ebc5aa8).(); |
| 44 | initFontcxx . . $ QCodeEditor#initFont(49f6e7a06ebc5aa8).(); |
| 45 | performConnectionscxx . . $ QCodeEditor#performConnections(49f6e7a06ebc5aa8).(); |
| 46 | |
| 47 | setSyntaxStylecxx . . $ QCodeEditor#setSyntaxStyle(1fc7b27a9b6cc29c).(QSyntaxStylecxx . . $ QSyntaxStyle#::defaultStylecxx . . $ QSyntaxStyle#defaultStyle(4772fd1b605239d8).()); |
| 48 | } |
| 49 | |
| 50 | void QCodeEditorcxx . . $ QCodeEditor#::initDocumentLayoutHandlerscxx . . $ QCodeEditor#initDocumentLayoutHandlers(49f6e7a06ebc5aa8).() |
| 51 | { |
| 52 | documentcxx . . $ QTextEdit#document(f21741221844491e).() |
| 53 | ->documentLayoutcxx . . $ QTextDocument#documentLayout(135eff1e02365923).() |
| 54 | ->registerHandlercxx . . $ QAbstractTextDocumentLayout#registerHandler(1ee1e1ac455d3e6e).( |
| 55 | QFramedTextAttributecxx . . $ QFramedTextAttribute#::typecxx . . $ QFramedTextAttribute#type(b126dc7c1de90089).(), |
| 56 | m_framedAttributecxx . . $ QCodeEditor#m_framedAttribute. |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | void QCodeEditorcxx . . $ QCodeEditor#::initFontcxx . . $ QCodeEditor#initFont(49f6e7a06ebc5aa8).() |
| 61 | { |
| 62 | auto fnt = QFontDatabasecxx . . $ QFont#QFont(d0a4bd0c8524b912).::systemFontcxx . . $ QFontDatabase#systemFont(2e2fed7ba119aa62).(QFontDatabasecxx . . $ QFontDatabase#::FixedFontcxx . . $ QFontDatabase#FixedFont.); |
| 63 | fnt.setFixedPitchcxx . . $ QFont#setFixedPitch(b45ddcbc8423892c).(true); |
| 64 | fnt.setPointSizecxx . . $ QFont#setPointSize(d4f767463ce0a6b3).(10); |
| 65 | |
| 66 | setFontcxx . . $ QWidget#setFont(d0a4bd0c8524b912).(fnt); |
| 67 | } |
| 68 | |
| 69 | void QCodeEditorcxx . . $ QCodeEditor#::performConnectionscxx . . $ QCodeEditor#performConnections(49f6e7a06ebc5aa8).() |
| 70 | { |
| 71 | connectcxx . . $ QObject#connect(835f87066c895669).( |
| 72 | documentcxx . . $ QTextEdit#document(f21741221844491e).(), |
| 73 | &QTextDocumentcxx . . $ QTextDocument#::blockCountChangedcxx . . $ QTextDocument#blockCountChanged(d4f767463ce0a6b3)., |
| 74 | this, |
| 75 | &QCodeEditorcxx . . $ QCodeEditor#::updateLineNumberAreaWidthcxx . . $ QCodeEditor#updateLineNumberAreaWidth(d4f767463ce0a6b3). |
| 76 | ); |
| 77 | |
| 78 | connectcxx . . $ QObject#connect(799f219bacec96aa).( |
| 79 | verticalScrollBarcxx . . $ QAbstractScrollArea#verticalScrollBar(49d9510c6adf8c19).(), |
| 80 | &QScrollBarcxx . . $ QScrollBar#::valueChangedcxx . . $ QAbstractSlider#valueChanged(d4f767463ce0a6b3)., |
| 81 | [this](int){ m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).(); } |
| 82 | ); |
| 83 | |
| 84 | connectcxx . . $ QObject#connect(835f87066c895669).( |
| 85 | this, |
| 86 | &QTextEditcxx . . $ QTextEdit#::cursorPositionChangedcxx . . $ QTextEdit#cursorPositionChanged(49f6e7a06ebc5aa8)., |
| 87 | this, |
| 88 | &QCodeEditorcxx . . $ QCodeEditor#::updateExtraSelectioncxx . . $ QCodeEditor#updateExtraSelection(49f6e7a06ebc5aa8). |
| 89 | ); |
| 90 | |
| 91 | connectcxx . . $ QObject#connect(835f87066c895669).( |
| 92 | this, |
| 93 | &QTextEditcxx . . $ QTextEdit#::selectionChangedcxx . . $ QTextEdit#selectionChanged(49f6e7a06ebc5aa8)., |
| 94 | this, |
| 95 | &QCodeEditorcxx . . $ QCodeEditor#::onSelectionChangedcxx . . $ QCodeEditor#onSelectionChanged(49f6e7a06ebc5aa8). |
| 96 | ); |
| 97 | } |
| 98 | |
| 99 | void QCodeEditorcxx . . $ QCodeEditor#::setHighlightercxx . . $ QCodeEditor#setHighlighter(c4055cb90adcfbb5).(QStyleSyntaxHighlightercxx . . $ QStyleSyntaxHighlighter#* highlighter) |
| 100 | { |
| 101 | if (m_highlightercxx . . $ QCodeEditor#m_highlighter.) |
| 102 | { |
| 103 | m_highlightercxx . . $ QCodeEditor#m_highlighter.->setDocumentcxx . . $ QSyntaxHighlighter#setDocument(68d7deb16251beb9).(nullptr); |
| 104 | } |
| 105 | |
| 106 | m_highlightercxx . . $ QCodeEditor#m_highlighter. = highlighter; |
| 107 | |
| 108 | if (m_highlightercxx . . $ QCodeEditor#m_highlighter.) |
| 109 | { |
| 110 | m_highlightercxx . . $ QCodeEditor#m_highlighter.->setSyntaxStylecxx . . $ QStyleSyntaxHighlighter#setSyntaxStyle(1fc7b27a9b6cc29c).(m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.); |
| 111 | m_highlightercxx . . $ QCodeEditor#m_highlighter.->setDocumentcxx . . $ QSyntaxHighlighter#setDocument(68d7deb16251beb9).(documentcxx . . $ QTextEdit#document(f21741221844491e).()); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | void QCodeEditorcxx . . $ QCodeEditor#::setSyntaxStylecxx . . $ QCodeEditor#setSyntaxStyle(1fc7b27a9b6cc29c).(QSyntaxStylecxx . . $ QSyntaxStyle#* style) |
| 116 | { |
| 117 | m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle. = style; |
| 118 | |
| 119 | m_framedAttributecxx . . $ QCodeEditor#m_framedAttribute.->setSyntaxStylecxx . . $ QFramedTextAttribute#setSyntaxStyle(1fc7b27a9b6cc29c).(m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.); |
| 120 | m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->setSyntaxStylecxx . . $ QLineNumberArea#setSyntaxStyle(1fc7b27a9b6cc29c).(m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.); |
| 121 | |
| 122 | if (m_highlightercxx . . $ QCodeEditor#m_highlighter.) |
| 123 | { |
| 124 | m_highlightercxx . . $ QCodeEditor#m_highlighter.->setSyntaxStylecxx . . $ QStyleSyntaxHighlighter#setSyntaxStyle(1fc7b27a9b6cc29c).(m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.); |
| 125 | } |
| 126 | |
| 127 | updateStylecxx . . $ QCodeEditor#updateStyle(49f6e7a06ebc5aa8).(); |
| 128 | } |
| 129 | |
| 130 | void QCodeEditorcxx . . $ QCodeEditor#::updateStylecxx . . $ QCodeEditor#updateStyle(49f6e7a06ebc5aa8).() |
| 131 | { |
| 132 | if (m_highlightercxx . . $ QCodeEditor#m_highlighter.) |
| 133 | { |
| 134 | m_highlightercxx . . $ QCodeEditor#m_highlighter.->rehighlightcxx . . $ QSyntaxHighlighter#rehighlight(49f6e7a06ebc5aa8).(); |
| 135 | } |
| 136 | |
| 137 | if (m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.) |
| 138 | { |
| 139 | auto currentPalette = palettecxx . . $ QPalette#QPalette(f826ed73d5553cd5).(); |
| 140 | |
| 141 | // Setting text format/color |
| 142 | currentPalette.setColorcxx . . $ QPalette#setColor(4fd5272df43acd68).( |
| 143 | QPalettecxx . . $ QPalette#::ColorRolecxx . . $ QPalette#ColorRole#::Textcxx . . $ QPalette#Text., |
| 144 | m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.->getFormatcxx . . $ QSyntaxStyle#getFormat(5b7fd501ba56a402).("Text"cxx . . $ QString#QString(e1217c004a86c950).).foregroundcxx . . $ QTextFormat#foreground(583354ac483a5b23).().colorcxx . . $ QBrush#color(a1044652a6e0ddd).() |
| 145 | ); |
| 146 | |
| 147 | // Setting common background |
| 148 | currentPalette.setColorcxx . . $ QPalette#setColor(4fd5272df43acd68).( |
| 149 | QPalettecxx . . $ QPalette#::Basecxx . . $ QPalette#Base., |
| 150 | m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.->getFormatcxx . . $ QSyntaxStyle#getFormat(5b7fd501ba56a402).("Text"cxx . . $ QString#QString(e1217c004a86c950).).backgroundcxx . . $ QTextFormat#background(583354ac483a5b23).().colorcxx . . $ QBrush#color(a1044652a6e0ddd).() |
| 151 | ); |
| 152 | |
| 153 | // Setting selection color |
| 154 | currentPalette.setColorcxx . . $ QPalette#setColor(4fd5272df43acd68).( |
| 155 | QPalettecxx . . $ QPalette#::Highlightcxx . . $ QPalette#Highlight., |
| 156 | m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.->getFormatcxx . . $ QSyntaxStyle#getFormat(5b7fd501ba56a402).("Selection"cxx . . $ QString#QString(e1217c004a86c950).).backgroundcxx . . $ QTextFormat#background(583354ac483a5b23).().colorcxx . . $ QBrush#color(a1044652a6e0ddd).() |
| 157 | ); |
| 158 | |
| 159 | setPalettecxx . . $ QWidget#setPalette(f826ed73d5553cd5).(currentPalette); |
| 160 | } |
| 161 | |
| 162 | updateExtraSelectioncxx . . $ QCodeEditor#updateExtraSelection(49f6e7a06ebc5aa8).(); |
| 163 | } |
| 164 | |
| 165 | void QCodeEditorcxx . . $ QCodeEditor#::onSelectionChangedcxx . . $ QCodeEditor#onSelectionChanged(49f6e7a06ebc5aa8).() |
| 166 | { |
| 167 | auto selected = textCursorcxx . . $ QString#QString(e1217c004a86c950).().selectedTextcxx . . $ QTextCursor#selectedText(6ef7b6c27b00b43d).(); |
| 168 | |
| 169 | auto cursor = textCursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).(); |
| 170 | |
| 171 | // Cursor is null if setPlainText was called. |
| 172 | if (cursor.isNullcxx . . $ QTextCursor#isNull(50ce9a9e25b4a850).()) |
| 173 | { |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | cursor.movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).(QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Leftcxx . . $ QTextCursor#Left.); |
| 178 | cursor.selectcxx . . $ QTextCursor#select(71b96aaf81af89cd).(QTextCursorcxx . . $ QTextCursor#::SelectionTypecxx . . $ QTextCursor#SelectionType#::WordUnderCursorcxx . . $ QTextCursor#WordUnderCursor.); |
| 179 | |
| 180 | QSignalBlockercxx . . $ QSignalBlocker# blockercxx . . $ QSignalBlocker#QSignalBlocker(749de1b6ae65bddd).(this); |
| 181 | m_framedAttributecxx . . $ QCodeEditor#m_framedAttribute.->clearcxx . . $ QFramedTextAttribute#clear(2dee62e7021fdd8c).(cursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).); |
| 182 | |
| 183 | if (selected.sizecxx . . $ QString#size(455f465bc33b4cdf).() > 1 && |
| 184 | cursor.selectedTextcxx . . $ QTextCursor#selectedText(6ef7b6c27b00b43d).() ==cxx . . $ `operator==`(edf9e4f73813982f). selected) |
| 185 | { |
| 186 | auto backup = textCursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).(); |
| 187 | |
| 188 | // Perform search selecting |
| 189 | handleSelectionQuerycxx . . $ QCodeEditor#handleSelectionQuery(2dee62e7021fdd8c).(cursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).); |
| 190 | |
| 191 | setTextCursorcxx . . $ QTextEdit#setTextCursor(a408cee6726ac3d5).(backup); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | void QCodeEditorcxx . . $ QCodeEditor#::resizeEventcxx . . $ QCodeEditor#resizeEvent(eeeec21cf8dc0387).(QResizeEventcxx . . $ QResizeEvent#* e) |
| 196 | { |
| 197 | QTextEditcxx . . $ QTextEdit#::resizeEventcxx . . $ QTextEdit#resizeEvent(eeeec21cf8dc0387).(e); |
| 198 | |
| 199 | updateLineGeometrycxx . . $ QCodeEditor#updateLineGeometry(49f6e7a06ebc5aa8).(); |
| 200 | } |
| 201 | |
| 202 | void QCodeEditorcxx . . $ QCodeEditor#::updateLineGeometrycxx . . $ QCodeEditor#updateLineGeometry(49f6e7a06ebc5aa8).() |
| 203 | { |
| 204 | QRectcxx . . $ QRect# cr = contentsRectcxx . . $ QWidget#contentsRect(d857385bac04cbf7).(); |
| 205 | m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->setGeometrycxx . . $ QWidget#setGeometry(22ba0428947158b).( |
| 206 | QRectcxx . . $ QRect#QRect(748afa4755bc9595).(cr.leftcxx . . $ QRect#left(455f465bc33b4cdf).(), |
| 207 | cr.topcxx . . $ QRect#top(455f465bc33b4cdf).(), |
| 208 | m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->sizeHintcxx . . $ QLineNumberArea#sizeHint(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(455f465bc33b4cdf).(), |
| 209 | cr.heightcxx . . $ QRect#height(455f465bc33b4cdf).() |
| 210 | ) |
| 211 | ); |
| 212 | } |
| 213 | |
| 214 | void QCodeEditorcxx . . $ QCodeEditor#::updateLineNumberAreaWidthcxx . . $ QCodeEditor#updateLineNumberAreaWidth(d4f767463ce0a6b3).(int) |
| 215 | { |
| 216 | setViewportMarginscxx . . $ QAbstractScrollArea#setViewportMargins(748afa4755bc9595).(m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->sizeHintcxx . . $ QLineNumberArea#sizeHint(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(455f465bc33b4cdf).(), 0, 0, 0); |
| 217 | } |
| 218 | |
| 219 | void QCodeEditorcxx . . $ QCodeEditor#::updateLineNumberAreacxx . . $ QCodeEditor#updateLineNumberArea(22ba0428947158b).(const QRectcxx . . $ QRect#& rect) |
| 220 | { |
| 221 | m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->updatecxx . . $ QWidget#update(748afa4755bc9595).( |
| 222 | 0, |
| 223 | rect.ycxx . . $ QRect#y(455f465bc33b4cdf).(), |
| 224 | m_lineNumberAreacxx . . $ QCodeEditor#m_lineNumberArea.->sizeHintcxx . . $ QLineNumberArea#sizeHint(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(455f465bc33b4cdf).(), |
| 225 | rect.heightcxx . . $ QRect#height(455f465bc33b4cdf).() |
| 226 | ); |
| 227 | updateLineGeometrycxx . . $ QCodeEditor#updateLineGeometry(49f6e7a06ebc5aa8).(); |
| 228 | |
| 229 | if (rect.containscxx . . $ QRect#contains(5bf0d0fc1552ade2).(viewportcxx . . $ QAbstractScrollArea#viewport(27f420ad5cce8994).()->rectcxx . . $ QWidget#rect(d857385bac04cbf7).())) |
| 230 | { |
| 231 | updateLineNumberAreaWidthcxx . . $ QCodeEditor#updateLineNumberAreaWidth(d4f767463ce0a6b3).(0); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | void QCodeEditorcxx . . $ QCodeEditor#::handleSelectionQuerycxx . . $ QCodeEditor#handleSelectionQuery(2dee62e7021fdd8c).(QTextCursorcxx . . $ QTextCursor# cursor) |
| 236 | { |
| 237 | |
| 238 | auto searchIterator = cursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).; |
| 239 | searchIterator.movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).(QTextCursorcxx . . $ QTextCursor#::Startcxx . . $ QTextCursor#Start.); |
| 240 | searchIterator =cxx . . $ QTextCursor#`operator=`(ea0024a71e5897e6). documentcxx . . $ QTextEdit#document(f21741221844491e).()->findcxx . . $ QTextDocument#find(9eb78c354e90353a).(cursor.selectedTextcxx . . $ QTextCursor#selectedText(6ef7b6c27b00b43d).(), searchIterator); |
| 241 | while (searchIterator.hasSelectioncxx . . $ QTextCursor#hasSelection(50ce9a9e25b4a850).()) |
| 242 | { |
| 243 | m_framedAttributecxx . . $ QCodeEditor#m_framedAttribute.->framecxx . . $ QFramedTextAttribute#frame(2dee62e7021fdd8c).(searchIteratorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).); |
| 244 | |
| 245 | searchIterator =cxx . . $ QTextCursor#`operator=`(ea0024a71e5897e6). documentcxx . . $ QTextEdit#document(f21741221844491e).()->findcxx . . $ QTextDocument#find(9eb78c354e90353a).(cursor.selectedTextcxx . . $ QTextCursor#selectedText(6ef7b6c27b00b43d).(), searchIterator); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void QCodeEditorcxx . . $ QCodeEditor#::updateExtraSelectioncxx . . $ QCodeEditor#updateExtraSelection(49f6e7a06ebc5aa8).() |
| 250 | { |
| 251 | QListcxx . . $ QList#<QTextEditcxx . . $ QTextEdit#::ExtraSelectioncxx . . $ QTextEdit#ExtraSelection#> extracxx . . $ QList#QList(49f6e7a06ebc5aa8).; |
| 252 | |
| 253 | highlightCurrentLinecxx . . $ QCodeEditor#highlightCurrentLine(756a146a09cbd9d6).(extra); |
| 254 | highlightParenthesiscxx . . $ QCodeEditor#highlightParenthesis(756a146a09cbd9d6).(extra); |
| 255 | |
| 256 | setExtraSelectionscxx . . $ QTextEdit#setExtraSelections(f699d81df9da7ae6).(extra); |
| 257 | } |
| 258 | |
| 259 | void QCodeEditorcxx . . $ QCodeEditor#::highlightParenthesiscxx . . $ QCodeEditor#highlightParenthesis(756a146a09cbd9d6).(QListcxx . . $ QList#<QTextEditcxx . . $ QTextEdit#::ExtraSelectioncxx . . $ QTextEdit#ExtraSelection#>& extraSelection) |
| 260 | { |
| 261 | auto currentSymbol = charUnderCursorcxx . . $ QCodeEditor#charUnderCursor(fee70a7e000c558e).(); |
| 262 | auto prevSymbol = charUnderCursorcxx . . $ QCodeEditor#charUnderCursor(fee70a7e000c558e).(-1); |
| 263 | |
| 264 | for (auto& pair : parenthesescxx . . $ parentheses.) |
| 265 | { |
| 266 | int direction; |
| 267 | |
| 268 | QCharcxx . . $ QChar# counterSymbolcxx . . $ QChar#QChar(49f6e7a06ebc5aa8).; |
| 269 | QCharcxx . . $ QChar# activeSymbolcxx . . $ QChar#QChar(49f6e7a06ebc5aa8).; |
| 270 | auto position = textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).().positioncxx . . $ QTextCursor#position(455f465bc33b4cdf).(); |
| 271 | |
| 272 | if (pair.firstcxx . . $ QPair#first. ==cxx . . $ `operator==`(773c7e6e3f91baa9). currentSymbol) |
| 273 | { |
| 274 | direction = 1; |
| 275 | counterSymbol =cxx . . $ QChar#`operator=`(685661bd65b18388). pair.secondcxx . . $ QPair#second.[cxx . . $ QString#`operator[]`(57436120916eb52c).0]; |
| 276 | activeSymbol =cxx . . $ QChar#`operator=`(171ce7ca8c6cef49). currentSymbol; |
| 277 | } |
| 278 | else if (pair.secondcxx . . $ QPair#second. ==cxx . . $ `operator==`(773c7e6e3f91baa9). prevSymbol) |
| 279 | { |
| 280 | direction = -1; |
| 281 | counterSymbol =cxx . . $ QChar#`operator=`(685661bd65b18388). pair.firstcxx . . $ QPair#first.[cxx . . $ QString#`operator[]`(57436120916eb52c).0]; |
| 282 | activeSymbol =cxx . . $ QChar#`operator=`(171ce7ca8c6cef49). prevSymbol; |
| 283 | position--; |
| 284 | } |
| 285 | else |
| 286 | { |
| 287 | continue; |
| 288 | } |
| 289 | |
| 290 | auto counter = 1; |
| 291 | |
| 292 | while (counter != 0 && |
| 293 | position > 0 && |
| 294 | position < (documentcxx . . $ QTextEdit#document(f21741221844491e).()->characterCountcxx . . $ QTextDocument#characterCount(455f465bc33b4cdf).() - 1)) |
| 295 | { |
| 296 | // Moving position |
| 297 | position += direction; |
| 298 | |
| 299 | auto character = documentcxx . . $ QTextEdit#document(f21741221844491e).()->characterAtcxx . . $ QTextDocument#characterAt(fee70a7e000c558e).(position); |
| 300 | // Checking symbol under position |
| 301 | if (character ==cxx . . $ `operator==`(266b2cc48a9d5b67). activeSymbol) |
| 302 | { |
| 303 | ++counter; |
| 304 | } |
| 305 | else if (character ==cxx . . $ `operator==`(266b2cc48a9d5b67). counterSymbol) |
| 306 | { |
| 307 | --counter; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | auto format = m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.->getFormatcxx . . $ QSyntaxStyle#getFormat(5b7fd501ba56a402).("Parentheses"cxx . . $ QString#QString(e1217c004a86c950).); |
| 312 | |
| 313 | // Found |
| 314 | if (counter == 0) |
| 315 | { |
| 316 | ExtraSelectioncxx . . $ QTextEdit#ExtraSelection# selection{}; |
| 317 | |
| 318 | auto directionEnum = |
| 319 | direction < 0 ? |
| 320 | QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Leftcxx . . $ QTextCursor#Left. |
| 321 | : |
| 322 | QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Rightcxx . . $ QTextCursor#Right.; |
| 323 | |
| 324 | selection.formatcxx . . $ QTextEdit#ExtraSelection#format. =cxx . . $ QTextCharFormat#`operator=`(74fb0fd9fc0c28a7). format; |
| 325 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor. =cxx . . $ QTextCursor#`operator=`(ea0024a71e5897e6). textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).(); |
| 326 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor..clearSelectioncxx . . $ QTextCursor#clearSelection(49f6e7a06ebc5aa8).(); |
| 327 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor..movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).( |
| 328 | directionEnum, |
| 329 | QTextCursorcxx . . $ QTextCursor#::MoveModecxx . . $ QTextCursor#MoveMode#::MoveAnchorcxx . . $ QTextCursor#MoveAnchor., |
| 330 | stdcxx . . $ std/::abs(textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).().positioncxx . . $ QTextCursor#position(455f465bc33b4cdf).() - position) |
| 331 | ); |
| 332 | |
| 333 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor..movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).( |
| 334 | QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Rightcxx . . $ QTextCursor#Right., |
| 335 | QTextCursorcxx . . $ QTextCursor#::MoveModecxx . . $ QTextCursor#MoveMode#::KeepAnchorcxx . . $ QTextCursor#KeepAnchor., |
| 336 | 1 |
| 337 | ); |
| 338 | |
| 339 | extraSelection.appendcxx . . $ QList#append(77d9f17553126ecb).(selection); |
| 340 | |
| 341 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor. =cxx . . $ QTextCursor#`operator=`(ea0024a71e5897e6). textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).(); |
| 342 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor..clearSelectioncxx . . $ QTextCursor#clearSelection(49f6e7a06ebc5aa8).(); |
| 343 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor..movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).( |
| 344 | directionEnum, |
| 345 | QTextCursorcxx . . $ QTextCursor#::MoveModecxx . . $ QTextCursor#MoveMode#::KeepAnchorcxx . . $ QTextCursor#KeepAnchor., |
| 346 | 1 |
| 347 | ); |
| 348 | |
| 349 | extraSelection.appendcxx . . $ QList#append(77d9f17553126ecb).(selection); |
| 350 | } |
| 351 | |
| 352 | break; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | void QCodeEditorcxx . . $ QCodeEditor#::highlightCurrentLinecxx . . $ QCodeEditor#highlightCurrentLine(756a146a09cbd9d6).(QListcxx . . $ QList#<QTextEditcxx . . $ QTextEdit#::ExtraSelectioncxx . . $ QTextEdit#ExtraSelection#>& extraSelection) |
| 357 | { |
| 358 | if (!isReadOnlycxx . . $ QTextEdit#isReadOnly(50ce9a9e25b4a850).()) |
| 359 | { |
| 360 | QTextEditcxx . . $ QTextEdit#::ExtraSelectioncxx . . $ QTextEdit#ExtraSelection# selection{}; |
| 361 | |
| 362 | selection.formatcxx . . $ QTextEdit#ExtraSelection#format. =cxx . . $ QTextCharFormat#`operator=`(4853e087512e0b03). m_syntaxStylecxx . . $ QCodeEditor#m_syntaxStyle.->getFormatcxx . . $ QSyntaxStyle#getFormat(5b7fd501ba56a402).("CurrentLine"cxx . . $ QString#QString(e1217c004a86c950).); |
| 363 | selection.formatcxx . . $ QTextEdit#ExtraSelection#format..setForegroundcxx . . $ QTextFormat#setForeground(ffc9f5d0bda78261).(QBrushcxx . . $ QBrush#QBrush(49f6e7a06ebc5aa8).()); |
| 364 | selection.formatcxx . . $ QTextEdit#ExtraSelection#format..setPropertycxx . . $ QTextFormat#setProperty(e71f85060bf8a055).(QTextFormatcxx . . $ QTextFormat#::FullWidthSelectioncxx . . $ QTextFormat#FullWidthSelection., truecxx . . $ QVariant#QVariant(b45ddcbc8423892c).); |
| 365 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor. =cxx . . $ QTextCursor#`operator=`(ea0024a71e5897e6). textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).(); |
| 366 | selection.cursorcxx . . $ QTextEdit#ExtraSelection#cursor..clearSelectioncxx . . $ QTextCursor#clearSelection(49f6e7a06ebc5aa8).(); |
| 367 | |
| 368 | extraSelection.appendcxx . . $ QList#append(77d9f17553126ecb).(selection); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | void QCodeEditorcxx . . $ QCodeEditor#::paintEventcxx . . $ QCodeEditor#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#* e) |
| 373 | { |
| 374 | updateLineNumberAreacxx . . $ QCodeEditor#updateLineNumberArea(22ba0428947158b).(e->rectcxx . . $ QPaintEvent#rect(f4023511c62cad66).()); |
| 375 | QTextEditcxx . . $ QTextEdit#::paintEventcxx . . $ QTextEdit#paintEvent(f239c9e85d61a220).(e); |
| 376 | } |
| 377 | |
| 378 | int QCodeEditorcxx . . $ QCodeEditor#::getFirstVisibleBlockcxx . . $ QCodeEditor#getFirstVisibleBlock(b126dc7c1de90089).() |
| 379 | { |
| 380 | // Detect the first block for which bounding rect - once translated |
| 381 | // in absolute coordinated - is contained by the editor's text area |
| 382 | |
| 383 | // Costly way of doing but since "blockBoundingGeometry(...)" doesn't |
| 384 | // exists for "QTextEdit"... |
| 385 | |
| 386 | QTextCursorcxx . . $ QTextCursor# curs = QTextCursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).(documentcxx . . $ QTextEdit#document(f21741221844491e).()); |
| 387 | curs.movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).(QTextCursorcxx . . $ QTextCursor#::Startcxx . . $ QTextCursor#Start.); |
| 388 | for(int i=0; i < documentcxx . . $ QTextEdit#document(f21741221844491e).()->blockCountcxx . . $ QTextDocument#blockCount(455f465bc33b4cdf).(); ++i) |
| 389 | { |
| 390 | QTextBlockcxx . . $ QTextBlock# block = curscxx . . $ QTextBlock#QTextBlock(ca9d602f58d4ee04)..blockcxx . . $ QTextCursor#block(fcb2c37f271a2a41).(); |
| 391 | |
| 392 | QRectcxx . . $ QRect# r1 = viewportcxx . . $ QAbstractScrollArea#viewport(27f420ad5cce8994).()->geometrycxx . . $ QWidget#geometry(f4023511c62cad66).(); |
| 393 | QRectcxx . . $ QRect# r2 = documentcxx . . $ QTextEdit#document(f21741221844491e).() |
| 394 | ->documentLayoutcxx . . $ QTextDocument#documentLayout(135eff1e02365923).() |
| 395 | ->blockBoundingRectcxx . . $ QAbstractTextDocumentLayout#blockBoundingRect(b25b5125f533bbfc).(block) |
| 396 | .translatedcxx . . $ QRectF#translated(3dca8665d0298123).( |
| 397 | viewportcxx . . $ QAbstractScrollArea#viewport(27f420ad5cce8994).()->geometrycxx . . $ QWidget#geometry(f4023511c62cad66).().xcxx . . $ QRect#x(455f465bc33b4cdf).(), |
| 398 | viewportcxx . . $ QAbstractScrollArea#viewport(27f420ad5cce8994).()->geometrycxx . . $ QWidget#geometry(f4023511c62cad66).().ycxx . . $ QRect#y(455f465bc33b4cdf).() - verticalScrollBarcxx . . $ QAbstractScrollArea#verticalScrollBar(49d9510c6adf8c19).()->sliderPositioncxx . . $ QAbstractSlider#sliderPosition(455f465bc33b4cdf).() |
| 399 | ).toRectcxx . . $ QRectF#toRect(d857385bac04cbf7).(); |
| 400 | |
| 401 | if (r1.intersectscxx . . $ QRect#intersects(49ff4cc075de370d).(r2)) |
| 402 | { |
| 403 | return i; |
| 404 | } |
| 405 | |
| 406 | curs.movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).(QTextCursorcxx . . $ QTextCursor#::NextBlockcxx . . $ QTextCursor#NextBlock.); |
| 407 | } |
| 408 | |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | bool QCodeEditorcxx . . $ QCodeEditor#::proceedCompleterBegincxx . . $ QCodeEditor#proceedCompleterBegin(654f5f472df72c38).(QKeyEventcxx . . $ QKeyEvent# *e) |
| 413 | { |
| 414 | if (m_completercxx . . $ QCodeEditor#m_completer. && |
| 415 | m_completercxx . . $ QCodeEditor#m_completer.->popupcxx . . $ QCompleter#popup(bf04caadd7ac52ca).()->isVisiblecxx . . $ QWidget#isVisible(50ce9a9e25b4a850).()) |
| 416 | { |
| 417 | switch (e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).()) |
| 418 | { |
| 419 | case Qtcxx . . $ Qt/::Key_Entercxx . . $ Qt/Key_Enter.: |
| 420 | case Qtcxx . . $ Qt/::Key_Returncxx . . $ Qt/Key_Return.: |
| 421 | case Qtcxx . . $ Qt/::Key_Escapecxx . . $ Qt/Key_Escape.: |
| 422 | case Qtcxx . . $ Qt/::Key_Tabcxx . . $ Qt/Key_Tab.: |
| 423 | case Qtcxx . . $ Qt/::Key_Backtabcxx . . $ Qt/Key_Backtab.: |
| 424 | e->ignorecxx . . $ QEvent#ignore(49f6e7a06ebc5aa8).(); |
| 425 | return true; // let the completer do default behavior |
| 426 | default: |
| 427 | break; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | // todo: Replace with modifiable QShortcut |
| 432 | auto isShortcut = ((e->modifierscxx . . $ QKeyEvent#modifiers(bf228902b3e5e63b).() &cxx . . $ QFlags#`operator&`(1933792fc5621fd5). Qtcxx . . $ Qt/::ControlModifiercxx . . $ Qt/ControlModifier.) && e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Spacecxx . . $ Qt/Key_Space.); |
| 433 | |
| 434 | return !(!m_completercxx . . $ QCodeEditor#m_completer. || !isShortcut); |
| 435 | |
| 436 | } |
| 437 | |
| 438 | void QCodeEditorcxx . . $ QCodeEditor#::proceedCompleterEndcxx . . $ QCodeEditor#proceedCompleterEnd(c92999c1b6b09cc0).(QKeyEventcxx . . $ QKeyEvent# *e) |
| 439 | { |
| 440 | auto ctrlOrShift = e->modifierscxx . . $ QKeyEvent#modifiers(bf228902b3e5e63b).() &cxx . . $ QFlags#`operator&`(e4b8f38b1f8adb0f). (Qtcxx . . $ Qt/::ControlModifiercxx . . $ Qt/ControlModifier. |cxx . . $ Qt/`operator|`(27f94a3b40a8fdff). Qtcxx . . $ Qt/::ShiftModifiercxx . . $ Qt/ShiftModifier.); |
| 441 | |
| 442 | if (!m_completercxx . . $ QCodeEditor#m_completer. || |
| 443 | (ctrlOrShift && e->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) || |
| 444 | e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Deletecxx . . $ Qt/Key_Delete.) |
| 445 | { |
| 446 | return; |
| 447 | } |
| 448 | |
| 449 | static QStringcxx . . $ QString# eowcxx . . $ QString#QString(85c52e162fed56f9).(R"(~!@#$%^&*()_+{}|:"<>?,./;'[]\-=)"); |
| 450 | |
| 451 | auto isShortcut = ((e->modifierscxx . . $ QKeyEvent#modifiers(bf228902b3e5e63b).() &cxx . . $ QFlags#`operator&`(1933792fc5621fd5). Qtcxx . . $ Qt/::ControlModifiercxx . . $ Qt/ControlModifier.) && e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Spacecxx . . $ Qt/Key_Space.); |
| 452 | auto completionPrefix = wordUnderCursorcxx . . $ QString#QString(e1217c004a86c950).(); |
| 453 | |
| 454 | if (!isShortcut && |
| 455 | (e->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() || |
| 456 | completionPrefix.lengthcxx . . $ QString#length(455f465bc33b4cdf).() < 2 || |
| 457 | eow.containscxx . . $ QString#contains(8cce4688c16f48f3).(e->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).().rightcxx . . $ QString#right(3f3c3d0e9c0eb37f).(1)))) |
| 458 | { |
| 459 | m_completercxx . . $ QCodeEditor#m_completer.->popupcxx . . $ QCompleter#popup(bf04caadd7ac52ca).()->hidecxx . . $ QWidget#hide(49f6e7a06ebc5aa8).(); |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | if (completionPrefix !=cxx . . $ `operator!=`(edf9e4f73813982f). m_completercxx . . $ QCodeEditor#m_completer.->completionPrefixcxx . . $ QCompleter#completionPrefix(6ef7b6c27b00b43d).()) |
| 464 | { |
| 465 | m_completercxx . . $ QCodeEditor#m_completer.->setCompletionPrefixcxx . . $ QCompleter#setCompletionPrefix(3520e46b33348bf6).(completionPrefix); |
| 466 | m_completercxx . . $ QCodeEditor#m_completer.->popupcxx . . $ QCompleter#popup(bf04caadd7ac52ca).()->setCurrentIndexcxx . . $ QAbstractItemView#setCurrentIndex(87a6de385263c395).(m_completercxx . . $ QCodeEditor#m_completer.->completionModelcxx . . $ QCompleter#completionModel(c9c1e11e7bd96493).()->indexcxx . . $ QAbstractItemModel#index(37dbccf64c4e392).(0, 0)); |
| 467 | } |
| 468 | |
| 469 | auto cursRect = cursorRectcxx . . $ QTextEdit#cursorRect(d857385bac04cbf7).(); |
| 470 | cursRect.setWidthcxx . . $ QRect#setWidth(d4f767463ce0a6b3).( |
| 471 | m_completercxx . . $ QCodeEditor#m_completer.->popupcxx . . $ QCompleter#popup(bf04caadd7ac52ca).()->sizeHintForColumncxx . . $ QAbstractItemView#sizeHintForColumn(7ccb52b1bfe01045).(0) + |
| 472 | m_completercxx . . $ QCodeEditor#m_completer.->popupcxx . . $ QCompleter#popup(bf04caadd7ac52ca).()->verticalScrollBarcxx . . $ QAbstractScrollArea#verticalScrollBar(49d9510c6adf8c19).()->sizeHintcxx . . $ QScrollBar#sizeHint(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(455f465bc33b4cdf).() |
| 473 | ); |
| 474 | |
| 475 | m_completercxx . . $ QCodeEditor#m_completer.->completecxx . . $ QCompleter#complete(22ba0428947158b).(cursRect); |
| 476 | } |
| 477 | |
| 478 | void QCodeEditorcxx . . $ QCodeEditor#::keyPressEventcxx . . $ QCodeEditor#keyPressEvent(c92999c1b6b09cc0).(QKeyEventcxx . . $ QKeyEvent#* e) { |
| 479 | #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= 0x050A00 |
| 480 | const int defaultIndent = tabStopDistancecxx . . $ QTextEdit#tabStopDistance(21b6c25e127938e2).() / fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().averageCharWidthcxx . . $ QFontMetrics#averageCharWidth(455f465bc33b4cdf).(); |
| 481 | #else |
| 482 | const int defaultIndent = tabStopWidth() / fontMetrics().averageCharWidth(); |
| 483 | #endif |
| 484 | |
| 485 | auto completerSkip = proceedCompleterBegincxx . . $ QCodeEditor#proceedCompleterBegin(654f5f472df72c38).(e); |
| 486 | |
| 487 | if (!completerSkip) { |
| 488 | if (m_replaceTabcxx . . $ QCodeEditor#m_replaceTab. && e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Tabcxx . . $ Qt/Key_Tab. && |
| 489 | e->modifierscxx . . $ QKeyEvent#modifiers(bf228902b3e5e63b).() == Qtcxx . . $ Qt/::NoModifiercxx . . $ Qt/NoModifier.) { |
| 490 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(m_tabReplacecxx . . $ QCodeEditor#m_tabReplace.); |
| 491 | return; |
| 492 | } |
| 493 | |
| 494 | // Auto indentation |
| 495 | int indentationLevel = getIndentationSpacescxx . . $ QCodeEditor#getIndentationSpaces(b126dc7c1de90089).(); |
| 496 | |
| 497 | #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= 0x050A00 |
| 498 | int tabCounts = |
| 499 | indentationLevel * fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().averageCharWidthcxx . . $ QFontMetrics#averageCharWidth(455f465bc33b4cdf).() / tabStopDistancecxx . . $ QTextEdit#tabStopDistance(21b6c25e127938e2).(); |
| 500 | #else |
| 501 | int tabCounts = |
| 502 | indentationLevel * fontMetrics().averageCharWidth() / tabStopWidth(); |
| 503 | #endif |
| 504 | |
| 505 | // Have Qt Edior like behaviour, if {|} and enter is pressed indent the two |
| 506 | // parenthesis |
| 507 | if (m_autoIndentationcxx . . $ QCodeEditor#m_autoIndentation. && |
| 508 | (e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Returncxx . . $ Qt/Key_Return. || e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Entercxx . . $ Qt/Key_Enter.) && |
| 509 | charUnderCursorcxx . . $ QCodeEditor#charUnderCursor(fee70a7e000c558e).() ==cxx . . $ `operator==`(266b2cc48a9d5b67). '}'cxx . . $ QChar#QChar(d4f767463ce0a6b3). && charUnderCursorcxx . . $ QCodeEditor#charUnderCursor(fee70a7e000c558e).(-1) ==cxx . . $ `operator==`(266b2cc48a9d5b67). '{'cxx . . $ QChar#QChar(d4f767463ce0a6b3).) |
| 510 | { |
| 511 | int charsBack = 0; |
| 512 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).("\n"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 513 | |
| 514 | if (m_replaceTabcxx . . $ QCodeEditor#m_replaceTab.) |
| 515 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(indentationLevel + defaultIndent, ' 'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)); |
| 516 | else |
| 517 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(tabCounts + 1, '\t'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)); |
| 518 | |
| 519 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).("\n"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 520 | charsBack++; |
| 521 | |
| 522 | if (m_replaceTabcxx . . $ QCodeEditor#m_replaceTab.) |
| 523 | { |
| 524 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(indentationLevel, ' 'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)); |
| 525 | charsBack += indentationLevel; |
| 526 | } |
| 527 | else |
| 528 | { |
| 529 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(tabCounts, '\t'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)); |
| 530 | charsBack += tabCounts; |
| 531 | } |
| 532 | |
| 533 | while (charsBack--) |
| 534 | moveCursorcxx . . $ QTextEdit#moveCursor(a1f32533f9180c25).(QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Leftcxx . . $ QTextCursor#Left.); |
| 535 | return; |
| 536 | } |
| 537 | |
| 538 | // Shortcut for moving line to left |
| 539 | if (m_replaceTabcxx . . $ QCodeEditor#m_replaceTab. && e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Backtabcxx . . $ Qt/Key_Backtab.) { |
| 540 | indentationLevel = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(indentationLevel, m_tabReplacecxx . . $ QCodeEditor#m_tabReplace..sizecxx . . $ QString#size(455f465bc33b4cdf).()); |
| 541 | |
| 542 | auto cursor = textCursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).(); |
| 543 | |
| 544 | cursor.movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).(QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::StartOfLinecxx . . $ QTextCursor#StartOfLine.); |
| 545 | cursor.movePositioncxx . . $ QTextCursor#movePosition(e5e992d8a5d1c17e).(QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Rightcxx . . $ QTextCursor#Right., |
| 546 | QTextCursorcxx . . $ QTextCursor#::MoveModecxx . . $ QTextCursor#MoveMode#::KeepAnchorcxx . . $ QTextCursor#KeepAnchor., indentationLevel); |
| 547 | |
| 548 | cursor.removeSelectedTextcxx . . $ QTextCursor#removeSelectedText(49f6e7a06ebc5aa8).(); |
| 549 | return; |
| 550 | } |
| 551 | |
| 552 | QTextEditcxx . . $ QTextEdit#::keyPressEventcxx . . $ QTextEdit#keyPressEvent(c92999c1b6b09cc0).(e); |
| 553 | |
| 554 | if (m_autoIndentationcxx . . $ QCodeEditor#m_autoIndentation. && (e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Returncxx . . $ Qt/Key_Return. || e->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).() == Qtcxx . . $ Qt/::Key_Entercxx . . $ Qt/Key_Enter.)) { |
| 555 | if (m_replaceTabcxx . . $ QCodeEditor#m_replaceTab.) |
| 556 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(indentationLevel, ' 'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)); |
| 557 | else |
| 558 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(QStringcxx . . $ QString#QString(96e7cefa75f5b4f8).(tabCounts, '\t'cxx . . $ QChar#QChar(d4f767463ce0a6b3).)); |
| 559 | } |
| 560 | |
| 561 | if (m_autoParenthesescxx . . $ QCodeEditor#m_autoParentheses.) |
| 562 | { |
| 563 | for (auto&& el : parenthesescxx . . $ parentheses.) |
| 564 | { |
| 565 | // Inserting closed brace |
| 566 | if (el.firstcxx . . $ QPair#first. ==cxx . . $ `operator==`(edf9e4f73813982f). e->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).()) |
| 567 | { |
| 568 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(el.secondcxx . . $ QPair#second.); |
| 569 | moveCursorcxx . . $ QTextEdit#moveCursor(a1f32533f9180c25).(QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Leftcxx . . $ QTextCursor#Left.); |
| 570 | break; |
| 571 | } |
| 572 | |
| 573 | // If it's close brace - check parentheses |
| 574 | if (el.secondcxx . . $ QPair#second. ==cxx . . $ `operator==`(edf9e4f73813982f). e->textcxx . . $ QKeyEvent#text(6ef7b6c27b00b43d).()) |
| 575 | { |
| 576 | auto symbol = charUnderCursorcxx . . $ QCodeEditor#charUnderCursor(fee70a7e000c558e).(); |
| 577 | |
| 578 | if (symbol ==cxx . . $ `operator==`(449a863179552d84). el.secondcxx . . $ QPair#second.) |
| 579 | { |
| 580 | textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).().deletePreviousCharcxx . . $ QTextCursor#deletePreviousChar(49f6e7a06ebc5aa8).(); |
| 581 | moveCursorcxx . . $ QTextEdit#moveCursor(a1f32533f9180c25).(QTextCursorcxx . . $ QTextCursor#::MoveOperationcxx . . $ QTextCursor#MoveOperation#::Rightcxx . . $ QTextCursor#Right.); |
| 582 | } |
| 583 | |
| 584 | break; |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | proceedCompleterEndcxx . . $ QCodeEditor#proceedCompleterEnd(c92999c1b6b09cc0).(e); |
| 591 | } |
| 592 | |
| 593 | void QCodeEditorcxx . . $ QCodeEditor#::setAutoIndentationcxx . . $ QCodeEditor#setAutoIndentation(b45ddcbc8423892c).(bool enabled) |
| 594 | { |
| 595 | m_autoIndentationcxx . . $ QCodeEditor#m_autoIndentation. = enabled; |
| 596 | } |
| 597 | |
| 598 | bool QCodeEditorcxx . . $ QCodeEditor#::autoIndentationcxx . . $ QCodeEditor#autoIndentation(50ce9a9e25b4a850).() const |
| 599 | { |
| 600 | return m_autoIndentationcxx . . $ QCodeEditor#m_autoIndentation.; |
| 601 | } |
| 602 | |
| 603 | void QCodeEditorcxx . . $ QCodeEditor#::setAutoParenthesescxx . . $ QCodeEditor#setAutoParentheses(b45ddcbc8423892c).(bool enabled) |
| 604 | { |
| 605 | m_autoParenthesescxx . . $ QCodeEditor#m_autoParentheses. = enabled; |
| 606 | } |
| 607 | |
| 608 | bool QCodeEditorcxx . . $ QCodeEditor#::autoParenthesescxx . . $ QCodeEditor#autoParentheses(50ce9a9e25b4a850).() const |
| 609 | { |
| 610 | return m_autoParenthesescxx . . $ QCodeEditor#m_autoParentheses.; |
| 611 | } |
| 612 | |
| 613 | void QCodeEditorcxx . . $ QCodeEditor#::setTabReplacecxx . . $ QCodeEditor#setTabReplace(b45ddcbc8423892c).(bool enabled) |
| 614 | { |
| 615 | m_replaceTabcxx . . $ QCodeEditor#m_replaceTab. = enabled; |
| 616 | } |
| 617 | |
| 618 | bool QCodeEditorcxx . . $ QCodeEditor#::tabReplacecxx . . $ QCodeEditor#tabReplace(50ce9a9e25b4a850).() const |
| 619 | { |
| 620 | return m_replaceTabcxx . . $ QCodeEditor#m_replaceTab.; |
| 621 | } |
| 622 | |
| 623 | void QCodeEditorcxx . . $ QCodeEditor#::setTabReplaceSizecxx . . $ QCodeEditor#setTabReplaceSize(d4f767463ce0a6b3).(int val) |
| 624 | { |
| 625 | m_tabReplacecxx . . $ QCodeEditor#m_tabReplace..clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 626 | |
| 627 | m_tabReplacecxx . . $ QCodeEditor#m_tabReplace..fillcxx . . $ QString#fill(feec2fc69f0958b3).(' 'cxx . . $ QChar#QChar(d4f767463ce0a6b3)., val); |
| 628 | } |
| 629 | |
| 630 | int QCodeEditorcxx . . $ QCodeEditor#::tabReplaceSizecxx . . $ QCodeEditor#tabReplaceSize(455f465bc33b4cdf).() const |
| 631 | { |
| 632 | return m_tabReplacecxx . . $ QCodeEditor#m_tabReplace..sizecxx . . $ QString#size(455f465bc33b4cdf).(); |
| 633 | } |
| 634 | |
| 635 | void QCodeEditorcxx . . $ QCodeEditor#::setCompletercxx . . $ QCodeEditor#setCompleter(638321c80ff6aea).(QCompletercxx . . $ QCompleter# *completer) |
| 636 | { |
| 637 | if (m_completercxx . . $ QCodeEditor#m_completer.) |
| 638 | { |
| 639 | disconnectcxx . . $ QObject#disconnect(cc30ff19c637f8ed).(m_completercxx . . $ QCodeEditor#m_completer., nullptr, this, nullptr); |
| 640 | } |
| 641 | |
| 642 | m_completercxx . . $ QCodeEditor#m_completer. = completer; |
| 643 | |
| 644 | if (!m_completercxx . . $ QCodeEditor#m_completer.) |
| 645 | { |
| 646 | return; |
| 647 | } |
| 648 | |
| 649 | m_completercxx . . $ QCodeEditor#m_completer.->setWidgetcxx . . $ QCompleter#setWidget(108f35f7aa7f3cf9).(this); |
| 650 | m_completercxx . . $ QCodeEditor#m_completer.->setCompletionModecxx . . $ QCompleter#setCompletionMode(73b436c818b58342).(QCompletercxx . . $ QCompleter#::CompletionModecxx . . $ QCompleter#CompletionMode#::PopupCompletioncxx . . $ QCompleter#PopupCompletion.); |
| 651 | |
| 652 | connectcxx . . $ QObject#connect(835f87066c895669).( |
| 653 | m_completercxx . . $ QCodeEditor#m_completer., |
| 654 | QOverloadcxx . . $ QOverload#<const QString&>::ofcxx . . $ QOverload#of(c2d37ffc247de3c4).(&QCompletercxx . . $ QCompleter#::activatedcxx . . $ QCompleter#activated(3520e46b33348bf6).), |
| 655 | this, |
| 656 | &QCodeEditorcxx . . $ QCodeEditor#::insertCompletioncxx . . $ QCodeEditor#insertCompletion(7df51288a9ebd664). |
| 657 | ); |
| 658 | } |
| 659 | |
| 660 | void QCodeEditorcxx . . $ QCodeEditor#::focusInEventcxx . . $ QCodeEditor#focusInEvent(897a5ce4b6676619).(QFocusEventcxx . . $ QFocusEvent# *e) |
| 661 | { |
| 662 | if (m_completercxx . . $ QCodeEditor#m_completer.) |
| 663 | { |
| 664 | m_completercxx . . $ QCodeEditor#m_completer.->setWidgetcxx . . $ QCompleter#setWidget(108f35f7aa7f3cf9).(this); |
| 665 | } |
| 666 | |
| 667 | QTextEditcxx . . $ QTextEdit#::focusInEventcxx . . $ QTextEdit#focusInEvent(897a5ce4b6676619).(e); |
| 668 | } |
| 669 | |
| 670 | void QCodeEditorcxx . . $ QCodeEditor#::insertCompletioncxx . . $ QCodeEditor#insertCompletion(7df51288a9ebd664).(QStringcxx . . $ QString# s) |
| 671 | { |
| 672 | if (m_completercxx . . $ QCodeEditor#m_completer.->widgetcxx . . $ QCompleter#widget(27f420ad5cce8994).() != this) |
| 673 | { |
| 674 | return; |
| 675 | } |
| 676 | |
| 677 | auto tc = textCursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).(); |
| 678 | tc.selectcxx . . $ QTextCursor#select(71b96aaf81af89cd).(QTextCursorcxx . . $ QTextCursor#::SelectionTypecxx . . $ QTextCursor#SelectionType#::WordUnderCursorcxx . . $ QTextCursor#WordUnderCursor.); |
| 679 | tc.insertTextcxx . . $ QTextCursor#insertText(3520e46b33348bf6).(s); |
| 680 | setTextCursorcxx . . $ QTextEdit#setTextCursor(a408cee6726ac3d5).(tc); |
| 681 | } |
| 682 | |
| 683 | QCompletercxx . . $ QCompleter# *QCodeEditorcxx . . $ QCodeEditor#::completercxx . . $ QCodeEditor#completer(2f221150cdd0896).() const |
| 684 | { |
| 685 | return m_completercxx . . $ QCodeEditor#m_completer.; |
| 686 | } |
| 687 | |
| 688 | QCharcxx . . $ QChar# QCodeEditorcxx . . $ QCodeEditor#::charUnderCursorcxx . . $ QCodeEditor#charUnderCursor(fee70a7e000c558e).(int offset) const |
| 689 | { |
| 690 | auto block = textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).().blockNumbercxx . . $ QTextCursor#blockNumber(455f465bc33b4cdf).(); |
| 691 | auto index = textCursorcxx . . $ QTextEdit#textCursor(878247cba2fd3c00).().positionInBlockcxx . . $ QTextCursor#positionInBlock(455f465bc33b4cdf).(); |
| 692 | auto text = documentcxx . . $ QString#QString(e1217c004a86c950).()->findBlockByNumbercxx . . $ QTextDocument#findBlockByNumber(c1425046715037b8).(block).textcxx . . $ QTextBlock#text(6ef7b6c27b00b43d).(); |
| 693 | |
| 694 | index += offset; |
| 695 | |
| 696 | if (index < 0 || index >= text.sizecxx . . $ QString#size(455f465bc33b4cdf).()) |
| 697 | { |
| 698 | return {cxx . . $ QChar#QChar(49f6e7a06ebc5aa8).}; |
| 699 | } |
| 700 | |
| 701 | return text[cxx . . $ QString#`operator[]`(57436120916eb52c).index]; |
| 702 | } |
| 703 | |
| 704 | QStringcxx . . $ QString# QCodeEditorcxx . . $ QCodeEditor#::wordUnderCursorcxx . . $ QCodeEditor#wordUnderCursor(6ef7b6c27b00b43d).() const |
| 705 | { |
| 706 | auto tc = textCursorcxx . . $ QTextCursor#QTextCursor(a408cee6726ac3d5).(); |
| 707 | tc.selectcxx . . $ QTextCursor#select(71b96aaf81af89cd).(QTextCursorcxx . . $ QTextCursor#::WordUnderCursorcxx . . $ QTextCursor#WordUnderCursor.); |
| 708 | return tccxx . . $ QString#QString(e1217c004a86c950)..selectedTextcxx . . $ QTextCursor#selectedText(6ef7b6c27b00b43d).(); |
| 709 | } |
| 710 | |
| 711 | void QCodeEditorcxx . . $ QCodeEditor#::insertFromMimeDatacxx . . $ QCodeEditor#insertFromMimeData(9f04b6fd1efe3797).(const QMimeDatacxx . . $ QMimeData#* source) |
| 712 | { |
| 713 | insertPlainTextcxx . . $ QTextEdit#insertPlainText(3520e46b33348bf6).(source->textcxx . . $ QMimeData#text(6ef7b6c27b00b43d).()); |
| 714 | } |
| 715 | |
| 716 | int QCodeEditorcxx . . $ QCodeEditor#::getIndentationSpacescxx . . $ QCodeEditor#getIndentationSpaces(b126dc7c1de90089).() |
| 717 | { |
| 718 | auto blockText = textCursorcxx . . $ QString#QString(e1217c004a86c950).().blockcxx . . $ QTextCursor#block(fcb2c37f271a2a41).().textcxx . . $ QTextBlock#text(6ef7b6c27b00b43d).(); |
| 719 | |
| 720 | int indentationLevel = 0; |
| 721 | |
| 722 | for (auto i = 0; |
| 723 | i < blockText.sizecxx . . $ QString#size(455f465bc33b4cdf).() && QStringcxx . . $ QString#QString(85c52e162fed56f9).("\t ").containscxx . . $ QString#contains(7cf081d1b6a1defd).(blockText[cxx . . $ QString#`operator[]`(57436120916eb52c).i]); |
| 724 | ++i) |
| 725 | { |
| 726 | if (blockText[cxx . . $ QString#`operator[]`(57436120916eb52c).i] ==cxx . . $ `operator==`(266b2cc48a9d5b67). ' 'cxx . . $ QChar#QChar(d4f767463ce0a6b3).) |
| 727 | { |
| 728 | indentationLevel++; |
| 729 | } |
| 730 | else |
| 731 | { |
| 732 | #if QT_VERSIONcxx . . $ `<external>/15045578679651060896/qglobal.h:57:9`! >= 0x050A00 |
| 733 | indentationLevel += tabStopDistancecxx . . $ QTextEdit#tabStopDistance(21b6c25e127938e2).() / fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().averageCharWidthcxx . . $ QFontMetrics#averageCharWidth(455f465bc33b4cdf).(); |
| 734 | #else |
| 735 | indentationLevel += tabStopWidth() / fontMetrics().averageCharWidth(); |
| 736 | #endif |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | return indentationLevel; |
| 741 | } |