Skip to content

Commit

Permalink
use rsyntaxhighlighterquick to paint qts textareas
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisGoosen committed Sep 5, 2024
1 parent d9fcd60 commit c49f788
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Desktop/components/JASP/Widgets/ComputeColumnWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.7
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.3
import JASP.Controls 1.0 as JaspControls
import JASP

import "FilterConstructor"

Expand Down Expand Up @@ -103,6 +104,12 @@ FocusScope
TextArea
{
id: computeColumnEdit

RSyntaxHighlighterQuick
{
textDocument: computeColumnEdit.textDocument
}


anchors.top: parent.top
anchors.left: parent.left
Expand Down
11 changes: 11 additions & 0 deletions Desktop/components/JASP/Widgets/FilterWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
import JASP.Controls 1.0 as JaspControls
import "FilterConstructor"
import JASP

FocusScope
{
Expand Down Expand Up @@ -302,6 +303,11 @@ FocusScope

TextArea
{
RSyntaxHighlighterQuick
{
textDocument: filterGeneratedEdit.textDocument
}

id: filterGeneratedEdit
anchors.top: filterGeneratedBox.top
anchors.left: resetAllGeneratedFilters.right
Expand Down Expand Up @@ -347,6 +353,11 @@ FocusScope
TextArea
{

RSyntaxHighlighterQuick
{
textDocument: filterEdit.textDocument
}

id: filterEdit
height: contentHeight + 30
selectByMouse: true
Expand Down
12 changes: 12 additions & 0 deletions Desktop/components/JASP/Widgets/RCommanderWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ Window

TextArea
{
RSyntaxHighlighterQuick
{
textDocument: outputWindow.textDocument
}

id: outputWindow
text: rCmd.output
font: jaspTheme.fontRCode
Expand Down Expand Up @@ -192,6 +197,13 @@ Window

TextArea
{

RSyntaxHighlighterQuick
{
textDocument: codeEntry.textDocument
}


id: codeEntry
font: jaspTheme.fontRCode
color: jaspTheme.textEnabled
Expand Down
9 changes: 8 additions & 1 deletion QMLComponents/controls/rsyntaxhighlighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class RSyntaxHighlighterQuick : public QQuickItem
Q_PROPERTY(QQuickTextDocument* textDocument READ textDocument WRITE setTextDocument NOTIFY textDocumentChanged)

public:
RSyntaxHighlighterQuick(QQuickItem * parent) : QQuickItem(parent)
RSyntaxHighlighterQuick(QQuickItem * parent = nullptr) : QQuickItem(parent)
{}

QQuickTextDocument * textDocument() { return _textDocument; }

void setTextDocument(QQuickTextDocument * textDocument)
{
if(_textDocument == textDocument)
Expand All @@ -66,7 +68,12 @@ class RSyntaxHighlighterQuick : public QQuickItem

if(_textDocument)
_highlighter = new RSyntaxHighlighter(_textDocument->textDocument());

emit textDocumentChanged();
}

signals:
void textDocumentChanged();

private:
RSyntaxHighlighter * _highlighter = nullptr;
Expand Down

0 comments on commit c49f788

Please sign in to comment.