SILICON
Loading...
Searching...
No Matches
codeEditor.cpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "codeEditor.hpp"
19
20
21#include <algorithm>
22#include <array>
23#include <stdexcept>
24#include <string_view>
25#include <utility>
26
27#include <QAbstractItemView>
28#include <QByteArray>
29#include <QCompleter>
30#include <QContextMenuEvent>
31#include <QEvent>
32#include <QFontInfo>
33#include <QFontMetrics>
34#include <QKeyEvent>
35#include <QMenu>
36#include <QPaintEvent>
37#include <QPainter>
38#include <QResizeEvent>
39#include <QScrollBar>
40#include <QStringListModel>
41#include <QTextBlock>
42#include <QWheelEvent>
43#include <QWidget>
44
47
48namespace SILICON::ui {
49namespace {
50
51 [[nodiscard]] QChar closingDelimiter(const QChar opening)
52 {
53 switch (opening.unicode()) {
54 case '(': return QLatin1Char(')');
55 case '[': return QLatin1Char(']');
56 case '{': return QLatin1Char('}');
57 default: return {};
58 }
59 }
60
61 [[nodiscard]] bool isClosingDelimiter(const QChar character)
62 {
63 return character == QLatin1Char(')') || character == QLatin1Char(']')
64 || character == QLatin1Char('}');
65 }
66
67} // namespace
68
69class CodeLineNumberArea : public QWidget {
70public:
72
73 [[nodiscard]] QSize sizeHint() const override
74 {
75 return {editor->lineNumberAreaWidth(), 0};
76 }
77
78protected:
79 void paintEvent(QPaintEvent* event) override { editor->paintLineNumberArea(event); }
80
81private:
83};
84
85CodeEditor::CodeEditor(QWidget* parent)
86 : QPlainTextEdit(parent),
89 completer(new QCompleter(this)),
90 completionModel(new QStringListModel(this))
91{
92 setLineWrapMode(QPlainTextEdit::NoWrap);
93 setProperty("class", "mono");
95 completer->setWidget(this);
96 completer->setModel(completionModel);
97 completer->setCaseSensitivity(Qt::CaseSensitive);
98 completer->setCompletionMode(QCompleter::PopupCompletion);
99 completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
100
101 callbacks.connect(completer, qOverload<const QString&>(&QCompleter::activated),
102 [this](const QString& completion) { insertCompletion(completion); });
103 callbacks.connect(this, &QPlainTextEdit::blockCountChanged,
104 [this] { updateLineNumberAreaWidth(); });
105 callbacks.connect(this, &QPlainTextEdit::updateRequest,
106 [this](const QRect& rect, const int dy) {
107 if (dy)
108 lineNumberArea->scroll(0, dy);
109 else
110 lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
111 if (rect.contains(viewport()->rect()))
113 });
114 callbacks.connect(this, &QPlainTextEdit::cursorPositionChanged, [this] {
115 lineNumberArea->update();
116 completer->popup()->hide();
117 });
119}
120
122{
124 throw std::invalid_argument("Code editor requires a code document type");
125
126 const auto* syntax = codeFilePresentation(type).syntax;
127 if (!syntax)
128 throw std::invalid_argument("Code document type has no syntax definition");
129
130 fileTypeValue = type;
131 syntaxHighlighter->setSyntax(syntax);
132 refreshTheme();
136}
137
139{
140 fileTypeValue.reset();
141 syntaxHighlighter->setSyntax(nullptr);
142 completionModel->setStringList({});
143 indentationTriggers.clear();
144 completer->popup()->hide();
145 clear();
146}
147
148const std::optional<SILICON::project::DocumentType>& CodeEditor::fileType() const
149{
150 return fileTypeValue;
151}
152
154{
155 syntaxHighlighter->setPalette(palette());
156}
157
159{
160 QStringList candidates;
161 if (fileTypeValue) {
162 const auto& syntax = *codeFilePresentation(*fileTypeValue).syntax;
163 for (const auto& group : syntax.keywordGroups) {
164 for (const auto word : group.words) {
165 candidates.append(
166 QString::fromUtf8(word.data(), static_cast<qsizetype>(word.size())));
167 }
168 }
169 }
170 candidates.removeDuplicates();
171 candidates.sort(Qt::CaseSensitive);
172 completionModel->setStringList(candidates);
173}
174
176{
177 indentationTriggers.clear();
178 if (!fileTypeValue)
179 return;
180
181 const auto* indentation = codeFilePresentation(*fileTypeValue).syntax->indentation;
182 if (!indentation)
183 return;
184
185 indentationTriggers.reserve(indentation->triggerPatterns.size());
186 for (const auto pattern : indentation->triggerPatterns) {
187 QRegularExpression expression(
188 QString::fromUtf8(pattern.data(), static_cast<qsizetype>(pattern.size())));
189 if (!expression.isValid())
190 throw std::invalid_argument(QString("Invalid indentation trigger '%1': %2")
191 .arg(expression.pattern(), expression.errorString())
192 .toStdString());
193 indentationTriggers.push_back(std::move(expression));
194 }
195}
196
198{
199 const auto line = textCursor().block().text();
200 return std::ranges::any_of(indentationTriggers, [&line](const auto& expression) {
201 return expression.match(line).hasMatch();
202 });
203}
204
206{
207 if (!fileTypeValue)
208 return;
209
210 const auto* indentation = codeFilePresentation(*fileTypeValue).syntax->indentation;
211 if (!indentation)
212 return;
213
214 QTextCursor cursor = textCursor();
215 const auto currentBlock = cursor.block();
216 const auto currentText = currentBlock.text();
217 const auto currentUtf8 = currentText.toUtf8();
218
219 std::array<QByteArray, 2> previousUtf8;
220 std::array<std::string_view, 2> previousLines;
221 std::size_t previousCount = 0;
222 for (auto block = currentBlock.previous(); block.isValid() && previousCount < 2;
223 block = block.previous()) {
224 if (block.text().trimmed().isEmpty())
225 continue;
226 previousUtf8[previousCount] = block.text().toUtf8();
227 previousLines[previousCount] =
228 std::string_view(previousUtf8[previousCount].constData(),
229 static_cast<std::size_t>(previousUtf8[previousCount].size()));
230 ++previousCount;
231 }
232
233 const CodeIndentationContext context{
234 .currentLine = std::string_view(currentUtf8.constData(),
235 static_cast<std::size_t>(currentUtf8.size())),
236 .previousNonBlankLines =
237 std::span<const std::string_view>(previousLines).first(previousCount),
238 .indentWidth = currentIndentWidth(),
239 };
240 const auto desiredIndentUtf8 = indentation->indentationFor(context);
241 const auto desiredIndent = QString::fromUtf8(
242 desiredIndentUtf8.data(), static_cast<qsizetype>(desiredIndentUtf8.size()));
243
244 qsizetype existingIndentLength = 0;
245 while (existingIndentLength < currentText.size()
246 && (currentText[existingIndentLength] == QLatin1Char(' ')
247 || currentText[existingIndentLength] == QLatin1Char('\t'))) {
248 ++existingIndentLength;
249 }
250 if (currentText.first(existingIndentLength) == desiredIndent)
251 return;
252
253 const int contentOffset =
254 std::max(0, cursor.positionInBlock() - static_cast<int>(existingIndentLength));
255 cursor.beginEditBlock();
256 QTextCursor indentationCursor(document());
257 indentationCursor.setPosition(currentBlock.position());
258 indentationCursor.setPosition(currentBlock.position()
259 + static_cast<int>(existingIndentLength),
260 QTextCursor::KeepAnchor);
261 indentationCursor.insertText(desiredIndent);
262 cursor.setPosition(currentBlock.position() + desiredIndent.size() + contentOffset);
263 setTextCursor(cursor);
264 cursor.endEditBlock();
265}
266
267bool CodeEditor::isWordDelimiter(const QChar character) const
268{
269 if (!fileTypeValue)
270 return true;
271 const auto& syntax = *codeFilePresentation(*fileTypeValue).syntax;
272 const auto extra =
273 QString::fromUtf8(syntax.extraWordCharacters.data(),
274 static_cast<qsizetype>(syntax.extraWordCharacters.size()));
275 return !character.isLetterOrNumber() && character != QLatin1Char('_')
276 && !extra.contains(character);
277}
278
280{
281 const QTextCursor cursor = textCursor();
282 const QString text = cursor.block().text();
283 int start = cursor.positionInBlock();
284 while (start > 0 && !isWordDelimiter(text.at(start - 1)))
285 --start;
286 return text.mid(start, cursor.positionInBlock() - start);
287}
288
289void CodeEditor::showCompletion(const bool explicitRequest)
290{
291 if (!fileTypeValue || completionModel->rowCount() == 0)
292 return;
293 const QString prefix = completionPrefix();
294 if (!explicitRequest && prefix.size() < 2) {
295 completer->popup()->hide();
296 return;
297 }
298 completer->setCompletionPrefix(prefix);
299 if (completer->completionCount() == 0) {
300 completer->popup()->hide();
301 return;
302 }
303 constexpr int COMPLETION_POPUP_PADDING = 8;
304 QRect rect = cursorRect();
305 rect.translate(0, COMPLETION_POPUP_PADDING);
306 rect.setWidth(completer->popup()->sizeHintForColumn(0)
307 + completer->popup()->verticalScrollBar()->sizeHint().width());
308 completer->complete(rect);
309 completer->popup()->setCurrentIndex(completer->completionModel()->index(0, 0));
310}
311
312void CodeEditor::insertCompletion(const QString& completion)
313{
314 QTextCursor cursor = textCursor();
315 cursor.beginEditBlock();
316 const auto prefix = completionPrefix();
317 cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor, prefix.size());
318 cursor.insertText(completion);
319 setTextCursor(cursor);
322 cursor.endEditBlock();
323}
324
325bool CodeEditor::insertAutoPair(const QChar typed)
326{
327 QTextCursor cursor = textCursor();
328 const auto line = cursor.block().text();
329 const int offset = cursor.positionInBlock();
330 const QChar next = offset < line.size() ? line.at(offset) : QChar{};
331 const QChar close = closingDelimiter(typed);
332
333 if (!close.isNull()) {
334 if (cursor.hasSelection()) {
335 const int start = cursor.selectionStart();
336 const auto selection =
337 cursor.selectedText().replace(QChar::ParagraphSeparator, QLatin1Char('\n'));
338 cursor.insertText(QString(typed) + selection + close);
339 cursor.setPosition(start + 1);
340 cursor.setPosition(start + 1 + selection.size(), QTextCursor::KeepAnchor);
341 } else if (next == close) {
342 cursor.insertText(QString(typed));
343 } else if (next.isNull() || next.isSpace() || isClosingDelimiter(next)
344 || next == QLatin1Char(';') || next == QLatin1Char(',')) {
345 const int position = cursor.position();
346 cursor.insertText(QString(typed) + close);
347 cursor.setPosition(position + 1);
348 } else {
349 return false;
350 }
351 setTextCursor(cursor);
352 return true;
353 }
354
355 if (!cursor.hasSelection() && isClosingDelimiter(typed) && next == typed) {
356 cursor.movePosition(QTextCursor::Right);
357 setTextCursor(cursor);
358 return true;
359 }
360
361 return false;
362}
363
365{
366 QTextCursor cursor = textCursor();
367 if (cursor.hasSelection())
368 return false;
369
370 const auto line = cursor.block().text();
371 const int offset = cursor.positionInBlock();
372 if (offset <= 0 || offset >= line.size()
373 || closingDelimiter(line.at(offset - 1)) != line.at(offset))
374 return false;
375
376 cursor.setPosition(cursor.position() - 1);
377 cursor.setPosition(cursor.position() + 2, QTextCursor::KeepAnchor);
378 cursor.removeSelectedText();
379 setTextCursor(cursor);
380 return true;
381}
382
384{
385 if (!fileTypeValue)
386 return false;
387 const auto* indentation = codeFilePresentation(*fileTypeValue).syntax->indentation;
388 if (!indentation || !indentation->expandPairsOnNewline)
389 return false;
390
391 QTextCursor cursor = textCursor();
392 if (cursor.hasSelection())
393 return false;
394
395 const auto line = cursor.block().text();
396 const int offset = cursor.positionInBlock();
397 if (offset <= 0 || offset >= line.size()
398 || closingDelimiter(line.at(offset - 1)) != line.at(offset))
399 return false;
400
401 qsizetype prefixLength = 0;
402 while (prefixLength < line.size()
403 && (line.at(prefixLength) == QLatin1Char(' ')
404 || line.at(prefixLength) == QLatin1Char('\t')))
405 ++prefixLength;
406
407 const auto baseIndent = line.first(prefixLength);
408 const auto innerIndent =
409 baseIndent + QString(indentation->indentWidth, QLatin1Char(' '));
410 const int position = cursor.position();
411 cursor.insertText(QLatin1Char('\n') + innerIndent + QLatin1Char('\n') + baseIndent);
412 cursor.setPosition(position + 1 + innerIndent.size());
413 setTextCursor(cursor);
414 return true;
415}
416
417void CodeEditor::keyPressEvent(QKeyEvent* event)
418{
419 if (completer->popup()->isVisible()) {
420 switch (event->key()) {
421 case Qt::Key_Enter:
422 case Qt::Key_Return:
423 case Qt::Key_Tab:
424 case Qt::Key_Backtab:
425 if (const auto index = completer->popup()->currentIndex(); index.isValid())
426 insertCompletion(index.data(Qt::DisplayRole).toString());
427 completer->popup()->hide();
428 event->accept();
429 return;
430 case Qt::Key_Escape:
431 completer->popup()->hide();
432 event->accept();
433 return;
434 default: break;
435 }
436 }
437
438 const bool plainKey =
439 fileTypeValue && !isReadOnly()
440 && !(event->modifiers()
441 & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier));
442 if (plainKey && event->key() == Qt::Key_Backspace && removeEmptyPair()) {
443 completer->popup()->hide();
444 event->accept();
445 return;
446 }
447
448 if (event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) {
449 if (event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)) {
450 QPlainTextEdit::keyPressEvent(event);
451 return;
452 }
453 const int indent = currentIndentWidth();
454 if (event->key() == Qt::Key_Tab) {
455 QTextCursor cursor = textCursor();
456 cursor.insertText(QString(indent, QLatin1Char(' ')));
457 setTextCursor(cursor);
458 } else {
460 }
461 event->accept();
462 return;
463 }
464
465 if (event->matches(QKeySequence::InsertParagraphSeparator)) {
466 if (plainKey && expandPairedDelimiters()) {
467 completer->popup()->hide();
468 event->accept();
469 return;
470 }
471 QTextCursor cursor = textCursor();
472 cursor.beginEditBlock();
473 QPlainTextEdit::keyPressEvent(event);
475 cursor.endEditBlock();
476 completer->popup()->hide();
477 return;
478 }
479 const bool explicitRequest =
480 event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Space;
481 const bool typedText =
482 !event->text().isEmpty()
483 && !(event->modifiers()
484 & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier));
485 if (plainKey && event->text().size() == 1 && insertAutoPair(event->text().front())) {
486 completer->popup()->hide();
487 event->accept();
488 return;
489 }
490 if (!explicitRequest)
491 QPlainTextEdit::keyPressEvent(event);
492 if (typedText && currentLineMatchesIndentationTrigger())
494 if (explicitRequest || typedText)
495 showCompletion(explicitRequest);
496 else
497 completer->popup()->hide();
498}
499
500#ifndef QT_NO_CONTEXTMENU
501void CodeEditor::contextMenuEvent(QContextMenuEvent* event)
502{
503 #ifdef __EMSCRIPTEN__
504 auto* menu = new QMenu(this);
505 menu->setAttribute(Qt::WA_DeleteOnClose);
506 #else
507 QMenu stackMenu(this);
508 auto* menu = &stackMenu;
509 #endif
510
511 auto* cutAction = menu->addAction(tr("Cut"), this, &QPlainTextEdit::cut);
512 cutAction->setEnabled(!isReadOnly() && textCursor().hasSelection());
513 auto* copyAction = menu->addAction(tr("Copy"), this, &QPlainTextEdit::copy);
514 copyAction->setEnabled(textCursor().hasSelection());
515 auto* pasteAction = menu->addAction(tr("Paste"), this, &QPlainTextEdit::paste);
516 pasteAction->setEnabled(!isReadOnly() && canPaste());
517 auto* deleteAction = menu->addAction(tr("Delete"), callbacks.context(), [this] {
518 auto cursor = textCursor();
519 cursor.removeSelectedText();
520 });
521 deleteAction->setEnabled(!isReadOnly() && textCursor().hasSelection());
522 menu->addSeparator();
523 auto* selectAllAction =
524 menu->addAction(tr("Select All"), this, &QPlainTextEdit::selectAll);
525 selectAllAction->setEnabled(!document()->isEmpty());
526
527 #ifdef __EMSCRIPTEN__
528 menu->popup(event->globalPos());
529 #else
530 menu->exec(event->globalPos());
531 #endif
532 event->accept();
533}
534#endif
535
536void CodeEditor::wheelEvent(QWheelEvent* event)
537{
538 const int delta = event->angleDelta().y();
539 if (!(event->modifiers() & Qt::ControlModifier) || delta == 0) {
540 QPlainTextEdit::wheelEvent(event);
541 return;
542 }
543
544 const int steps = std::max(1, std::abs(delta) / 120);
545 zoomBy(delta > 0 ? steps : -steps);
546 event->accept();
547}
548
549void CodeEditor::zoomBy(int steps)
550{
551 constexpr qreal MINIMUM_FONT_SIZE = 6.0;
552 constexpr qreal MAXIMUM_FONT_SIZE = 48.0;
553
554 if (zoomFontPointSize <= 0.0)
555 zoomFontPointSize = QFontInfo(font()).pointSizeF();
556 if (zoomFontPointSize <= 0.0)
557 zoomFontPointSize = 10.0;
558 zoomFontPointSize = std::clamp(zoomFontPointSize + steps,
559 MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE);
560
561 QFont editorFont = font();
562 editorFont.setPointSizeF(zoomFontPointSize);
563 setFont(editorFont);
564 document()->setDefaultFont(editorFont);
567 lineNumberArea->update();
568}
569
571{
572 QFont lineFont = document()->defaultFont();
573 if (zoomFontPointSize > 0.0)
574 lineFont.setPointSizeF(zoomFontPointSize);
575 return lineFont;
576}
577
579{
580 int digits = 1;
581 for (int lines = std::max(1, blockCount()); lines >= 10; lines /= 10)
582 ++digits;
583 return 12 + QFontMetrics(lineNumberFont()).horizontalAdvance(QLatin1Char('9')) * digits;
584}
585
586void CodeEditor::paintLineNumberArea(QPaintEvent* event)
587{
588 QPainter painter(lineNumberArea);
589 painter.setFont(lineNumberFont());
590 const QFontMetrics metrics = painter.fontMetrics();
591 painter.fillRect(event->rect(), palette().color(QPalette::AlternateBase));
592 QTextBlock block = firstVisibleBlock();
593 int blockNumber = block.blockNumber();
594 int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
595 int bottom = top + qRound(blockBoundingRect(block).height());
596 const int currentBlock = textCursor().blockNumber();
597 while (block.isValid() && top <= event->rect().bottom()) {
598 if (block.isVisible() && bottom >= event->rect().top()) {
599 painter.setPen(palette().color(
600 blockNumber == currentBlock ? QPalette::Text : QPalette::PlaceholderText));
601 painter.drawText(0, top, lineNumberArea->width() - 6, metrics.height(),
602 Qt::AlignRight, QString::number(blockNumber + 1));
603 }
604 block = block.next();
605 top = bottom;
606 bottom = top + qRound(blockBoundingRect(block).height());
607 ++blockNumber;
608 }
609}
610
611void CodeEditor::resizeEvent(QResizeEvent* event)
612{
613 QPlainTextEdit::resizeEvent(event);
615}
616
617void CodeEditor::changeEvent(QEvent* event)
618{
619 QPlainTextEdit::changeEvent(event);
620 if (event->type() == QEvent::PaletteChange) {
621 refreshTheme();
622 lineNumberArea->update();
623 } else if (event->type() == QEvent::FontChange
624 || event->type() == QEvent::ApplicationFontChange) {
627 lineNumberArea->update();
628 }
629}
630
632{
633 setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
635}
636
638{
639 const QRect contents = contentsRect();
640 lineNumberArea->setGeometry(
641 QRect(contents.left(), contents.top(), lineNumberAreaWidth(), contents.height()));
642}
643
645{
646 if (!fileTypeValue)
647 return 4;
648 const auto* indentation = codeFilePresentation(*fileTypeValue).syntax->indentation;
649 return indentation ? indentation->indentWidth : 4;
650}
651
653{
654 const int width = currentIndentWidth();
655 setTabStopDistance(fontMetrics().horizontalAdvance(QLatin1Char(' '))
656 * static_cast<qreal>(width));
657}
658
660{
661 QTextCursor cursor = textCursor();
662 const int indent = currentIndentWidth();
663 cursor.beginEditBlock();
664
665 const QTextBlock firstBlock = cursor.block();
666 const QTextBlock lastBlock =
667 cursor.hasSelection() ? document()->findBlock(cursor.selectionEnd()) : firstBlock;
668
669 std::vector<std::pair<int, int>> removals;
670 for (QTextBlock block = firstBlock;
671 block.isValid() && block.position() <= lastBlock.position();
672 block = block.next()) {
673 const QString text = block.text();
674 int removeCount = 0;
675 while (removeCount < text.size() && removeCount < indent) {
676 const QChar ch = text.at(removeCount);
677 if (ch == QLatin1Char(' ')) {
678 ++removeCount;
679 } else if (ch == QLatin1Char('\t')) {
680 ++removeCount;
681 break;
682 } else {
683 break;
684 }
685 }
686 if (removeCount > 0)
687 removals.emplace_back(block.position(), removeCount);
688 }
689
690 for (auto it = removals.rbegin(); it != removals.rend(); ++it) {
691 QTextCursor blockCursor(document());
692 blockCursor.setPosition(it->first);
693 blockCursor.setPosition(it->first + it->second, QTextCursor::KeepAnchor);
694 blockCursor.removeSelectedText();
695 }
696
697 cursor.endEditBlock();
698 setTextCursor(cursor);
699}
700
701} // namespace SILICON::ui
void changeEvent(QEvent *event) override
CodeEditor(QWidget *parent=nullptr)
bool isWordDelimiter(QChar character) const
CodeLineNumberArea * lineNumberArea
void contextMenuEvent(QContextMenuEvent *event) override
QString completionPrefix() const
bool currentLineMatchesIndentationTrigger() const
CallbackScope callbacks
void keyPressEvent(QKeyEvent *event) override
void setFileType(SILICON::project::DocumentType type)
QFont lineNumberFont() const
int currentIndentWidth() const
std::optional< SILICON::project::DocumentType > fileTypeValue
void resizeEvent(QResizeEvent *event) override
void insertCompletion(const QString &completion)
const std::optional< SILICON::project::DocumentType > & fileType() const
void wheelEvent(QWheelEvent *event) override
void zoomBy(int steps)
Adjusts text and line-number size by the given number of points.
bool insertAutoPair(QChar typed)
CodeSyntaxHighlighter * syntaxHighlighter
void paintLineNumberArea(QPaintEvent *event)
QStringListModel * completionModel
void showCompletion(bool explicitRequest)
int lineNumberAreaWidth() const
std::vector< QRegularExpression > indentationTriggers
friend class CodeLineNumberArea
QSize sizeHint() const override
CodeLineNumberArea(CodeEditor *editor)
void paintEvent(QPaintEvent *event) override
constexpr bool isCodeDocument(const DocumentType type)
const CodeFilePresentation & codeFilePresentation(const project::DocumentType type)
const CodeIndentation * indentation