diff --git a/openscad.pro b/openscad.pro index 746b3ca2..89af240b 100644 --- a/openscad.pro +++ b/openscad.pro @@ -92,6 +92,7 @@ win* { } CONFIG += qt +CONFIG += qscintilla2 QT += opengl # see http://fedoraproject.org/wiki/UnderstandingDSOLinkChange diff --git a/src/MainWindow.h b/src/MainWindow.h index 3a81f75e..6ace35b5 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -108,7 +108,7 @@ private: LegacyEditor *legacy; ScintillaEditor *scintilla; - Editor *editor; + EditorInterface *editor; class QMessageBox *openglbox; class FontListDialog *font_list_dialog; diff --git a/src/editor.cc b/src/editor.cc index 923215e6..32c876ea 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -1,14 +1,14 @@ #include "editor.h" #include "Preferences.h" -Editor::Editor(QWidget *parent) : QWidget(parent) +EditorInterface::EditorInterface(QWidget *parent) : QWidget(parent) { // This needed to avoid QTextEdit accepting filename drops as we want // to handle these ourselves in MainWindow setAcceptDrops(false); this->highlighter = new Highlighter(this->document()); } -Editor::~Editor() +EditorInterface::~EditorInterface() { delete highlighter; } diff --git a/src/editor.h b/src/editor.h index 9f1a3496..9dc540f1 100644 --- a/src/editor.h +++ b/src/editor.h @@ -8,12 +8,12 @@ #include #include "highlighter.h" -class Editor : public QWidget +class EditorInterface : public QWidget { Q_OBJECT public: - Editor(QWidget *parent); - ~Editor(); + EditorInterface(QWidget *parent); + ~EditorInterface(); virtual QSize sizeHint(){ QSize size; return size;} virtual void setInitialSizeHint(const QSize &size) { } virtual void wheelEvent ( QWheelEvent * event ) { } diff --git a/src/legacyeditor.cc b/src/legacyeditor.cc index 8c7d5c0c..0d0a9e3b 100644 --- a/src/legacyeditor.cc +++ b/src/legacyeditor.cc @@ -1,7 +1,7 @@ #include "legacyeditor.h" #include "Preferences.h" -LegacyEditor::LegacyEditor(QWidget *parent) : Editor(parent) +LegacyEditor::LegacyEditor(QWidget *parent) : EditorInterface(parent) { legacyeditorLayout = new QVBoxLayout(this); textedit = new QTextEdit(this); diff --git a/src/legacyeditor.h b/src/legacyeditor.h index 00988ce3..0ac19705 100644 --- a/src/legacyeditor.h +++ b/src/legacyeditor.h @@ -10,7 +10,7 @@ #include "highlighter.h" #include "editor.h" -class LegacyEditor : public Editor +class LegacyEditor : public EditorInterface { Q_OBJECT public: diff --git a/src/mainwin.cc b/src/mainwin.cc index deb4b828..77982c81 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -168,12 +168,11 @@ MainWindow::MainWindow(const QString &filename) { setupUi(this); // legacy = new LegacyEditor(editorDockContents); -// editor = legacy; + // editor = legacy; scintilla = new ScintillaEditor(editorDockContents); editor = scintilla; - editorDockContents->layout()->addWidget(editor); - editor->setMinimumSize(editorDockContents->sizeHint()); + verticalLayout_4->addWidget(editor); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); diff --git a/src/scintillaeditor.cpp b/src/scintillaeditor.cpp index ee92bef6..26f6fccc 100644 --- a/src/scintillaeditor.cpp +++ b/src/scintillaeditor.cpp @@ -1,9 +1,70 @@ +#include +#include #include "scintillaeditor.h" -ScintillaEditor::ScintillaEditor(QWidget *parent) : Editor(parent) +ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent) { - layout = new QVBoxLayout(this); - qsci = new QsciScintilla(this);; - layout->addWidget(qsci); - qsci->setMarginLineNumbers(10,true); + scintillaLayout = new QVBoxLayout(this); + qsci = new QsciScintilla(this); + scintillaLayout->addWidget(qsci); + qsci->setMarginLineNumbers(1,true); } +void ScintillaEditor::indentSelection() +{ + int line,index; + int currentLine = qsci->positionFromLineIndex(line,index); + std::cout << "--------------------------------------"<setIndentation(currentLine, 5); +} +void ScintillaEditor::unindentSelection() +{ } +void ScintillaEditor::commentSelection() +{} +void ScintillaEditor::uncommentSelection() +{} +void ScintillaEditor::setPlainText(const QString &text) +{ } +void ScintillaEditor::highlightError(int error_pos) +{} +void ScintillaEditor::unhighlightLastError() +{} +void ScintillaEditor::setHighlightScheme(const QString &name) +{ } +void ScintillaEditor::insertPlainText(const QString &text) +{ } + +void ScintillaEditor::undo() +{ + qsci->undo(); +} + +void ScintillaEditor::redo() +{ + qsci->redo(); +} + +void ScintillaEditor::cut() +{ + qsci->cut(); +} + +void ScintillaEditor::copy() +{ + qsci->copy(); +} + +void ScintillaEditor::paste() +{ + qsci->paste(); +} + +void ScintillaEditor::zoomIn() +{ + qsci->zoomIn(); +} + +void ScintillaEditor::zoomOut() +{ + qsci->zoomOut(); +} + diff --git a/src/scintillaeditor.h b/src/scintillaeditor.h index 36c3ef19..611db60d 100644 --- a/src/scintillaeditor.h +++ b/src/scintillaeditor.h @@ -3,17 +3,51 @@ #include #include +#include #include #include #include "editor.h" -class ScintillaEditor : public Editor +class ScintillaEditor : public EditorInterface { public: ScintillaEditor(QWidget *parent); QsciScintilla *qsci; - QVBoxLayout *layout; +/* virtual QSize sizeHint(){ QSize size; return size;} + virtual void setInitialSizeHint(const QSize &size) { } + virtual void wheelEvent ( QWheelEvent * event ) { } + virtual void setTabStopWidth(int width) { } + virtual QString toPlainText() { QString s; return s;} + virtual QTextCursor textCursor() { QTextCursor c; return c;} + virtual void setTextCursor (const QTextCursor &cursor) { } + virtual QTextDocument *document(){QTextDocument *t = new QTextDocument; return t;} + virtual bool find(const QString & exp, QTextDocument::FindFlags options = 0){ return options;} +*/ +public slots: + void zoomIn(); + void zoomOut(); + // virtual void setLineWrapping(bool on) { } + // virtual void setContentModified(bool y){ } + // virtual bool isContentModified(){ return true; } + void indentSelection(); + void unindentSelection(); + void commentSelection(); + void uncommentSelection(); + void setPlainText(const QString &text); + void highlightError(int error_pos); + void unhighlightLastError(); + void setHighlightScheme(const QString &name); + void insertPlainText(const QString &text); + void undo(); + void redo(); + void cut(); + void copy(); + void paste(); +private: + // Highlighter *highlighter; + // QSize initialSizeHint; + QVBoxLayout *scintillaLayout; }; #endif // SCINTILLAEDITOR_H