| 16 | #include "mainwindow.h" |
| 17 | |
| 18 | void |
| 19 | CodeEditor::initUI(QFont& font) |
| 20 | { |
| 21 | setFont(font); |
| 22 | QFontMetrics metrics(font); |
| 23 | setTabStopDistance(metrics.horizontalAdvance(' ') * indentSize); |
| 24 | |
| 25 | lineNumbers= new LineNumbers(this); |
| 26 | debugInfo = new DebugInfo(this); |
| 27 | editorHeader = new EditorHeader(this); |
| 28 | debugInfo->hide(); |
| 29 | connect(this, &QPlainTextEdit::blockCountChanged, this, &CodeEditor::setViewportWidth); |
| 30 | connect(this, &QPlainTextEdit::updateRequest, this, &CodeEditor::setLineNumbers); |
| 31 | connect(this, &QPlainTextEdit::updateRequest, this, &CodeEditor::setDebugInfoPos); |
| 32 | connect(this, &QPlainTextEdit::cursorPositionChanged, this, &CodeEditor::cursorChange); |
| 33 | connect(document(), &QTextDocument::modificationChanged, this, &CodeEditor::docChanged); |
| 34 | connect(document(), &QTextDocument::contentsChanged, this, &CodeEditor::contentsChanged); |
| 35 | |
| 36 | setViewportWidth(0); |
| 37 | cursorChange(); |
| 38 | |
| 39 | highlighter = new Highlighter(font,theme,darkMode,document()); |
| 40 | setTheme(theme, darkMode); |
| 41 | |
| 42 | QTextCursor cursor(textCursor()); |
| 43 | cursor.movePosition(QTextCursor::Start); |
| 44 | setTextCursor(cursor); |
| 45 | ensureCursorVisible(); |
| 46 | setFocus(); |
| 47 | } |
| 48 | |
| 49 | CodeEditor::CodeEditor(QTextDocument* doc, const QString& path, bool isNewFile, bool large, |
| 50 | QFont& font, int indentSize0, bool useTabs0, const Theme& theme0, bool darkMode0, |
nothing calls this directly
no outgoing calls
no test coverage detected