mirror of https://github.com/vitalif/openscad
legacyeditor
parent
acd6cb1a4e
commit
5a0df4e6d9
|
@ -284,7 +284,8 @@ HEADERS += src/typedefs.h \
|
|||
src/system-gl.h \
|
||||
src/CsgInfo.h \
|
||||
\
|
||||
src/AutoUpdater.h
|
||||
src/AutoUpdater.h \
|
||||
src/legacyeditor.h
|
||||
|
||||
SOURCES += src/version_check.cc \
|
||||
src/ProgressWidget.cc \
|
||||
|
@ -367,7 +368,8 @@ SOURCES += src/version_check.cc \
|
|||
\
|
||||
src/openscad.cc \
|
||||
src/mainwin.cc \
|
||||
src/FontListDialog.cc
|
||||
src/FontListDialog.cc \
|
||||
src/legacyeditor.cc
|
||||
|
||||
# ClipperLib
|
||||
SOURCES += src/polyclipping/clipper.cpp
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by Qt Creator 2.4.1, 2012-02-15T08:41:23. -->
|
||||
<!-- Written by QtCreator 2.8.1, 2014-06-01T01:42:15. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
@ -11,6 +11,7 @@
|
|||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
|
@ -24,9 +25,10 @@
|
|||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">System</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
|
@ -51,14 +53,14 @@
|
|||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5feaa906-51d1-436d-a443-3bc608e0fec2}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">INVALID</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
|
@ -68,11 +70,16 @@
|
|||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
|
@ -82,11 +89,16 @@
|
|||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
|
@ -103,63 +115,7 @@
|
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">$$PWD/../openscad-build-desktop</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">-1</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments">-spec macx-g++</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-j4</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges">
|
||||
<value type="QString">OPENSCAD_LIBRARIES=$$PWD/../libraries/install</value>
|
||||
<value type="QString">CCACHE_BASEDIR=$$PWD/..</value>
|
||||
<value type="QString">PATH=/opt/local/libexec/ccache:/usr/bin:$QTDIR/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin</value>
|
||||
<value type="QString">EIGEN2DIR=$$PWD/../libraries/install/include/eigen2</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 4.7.4 for GCC (Qt SDK) Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">$$PWD</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">3</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/shaina/myrepo/openscad</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
|
@ -328,34 +284,21 @@
|
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
|
||||
<value type="bool" key="Analyzer.Project.UseGlobal">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
|
@ -374,35 +317,20 @@
|
|||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">openscad</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/shaina/fresh/openscad/openscad.pro</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">openscad.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
|
||||
</valuemap>
|
||||
|
@ -415,10 +343,10 @@
|
|||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
|
||||
<value type="QString">{b7a15081-01e1-47e4-b2e5-20f6404deb62}</value>
|
||||
<value type="QByteArray">{ced832b3-b30c-421a-b068-ce4699c38209}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">10</value>
|
||||
<value type="int">14</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "module.h"
|
||||
#include "Tree.h"
|
||||
#include "memory.h"
|
||||
#include "legacyeditor.h"
|
||||
#include "editor.h"
|
||||
#include <vector>
|
||||
#include <QMutex>
|
||||
#include <QSet>
|
||||
|
@ -103,6 +105,9 @@ private:
|
|||
void show_examples();
|
||||
void setDockWidgetTitle(QDockWidget *dockWidget, QString prefix, bool topLevel);
|
||||
|
||||
LegacyEditor *legacy;
|
||||
Editor *editor;
|
||||
|
||||
class QMessageBox *openglbox;
|
||||
class FontListDialog *font_list_dialog;
|
||||
|
||||
|
|
161
src/editor.cc
161
src/editor.cc
|
@ -1,172 +1,13 @@
|
|||
#include "editor.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
Editor::Editor(QWidget *parent) : QTextEdit(parent)
|
||||
Editor::Editor(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setAcceptRichText(false);
|
||||
// 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());
|
||||
}
|
||||
|
||||
void Editor::indentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)), QString(QChar(8233)) + QString("\t"));
|
||||
if (txt.endsWith(QString(QChar(8233)) + QString("\t")))
|
||||
txt.chop(1);
|
||||
txt = QString("\t") + txt;
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void Editor::unindentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)) + QString("\t"), QString(QChar(8233)));
|
||||
if (txt.startsWith(QString("\t")))
|
||||
txt.remove(0, 1);
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void Editor::commentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)), QString(QChar(8233)) + QString("//"));
|
||||
if (txt.endsWith(QString(QChar(8233)) + QString("//")))
|
||||
txt.chop(2);
|
||||
txt = QString("//") + txt;
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void Editor::uncommentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)) + QString("//"), QString(QChar(8233)));
|
||||
if (txt.startsWith(QString("//")))
|
||||
txt.remove(0, 2);
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void Editor::zoomIn()
|
||||
{
|
||||
// See also QT's implementation in QEditor.cpp
|
||||
QSettings settings;
|
||||
QFont tmp_font = this->font() ;
|
||||
if ( font().pointSize() >= 1 )
|
||||
tmp_font.setPointSize( 1 + font().pointSize() );
|
||||
else
|
||||
tmp_font.setPointSize( 1 );
|
||||
settings.setValue("editor/fontsize", tmp_font.pointSize());
|
||||
this->setFont( tmp_font );
|
||||
}
|
||||
|
||||
void Editor::zoomOut()
|
||||
{
|
||||
QSettings settings;
|
||||
QFont tmp_font = this->font();
|
||||
if ( font().pointSize() >= 2 )
|
||||
tmp_font.setPointSize( -1 + font().pointSize() );
|
||||
else
|
||||
tmp_font.setPointSize( 1 );
|
||||
settings.setValue("editor/fontsize", tmp_font.pointSize());
|
||||
this->setFont( tmp_font );
|
||||
}
|
||||
|
||||
void Editor::wheelEvent ( QWheelEvent * event )
|
||||
{
|
||||
QSettings settings;
|
||||
bool wheelzoom_enabled = Preferences::inst()->getValue("editor/ctrlmousewheelzoom").toBool();
|
||||
if ((event->modifiers() == Qt::ControlModifier) && wheelzoom_enabled ) {
|
||||
if (event->delta() > 0 )
|
||||
zoomIn();
|
||||
else if (event->delta() < 0 )
|
||||
zoomOut();
|
||||
} else {
|
||||
QTextEdit::wheelEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::setPlainText(const QString &text)
|
||||
{
|
||||
int y = verticalScrollBar()->sliderPosition();
|
||||
// Save current cursor position
|
||||
QTextCursor cursor = textCursor();
|
||||
int n = cursor.position();
|
||||
QTextEdit::setPlainText(text);
|
||||
// Restore cursor position
|
||||
if (n < text.length()) {
|
||||
cursor.setPosition(n);
|
||||
setTextCursor(cursor);
|
||||
verticalScrollBar()->setSliderPosition(y);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::highlightError(int error_pos)
|
||||
{
|
||||
highlighter->highlightError( error_pos );
|
||||
QTextCursor cursor = this->textCursor();
|
||||
cursor.setPosition( error_pos );
|
||||
this->setTextCursor( cursor );
|
||||
}
|
||||
|
||||
void Editor::unhighlightLastError()
|
||||
{
|
||||
highlighter->unhighlightLastError();
|
||||
}
|
||||
|
||||
void Editor::setHighlightScheme(const QString &name)
|
||||
{
|
||||
highlighter->assignFormatsToTokens( name );
|
||||
highlighter->rehighlight(); // slow on large files
|
||||
}
|
||||
|
||||
QSize Editor::sizeHint() const
|
||||
{
|
||||
if (initialSizeHint.width() <= 0) {
|
||||
return QTextEdit::sizeHint();
|
||||
} else {
|
||||
return initialSizeHint;
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::setInitialSizeHint(const QSize &size)
|
||||
{
|
||||
initialSizeHint = size;
|
||||
}
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
delete highlighter;
|
||||
|
|
54
src/editor.h
54
src/editor.h
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
@ -6,30 +8,44 @@
|
|||
#include <QTextEdit>
|
||||
#include "highlighter.h"
|
||||
|
||||
class Editor : public QTextEdit
|
||||
class Editor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Editor(QWidget *parent);
|
||||
~Editor();
|
||||
QSize sizeHint() const;
|
||||
void setInitialSizeHint(const QSize &size);
|
||||
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();
|
||||
void setLineWrapping(bool on) { if(on) setWordWrapMode(QTextOption::WrapAnywhere); }
|
||||
void setContentModified(bool y) { document()->setModified(y); }
|
||||
bool isContentModified() { return document()->isModified(); }
|
||||
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);
|
||||
virtual void zoomIn(){ }
|
||||
virtual void zoomOut() { }
|
||||
virtual void setLineWrapping(bool on) { }
|
||||
virtual void setContentModified(bool y){ }
|
||||
virtual bool isContentModified(){ return true; }
|
||||
virtual void indentSelection(){ }
|
||||
virtual void unindentSelection(){ }
|
||||
virtual void commentSelection() {}
|
||||
virtual void uncommentSelection(){}
|
||||
virtual void setPlainText(const QString &text){ }
|
||||
virtual void highlightError(int error_pos) {}
|
||||
virtual void unhighlightLastError() {}
|
||||
virtual void setHighlightScheme(const QString &name){ }
|
||||
virtual void insertPlainText(const QString &text){ }
|
||||
virtual void undo(){ }
|
||||
virtual void redo(){ }
|
||||
virtual void cut(){ }
|
||||
virtual void copy(){ }
|
||||
virtual void paste(){ }
|
||||
private:
|
||||
void wheelEvent ( QWheelEvent * event );
|
||||
Highlighter *highlighter;
|
||||
QSize initialSizeHint;
|
||||
Highlighter *highlighter;
|
||||
QSize initialSizeHint;
|
||||
|
||||
};
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
#include "legacyeditor.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
LegacyEditor::LegacyEditor(QWidget *parent) : Editor(parent)
|
||||
{
|
||||
legacyeditorLayout = new QVBoxLayout(this);
|
||||
textedit = new QTextEdit(this);
|
||||
legacyeditorLayout->addWidget(textedit);
|
||||
textedit->setAcceptRichText(false);
|
||||
setAcceptDrops(false);
|
||||
this->highlighter = new Highlighter(this->textedit->document());
|
||||
}
|
||||
|
||||
void LegacyEditor::indentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)), QString(QChar(8233)) + QString("\t"));
|
||||
if (txt.endsWith(QString(QChar(8233)) + QString("\t")))
|
||||
txt.chop(1);
|
||||
txt = QString("\t") + txt;
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
textedit->setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void LegacyEditor::unindentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)) + QString("\t"), QString(QChar(8233)));
|
||||
if (txt.startsWith(QString("\t")))
|
||||
txt.remove(0, 1);
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
textedit->setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void LegacyEditor::commentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)), QString(QChar(8233)) + QString("//"));
|
||||
if (txt.endsWith(QString(QChar(8233)) + QString("//")))
|
||||
txt.chop(2);
|
||||
txt = QString("//") + txt;
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
textedit->setTextCursor(cursor);
|
||||
|
||||
}
|
||||
|
||||
void LegacyEditor::uncommentSelection()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int p1 = cursor.selectionStart();
|
||||
QString txt = cursor.selectedText();
|
||||
|
||||
txt.replace(QString(QChar(8233)) + QString("//"), QString(QChar(8233)));
|
||||
if (txt.startsWith(QString("//")))
|
||||
txt.remove(0, 2);
|
||||
|
||||
cursor.insertText(txt);
|
||||
int p2 = cursor.position();
|
||||
cursor.setPosition(p1, QTextCursor::MoveAnchor);
|
||||
cursor.setPosition(p2, QTextCursor::KeepAnchor);
|
||||
textedit->setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void LegacyEditor::zoomIn()
|
||||
{
|
||||
// See also QT's implementation in QLegacyEditor.cpp
|
||||
QSettings settings;
|
||||
QFont tmp_font = this->font() ;
|
||||
if ( font().pointSize() >= 1 )
|
||||
tmp_font.setPointSize( 1 + font().pointSize() );
|
||||
else
|
||||
tmp_font.setPointSize( 1 );
|
||||
settings.setValue("editor/fontsize", tmp_font.pointSize());
|
||||
this->setFont( tmp_font );
|
||||
}
|
||||
|
||||
void LegacyEditor::zoomOut()
|
||||
{
|
||||
|
||||
QSettings settings;
|
||||
QFont tmp_font = this->font();
|
||||
if ( font().pointSize() >= 2 )
|
||||
tmp_font.setPointSize( -1 + font().pointSize() );
|
||||
else
|
||||
tmp_font.setPointSize( 1 );
|
||||
settings.setValue("editor/fontsize", tmp_font.pointSize());
|
||||
this->setFont( tmp_font );
|
||||
|
||||
}
|
||||
|
||||
void LegacyEditor::wheelEvent ( QWheelEvent * event )
|
||||
{
|
||||
QSettings settings;
|
||||
bool wheelzoom_enabled = Preferences::inst()->getValue("editor/ctrlmousewheelzoom").toBool();
|
||||
if ((event->modifiers() == Qt::ControlModifier) && wheelzoom_enabled ) {
|
||||
if (event->delta() > 0 )
|
||||
zoomIn();
|
||||
else if (event->delta() < 0 )
|
||||
zoomOut();
|
||||
} else {
|
||||
QWidget::wheelEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
void LegacyEditor::setPlainText(const QString &text)
|
||||
{
|
||||
|
||||
int y = textedit->verticalScrollBar()->sliderPosition();
|
||||
// Save current cursor position
|
||||
QTextCursor cursor = textCursor();
|
||||
int n = cursor.position();
|
||||
/*QTextEdit::*/textedit->setPlainText(text);
|
||||
// Restore cursor position
|
||||
if (n < text.length()) {
|
||||
cursor.setPosition(n);
|
||||
textedit->setTextCursor(cursor);
|
||||
textedit->verticalScrollBar()->setSliderPosition(y);
|
||||
}
|
||||
}
|
||||
|
||||
void LegacyEditor::highlightError(int error_pos)
|
||||
{
|
||||
highlighter->highlightError( error_pos );
|
||||
QTextCursor cursor = this->textCursor();
|
||||
cursor.setPosition( error_pos );
|
||||
this->setTextCursor( cursor );
|
||||
|
||||
}
|
||||
|
||||
void LegacyEditor::unhighlightLastError()
|
||||
{
|
||||
highlighter->unhighlightLastError();
|
||||
}
|
||||
|
||||
void LegacyEditor::setHighlightScheme(const QString &name)
|
||||
{
|
||||
highlighter->assignFormatsToTokens( name );
|
||||
highlighter->rehighlight(); // slow on large files
|
||||
}
|
||||
|
||||
QSize LegacyEditor::sizeHint() const
|
||||
{
|
||||
if (initialSizeHint.width() <= 0) {
|
||||
return /*QTextEdit::*/textedit->sizeHint();
|
||||
} else {
|
||||
return initialSizeHint;
|
||||
}
|
||||
}
|
||||
|
||||
void LegacyEditor::setInitialSizeHint(const QSize &size)
|
||||
{
|
||||
initialSizeHint = size;
|
||||
}
|
||||
|
||||
void LegacyEditor::setTabStopWidth(int width)
|
||||
{
|
||||
textedit->setTabStopWidth(width);
|
||||
}
|
||||
|
||||
QString LegacyEditor::toPlainText()
|
||||
{
|
||||
return textedit->toPlainText();
|
||||
}
|
||||
QTextCursor LegacyEditor::textCursor() const
|
||||
{
|
||||
return textedit->textCursor();
|
||||
}
|
||||
void LegacyEditor::setTextCursor (const QTextCursor &cursor)
|
||||
{
|
||||
textedit->setTextCursor(cursor);
|
||||
}
|
||||
bool LegacyEditor::find(const QString & exp, QTextDocument::FindFlags options)
|
||||
{
|
||||
return textedit->find(exp, options);
|
||||
}
|
||||
void LegacyEditor::insertPlainText(const QString &text)
|
||||
{
|
||||
textedit->insertPlainText(text);
|
||||
}
|
||||
void LegacyEditor::undo()
|
||||
{
|
||||
textedit->undo();
|
||||
}
|
||||
void LegacyEditor::redo()
|
||||
{
|
||||
textedit->redo();
|
||||
}
|
||||
void LegacyEditor::cut()
|
||||
{
|
||||
textedit->cut();
|
||||
}
|
||||
void LegacyEditor::copy()
|
||||
{
|
||||
textedit->copy();
|
||||
}
|
||||
void LegacyEditor::paste()
|
||||
{
|
||||
textedit->paste();
|
||||
}
|
||||
LegacyEditor::~LegacyEditor()
|
||||
{
|
||||
delete highlighter;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QWheelEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include "highlighter.h"
|
||||
#include "editor.h"
|
||||
|
||||
class LegacyEditor : public Editor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LegacyEditor(QWidget *parent);
|
||||
~LegacyEditor();
|
||||
QTextEdit *textedit;
|
||||
QSize sizeHint() const;
|
||||
void setInitialSizeHint(const QSize &size);
|
||||
void setTabStopWidth(int width);
|
||||
void wheelEvent (QWheelEvent * event);
|
||||
QString toPlainText();
|
||||
QTextCursor textCursor() const;
|
||||
void setTextCursor (const QTextCursor &cursor);
|
||||
QTextDocument *document() { return textedit->document(); }
|
||||
bool find(const QString & exp, QTextDocument::FindFlags options = 0);
|
||||
public slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void setLineWrapping(bool on) { if(on) textedit->setWordWrapMode(QTextOption::WrapAnywhere); }
|
||||
void setContentModified(bool y) { textedit->document()->setModified(y); }
|
||||
bool isContentModified() {return textedit->document()->isModified();}
|
||||
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;
|
||||
//LegacyEditor *legacy;
|
||||
QSize initialSizeHint;
|
||||
QVBoxLayout *legacyeditorLayout;
|
||||
};
|
|
@ -166,6 +166,9 @@ bool MainWindow::undockMode = false;
|
|||
MainWindow::MainWindow(const QString &filename)
|
||||
: root_inst("group"), font_list_dialog(NULL), tempFile(NULL), progresswidget(NULL)
|
||||
{
|
||||
legacy = new LegacyEditor(editorDockContents);
|
||||
editor = legacy;
|
||||
|
||||
setupUi(this);
|
||||
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
||||
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||
|
@ -1400,6 +1403,7 @@ void MainWindow::compileTopLevelDocument()
|
|||
resetPrintedDeprecations();
|
||||
|
||||
this->last_compiled_doc = editor->toPlainText();
|
||||
|
||||
std::string fulltext =
|
||||
std::string(this->last_compiled_doc.toLocal8Bit().constData()) +
|
||||
"\n" + commandline_commands;
|
||||
|
@ -1987,7 +1991,7 @@ void MainWindow::viewModeAnimate()
|
|||
|
||||
void MainWindow::animateUpdateDocChanged()
|
||||
{
|
||||
QString current_doc = editor->toPlainText();
|
||||
QString current_doc = editor->toPlainText();
|
||||
if (current_doc != last_compiled_doc)
|
||||
animateUpdate();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue