Merge pull request #879 from openscad/scintillaeditor

Scintilla Editor
master
Marius Kintel 2014-09-03 16:44:35 -04:00
commit c4485cfdeb
29 changed files with 1660 additions and 1023 deletions

View File

@ -16,3 +16,4 @@ include(sparkle.pri)
include(harfbuzz.pri)
include(freetype.pri)
include(fontconfig.pri)
include(scintilla.pri)

View File

@ -1,14 +1,14 @@
# Environment variables which can be set to specify library locations:
# MPIRDIR
# MPFRDIR
# BOOSTDIR
# CGALDIR
# EIGENDIR
# GLEWDIR
# OPENCSGDIR
# OPENSCAD_LIBRARIES
# MPIRDIR
# MPFRDIR
# BOOSTDIR
# CGALDIR
# EIGENDIR
# GLEWDIR
# OPENCSGDIR
# OPENSCAD_LIBRARIES
#
# Please see the 'Building' sections of the OpenSCAD user manual
# Please see the 'Building' sections of the OpenSCAD user manual
# for updated tips & workarounds.
#
# http://en.wikibooks.org/wiki/OpenSCAD_User_Manual
@ -135,13 +135,13 @@ netbsd* {
}
# Prevent LD_LIBRARY_PATH problems when running the openscad binary
# on systems where uni-build-dependencies.sh was used.
# on systems where uni-build-dependencies.sh was used.
# Will not affect 'normal' builds.
!isEmpty(OPENSCAD_LIBDIR) {
unix:!macx {
QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib $$QMAKE_LFLAGS
# need /lib64 beause GLEW installs itself there on 64 bit machines
QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib64 $$QMAKE_LFLAGS
QMAKE_LFLAGS = -Wl,-R$$OPENSCAD_LIBDIR/lib64 $$QMAKE_LFLAGS
}
}
@ -179,8 +179,8 @@ CONFIG += harfbuzz
CONFIG += freetype
CONFIG += fontconfig
#Uncomment the following line to enable QCodeEdit
#CONFIG += qcodeedit
#Uncomment the following line to enable the QScintilla editor
CONFIG += scintilla
# Make experimental features available
experimental {
@ -208,7 +208,7 @@ win* {
RESOURCES = openscad.qrc
FORMS += src/MainWindow.ui \
FORMS += src/MainWindow.ui \
src/Preferences.ui \
src/OpenCSGWarningDialog.ui \
src/AboutDialog.ui \
@ -283,9 +283,9 @@ HEADERS += src/typedefs.h \
src/GeometryEvaluator.h \
src/CSGTermEvaluator.h \
src/Tree.h \
src/DrawingCallback.h \
src/FreetypeRenderer.h \
src/FontCache.h \
src/DrawingCallback.h \
src/FreetypeRenderer.h \
src/FontCache.h \
src/mathc99.h \
src/memory.h \
src/linalg.h \
@ -305,7 +305,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 \
@ -360,9 +361,9 @@ SOURCES += src/version_check.cc \
src/ModuleCache.cc \
src/GeometryCache.cc \
src/Tree.cc \
src/DrawingCallback.cc \
src/FreetypeRenderer.cc \
src/FontCache.cc \
src/DrawingCallback.cc \
src/FreetypeRenderer.cc \
src/FontCache.cc \
\
src/rendersettings.cc \
src/highlighter.cc \
@ -391,7 +392,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
@ -488,4 +490,3 @@ INSTALLS += man
CONFIG(winconsole) {
include(winconsole.pri)
}

View File

@ -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 3.0.1, 2014-08-11T22:59:13. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -11,22 +11,24 @@
<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">
<value type="QString" key="CurrentPreferences">CppGlobal</value>
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</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>
@ -49,135 +51,34 @@
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<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.DefaultDisplayName">Qt 4.8.6 (qt4)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 4.8.6 (qt4)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{90222843-28c9-4a66-ac82-99bd31ae7263}</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>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></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>
<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"></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"></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>
</valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MacPorts QT4 Release</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">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="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<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="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"></value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments">CONFIG+=experimental</value>
<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.MakeCommand"></value>
@ -189,9 +90,14 @@
</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.MakeCommand"></value>
@ -204,117 +110,13 @@
<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" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">4.7.4 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/../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.3">
<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="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"></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"></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" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">4.7.4 Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</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">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.4">
<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">Clone of qmake</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">Clone of Make</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"></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">Clone of Build</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">Clone of Make</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">Clone of Clean</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>
</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">Desktop Qt 4.7.4 for GCC (Qt SDK)</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-release-desktop</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">3</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
@ -323,39 +125,29 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<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.LeakCheckOnFinish">1</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="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<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,37 +166,22 @@
<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/letsbegin/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>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
@ -415,10 +192,10 @@
</data>
<data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QString">{b7a15081-01e1-47e4-b2e5-20f6404deb62}</value>
<value type="QByteArray">{56f57d1a-fe9b-42b2-a96b-3ac76cf7565f}</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">10</value>
<value type="int">15</value>
</data>
</qtcreator>

12
qscintilla2.prf Normal file
View File

@ -0,0 +1,12 @@
greaterThan(QT_MAJOR_VERSION, 4) {
QT += widgets printsupport
greaterThan(QT_MINOR_VERSION, 1) {
macx:QT += macextras
}
}
INCLUDEPATH += $$[QT_INSTALL_HEADERS]
LIBS += -L$$[QT_INSTALL_LIBS]
LIBS += -lqscintilla2

11
scintilla.pri Normal file
View File

@ -0,0 +1,11 @@
scintilla {
HEADERS += src/scintillaeditor.h src/scadlexer.h
SOURCES += src/scintillaeditor.cpp src/scadlexer.cpp
DEFINES += USE_SCINTILLA_EDITOR
# The qscintilla2.prf which ships with QScintilla is broken for Mac/Windows
# debug builds, so we supply our own
win32|macx: include(qscintilla2.prf)
else: CONFIG += qscintilla2
}

View File

@ -55,6 +55,7 @@ build_libxml2()
build_fontconfig()
{
version=$1
extra_config_flags="$2"
if [ -e $DEPLOYDIR/include/fontconfig ]; then
echo "fontconfig already installed. not building"
@ -70,10 +71,10 @@ build_fontconfig()
tar xzf "fontconfig-$version.tar.gz"
cd "fontconfig-$version"
export PKG_CONFIG_PATH="$DEPLOYDIR/lib/pkgconfig"
./configure --prefix="$DEPLOYDIR" --enable-libxml2 --disable-docs
./configure --prefix=/ --enable-libxml2 --disable-docs $extra_config_flags
unset PKG_CONFIG_PATH
make -j$NUMCPU
make install
DESTDIR="$DEPLOYDIR" make -j$NUMCPU
DESTDIR="$DEPLOYDIR" make install
}
build_libffi()

View File

@ -133,6 +133,22 @@ build_qt5()
make -j"$NUMCPU" install
}
build_qscintilla()
{
version=$1
echo "Building QScintilla" $version "..."
cd $BASEDIR/src
rm -rf QScintilla-gpl-$version
if [ ! -f QScintilla-gpl-$version.tar.gz ]; then
curl -LO http://downloads.sourceforge.net/project/pyqt/QScintilla2/QScintilla-$version/QScintilla-gpl-$version.tar.gz
fi
tar xzf QScintilla-gpl-$version.tar.gz
cd QScintilla-gpl-$version/Qt4Qt5
qmake qscintilla.pro
make -j6 install
install_name_tool -id $DEPLOYDIR/lib/libqscintilla2.dylib $DEPLOYDIR/lib/libqscintilla2.dylib
}
# Hack warning: gmplib is built separately in 32-bit and 64-bit mode
# and then merged afterwards. gmplib's header files are dependent on
# the CPU architecture on which configure was run and will be patched accordingly.
@ -754,6 +770,7 @@ fi
echo "Using basedir:" $BASEDIR
mkdir -p $SRCDIR $DEPLOYDIR
build_qt5 5.3.1
build_qscintilla 2.8.3
# NB! For eigen, also update the path in the function
build_eigen 3.2.1
build_gmp 5.1.3

View File

@ -65,14 +65,14 @@ if [ "`echo $* | grep 64`" ]; then
if [ "`echo $* | grep download`" ]; then
PACKAGES='download-mpfr download-eigen download-opencsg download-cgal download-qtbase download-glib download-freetype download-fontconfig download-harfbuzz'
else
PACKAGES='qtbase mpfr eigen opencsg cgal glib freetype fontconfig harfbuzz'
PACKAGES='qtbase qscintilla2 mpfr eigen opencsg cgal glib freetype fontconfig harfbuzz'
fi
else
MXE_TARGETS='i686-w64-mingw32.static'
if [ "`echo $* | grep download`" ]; then
PACKAGES='download-mpfr download-eigen download-opencsg download-cgal download-qtbase download-nsis download-glib download-freetype download-fontconfig download-harfbuzz'
else
PACKAGES='qtbase mpfr eigen opencsg cgal nsis glib freetype fontconfig harfbuzz'
PACKAGES='qtbase qscintilla2 mpfr eigen opencsg cgal nsis glib freetype fontconfig harfbuzz'
fi
fi
echo make $PACKAGES MXE_TARGETS=$MXE_TARGETS -j $NUMCPU JOBS=$NUMJOBS

View File

@ -4,5 +4,6 @@ cd "$( dirname "$( type -p $0 )" )"
libdir=$PWD/../lib/openscad/
cd "$OLDPWD"
export LIBGL_DRIVERS_PATH="$libdir"/dri
export LD_LIBRARY_PATH="$libdir${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
exec $libdir/openscad "$@"

View File

@ -455,12 +455,26 @@ case $OS in
gcc -o chrpath_linux -DSIZEOF_VOID_P=4 scripts/chrpath_linux.c
fi
./chrpath_linux -d openscad-$VERSION/lib/openscad/openscad
ldd openscad | sed -re 's,.* => ,,; s,[\t ].*,,;' -e '/Qt|boost/ { p; d; };' \
-e '/lib(icu.*|stdc.*|audio|CGAL|GLEW|opencsg|png|gmp|gmpxx|mpfr)\.so/ { p; d; };' \
-e 'd;' | xargs cp -vt openscad-$VERSION/lib/openscad/
QTLIBDIR=$(dirname $(ldd openscad | grep Qt5Gui | head -n 1 | awk '{print $3;}'))
( ldd openscad ; ldd "$QTLIBDIR"/qt5/plugins/platforms/libqxcb.so ) \
| sed -re 's,.* => ,,; s,[\t ].*,,;' -e '/^$/d' -e '/libc\.so|libm\.so|libdl\.so|libgcc_|libpthread\.so/d' \
| sort -u \
| xargs cp -vt "openscad-$VERSION/lib/openscad/"
PLATFORMDIR="openscad-$VERSION/lib/openscad/platforms/"
mkdir -p "$PLATFORMDIR"
cp -av "$QTLIBDIR"/qt5/plugins/platforms/libqxcb.so "$PLATFORMDIR"
DRIDRIVERDIR=$(find /usr/lib -xdev -type d -name dri)
if [ -d "$DRIDRIVERDIR" ]
then
DRILIB="openscad-$VERSION/lib/openscad/dri/"
mkdir -p "$DRILIB"
cp -av "$DRIDRIVERDIR"/swrast_dri.so "$DRILIB"
fi
strip openscad-$VERSION/lib/openscad/*
mkdir -p openscad-$VERSION/share/appdata
cp openscad.appdata.xml openscad-$VERSION/share/appdata
cp icons/openscad.{desktop,png,xml} openscad-$VERSION/share/appdata
cp scripts/installer-linux.sh openscad-$VERSION/install.sh
chmod 755 -R openscad-$VERSION/
PACKAGEFILE=openscad-$VERSION.x86-$ARCH.tar.gz

View File

@ -131,6 +131,56 @@ build_qt4()
echo "----------"
}
build_qt5()
{
version=$1
if [ -f $DEPLOYDIR/lib/libQt5Core.a ]; then
echo "Qt5 already installed. not building"
return
fi
echo "Building Qt" $version "..."
cd $BASEDIR/src
rm -rf qt-everywhere-opensource-src-$version
v=`echo "$version" | sed -e 's/\.[0-9]$//'`
if [ ! -f qt-everywhere-opensource-src-$version.tar.gz ]; then
curl -O -L http://download.qt-project.org/official_releases/qt/$v/$version/single/qt-everywhere-opensource-src-$version.tar.gz
fi
tar xzf qt-everywhere-opensource-src-$version.tar.gz
cd qt-everywhere-opensource-src-$version
./configure -prefix $DEPLOYDIR -release -static -opensource -confirm-license \
-nomake examples -nomake tests \
-qt-xcb -no-c++11 -no-glib -no-harfbuzz -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc \
-no-sql-psql -no-sql-sqlite2 -no-sql-tds -no-cups -no-qml-debug \
-skip activeqt -skip connectivity -skip declarative -skip doc \
-skip enginio -skip graphicaleffects -skip location -skip multimedia \
-skip quick1 -skip quickcontrols -skip script -skip sensors -skip serialport \
-skip svg -skip webkit -skip webkit-examples -skip websockets -skip xmlpatterns
make -j"$NUMCPU" install
}
build_qt5scintilla2()
{
version=$1
if [ -d $DEPLOYDIR/lib/libqt5scintilla2.a ]; then
echo "Qt5Scintilla2 already installed. not building"
return
fi
echo "Building Qt5Scintilla2" $version "..."
cd $BASEDIR/src
#rm -rf QScintilla-gpl-$version.tar.gz
if [ ! -f QScintilla-gpl-$version.tar.gz ]; then
curl -L -o "QScintilla-gpl-$version.tar.gz" "http://downloads.sourceforge.net/project/pyqt/QScintilla2/QScintilla-$version/QScintilla-gpl-$version.tar.gz?use_mirror=switch"
fi
tar xzf QScintilla-gpl-$version.tar.gz
cd QScintilla-gpl-$version/Qt4Qt5/
qmake CONFIG+=staticlib
make -j"$NUMCPU" install
}
build_bison()
{
version=$1
@ -210,7 +260,7 @@ build_gmp()
cd $BASEDIR/src
rm -rf gmp-$version
if [ ! -f gmp-$version.tar.bz2 ]; then
curl --insecure -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2
curl --insecure -O https://gmplib.org/download/gmp/gmp-$version.tar.bz2
fi
tar xjf gmp-$version.tar.bz2
cd gmp-$version
@ -315,6 +365,7 @@ build_cgal()
echo "Building CGAL" $version "..."
cd $BASEDIR/src
rm -rf CGAL-$version
ver4_4="curl --insecure -O https://gforge.inria.fr/frs/download.php/file/33524/CGAL-4.4.tar.bz2"
ver4_2="curl --insecure -O https://gforge.inria.fr/frs/download.php/32360/CGAL-4.2.tar.bz2"
ver4_1="curl --insecure -O https://gforge.inria.fr/frs/download.php/31640/CGAL-4.1.tar.bz2"
ver4_0_2="curl --insecure -O https://gforge.inria.fr/frs/download.php/31174/CGAL-4.0.2.tar.bz2"
@ -509,6 +560,7 @@ build_eigen()
cd $BASEDIR/src
rm -rf eigen-$version
EIGENDIR="none"
if [ $version = "3.2.2" ]; then EIGENDIR=eigen-eigen-1306d75b4a21; fi
if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi
if [ $EIGENDIR = "none" ]; then
echo Unknown eigen version. Please edit script.
@ -697,7 +749,7 @@ if [ $1 ]; then
exit $?
fi
if [ $1 = "cgal" ]; then
build_cgal 4.0.2 use-sys-libs
build_cgal 4.4 use-sys-libs
exit $?
fi
if [ $1 = "opencsg" ]; then
@ -709,6 +761,11 @@ if [ $1 ]; then
build_qt4 4.8.4
exit $?
fi
if [ $1 = "qt5" ]; then
build_qt5 5.3.1
build_qt5scintilla2 2.8.3
exit $?
fi
if [ $1 = "glu" ]; then
# Mesa and GLU split in late 2012, so it's not on some systems
build_glu 9.0.0
@ -741,21 +798,21 @@ fi
#
# Some of these are defined in scripts/common-build-dependencies.sh
build_eigen 3.1.1
build_eigen 3.2.2
build_gmp 5.0.5
build_mpfr 3.1.1
build_boost 1.53.0
build_boost 1.56.0
# NB! For CGAL, also update the actual download URL in the function
build_cgal 4.0.2
build_cgal 4.4
build_glew 1.9.0
build_opencsg 1.3.2
build_gettext 0.18.3.1
build_glib2 2.38.2
# the following are only needed for text()
build_freetype 2.5.0.1
build_freetype 2.5.0.1 --without-png
build_libxml2 2.9.1
build_fontconfig 2.11.0
build_fontconfig 2.11.0 --with-add-fonts=/usr/X11R6/lib/X11/fonts,/usr/local/share/fonts
build_ragel 6.8
build_harfbuzz 0.9.23 --with-glib=yes

View File

@ -57,7 +57,7 @@ get_mageia_deps()
get_debian_deps()
{
for pkg in build-essential libqt4-dev libqt4-opengl-dev \
for pkg in build-essential curl libffi-dev qtbase5-dev \
libxmu-dev cmake bison flex git-core libboost-all-dev \
libXi-dev libmpfr-dev libboost-dev libglew-dev \
libeigen3-dev libcgal-dev libopencsg-dev libgmp3-dev libgmp-dev \
@ -65,6 +65,15 @@ get_debian_deps()
libharfbuzz-dev gtk-doc-tools libglib2.0-dev gettext; do
sudo apt-get -y install $pkg;
done
# The following packages are only needed to build the static
# Qt5 version for release builds / older distributions.
for pkg in libdbus-1-dev \
libxcb1-dev libx11-xcb-dev libxcb-keysyms1-dev libxcb-image0-dev \
libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync0-dev libxcb-xfixes0-dev \
libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev; do
sudo apt-get -y install $pkg;
done
}
unknown()

View File

@ -1,4 +1,4 @@
export OPENSCAD_LIBRARIES=$PWD/../libraries/install
export OPENSCAD_LIBRARIES=$PWD/../libraries/install-qt4
export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib
export DYLD_FRAMEWORK_PATH=$OPENSCAD_LIBRARIES/lib
export QMAKESPEC=unsupported/macx-clang

View File

@ -1,6 +1,9 @@
#include "LibraryInfo.h"
#include <glib.h>
#include <vector>
#ifdef USE_SCINTILLA_EDITOR
#include <Qsci/qsciglobal.h>
#endif
#include "version_check.h"
#define STRINGIFY(x) #x
@ -82,6 +85,9 @@ std::string LibraryInfo::info()
<< "\nCGAL version, kernels: " << TOSTRING(CGAL_VERSION) << ", " << cgal_3d_kernel << ", " << cgal_2d_kernel << ", " << cgal_2d_kernelEx
<< "\nOpenCSG version: " << OPENCSG_VERSION_STRING
<< "\nQt version: " << qtVersion
#ifdef USE_SCINTILLA_EDITOR
<< "\nQScintilla version: " << QSCINTILLA_VERSION_STR
#endif
<< "\nMingW build: " << mingwstatus
<< "\nGLib version: " << GLIB_MAJOR_VERSION << "." << GLIB_MINOR_VERSION << "." << GLIB_MICRO_VERSION
<< "\nOPENSCADPATH: " << (env_path == NULL ? "<not set>" : env_path)

View File

@ -7,6 +7,7 @@
#include "module.h"
#include "Tree.h"
#include "memory.h"
#include "editor.h"
#include <vector>
#include <QMutex>
#include <QSet>
@ -65,6 +66,9 @@ public:
static const int maxRecentFiles = 10;
QAction *actionRecentFile[maxRecentFiles];
QMap<QString, QString> knownFileExtensions;
QString editortype;
bool useScintilla;
MainWindow(const QString &filename);
~MainWindow();
@ -105,6 +109,8 @@ private:
void show_examples();
void setDockWidgetTitle(QDockWidget *dockWidget, QString prefix, bool topLevel);
EditorInterface *editor;
class QMessageBox *openglbox;
class FontListDialog *font_list_dialog;
@ -135,14 +141,13 @@ private slots:
private slots:
void selectFindType(int);
void find();
void findString(QString);
void findAndReplace();
void findNext();
void findPrev();
void useSelectionForFind();
void replace();
void replaceAll();
protected:
bool findOperation(QTextDocument::FindFlags options = 0);
virtual bool eventFilter(QObject* obj, QEvent *event);
private slots:

View File

@ -179,7 +179,6 @@
<addaction name="separator"/>
<addaction name="editActionIndent"/>
<addaction name="editActionUnindent"/>
<addaction name="separator"/>
<addaction name="editActionComment"/>
<addaction name="editActionUncomment"/>
<addaction name="separator"/>
@ -295,6 +294,15 @@
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="findTypeComboBox">
<item>
@ -361,25 +369,6 @@
</layout>
</widget>
</item>
<item>
<widget class="Editor" name="editor" native="true">
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="font">
<font>
<family>Monaco</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::WheelFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -461,7 +450,7 @@
<string>Ctrl+Z</string>
</property>
<property name="shortcutContext">
<enum>Qt::WidgetWithChildrenShortcut</enum>
<enum>Qt::WindowShortcut</enum>
</property>
</action>
<action name="editActionRedo">
@ -472,7 +461,7 @@
<string>Ctrl+Shift+Z</string>
</property>
<property name="shortcutContext">
<enum>Qt::WidgetWithChildrenShortcut</enum>
<enum>Qt::WindowShortcut</enum>
</property>
</action>
<action name="editActionCut">
@ -483,7 +472,7 @@
<string>Ctrl+X</string>
</property>
<property name="shortcutContext">
<enum>Qt::WidgetWithChildrenShortcut</enum>
<enum>Qt::WindowShortcut</enum>
</property>
</action>
<action name="editActionCopy">
@ -494,7 +483,7 @@
<string>Ctrl+C</string>
</property>
<property name="shortcutContext">
<enum>Qt::WidgetWithChildrenShortcut</enum>
<enum>Qt::WindowShortcut</enum>
</property>
</action>
<action name="editActionPaste">
@ -505,7 +494,7 @@
<string>Ctrl+V</string>
</property>
<property name="shortcutContext">
<enum>Qt::WidgetWithChildrenShortcut</enum>
<enum>Qt::WindowShortcut</enum>
</property>
</action>
<action name="editActionIndent">
@ -776,9 +765,6 @@
<property name="text">
<string>Center</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="viewActionPerspective">
<property name="checkable">
@ -975,15 +961,8 @@
<header>QGLView.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Editor</class>
<extends>QWidget</extends>
<header>editor.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../openscad.qrc"/>
</resources>
<resources/>
<connections>
<connection>
<sender>fileActionClose</sender>

View File

@ -3,6 +3,9 @@
#include "PlatformUtils.h"
#include "boosty.h"
#include <Eigen/Core>
#ifdef USE_SCINTILLA_EDITOR
#include <Qsci/qsciglobal.h>
#endif
extern std::vector<std::string> librarypath;
extern std::vector<std::string> fontpath;

View File

@ -66,6 +66,7 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
this->defaultmap["editor/fontfamily"] = found_family;
this->defaultmap["editor/fontsize"] = 12;
this->defaultmap["editor/syntaxhighlight"] = "For Light Background";
this->defaultmap["editor/editortype"] = "Simple Editor";
#if defined (Q_OS_MAC)
this->defaultmap["editor/ctrlmousewheelzoom"] = false;
@ -85,9 +86,12 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
connect(this->fontSize, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(on_fontSize_editTextChanged(const QString &)));
connect(this->editorType, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(on_editorType_editTextChanged(const QString &)));
// reset GUI fontsize if fontSize->addItem emitted signals that changed it.
this->fontSize->setEditText( QString("%1").arg( savedsize ) );
// Setup default settings
this->defaultmap["advanced/opencsg_show_warning"] = true;
this->defaultmap["advanced/enable_opencsg_opengl1x"] = true;
@ -261,6 +265,12 @@ void Preferences::on_fontSize_editTextChanged(const QString &size)
emit fontChanged(getValue("editor/fontfamily").toString(), intsize);
}
void Preferences::on_editorType_editTextChanged(const QString &type)
{
QSettings settings;
settings.setValue("editor/editortype", type);
}
void Preferences::on_syntaxHighlight_currentIndexChanged(const QString &s)
{
QSettings settings;
@ -430,6 +440,10 @@ void Preferences::updateGUI()
int shidx = this->syntaxHighlight->findText(shighlight);
if (shidx >= 0) this->syntaxHighlight->setCurrentIndex(shidx);
QString editortypevar = getValue("editor/editortype").toString();
int edidx = this->editorType->findText(editortypevar);
if (edidx >=0) this->editorType->setCurrentIndex(edidx);
this->mouseWheelZoomBox->setChecked(getValue("editor/ctrlmousewheelzoom").toBool());
if (AutoUpdater *updater = AutoUpdater::updater()) {

View File

@ -35,7 +35,7 @@ public slots:
void on_mdiCheckBox_toggled(bool);
void on_undockCheckBox_toggled(bool);
void on_checkNowButton_clicked();
void on_editorType_editTextChanged(const QString &);
signals:
void requestRedraw() const;
void updateMdiMode(bool mdi) const;
@ -44,6 +44,7 @@ signals:
void colorSchemeChanged(const QString &scheme) const;
void openCSGSettingsChanged() const;
void syntaxHighlightChanged(const QString &s);
void editorTypeChanged(const QString &type);
private:
Preferences(QWidget *parent = NULL);

File diff suppressed because it is too large Load Diff

View File

@ -1,173 +1,16 @@
#include "editor.h"
#include "Preferences.h"
Editor::Editor(QWidget *parent) : QTextEdit(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 )
void EditorInterface::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 )
if ((event->modifiers() == Qt::ControlModifier) && wheelzoom_enabled) {
if (event->delta() > 0)
zoomIn();
else if (event->delta() < 0 )
else if (event->delta() < 0)
zoomOut();
} else {
QTextEdit::wheelEvent( event );
QWidget::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;
}

View File

@ -1,35 +1,52 @@
#pragma once
#include <QObject>
#include <QString>
#include <QWidget>
#include <QWheelEvent>
#include <QScrollBar>
#include <QTextEdit>
#include "highlighter.h"
class Editor : public QTextEdit
class EditorInterface : public QWidget
{
Q_OBJECT
public:
Editor(QWidget *parent);
~Editor();
QSize sizeHint() const;
void setInitialSizeHint(const QSize &size);
EditorInterface(QWidget *parent) : QWidget(parent) {}
virtual ~EditorInterface() {}
virtual QSize sizeHint(){ QSize size; return size;}
virtual void setInitialSizeHint(const QSize&) { }
virtual void wheelEvent(QWheelEvent*);
virtual QString toPlainText() = 0;
virtual QTextDocument *document(){QTextDocument *t = new QTextDocument; return t;}
virtual QString selectedText() = 0;
virtual bool find(const QString &, bool findNext = false, bool findBackwards = false) = 0;
virtual void replaceSelectedText(const QString &) = 0;
signals:
void contentsChanged();
void modificationChanged(bool);
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() = 0;
virtual void zoomOut() = 0;
virtual void setContentModified(bool) = 0;
virtual bool isContentModified() = 0;
virtual void indentSelection() = 0;
virtual void unindentSelection() = 0;
virtual void commentSelection() = 0;
virtual void uncommentSelection() = 0;
virtual void setPlainText(const QString &) = 0;
virtual void highlightError(int) = 0;
virtual void unhighlightLastError() = 0;
virtual void setHighlightScheme(const QString&) = 0;
virtual void insert(const QString&) = 0;
virtual void undo() = 0;
virtual void redo() = 0;
virtual void cut() = 0;
virtual void copy() = 0;
virtual void paste() = 0;
virtual void initFont(const QString&, uint) = 0;
private:
void wheelEvent ( QWheelEvent * event );
Highlighter *highlighter;
QSize initialSizeHint;
QSize initialSizeHint;
};

267
src/legacyeditor.cc Normal file
View File

@ -0,0 +1,267 @@
#include "legacyeditor.h"
#include "Preferences.h"
#include "highlighter.h"
LegacyEditor::LegacyEditor(QWidget *parent) : EditorInterface(parent)
{
QVBoxLayout *legacyeditorLayout = new QVBoxLayout(this);
legacyeditorLayout->setContentsMargins(0, 0, 0, 0);
this->textedit = new QTextEdit(this);
legacyeditorLayout->addWidget(this->textedit);
this->textedit->setAcceptRichText(false);
// This needed to avoid the editor accepting filename drops as we want
// to handle these ourselves in MainWindow
this->textedit->setAcceptDrops(false);
this->textedit->setWordWrapMode(QTextOption::WrapAnywhere);
this->textedit->setTabStopWidth(30);
this->highlighter = new Highlighter(this->textedit->document());
connect(this->textedit, SIGNAL(textChanged()), this, SIGNAL(contentsChanged()));
connect(this->textedit->document(), SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool)));
}
void LegacyEditor::indentSelection()
{
QTextCursor cursor = textedit->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 = textedit->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 = textedit->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 = textedit->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::setPlainText(const QString &text)
{
int y = textedit->verticalScrollBar()->sliderPosition();
// Save current cursor position
QTextCursor cursor = textedit->textCursor();
int n = cursor.position();
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->textedit->textCursor();
cursor.setPosition(error_pos);
this->textedit->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 textedit->sizeHint();
} else {
return initialSizeHint;
}
}
void LegacyEditor::setInitialSizeHint(const QSize &size)
{
initialSizeHint = size;
}
QString LegacyEditor::toPlainText()
{
return textedit->toPlainText();
}
void LegacyEditor::insert(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;
}
void LegacyEditor::replaceSelectedText(const QString &newText)
{
QTextCursor cursor = this->textedit->textCursor();
if (cursor.selectedText() != newText) {
cursor.insertText(newText);
}
}
bool LegacyEditor::findString(const QString & exp, bool findBackwards) const
{
return textedit->find(exp, findBackwards ? QTextDocument::FindBackward : QTextDocument::FindFlags(0));
}
bool LegacyEditor::find(const QString &newText, bool findNext, bool findBackwards)
{
bool success = this->findString(newText, findBackwards);
if (!success) { // Implement wrap-around search behavior
QTextCursor old_cursor = this->textedit->textCursor();
QTextCursor tmp_cursor = old_cursor;
tmp_cursor.movePosition(findBackwards ? QTextCursor::End : QTextCursor::Start);
this->textedit->setTextCursor(tmp_cursor);
bool success = this->findString(newText, findBackwards);
if (!success) {
this->textedit->setTextCursor(old_cursor);
}
return success;
}
return true;
}
void LegacyEditor::initFont(const QString& family, uint size)
{
QFont font;
if (!family.isEmpty()) font.setFamily(family);
else font.setFixedPitch(true);
if (size > 0) font.setPointSize(size);
font.setStyleHint(QFont::TypeWriter);
this->setFont(font);
}
QString LegacyEditor::selectedText()
{
return textedit->textCursor().selectedText();
}
void LegacyEditor::setContentModified(bool y)
{
textedit->document()->setModified(y);
}
bool LegacyEditor::isContentModified()
{
return textedit->document()->isModified();
}

43
src/legacyeditor.h Normal file
View File

@ -0,0 +1,43 @@
#pragma once
#include "editor.h"
class LegacyEditor : public EditorInterface
{
Q_OBJECT
public:
LegacyEditor(class QWidget *parent);
virtual ~LegacyEditor();
QSize sizeHint() const;
void setInitialSizeHint(const QSize&);
QString toPlainText();
QString selectedText();
bool find(const QString &, bool findNext = false, bool findBackwards = false);
void replaceSelectedText(const QString &newText);
bool findString(const QString & exp, bool findBackwards) const;
public slots:
void zoomIn();
void zoomOut();
void setContentModified(bool);
bool isContentModified();
void indentSelection();
void unindentSelection();
void commentSelection();
void uncommentSelection();
void setPlainText(const QString&);
void highlightError(int);
void unhighlightLastError();
void setHighlightScheme(const QString&);
void insert(const QString&);
void undo();
void redo();
void cut();
void copy();
void paste();
void initFont(const QString&, uint);
private:
class QTextEdit *textedit;
class Highlighter *highlighter;
QSize initialSizeHint;
};

View File

@ -23,7 +23,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "GeometryCache.h"
#include "ModuleCache.h"
#include "MainWindow.h"
@ -40,6 +39,10 @@
#include "expression.h"
#include "progress.h"
#include "dxfdim.h"
#include "legacyeditor.h"
#ifdef USE_SCINTILLA_EDITOR
#include "scintillaeditor.h"
#endif
#include "AboutDialog.h"
#include "FontListDialog.h"
#ifdef ENABLE_OPENCSG
@ -166,6 +169,20 @@ MainWindow::MainWindow(const QString &filename)
: root_inst("group"), font_list_dialog(NULL), tempFile(NULL), progresswidget(NULL)
{
setupUi(this);
editortype = Preferences::inst()->getValue("editor/editortype").toString();
useScintilla = (editortype == "QScintilla Editor");
#ifdef USE_SCINTILLA_EDITOR
if (useScintilla) {
editor = new ScintillaEditor(editorDockContents);
}
else
#endif
editor = new LegacyEditor(editorDockContents);
editorDockContents->layout()->addWidget(editor);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
@ -219,8 +236,6 @@ MainWindow::MainWindow(const QString &filename)
connect(this, SIGNAL(highlightError(int)), editor, SLOT(highlightError(int)));
connect(this, SIGNAL(unhighlightLastError()), editor, SLOT(unhighlightLastError()));
editor->setTabStopWidth(30);
editor->setLineWrapping(true); // Not designable
this->qglview->statusLabel = new QLabel(this);
statusBar()->addWidget(this->qglview->statusLabel);
@ -315,7 +330,6 @@ MainWindow::MainWindow(const QString &filename)
connect(this->editActionFindAndReplace, SIGNAL(triggered()), this, SLOT(findAndReplace()));
connect(this->editActionFindNext, SIGNAL(triggered()), this, SLOT(findNext()));
connect(this->editActionFindPrevious, SIGNAL(triggered()), this, SLOT(findPrev()));
connect(this->editActionUseSelectionForFind, SIGNAL(triggered()), this, SLOT(useSelectionForFind()));
// Design menu
connect(this->designActionAutoReload, SIGNAL(toggled(bool)), this, SLOT(autoReloadSet(bool)));
@ -397,15 +411,15 @@ MainWindow::MainWindow(const QString &filename)
}
updateRecentFileActions();
connect(editor->document(), SIGNAL(contentsChanged()), this, SLOT(animateUpdateDocChanged()));
connect(editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
connect(editor, SIGNAL(contentsChanged()), this, SLOT(animateUpdateDocChanged()));
connect(editor, SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
connect(this->qglview, SIGNAL(doAnimateUpdate()), this, SLOT(animateUpdate()));
connect(Preferences::inst(), SIGNAL(requestRedraw()), this->qglview, SLOT(updateGL()));
connect(Preferences::inst(), SIGNAL(updateMdiMode(bool)), this, SLOT(updateMdiMode(bool)));
connect(Preferences::inst(), SIGNAL(updateUndockMode(bool)), this, SLOT(updateUndockMode(bool)));
connect(Preferences::inst(), SIGNAL(fontChanged(const QString&,uint)),
this, SLOT(setFont(const QString&,uint)));
editor, SLOT(initFont(const QString&,uint)));
connect(Preferences::inst(), SIGNAL(openCSGSettingsChanged()),
this, SLOT(openCSGSettingsChanged()));
connect(Preferences::inst(), SIGNAL(syntaxHighlightChanged(const QString&)),
@ -417,7 +431,9 @@ MainWindow::MainWindow(const QString &filename)
QString cs = Preferences::inst()->getValue("3dview/colorscheme").toString();
this->setColorScheme(cs);
//find and replace panel
connect(this->findTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFindType(int)));
connect(this->findInputField, SIGNAL(textChanged(QString)), this, SLOT(findString(QString)));
connect(this->findInputField, SIGNAL(returnPressed()), this->nextButton, SLOT(animateClick()));
find_panel->installEventFilter(this);
@ -470,8 +486,7 @@ MainWindow::MainWindow(const QString &filename)
clearCurrentOutput();
}
void
MainWindow::loadViewSettings(){
void MainWindow::loadViewSettings(){
QSettings settings;
if (settings.value("view/showEdges").toBool()) {
viewActionShowEdges->setChecked(true);
@ -498,8 +513,7 @@ MainWindow::loadViewSettings(){
updateUndockMode(settings.value("advanced/undockableWindows").toBool());
}
void
MainWindow::loadDesignSettings()
void MainWindow::loadDesignSettings()
{
QSettings settings;
if (settings.value("design/autoReload").toBool()) {
@ -591,8 +605,8 @@ void MainWindow::requestOpenFile(const QString &filename)
one is not empty. Otherwise the current window content is overwritten.
Any check whether to replace the content have to be made before.
*/
void
MainWindow::openFile(const QString &new_filename)
void MainWindow::openFile(const QString &new_filename)
{
if (MainWindow::mdiMode) {
if (!editor->toPlainText().isEmpty()) {
@ -622,8 +636,7 @@ MainWindow::openFile(const QString &new_filename)
clearCurrentOutput();
}
void
MainWindow::setFileName(const QString &filename)
void MainWindow::setFileName(const QString &filename)
{
if (filename.isEmpty()) {
this->fileName.clear();
@ -1091,6 +1104,7 @@ void MainWindow::show_examples()
{
bool found_example = false;
QStringList categories;
//categories in File menu item - Examples
categories << "Basics" << "Shapes" << "Extrusion" << "Advanced";
foreach (const QString &cat, categories){
@ -1243,19 +1257,17 @@ void MainWindow::actionReload()
void MainWindow::pasteViewportTranslation()
{
QTextCursor cursor = editor->textCursor();
QString txt;
txt.sprintf("[ %.2f, %.2f, %.2f ]", -qglview->cam.object_trans.x(), -qglview->cam.object_trans.y(), -qglview->cam.object_trans.z());
cursor.insertText(txt);
this->editor->insert(txt);
}
void MainWindow::pasteViewportRotation()
{
QTextCursor cursor = editor->textCursor();
QString txt;
txt.sprintf("[ %.2f, %.2f, %.2f ]",
fmodf(360 - qglview->cam.object_rot.x() + 90, 360), fmodf(360 - qglview->cam.object_rot.y(), 360), fmodf(360 - qglview->cam.object_rot.z(), 360));
cursor.insertText(txt);
this->editor->insert(txt);
}
void MainWindow::find()
@ -1265,10 +1277,16 @@ void MainWindow::find()
replaceButton->hide();
replaceAllButton->hide();
find_panel->show();
findInputField->setText(editor->selectedText());
findInputField->setFocus();
findInputField->selectAll();
}
void MainWindow::findString(QString textToFind)
{
editor->find(textToFind, false, false);
}
void MainWindow::findAndReplace()
{
findTypeComboBox->setCurrentIndex(1);
@ -1285,55 +1303,25 @@ void MainWindow::selectFindType(int type) {
if (type == 1) findAndReplace();
}
bool MainWindow::findOperation(QTextDocument::FindFlags options) {
bool success = editor->find(findInputField->text(), options);
if (!success) { // Implement wrap-around search behavior
QTextCursor old_cursor = editor->textCursor();
QTextCursor tmp_cursor = old_cursor;
tmp_cursor.movePosition((options & QTextDocument::FindBackward) ? QTextCursor::End : QTextCursor::Start);
editor->setTextCursor(tmp_cursor);
bool success = editor->find(findInputField->text(), options);
if (!success) {
editor->setTextCursor(old_cursor);
}
return success;
}
return true;
}
void MainWindow::replace() {
QTextCursor cursor = editor->textCursor();
QString selectedText = cursor.selectedText();
if (selectedText == findInputField->text()) {
cursor.insertText(replaceInputField->text());
}
findNext();
this->editor->replaceSelectedText(this->replaceInputField->text());
this->editor->find(this->findInputField->text());
}
void MainWindow::replaceAll() {
QTextCursor old_cursor = editor->textCursor();
QTextCursor tmp_cursor = old_cursor;
tmp_cursor.movePosition(QTextCursor::Start);
editor->setTextCursor(tmp_cursor);
while (editor->find(findInputField->text())) {
editor->textCursor().insertText(replaceInputField->text());
while (this->editor->find(this->findInputField->text(), true)) {
this->editor->replaceSelectedText(this->replaceInputField->text());
}
editor->setTextCursor(old_cursor);
}
void MainWindow::findNext()
{
findOperation();
editor->find(this->findInputField->text(), true);
}
void MainWindow::findPrev()
{
findOperation(QTextDocument::FindBackward);
}
void MainWindow::useSelectionForFind()
{
findInputField->setText(editor->textCursor().selectedText());
editor->find(this->findInputField->text(), true, true);
}
bool MainWindow::eventFilter(QObject* obj, QEvent *event)
@ -1473,6 +1461,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;
@ -1481,10 +1470,8 @@ void MainWindow::compileTopLevelDocument()
this->root_module = NULL;
this->root_module = parse(fulltext.c_str(),
this->fileName.isEmpty() ?
"" :
QFileInfo(this->fileName).absolutePath().toLocal8Bit(),
false);
this->fileName.isEmpty() ? "" :
QFileInfo(this->fileName).absolutePath().toLocal8Bit(), false);
updateCamera();
}
@ -1921,8 +1908,9 @@ void MainWindow::actionExportCSG()
}
QString csg_filename = QFileDialog::getSaveFileName(this, "Export CSG File",
this->fileName.isEmpty() ? "Untitled.csg" : QFileInfo(this->fileName).baseName()+".csg",
"CSG Files (*.csg)");
this->fileName.isEmpty() ? "Untitled.csg" : QFileInfo(this->fileName).baseName()+".csg",
"CSG Files (*.csg)");
if (csg_filename.isEmpty()) {
PRINT("No filename specified. CSG export aborted.");
clearCurrentOutput();
@ -2071,7 +2059,7 @@ void MainWindow::viewModeAnimate()
void MainWindow::animateUpdateDocChanged()
{
QString current_doc = editor->toPlainText();
QString current_doc = editor->toPlainText();
if (current_doc != last_compiled_doc)
animateUpdate();
}
@ -2260,7 +2248,7 @@ void MainWindow::handleFileDrop(const QString &filename)
}
openFile(filename);
} else {
editor->insertPlainText(cmd.arg(filename));
editor->insert(cmd.arg(filename));
}
}
@ -2402,7 +2390,8 @@ void MainWindow::consoleOutput(const std::string &msg, void *userdata)
// originates in a worker thread.
MainWindow *thisp = static_cast<MainWindow*>(userdata);
QMetaObject::invokeMethod(thisp->console, "append", Qt::QueuedConnection,
Q_ARG(QString, QString::fromLocal8Bit(msg.c_str())));
Q_ARG(QString, QString::fromLocal8Bit(msg.c_str())));
if (thisp->procevents) QApplication::processEvents();
}
@ -2419,6 +2408,7 @@ void MainWindow::clearCurrentOutput()
void MainWindow::openCSGSettingsChanged()
{
#ifdef ENABLE_OPENCSG
OpenCSG::setOption(OpenCSG::AlgorithmSetting, Preferences::inst()->getValue("advanced/forceGoldfeather").toBool() ? OpenCSG::Goldfeather : OpenCSG::Automatic);
OpenCSG::setOption(OpenCSG::AlgorithmSetting, Preferences::inst()->getValue("advanced/forceGoldfeather").toBool() ?
OpenCSG::Goldfeather : OpenCSG::Automatic);
#endif
}

38
src/scadlexer.cpp Normal file
View File

@ -0,0 +1,38 @@
#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 "if else for module function intersection_for assign echo search "
" str let true false "; // -> Style: Keyword
if (set == 2)
return " abs sign acos asin atan atan2 sin cos tan floor round ceil len ln "
" log lookup min max pow sqrt exp rands version version_num "
" group difference union intersection render translate rotate scale multmatrix color "
" projection hull resize mirror minkowski glide subdiv child "
" include use dxf_dim dxf_cross "
" linear_extrude rotate_extrude "; // -> Style: KeywordSet2
if (set == 3)
return " param author "; // -> used in comments only like /*! \cube */
if (set == 4)
return "cube circle cylinder polygon polyhedron square sphere "
"surface import "; // -> Style: GlobalClass
return 0;
}

19
src/scadlexer.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#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 &);
};

349
src/scintillaeditor.cpp Normal file
View File

@ -0,0 +1,349 @@
#include <algorithm>
#include <QString>
#include <QChar>
#include "scintillaeditor.h"
#include <Qsci/qscicommandset.h>
#include "Preferences.h"
ScintillaEditor::ScintillaEditor(QWidget *parent) : EditorInterface(parent)
{
scintillaLayout = new QVBoxLayout(this);
qsci = new QsciScintilla(this);
//
// Remapping some scintilla key binding which conflict with OpenSCAD global
// key bindings, as well as some minor scintilla bugs
//
QsciCommand *c;
#ifdef Q_OS_MAC
// Alt-Backspace should delete left word (Alt-Delete already deletes right word)
c= qsci->standardCommands()->find(QsciCommand::DeleteWordLeft);
c->setKey(Qt::Key_Backspace | Qt::ALT);
#endif
// Cmd/Ctrl-T is handled by the menu
c = qsci->standardCommands()->boundTo(Qt::Key_T | Qt::CTRL);
c->setKey(0);
// Cmd/Ctrl-D is handled by the menu
c = qsci->standardCommands()->boundTo(Qt::Key_D | Qt::CTRL);
c->setKey(0);
// Ctrl-Shift-Z should redo on all platforms
c= qsci->standardCommands()->find(QsciCommand::Redo);
c->setKey(Qt::Key_Z | Qt::CTRL | Qt::SHIFT);
scintillaLayout->setContentsMargins(0, 0, 0, 0);
scintillaLayout->addWidget(qsci);
qsci->setBraceMatching (QsciScintilla::SloppyBraceMatch);
qsci->setWrapMode(QsciScintilla::WrapCharacter);
qsci->setWrapVisualFlags(QsciScintilla::WrapFlagByBorder, QsciScintilla::WrapFlagNone, 0);
qsci->setAutoIndent(true);
qsci->indicatorDefine(QsciScintilla::RoundBoxIndicator, indicatorNumber);
qsci->markerDefine(QsciScintilla::Circle, markerNumber);
qsci->setUtf8(true);
lexer = new ScadLexer(this);
initLexer();
initMargin();
qsci->setFolding(QsciScintilla::BoxedTreeFoldStyle, 4);
qsci->setCaretLineVisible(true);
this->setHighlightScheme(Preferences::inst()->getValue("editor/syntaxhighlight").toString());
connect(qsci, SIGNAL(textChanged()), this, SIGNAL(contentsChanged()));
connect(qsci, SIGNAL(modificationChanged(bool)), this, SIGNAL(modificationChanged(bool)));
}
void ScintillaEditor::setPlainText(const QString &text)
{
qsci->setText(text);
setContentModified(false);
}
QString ScintillaEditor::toPlainText()
{
return qsci->text();
}
void ScintillaEditor::setContentModified(bool modified)
{
qsci->setModified(modified);
}
bool ScintillaEditor::isContentModified()
{
return qsci->isModified();
}
void ScintillaEditor::highlightError(int error_pos)
{
int line, index;
qsci->lineIndexFromPosition(error_pos, &line, &index);
qsci->fillIndicatorRange(line, index, line, index+1, indicatorNumber);
qsci->setIndicatorForegroundColor(QColor(255,0,0,100));
qsci->markerAdd(line, markerNumber);
}
void ScintillaEditor::unhighlightLastError()
{
int totalLength = qsci->text().length();
int line, index;
qsci->lineIndexFromPosition(totalLength, &line, &index);
qsci->clearIndicatorRange(0, 0, line, index, indicatorNumber);
qsci->markerDeleteAll(markerNumber);
}
//Editor themes
void ScintillaEditor::forLightBackground()
{
lexer->setPaper("#fff");
lexer->setColor(QColor("#272822")); // -> Style: Default text
lexer->setColor(QColor("Green"), QsciLexerCPP::Keyword); // -> Style: Keyword
lexer->setColor(QColor("Green"), QsciLexerCPP::KeywordSet2); // -> Style: KeywordSet2
lexer->setColor(Qt::blue, QsciLexerCPP::CommentDocKeyword); // -> used in comments only like /*! \cube */
lexer->setColor(QColor("DarkBlue"), QsciLexerCPP::GlobalClass); // -> Style: GlobalClass
lexer->setColor(Qt::blue, QsciLexerCPP::Operator);
lexer->setColor(Qt::darkMagenta, QsciLexerCPP::DoubleQuotedString);
lexer->setColor(Qt::darkCyan, QsciLexerCPP::Comment);
lexer->setColor(Qt::darkCyan, QsciLexerCPP::CommentLine);
lexer->setColor(QColor("DarkRed"), QsciLexerCPP::Number);
qsci->setMarkerBackgroundColor(QColor(255, 0, 0, 100), markerNumber);
qsci->setCaretLineBackgroundColor(QColor("#ffe4e4"));
qsci->setMarginsBackgroundColor(QColor("#ccc"));
qsci->setMarginsForegroundColor(QColor("#111"));
qsci->setMatchedBraceBackgroundColor(QColor("#333"));
qsci->setMatchedBraceForegroundColor(QColor("#fff"));
}
void ScintillaEditor::forDarkBackground()
{
lexer->setPaper(QColor("#272822"));
lexer->setColor(QColor(Qt::white));
lexer->setColor(QColor("#f12971"), QsciLexerCPP::Keyword);
lexer->setColor(QColor("#56dbf0"),QsciLexerCPP::KeywordSet2);
lexer->setColor(QColor("#ccdf32"), QsciLexerCPP::CommentDocKeyword);
lexer->setColor(QColor("#56d8f0"), QsciLexerCPP::GlobalClass);
lexer->setColor(QColor("#d8d8d8"), QsciLexerCPP::Operator);
lexer->setColor(QColor("#e6db74"), QsciLexerCPP::DoubleQuotedString);
lexer->setColor(QColor("#e6db74"), QsciLexerCPP::CommentLine);
lexer->setColor(QColor("#af7dff"), QsciLexerCPP::Number);
qsci->setCaretLineBackgroundColor(QColor(104,225,104, 127));
qsci->setMarkerBackgroundColor(QColor(255, 0, 0, 100), markerNumber);
qsci->setMarginsBackgroundColor(QColor("20,20,20,150"));
qsci->setMarginsForegroundColor(QColor("#fff"));
qsci->setCaretWidth(2);
qsci->setCaretForegroundColor(QColor("#ffff00"));
}
void ScintillaEditor::Monokai()
{
lexer->setPaper("#272822");
lexer->setColor(QColor("#f8f8f2")); // -> Style: Default text
lexer->setColor(QColor("#66c3b3"), QsciLexerCPP::Keyword); // -> Style: Keyword
lexer->setColor(QColor("#79abff"), QsciLexerCPP::KeywordSet2); // -> Style: KeywordSet2
lexer->setColor(QColor("#ccdf32"), QsciLexerCPP::CommentDocKeyword); // -> used in comments only like /*! \cube */
lexer->setColor(QColor("#ffffff"), QsciLexerCPP::GlobalClass); // -> Style: GlobalClass
lexer->setColor(QColor("#d8d8d8"), QsciLexerCPP::Operator);
lexer->setColor(QColor("#e6db74"), QsciLexerCPP::DoubleQuotedString);
lexer->setColor(QColor("#75715e"), QsciLexerCPP::CommentLine);
lexer->setColor(QColor("#7fb347"), QsciLexerCPP::Number);
qsci->setMarkerBackgroundColor(QColor(255, 0, 0, 100), markerNumber);
qsci->setCaretLineBackgroundColor(QColor("#3e3d32"));
qsci->setMarginsBackgroundColor(QColor("#757575"));
qsci->setMarginsForegroundColor(QColor("#f8f8f2"));
qsci->setCaretWidth(2);
qsci->setCaretForegroundColor(QColor("#ffff00"));
}
void ScintillaEditor::Solarized_light()
{
lexer->setPaper("#fdf6e3");
lexer->setColor(QColor("#657b83")); // -> Style: Default text
lexer->setColor(QColor("#268ad1"), QsciLexerCPP::Keyword); // -> Style: Keyword
lexer->setColor(QColor("#6c71c4"), QsciLexerCPP::KeywordSet2); // -> Style: KeywordSet2
lexer->setColor(QColor("#b58900"), QsciLexerCPP::CommentDocKeyword); // -> used in comments only like /*! \cube */
lexer->setColor(QColor("#b58800"), QsciLexerCPP::GlobalClass); // -> Style: GlobalClass
lexer->setColor(QColor("#859900"), QsciLexerCPP::Operator);
lexer->setColor(QColor("#2aa198"), QsciLexerCPP::DoubleQuotedString);
lexer->setColor(QColor("#b58800"), QsciLexerCPP::CommentLine);
lexer->setColor(QColor("#cb4b16"), QsciLexerCPP::Number);
qsci->setMarkerBackgroundColor(QColor(255, 0, 0, 100), markerNumber);
qsci->setCaretLineBackgroundColor(QColor("#eeead5"));
qsci->setMarginsBackgroundColor(QColor("#eee8d5"));
qsci->setMarginsForegroundColor(QColor("#93a1a1"));
qsci->setMatchedBraceBackgroundColor(QColor("#0000ff"));
qsci->setMatchedBraceBackgroundColor(QColor("#333"));
qsci->setMatchedBraceForegroundColor(QColor("#fff"));
}
void ScintillaEditor::noColor()
{
lexer->setPaper(Qt::white);
lexer->setColor(Qt::black);
qsci->setMarginsBackgroundColor(QColor("#ccc"));
qsci->setMarginsForegroundColor(QColor("#111"));
}
void ScintillaEditor::setHighlightScheme(const QString &name)
{
if(name == "For Light Background") {
forLightBackground();
}
else if(name == "For Dark Background") {
forDarkBackground();
}
else if(name == "Monokai") {
Monokai();
}
else if(name == "Solarized") {
Solarized_light();
}
else if(name == "Off") {
noColor();
}
}
void ScintillaEditor::insert(const QString &text)
{
qsci->insert(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();
}
void ScintillaEditor::initFont(const QString& fontName, uint size)
{
QFont font(fontName, size);
font.setFixedPitch(true);
lexer->setFont(font);
}
void ScintillaEditor::initLexer()
{
qsci->setLexer(lexer);
}
void ScintillaEditor::initMargin()
{
QFontMetrics fontmetrics = QFontMetrics(qsci->font());
qsci->setMarginsFont(qsci->font());
qsci->setMarginWidth(1, fontmetrics.width(QString::number(qsci->lines())) + 6);
qsci->setMarginLineNumbers(1, true);
connect(qsci, SIGNAL(textChanged()), this, SLOT(onTextChanged()));
}
void ScintillaEditor::onTextChanged()
{
QFontMetrics fontmetrics = qsci->fontMetrics();
qsci->setMarginWidth(1, fontmetrics.width(QString::number(qsci->lines())) + 6);
}
bool ScintillaEditor::find(const QString &expr, bool findNext, bool findBackwards)
{
int startline = -1, startindex = -1;
// If findNext, start from the end of the current selection
if (qsci->hasSelectedText()) {
int lineFrom, indexFrom, lineTo, indexTo;
qsci->getSelection(&lineFrom, &indexFrom, &lineTo, &indexTo);
startline = !(findBackwards xor findNext) ? std::min(lineFrom, lineTo) : std::max(lineFrom, lineTo);
startindex = !(findBackwards xor findNext) ? std::min(indexFrom, indexTo) : std::max(indexFrom, indexTo);
}
return qsci->findFirst(expr, false, false, false, true,
!findBackwards, startline, startindex);
}
void ScintillaEditor::replaceSelectedText(const QString &newText)
{
if (qsci->selectedText() != newText) qsci->replaceSelectedText(newText);
}
void ScintillaEditor::get_range(int *lineFrom, int *lineTo)
{
int indexFrom, indexTo;
if (qsci->hasSelectedText()) {
qsci->getSelection(lineFrom, &indexFrom, lineTo, &indexTo);
} else {
qsci->getCursorPosition(lineFrom, &indexFrom);
*lineTo = *lineFrom;
}
}
void ScintillaEditor::indentSelection()
{
int lineFrom, lineTo;
get_range(&lineFrom, &lineTo);
for (int line = lineFrom;line <= lineTo;line++) {
qsci->indent(line);
}
}
void ScintillaEditor::unindentSelection()
{
int lineFrom, lineTo;
get_range(&lineFrom, &lineTo);
for (int line = lineFrom;line <= lineTo;line++) {
qsci->unindent(line);
}
}
void ScintillaEditor::commentSelection()
{
int lineFrom, lineTo;
get_range(&lineFrom, &lineTo);
for (int line = lineFrom;line <= lineTo;line++) {
qsci->insertAt("//", line, 0);
}
}
void ScintillaEditor::uncommentSelection()
{
int lineFrom, lineTo;
get_range(&lineFrom, &lineTo);
for (int line = lineFrom;line <= lineTo;line++) {
QString lineText = qsci->text(line);
if (lineText.startsWith("//")) {
qsci->setSelection(line, 0, line, 2);
qsci->removeSelectedText();
}
}
}
QString ScintillaEditor::selectedText()
{
return qsci->selectedText();
}

62
src/scintillaeditor.h Normal file
View File

@ -0,0 +1,62 @@
#pragma once
#include <QObject>
#include <QWidget>
#include <QVBoxLayout>
#include <Qsci/qsciscintilla.h>
#include <QVBoxLayout>
#include "editor.h"
#include "scadlexer.h"
class ScintillaEditor : public EditorInterface
{
Q_OBJECT;
public:
ScintillaEditor(QWidget *parent);
virtual ~ScintillaEditor() {}
QsciScintilla *qsci;
QString toPlainText();
void initMargin();
void initLexer();
void forLightBackground();
void forDarkBackground();
void Monokai();
void Solarized_light();
void noColor();
QString selectedText();
bool find(const QString &, bool findNext = false, bool findBackwards = false);
void replaceSelectedText(const QString&);
private:
void get_range(int *lineFrom, int *lineTo);
public slots:
void zoomIn();
void zoomOut();
void setPlainText(const QString&);
void setContentModified(bool);
bool isContentModified();
void highlightError(int);
void unhighlightLastError();
void setHighlightScheme(const QString&);
void indentSelection();
void unindentSelection();
void commentSelection();
void uncommentSelection();
void insert(const QString&);
void undo();
void redo();
void cut();
void copy();
void paste();
void initFont(const QString&, uint);
private slots:
void onTextChanged();
private:
QVBoxLayout *scintillaLayout;
static const int indicatorNumber = 1;
static const int markerNumber = 2;
ScadLexer *lexer;
};