Removed dependency on QScintilla, switched to jsedit
QScintilla was *EXTREMELY* overkill for what I really needed. It also created problems for people trying to compile the source. The new solution is much easier to compile and use.
This commit is contained in:
+7
-7
@@ -10,13 +10,12 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport printsupport qml
|
|||||||
|
|
||||||
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
|
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
|
||||||
|
|
||||||
CONFIG += c++11 qscintilla2
|
CONFIG += c++11
|
||||||
|
|
||||||
|
DEFINES += QCUSTOMPLOT_USE_OPENGL
|
||||||
|
|
||||||
TARGET = SavvyCAN
|
TARGET = SavvyCAN
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
#you are fairly likely to have to change this next include to match your linux distro
|
|
||||||
#this works on Linux Mint 18.1
|
|
||||||
unix:!macx: INCLUDEPATH +=/usr/include/x86_64-linux-gnu/qt5
|
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
@@ -64,7 +63,8 @@ SOURCES += main.cpp\
|
|||||||
signalviewerwindow.cpp \
|
signalviewerwindow.cpp \
|
||||||
bus_protocols/isotp_handler.cpp \
|
bus_protocols/isotp_handler.cpp \
|
||||||
bus_protocols/j1939_handler.cpp \
|
bus_protocols/j1939_handler.cpp \
|
||||||
bus_protocols/uds_handler.cpp
|
bus_protocols/uds_handler.cpp \
|
||||||
|
jsedit.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
can_structs.h \
|
can_structs.h \
|
||||||
@@ -116,7 +116,8 @@ HEADERS += mainwindow.h \
|
|||||||
bus_protocols/isotp_handler.h \
|
bus_protocols/isotp_handler.h \
|
||||||
bus_protocols/j1939_handler.h \
|
bus_protocols/j1939_handler.h \
|
||||||
bus_protocols/uds_handler.h \
|
bus_protocols/uds_handler.h \
|
||||||
bus_protocols/isotp_message.h
|
bus_protocols/isotp_message.h \
|
||||||
|
jsedit.h
|
||||||
|
|
||||||
FORMS += ui/candatagrid.ui \
|
FORMS += ui/candatagrid.ui \
|
||||||
ui/connectionwindow.ui \
|
ui/connectionwindow.ui \
|
||||||
@@ -150,4 +151,3 @@ RESOURCES += \
|
|||||||
icons.qrc \
|
icons.qrc \
|
||||||
images.qrc
|
images.qrc
|
||||||
|
|
||||||
unix:!macx: LIBS += -lqt5scintilla2
|
|
||||||
|
|||||||
+1039
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the Ofi Labs X2 project.
|
||||||
|
|
||||||
|
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
Copyright (C) 2010 Ariya Hidayat <ariya.hidayat@gmail.com>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the <organization> nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OFILABS_JSEDIT
|
||||||
|
#define OFILABS_JSEDIT
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
class JSEditPrivate;
|
||||||
|
|
||||||
|
class JSEdit: public QPlainTextEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool bracketsMatchingEnabled READ isBracketsMatchingEnabled WRITE setBracketsMatchingEnabled)
|
||||||
|
Q_PROPERTY(bool codeFoldingEnabled READ isCodeFoldingEnabled WRITE setCodeFoldingEnabled)
|
||||||
|
Q_PROPERTY(bool lineNumbersVisible READ isLineNumbersVisible WRITE setLineNumbersVisible)
|
||||||
|
Q_PROPERTY(bool textWrapEnabled READ isTextWrapEnabled WRITE setTextWrapEnabled)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Background,
|
||||||
|
Normal,
|
||||||
|
Comment,
|
||||||
|
Number,
|
||||||
|
String,
|
||||||
|
Operator,
|
||||||
|
Identifier,
|
||||||
|
Keyword,
|
||||||
|
BuiltIn,
|
||||||
|
Sidebar,
|
||||||
|
LineNumber,
|
||||||
|
Cursor,
|
||||||
|
Marker,
|
||||||
|
BracketMatch,
|
||||||
|
BracketError,
|
||||||
|
FoldIndicator
|
||||||
|
} ColorComponent;
|
||||||
|
|
||||||
|
JSEdit(QWidget *parent = 0);
|
||||||
|
~JSEdit();
|
||||||
|
|
||||||
|
void setColor(ColorComponent component, const QColor &color);
|
||||||
|
|
||||||
|
QStringList keywords() const;
|
||||||
|
void setKeywords(const QStringList &keywords);
|
||||||
|
|
||||||
|
bool isBracketsMatchingEnabled() const;
|
||||||
|
bool isCodeFoldingEnabled() const;
|
||||||
|
bool isLineNumbersVisible() const;
|
||||||
|
bool isTextWrapEnabled() const;
|
||||||
|
|
||||||
|
bool isFoldable(int line) const;
|
||||||
|
bool isFolded(int line) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateSidebar();
|
||||||
|
void mark(const QString &str, Qt::CaseSensitivity sens = Qt::CaseInsensitive);
|
||||||
|
void setBracketsMatchingEnabled(bool enable);
|
||||||
|
void setCodeFoldingEnabled(bool enable);
|
||||||
|
void setLineNumbersVisible(bool visible);
|
||||||
|
void setTextWrapEnabled(bool enable);
|
||||||
|
|
||||||
|
void fold(int line);
|
||||||
|
void unfold(int line);
|
||||||
|
void toggleFold(int line);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
void wheelEvent(QWheelEvent *e);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateCursor();
|
||||||
|
void updateSidebar(const QRect &rect, int d);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<JSEditPrivate> d_ptr;
|
||||||
|
Q_DECLARE_PRIVATE(JSEdit);
|
||||||
|
Q_DISABLE_COPY(JSEdit);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OFILABS_JSEDIT
|
||||||
+15
-9
@@ -4,7 +4,6 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <Qsci/qscilexerjavascript.h>
|
|
||||||
|
|
||||||
#include "connections/canconmanager.h"
|
#include "connections/canconmanager.h"
|
||||||
|
|
||||||
@@ -14,6 +13,13 @@ ScriptingWindow::ScriptingWindow(const QVector<CANFrame> *frames, QWidget *paren
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
editor = new JSEdit();
|
||||||
|
editor->setFrameShape(JSEdit::NoFrame);
|
||||||
|
editor->setWordWrapMode(QTextOption::NoWrap);
|
||||||
|
editor->setTabStopWidth(4);
|
||||||
|
editor->show();
|
||||||
|
ui->verticalLayout->insertWidget(2,editor, 10);
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
modelFrames = frames;
|
modelFrames = frames;
|
||||||
@@ -27,11 +33,11 @@ ScriptingWindow::ScriptingWindow(const QVector<CANFrame> *frames, QWidget *paren
|
|||||||
|
|
||||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, this, &ScriptingWindow::newFrames);
|
connect(CANConManager::getInstance(), &CANConManager::framesReceived, this, &ScriptingWindow::newFrames);
|
||||||
|
|
||||||
ui->txtScriptSource->setLexer(new QsciLexerJavaScript(ui->txtScriptSource));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptingWindow::~ScriptingWindow()
|
ScriptingWindow::~ScriptingWindow()
|
||||||
{
|
{
|
||||||
|
delete editor;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +132,8 @@ void ScriptingWindow::loadNewScript()
|
|||||||
container->compileScript();
|
container->compileScript();
|
||||||
scripts.append(container);
|
scripts.append(container);
|
||||||
currentScript = container;
|
currentScript = container;
|
||||||
ui->txtScriptSource->setText(container->scriptText);
|
editor->setPlainText(container->scriptText);
|
||||||
ui->txtScriptSource->setEnabled(true);
|
setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,8 +157,8 @@ void ScriptingWindow::createNewScript()
|
|||||||
scripts.append(container);
|
scripts.append(container);
|
||||||
ui->listLoadedScripts->addItem(container->fileName);
|
ui->listLoadedScripts->addItem(container->fileName);
|
||||||
currentScript = container;
|
currentScript = container;
|
||||||
ui->txtScriptSource->setText(container->scriptText);
|
editor->setPlainText(container->scriptText);
|
||||||
ui->txtScriptSource->setEnabled(true);
|
editor->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingWindow::deleteCurrentScript()
|
void ScriptingWindow::deleteCurrentScript()
|
||||||
@@ -162,7 +168,7 @@ void ScriptingWindow::deleteCurrentScript()
|
|||||||
|
|
||||||
void ScriptingWindow::refreshSourceWindow()
|
void ScriptingWindow::refreshSourceWindow()
|
||||||
{
|
{
|
||||||
ui->txtScriptSource->setText(currentScript->scriptText);
|
editor->setPlainText(currentScript->scriptText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingWindow::saveScript()
|
void ScriptingWindow::saveScript()
|
||||||
@@ -191,7 +197,7 @@ void ScriptingWindow::saveScript()
|
|||||||
delete outFile;
|
delete outFile;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
outFile->write(ui->txtScriptSource->text().toUtf8());
|
outFile->write(editor->toPlainText().toUtf8());
|
||||||
outFile->close();
|
outFile->close();
|
||||||
delete outFile;
|
delete outFile;
|
||||||
}
|
}
|
||||||
@@ -205,6 +211,6 @@ void ScriptingWindow::revertScript()
|
|||||||
|
|
||||||
void ScriptingWindow::recompileScript()
|
void ScriptingWindow::recompileScript()
|
||||||
{
|
{
|
||||||
currentScript->scriptText = ui->txtScriptSource->text();
|
currentScript->scriptText = editor->toPlainText();
|
||||||
currentScript->compileScript();
|
currentScript->compileScript();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "can_structs.h"
|
#include "can_structs.h"
|
||||||
#include "scriptcontainer.h"
|
#include "scriptcontainer.h"
|
||||||
#include "connections/canconnection.h"
|
#include "connections/canconnection.h"
|
||||||
|
#include "jsedit.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QJSEngine>
|
#include <QJSEngine>
|
||||||
@@ -37,6 +38,7 @@ private:
|
|||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
Ui::ScriptingWindow *ui;
|
Ui::ScriptingWindow *ui;
|
||||||
|
JSEdit *editor;
|
||||||
QList<ScriptContainer *> scripts;
|
QList<ScriptContainer *> scripts;
|
||||||
ScriptContainer *currentScript;
|
ScriptContainer *currentScript;
|
||||||
const QVector<CANFrame> *modelFrames;
|
const QVector<CANFrame> *modelFrames;
|
||||||
|
|||||||
+1
-18
@@ -53,7 +53,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,10,0,0,4">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -64,16 +64,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QsciScintilla" name="txtScriptSource">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="whatsThis">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
@@ -116,13 +106,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QsciScintilla</class>
|
|
||||||
<extends>QFrame</extends>
|
|
||||||
<header>Qsci/qsciscintilla.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user