From 2aa33db8be7397d39080e6ec96a9158e0c1e63e5 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 2 Jul 2019 18:53:21 +0200 Subject: Simple highlighter for assembly language added. Signed-off-by: Pavel Pisa --- qtmips_gui/qtmips_gui.pro | 6 ++++-- qtmips_gui/srceditor.cpp | 4 +++- qtmips_gui/srceditor.h | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'qtmips_gui') diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index 1075f96..ae4f525 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -74,7 +74,8 @@ SOURCES += \ hinttabledelegate.cpp \ coreview/minimux.cpp \ srceditor.cpp \ - fixmatheval.cpp + fixmatheval.cpp \ + highlighter.cpp HEADERS += \ mainwindow.h \ @@ -119,7 +120,8 @@ HEADERS += \ hinttabledelegate.h \ coreview/minimux.h \ srceditor.h \ - fixmatheval.h + fixmatheval.h \ + highlighter.h wasm: SOURCES += \ qhtml5file_html5.cpp diff --git a/qtmips_gui/srceditor.cpp b/qtmips_gui/srceditor.cpp index e8bdb85..bb6da16 100644 --- a/qtmips_gui/srceditor.cpp +++ b/qtmips_gui/srceditor.cpp @@ -40,6 +40,7 @@ #include #include "srceditor.h" +#include "highlighter.h" void SrcEditor::setup_common() { QFont font; @@ -48,6 +49,7 @@ void SrcEditor::setup_common() { font.setPointSize(10); setFont(font); tname = "Unknown"; + highlighter = new Highlighter(document()); } SrcEditor::SrcEditor(QWidget *parent) : Super(parent) { @@ -59,7 +61,7 @@ SrcEditor::SrcEditor(const QString &text, QWidget *parent) : Super(text, parent) } SrcEditor::~SrcEditor() { - + delete highlighter; } QString SrcEditor::filename() { diff --git a/qtmips_gui/srceditor.h b/qtmips_gui/srceditor.h index 9d25be7..1c2e677 100644 --- a/qtmips_gui/srceditor.h +++ b/qtmips_gui/srceditor.h @@ -39,6 +39,7 @@ #include #include #include "qtmipsmachine.h" +#include "highlighter.h" class SrcEditor : public QTextEdit { Q_OBJECT @@ -54,6 +55,7 @@ public: bool loadByteArray(const QByteArray &content, QString filename = ""); void setCursorToLine(int ln); private: + Highlighter *highlighter; void setup_common(); QString fname; QString tname; -- cgit v1.2.3