mirror of https://github.com/vitalif/openscad
scad lexer added
parent
6ff02a9ada
commit
9d35c792ed
|
@ -289,7 +289,9 @@ HEADERS += src/typedefs.h \
|
|||
\
|
||||
src/AutoUpdater.h \
|
||||
src/legacyeditor.h \
|
||||
src/scintillaeditor.h
|
||||
src/scintillaeditor.h \
|
||||
src/scintillahighlighter.h \
|
||||
src/scadlexer.h
|
||||
|
||||
SOURCES += src/version_check.cc \
|
||||
src/ProgressWidget.cc \
|
||||
|
@ -374,7 +376,9 @@ SOURCES += src/version_check.cc \
|
|||
src/mainwin.cc \
|
||||
src/FontListDialog.cc \
|
||||
src/legacyeditor.cc \
|
||||
src/scintillaeditor.cpp
|
||||
src/scintillaeditor.cpp \
|
||||
src/scintillahighlighter.cpp \
|
||||
src/scadlexer.cpp
|
||||
|
||||
# ClipperLib
|
||||
SOURCES += src/polyclipping/clipper.cpp
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include "scadlexer.h"
|
||||
|
||||
ScadLexer::ScadLexer(QObject *parent)
|
||||
: QsciLexerCPP(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ScadLexer::~ScadLexer()
|
||||
{
|
||||
}
|
||||
|
||||
const char *ScadLexer::language() const
|
||||
{
|
||||
return "SCAD";
|
||||
}
|
||||
|
||||
const char *ScadLexer::keywords(int set) const
|
||||
{
|
||||
if (set != 1)
|
||||
return 0;
|
||||
|
||||
return "abstract assert boolean break byte case catch char class "
|
||||
"const continue default do double else extends final finally "
|
||||
"float for future generic goto if implements import inner "
|
||||
"instanceof int interface long native new null operator outer "
|
||||
"package private protected public rest return short static "
|
||||
"super switch synchronized this throw throws transient try var "
|
||||
"void volatile while";
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef SCADLEXER_H
|
||||
#define SCADLEXER_H
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
//#include <Qsci/qsciglobal.h>
|
||||
#include <Qsci/qscilexercpp.h>
|
||||
|
||||
class ScadLexer : public QsciLexerCPP
|
||||
{
|
||||
public:
|
||||
ScadLexer(QObject *parent);
|
||||
virtual ~ScadLexer();
|
||||
const char *language() const;
|
||||
const char *keywords(int set) const;
|
||||
|
||||
private:
|
||||
ScadLexer(const ScadLexer &);
|
||||
ScadLexer &operator=(const ScadLexer &);
|
||||
|
||||
};
|
||||
|
||||
#endif // SCADLEXER_H
|
|
@ -1,9 +1,10 @@
|
|||
#include <iostream>
|
||||
#include <QString>
|
||||
#include <QChar>
|
||||
#include <Qsci/qscilexercpp.h>
|
||||
#include "scadlexer.h"
|
||||
#include "scintillaeditor.h"
|
||||
#include "parsersettings.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
|
||||
{
|
||||
|
@ -18,10 +19,10 @@ ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
|
|||
qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator, indicatorNumber);
|
||||
qsci->markerDefine(QsciScintilla::Circle, markerNumber);
|
||||
qsci->setMarkerBackgroundColor(QColor(255, 0, 0, 100), markerNumber);
|
||||
highlighter = new ScintillaHighlighter(this);
|
||||
initFont();
|
||||
initMargin();
|
||||
initLexer();
|
||||
|
||||
}
|
||||
void ScintillaEditor::indentSelection()
|
||||
{
|
||||
|
@ -69,7 +70,7 @@ void ScintillaEditor::unhighlightLastError()
|
|||
|
||||
void ScintillaEditor::setHighlightScheme(const QString &name)
|
||||
{
|
||||
|
||||
highlighter->assignFormatsToTokens(name);
|
||||
}
|
||||
|
||||
void ScintillaEditor::insertPlainText(const QString &text)
|
||||
|
@ -138,8 +139,6 @@ void ScintillaEditor::onTextChanged()
|
|||
|
||||
void ScintillaEditor::initLexer()
|
||||
{
|
||||
QsciLexerCPP *lexer = new QsciLexerCPP();
|
||||
lexer->setDefaultFont(qsci->font());
|
||||
lexer->setFoldComments(true);
|
||||
qsci->setLexer(lexer);
|
||||
ScadLexer *lexer = new ScadLexer(this);
|
||||
qsci->setLexer(lexer);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <Qsci/qsciscintilla.h>
|
||||
#include <QVBoxLayout>
|
||||
#include "highlighter.h"
|
||||
#include "scintillahighlighter.h"
|
||||
#include "editor.h"
|
||||
|
||||
class ScintillaEditor : public EditorInterface
|
||||
|
@ -18,6 +18,7 @@ public:
|
|||
void initFont();
|
||||
void initMargin();
|
||||
void initLexer();
|
||||
//QsciDocument *document() { return qsci->document();}
|
||||
|
||||
public slots:
|
||||
void zoomIn();
|
||||
|
@ -41,6 +42,7 @@ private:
|
|||
QVBoxLayout *scintillaLayout;
|
||||
const int indicatorNumber = 1;
|
||||
const int markerNumber = 2;
|
||||
ScintillaHighlighter *highlighter;
|
||||
};
|
||||
|
||||
#endif // SCINTILLAEDITOR_H
|
||||
|
|
Loading…
Reference in New Issue