diff --git a/src/propelleride/editor.cpp b/src/propelleride/editor.cpp index ed28702..6461335 100644 --- a/src/propelleride/editor.cpp +++ b/src/propelleride/editor.cpp @@ -13,12 +13,17 @@ #include "mainwindow.h" -Editor::Editor(QWidget *parent) : QPlainTextEdit(parent) +#include "logging.h" + +Editor::Editor(Language * language, QWidget *parent) : QPlainTextEdit(parent) { + this->language = language; + this->parser = language->getParser(); + propDialog = &((MainWindow *) parent)->preferences; - blocks = lang.listBlocks(); - re_blocks = lang.buildTokenizer(blocks); + blocks = language->listBlocks(); + re_blocks = language->buildTokenizer(blocks); ctrlPressed = false; expectAutoComplete = false; @@ -332,12 +337,6 @@ QString Editor::selectAutoComplete() int Editor::spinAutoComplete() { QString text = selectAutoComplete(); -// qDebug() << "keyPressEvent object dot pressed" << text; - - QSettings settings; - settings.beginGroup("Paths"); - lang.parser.setLibraryPaths(QStringList() << settings.value("Library").toString()); - settings.endGroup(); cbAuto->clear(); cbAuto->addItem("."); @@ -345,25 +344,25 @@ int Editor::spinAutoComplete() QList matches; if(text.length() > 0) { - matches = lang.parser.matchRule("_includes_",toPlainText()); + matches = parser->matchRule("_includes_",toPlainText()); QStringList filenames; foreach(ProjectParser::Match m, matches) { if (m.exact.contains(text)) - filenames << lang.parser.findFileName(m.pretty); + filenames << parser->findFileName(m.pretty); } if (!(filenames.count() > 0)) return 0; - lang.parser.setFile(filenames[0]); + parser->setFile(filenames[0]); - matches = lang.parser.matchRuleFromFile("public",filenames[0]); + matches = parser->matchRuleFromFile("public",filenames[0]); } else { - matches = lang.parser.matchRule("public",toPlainText()); + matches = parser->matchRule("public",toPlainText()); if (!(matches.count() > 0)) return 0; diff --git a/src/propelleride/editor.h b/src/propelleride/editor.h index 1901e95..2465618 100644 --- a/src/propelleride/editor.h +++ b/src/propelleride/editor.h @@ -9,33 +9,36 @@ #include "highlighter.h" #include "preferences.h" +#include "language.h" + class LineNumberArea; class Editor : public QPlainTextEdit { Q_OBJECT -public: - Editor(QWidget *parent); - virtual ~Editor(); - - void saveContent(); - int contentChanged(); + Language * language; + ProjectParser * parser; -private: - Language lang; - QStringList blocks; QRegularExpression re_blocks; bool tabOn; - int tabStop; + bool smartIndent; bool indentGuides; bool autoComplete; bool highlightLine; +public: + Editor(Language * language, + QWidget * parent); + virtual ~Editor(); + + void saveContent(); + int contentChanged(); + public slots: bool getUndo(); bool getRedo(); diff --git a/src/propelleride/filemanager.cpp b/src/propelleride/filemanager.cpp index e4b936e..357c746 100644 --- a/src/propelleride/filemanager.cpp +++ b/src/propelleride/filemanager.cpp @@ -15,12 +15,18 @@ FileManager::FileManager(QWidget *parent) : connect(this, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int))); } +// THIS IS A HACK OMG SUCH A HACK +void FileManager::setLanguage(Language * language) +{ + this->language = language; +} + int FileManager::newFile() { // removes the background image (need to move this elsewhere) setStyleSheet(""); - Editor *editor = new Editor(QWidget::window()); + Editor * editor = new Editor(language, QWidget::window()); editor->setAttribute(Qt::WA_DeleteOnClose); editor->installEventFilter(QWidget::window()); editor->saveContent(); diff --git a/src/propelleride/filemanager.h b/src/propelleride/filemanager.h index 47a401f..49ae131 100644 --- a/src/propelleride/filemanager.h +++ b/src/propelleride/filemanager.h @@ -4,13 +4,16 @@ #include #include +#include "language.h" #include "editor.h" #include "logging.h" class FileManager : public QTabWidget { Q_OBJECT -private: + + Language * language; + void createBackgroundImage(); QString reformatText(QString text); @@ -20,6 +23,7 @@ class FileManager : public QTabWidget Editor * getEditor(int num); int isFileOpen(const QString & fileName); int isFileEmpty(int index); + void setLanguage(Language * language); public slots: int newFile(); diff --git a/src/propelleride/language.h b/src/propelleride/language.h index 99d0efd..6d9c4fd 100644 --- a/src/propelleride/language.h +++ b/src/propelleride/language.h @@ -10,7 +10,8 @@ class Language { -private: + ProjectParser parser; + bool case_sensitive; bool enable_blocks; QString escape_char; @@ -28,7 +29,6 @@ class Language QStringList mergeList(QStringList list); public: - ProjectParser parser; void buildParser(QJsonArray projectparser); void loadLanguage(QString filename); diff --git a/src/propelleride/mainwindow.cpp b/src/propelleride/mainwindow.cpp index e5eb362..7592858 100644 --- a/src/propelleride/mainwindow.cpp +++ b/src/propelleride/mainwindow.cpp @@ -19,6 +19,10 @@ MainWindow::MainWindow(QWidget *parent) setWindowTitle(QCoreApplication::applicationName()); ui.setupUi(this); + // ===== HACK ZONE ===== + ui.editorTabs->setLanguage(&language); + // ===== END HACK ZONE ===== + // setup preferences dialog connect(&preferences, SIGNAL(accepted()), this, SLOT(getApplicationSettings()));