Add Python mode, improve output handling, add history buffer in Interpreter, tweak display settings, add save function to PrefStorage, change derivative function (d -> D) to allow use of variable "d" in scripts
This commit is contained in:
parent
000ab2153f
commit
05b6677096
BIN
lib/jython-standalone-2.7-b3.jar
Normal file
BIN
lib/jython-standalone-2.7-b3.jar
Normal file
Binary file not shown.
@ -67,7 +67,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<echo message="running.on.mac = ${running.on.mac}" level="verbose"/>
|
||||
<echo message="running.on.unix = ${running.on.unix}" level="verbose"/>
|
||||
<echo message="running.on.windows = ${running.on.windows}" level="verbose"/>
|
||||
</target>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- Check availability of JavaFX SDK deployment support (ant-javafx.jar) -->
|
||||
@ -89,27 +89,19 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<condition property="javafx.sdk.defined">
|
||||
<and>
|
||||
<isset property="javafx.sdk"/>
|
||||
<not>
|
||||
<contains string="${javafx.sdk}" substring="$${platform" casesensitive="false"/>
|
||||
</not>
|
||||
<not><contains string="${javafx.sdk}" substring="$${platform" casesensitive="false"/></not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javafx.sdk.missing+default">
|
||||
<and>
|
||||
<equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/>
|
||||
<not>
|
||||
<isset property="javafx.sdk.defined"/>
|
||||
</not>
|
||||
<not><isset property="javafx.sdk.defined"/></not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="javafx.sdk.missing-default">
|
||||
<and>
|
||||
<not>
|
||||
<equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/>
|
||||
</not>
|
||||
<not>
|
||||
<isset property="javafx.sdk.defined"/>
|
||||
</not>
|
||||
<not><equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/></not>
|
||||
<not><isset property="javafx.sdk.defined"/></not>
|
||||
</and>
|
||||
</condition>
|
||||
<echo message="javafx.sdk.defined = ${javafx.sdk.defined}" level="verbose"/>
|
||||
@ -120,9 +112,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-fxsdk-lib" depends="-check-property-javafx.sdk" if="javafx.sdk.defined">
|
||||
<condition property="do.set.ant-javafx.in.fxsdk.lib">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${javafx.sdk}${file.separator}lib${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -133,9 +123,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-fxsdk-tools" depends="-check-property-javafx.sdk" if="javafx.sdk.defined">
|
||||
<condition property="do.set.ant-javafx.in.fxsdk.tools">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${javafx.sdk}${file.separator}tools${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -146,9 +134,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-platform-home-lib" if="platform.home">
|
||||
<condition property="do.set.ant-javafx.in.platform.home.lib">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${platform.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -159,9 +145,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-platform-home-tools" if="platform.home">
|
||||
<condition property="do.set.ant-javafx.in.platform.home.tools">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${platform.home}${file.separator}tools${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -172,9 +156,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-probjdk-lib" unless="ant-javafx.jar.location">
|
||||
<condition property="do.set.ant-javafx.in.probjdk.lib">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${java.home}${file.separator}..${file.separator}lib${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -185,9 +167,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-probjdk-tools" unless="ant-javafx.jar.location">
|
||||
<condition property="do.set.ant-javafx.in.probjdk.tools">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${java.home}${file.separator}..${file.separator}tools${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -198,9 +178,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<target name="-check-ant-javafx-in-macjdk-lib" unless="ant-javafx.jar.location">
|
||||
<condition property="do.set.ant-javafx.in.macjdk.lib">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${java.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -212,9 +190,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<property environment="env"/>
|
||||
<condition property="do.set.ant-javafx.in.envjdk.lib">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${env.JAVA_HOME}${file.separator}lib${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -226,9 +202,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<property environment="env"/>
|
||||
<condition property="do.set.ant-javafx.in.envjdk.tools">
|
||||
<and>
|
||||
<not>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx.jar.location"/></not>
|
||||
<available file="${env.JAVA_HOME}${file.separator}tools${file.separator}ant-javafx.jar"/>
|
||||
</and>
|
||||
</condition>
|
||||
@ -240,9 +214,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<condition property="do.check.ant-javafx.version">
|
||||
<and>
|
||||
<isset property="ant-javafx.jar.location"/>
|
||||
<not>
|
||||
<isset property="ant-javafx-version-already-checked-in-jfximpl"/>
|
||||
</not>
|
||||
<not><isset property="ant-javafx-version-already-checked-in-jfximpl"/></not>
|
||||
</and>
|
||||
</condition>
|
||||
</target>
|
||||
@ -258,8 +230,8 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<echo message="ant-javafx.jar.location = ${ant-javafx.jar.location}" level="verbose"/>
|
||||
<echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/>
|
||||
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
|
||||
uri="javafx:com.sun.javafx.tools.ant"
|
||||
classpath="${javafx.ant.classpath}"/>
|
||||
uri="javafx:com.sun.javafx.tools.ant"
|
||||
classpath="${javafx.ant.classpath}"/>
|
||||
<condition property="have-fx-ant-init">
|
||||
<typefound name="javafx:com.sun.javafx.tools.ant:init-ant"/>
|
||||
</condition>
|
||||
@ -397,23 +369,13 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<echo message="exec-error:${exec-error}" level="verbose"/>
|
||||
<echo message="exec-result:${exec-result}" level="verbose"/>
|
||||
<condition property="missing.Inno">
|
||||
<not>
|
||||
<and>
|
||||
<contains string="${exec-output}" substring="Inno Setup"/>
|
||||
<not>
|
||||
<contains string="${exec-output}" substring="Inno Setup 1"/>
|
||||
</not>
|
||||
<not>
|
||||
<contains string="${exec-output}" substring="Inno Setup 2"/>
|
||||
</not>
|
||||
<not>
|
||||
<contains string="${exec-output}" substring="Inno Setup 3"/>
|
||||
</not>
|
||||
<not>
|
||||
<contains string="${exec-output}" substring="Inno Setup 4"/>
|
||||
</not>
|
||||
</and>
|
||||
</not>
|
||||
<not><and>
|
||||
<contains string="${exec-output}" substring="Inno Setup"/>
|
||||
<not><contains string="${exec-output}" substring="Inno Setup 1"/></not>
|
||||
<not><contains string="${exec-output}" substring="Inno Setup 2"/></not>
|
||||
<not><contains string="${exec-output}" substring="Inno Setup 3"/></not>
|
||||
<not><contains string="${exec-output}" substring="Inno Setup 4"/></not>
|
||||
</and></not>
|
||||
</condition>
|
||||
</target>
|
||||
<target name="-check-WiX-presence" depends="-check-native-bundling-type" if="need.WiX.presence">
|
||||
@ -427,17 +389,11 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<echo message="exec-error:${exec-error}" level="verbose"/>
|
||||
<echo message="exec-result:${exec-result}" level="verbose"/>
|
||||
<condition property="missing.WiX">
|
||||
<not>
|
||||
<and>
|
||||
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version"/>
|
||||
<not>
|
||||
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version 1"/>
|
||||
</not>
|
||||
<not>
|
||||
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version 2"/>
|
||||
</not>
|
||||
</and>
|
||||
</not>
|
||||
<not><and>
|
||||
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version"/>
|
||||
<not><contains string="${exec-output}" substring="Windows Installer Xml Compiler version 1"/></not>
|
||||
<not><contains string="${exec-output}" substring="Windows Installer Xml Compiler version 2"/></not>
|
||||
</and></not>
|
||||
</condition>
|
||||
</target>
|
||||
<target name="-check-dpkg-presence" depends="-check-native-bundling-type" if="need.dpkg.presence">
|
||||
@ -447,16 +403,12 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<arg line="-v dpkg"/>
|
||||
</exec>
|
||||
<condition property="missing.dpkg">
|
||||
<not>
|
||||
<and>
|
||||
<isset property="exec.which.dpkg.result"/>
|
||||
<equals arg1="${exec.which.dpkg.result}" arg2="0"/>
|
||||
<isset property="exec.which.dpkg.output"/>
|
||||
<not>
|
||||
<equals arg1="${exec.which.dpkg.output}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</not>
|
||||
<not><and>
|
||||
<isset property="exec.which.dpkg.result"/>
|
||||
<equals arg1="${exec.which.dpkg.result}" arg2="0"/>
|
||||
<isset property="exec.which.dpkg.output"/>
|
||||
<not><equals arg1="${exec.which.dpkg.output}" arg2=""/></not>
|
||||
</and></not>
|
||||
</condition>
|
||||
</target>
|
||||
<target name="-check-rpmbuild-presence" depends="-check-native-bundling-type" if="need.rpmbuild.presence">
|
||||
@ -466,16 +418,12 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<arg line="-v rpmbuild"/>
|
||||
</exec>
|
||||
<condition property="missing.rpmbuild">
|
||||
<not>
|
||||
<and>
|
||||
<isset property="exec.which.rpmbuild.result"/>
|
||||
<equals arg1="${exec.which.rpmbuild.result}" arg2="0"/>
|
||||
<isset property="exec.which.rpmbuild.output"/>
|
||||
<not>
|
||||
<equals arg1="${exec.which.rpmbuild.output}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</not>
|
||||
<not><and>
|
||||
<isset property="exec.which.rpmbuild.result"/>
|
||||
<equals arg1="${exec.which.rpmbuild.result}" arg2="0"/>
|
||||
<isset property="exec.which.rpmbuild.output"/>
|
||||
<not><equals arg1="${exec.which.rpmbuild.output}" arg2=""/></not>
|
||||
</and></not>
|
||||
</condition>
|
||||
</target>
|
||||
<target name="-check-native-packager-external-tools" depends="-check-Inno-presence, -check-WiX-presence, -check-dpkg-presence, -check-rpmbuild-presence">
|
||||
@ -514,11 +462,11 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
|
||||
<map from="${basedir}${file.separator}${dist.jar}" to=""/>
|
||||
<scriptmapper language="javascript">
|
||||
self.addMappedName(
|
||||
(source.indexOf("jfxrt.jar") >= 0) ||
|
||||
(source.indexOf("deploy.jar") >= 0) ||
|
||||
(source.indexOf("javaws.jar") >= 0) ||
|
||||
(source.indexOf("plugin.jar") >= 0)
|
||||
? "" : source
|
||||
(source.indexOf("jfxrt.jar") >= 0) ||
|
||||
(source.indexOf("deploy.jar") >= 0) ||
|
||||
(source.indexOf("javaws.jar") >= 0) ||
|
||||
(source.indexOf("plugin.jar") >= 0)
|
||||
? "" : source
|
||||
);
|
||||
</scriptmapper>
|
||||
</pathconvert>
|
||||
|
1005
nbproject/build-native.xml~
Normal file
1005
nbproject/build-native.xml~
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.splash=C:\\Users\\Skylar\\SparkleShare\\aplabs\\appmedia\\SyMAT\\splash0.5.png
|
||||
application.splash=C:\\Users\\Skylar\\SparkleShare\\aplabs\\appmedia\\SyMAT\\splash0.6.png
|
||||
application.title=SyMAT
|
||||
application.vendor=Apocalypse Laboratories
|
||||
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
|
||||
@ -36,6 +36,7 @@ file.reference.iText-4.2.0-com.itextpdf.jar=lib/iText-4.2.0-com.itextpdf.jar
|
||||
file.reference.JavaPrettify-1.2.1.jar=lib/JavaPrettify-1.2.1.jar
|
||||
file.reference.js-engine.jar=lib/js-engine.jar
|
||||
file.reference.js.jar=lib/js.jar
|
||||
file.reference.jython-standalone-2.7-b3.jar=lib/jython-standalone-2.7-b3.jar
|
||||
file.reference.log4j-1.2.11.jar=lib/log4j-1.2.11.jar
|
||||
file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar
|
||||
includes=**
|
||||
@ -49,7 +50,8 @@ javac.classpath=\
|
||||
${file.reference.iText-4.2.0-com.itextpdf.jar}:\
|
||||
${file.reference.htmlcleaner-2.10.jar}:\
|
||||
${file.reference.js-engine.jar}:\
|
||||
${file.reference.js.jar}
|
||||
${file.reference.js.jar}:\
|
||||
${file.reference.jython-standalone-2.7-b3.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
@ -25,14 +25,16 @@
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.ButtonGroup" name="langBtnGroup">
|
||||
</Component>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu1">
|
||||
<Menu class="javax.swing.JMenu" name="fileMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
|
||||
<MenuItem class="javax.swing.JMenuItem" name="openMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+O"/>
|
||||
@ -40,10 +42,10 @@
|
||||
<Property name="text" type="java.lang.String" value="Open..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+S"/>
|
||||
@ -51,10 +53,10 @@
|
||||
<Property name="text" type="java.lang.String" value="Save..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Shift+Ctrl+S"/>
|
||||
@ -62,25 +64,28 @@
|
||||
<Property name="text" type="java.lang.String" value="Save as..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem8">
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exportMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+E"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Export..."/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem8ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu5">
|
||||
<Menu class="javax.swing.JMenu" name="editMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem6">
|
||||
<MenuItem class="javax.swing.JMenuItem" name="clrOutputMenu">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+W"/>
|
||||
@ -88,17 +93,41 @@
|
||||
<Property name="text" type="java.lang.String" value="Clear output"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem6ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clrOutputMenuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<Menu class="javax.swing.JMenu" name="codeLangMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Language"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JRadioButtonMenuItem" name="javascriptOption">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="langBtnGroup"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Javascript"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JRadioButtonMenuItem" name="pythonOption">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="langBtnGroup"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Python"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu2">
|
||||
<Menu class="javax.swing.JMenu" name="runMenu">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Run"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenu2ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="runMenuActionPerformed"/>
|
||||
</Events>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
/*
|
||||
* Apocalypse Laboratories
|
||||
* Open Source License
|
||||
*
|
||||
*
|
||||
* Source code can be used for any purpose, as long as:
|
||||
* - Compiled binaries are rebranded and trademarks are not
|
||||
* visible by the end user at any time, except to give
|
||||
@ -14,7 +14,7 @@
|
||||
* - and you provide your modified source code for download,
|
||||
* under the terms of the GNU LGPL v3 or a comparable
|
||||
* license.
|
||||
*
|
||||
*
|
||||
* Compiled binaries cannot be redistributed or mirrored,
|
||||
* unless:
|
||||
* - You have written permission from Apocalypse Laboratories;
|
||||
@ -22,7 +22,7 @@
|
||||
* not even behind a paywall or other blocking mechanism;
|
||||
* - or you have received a multi-computer license, in which
|
||||
* case you should take measures to prevent unauthorized
|
||||
* downloads, such as preventing download access from the
|
||||
* downloads, such as preventing download access from the
|
||||
* Internet.
|
||||
*/
|
||||
package net.apocalypselabs.symat;
|
||||
@ -68,12 +68,19 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
*/
|
||||
public CodeEditor() {
|
||||
initComponents();
|
||||
FileFilter filter = new FileNameExtensionFilter("SyMAT script (.symt)", "symt");
|
||||
|
||||
if (!PrefStorage.isset("advancedcontrols")) {
|
||||
runMenu.remove(codeLangMenu);
|
||||
}
|
||||
|
||||
FileFilter filter = new FileNameExtensionFilter("SyMAT JavaScript (.syjs)", "syjs");
|
||||
fc.setFileFilter(filter);
|
||||
fc.addChoosableFileFilter(filter);
|
||||
filter = new FileNameExtensionFilter("SyMAT Python (.sypy)", "sypy");
|
||||
fc.addChoosableFileFilter(filter);
|
||||
filter = new FileNameExtensionFilter("JavaScript file (.js)", "js");
|
||||
fc.addChoosableFileFilter(filter);
|
||||
filter = new FileNameExtensionFilter("MeetLeeb script (.mls)", "mls");
|
||||
filter = new FileNameExtensionFilter("Python script (.py)", "py");
|
||||
fc.addChoosableFileFilter(filter);
|
||||
int font_size = 12;
|
||||
try {
|
||||
@ -132,6 +139,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
jMenuBar2 = new javax.swing.JMenuBar();
|
||||
jMenu3 = new javax.swing.JMenu();
|
||||
jMenu4 = new javax.swing.JMenu();
|
||||
langBtnGroup = new javax.swing.ButtonGroup();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
scrollPane = new JScrollPane(codeBox);
|
||||
@ -140,14 +148,17 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
outputBox = new javax.swing.JTextArea();
|
||||
jMenuBar1 = new javax.swing.JMenuBar();
|
||||
jMenu1 = new javax.swing.JMenu();
|
||||
jMenuItem1 = new javax.swing.JMenuItem();
|
||||
jMenuItem2 = new javax.swing.JMenuItem();
|
||||
jMenuItem3 = new javax.swing.JMenuItem();
|
||||
jMenuItem8 = new javax.swing.JMenuItem();
|
||||
jMenu5 = new javax.swing.JMenu();
|
||||
jMenuItem6 = new javax.swing.JMenuItem();
|
||||
jMenu2 = new javax.swing.JMenu();
|
||||
fileMenu = new javax.swing.JMenu();
|
||||
openMenu = new javax.swing.JMenuItem();
|
||||
saveMenu = new javax.swing.JMenuItem();
|
||||
saveAsMenu = new javax.swing.JMenuItem();
|
||||
exportMenu = new javax.swing.JMenuItem();
|
||||
editMenu = new javax.swing.JMenu();
|
||||
clrOutputMenu = new javax.swing.JMenuItem();
|
||||
codeLangMenu = new javax.swing.JMenu();
|
||||
javascriptOption = new javax.swing.JRadioButtonMenuItem();
|
||||
pythonOption = new javax.swing.JRadioButtonMenuItem();
|
||||
runMenu = new javax.swing.JMenu();
|
||||
jMenuItem5 = new javax.swing.JMenuItem();
|
||||
|
||||
jMenuItem4.setText("jMenuItem4");
|
||||
@ -213,62 +224,76 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jMenu1.setText("File");
|
||||
fileMenu.setText("File");
|
||||
|
||||
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
|
||||
jMenuItem1.setText("Open...");
|
||||
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
||||
openMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
|
||||
openMenu.setText("Open...");
|
||||
openMenu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem1ActionPerformed(evt);
|
||||
openMenuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu1.add(jMenuItem1);
|
||||
fileMenu.add(openMenu);
|
||||
|
||||
jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
|
||||
jMenuItem2.setText("Save...");
|
||||
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
|
||||
saveMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
|
||||
saveMenu.setText("Save...");
|
||||
saveMenu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem2ActionPerformed(evt);
|
||||
saveMenuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu1.add(jMenuItem2);
|
||||
fileMenu.add(saveMenu);
|
||||
|
||||
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
|
||||
jMenuItem3.setText("Save as...");
|
||||
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
|
||||
saveAsMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
|
||||
saveAsMenu.setText("Save as...");
|
||||
saveAsMenu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem3ActionPerformed(evt);
|
||||
saveAsMenuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu1.add(jMenuItem3);
|
||||
fileMenu.add(saveAsMenu);
|
||||
|
||||
jMenuItem8.setText("Export...");
|
||||
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
|
||||
exportMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
|
||||
exportMenu.setText("Export...");
|
||||
exportMenu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem8ActionPerformed(evt);
|
||||
exportMenuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu1.add(jMenuItem8);
|
||||
fileMenu.add(exportMenu);
|
||||
|
||||
jMenuBar1.add(jMenu1);
|
||||
jMenuBar1.add(fileMenu);
|
||||
|
||||
jMenu5.setText("Edit");
|
||||
editMenu.setText("Edit");
|
||||
|
||||
jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
|
||||
jMenuItem6.setText("Clear output");
|
||||
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
|
||||
clrOutputMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
|
||||
clrOutputMenu.setText("Clear output");
|
||||
clrOutputMenu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem6ActionPerformed(evt);
|
||||
clrOutputMenuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu5.add(jMenuItem6);
|
||||
editMenu.add(clrOutputMenu);
|
||||
|
||||
jMenuBar1.add(jMenu5);
|
||||
codeLangMenu.setText("Language");
|
||||
|
||||
jMenu2.setText("Run");
|
||||
jMenu2.addActionListener(new java.awt.event.ActionListener() {
|
||||
langBtnGroup.add(javascriptOption);
|
||||
javascriptOption.setSelected(true);
|
||||
javascriptOption.setText("Javascript");
|
||||
codeLangMenu.add(javascriptOption);
|
||||
|
||||
langBtnGroup.add(pythonOption);
|
||||
pythonOption.setText("Python");
|
||||
codeLangMenu.add(pythonOption);
|
||||
|
||||
editMenu.add(codeLangMenu);
|
||||
|
||||
jMenuBar1.add(editMenu);
|
||||
|
||||
runMenu.setText("Run");
|
||||
runMenu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenu2ActionPerformed(evt);
|
||||
runMenuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
@ -279,9 +304,9 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
jMenuItem5ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu2.add(jMenuItem5);
|
||||
runMenu.add(jMenuItem5);
|
||||
|
||||
jMenuBar1.add(jMenu2);
|
||||
jMenuBar1.add(runMenu);
|
||||
|
||||
setJMenuBar(jMenuBar1);
|
||||
|
||||
@ -299,7 +324,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
|
||||
private void openMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuActionPerformed
|
||||
int r = fc.showOpenDialog(this);
|
||||
if (r == JFileChooser.APPROVE_OPTION) {
|
||||
try {
|
||||
@ -314,7 +339,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
}
|
||||
}
|
||||
codeBox.setCaretPosition(0);
|
||||
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
||||
}//GEN-LAST:event_openMenuActionPerformed
|
||||
|
||||
public void openFileFromString(String file) {
|
||||
try {
|
||||
@ -323,13 +348,20 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
isSaved = true;
|
||||
lastSaved = codeBox.getText();
|
||||
setTitle("Editor - " + f.getName());
|
||||
if (file.matches(".*\\.(js|mls|symt|syjs)")) {
|
||||
javascriptOption.setSelected(true);
|
||||
pythonOption.setSelected(false);
|
||||
} else if (file.matches(".*\\.(sypy|py)")) {
|
||||
javascriptOption.setSelected(false);
|
||||
pythonOption.setSelected(true);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
JOptionPane.showInternalMessageDialog(this,
|
||||
"Error: Cannot load file: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
|
||||
private void saveMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuActionPerformed
|
||||
if (!isSaved) {
|
||||
int r = fc.showSaveDialog(this);
|
||||
if (r == JFileChooser.APPROVE_OPTION) {
|
||||
@ -346,41 +378,58 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_jMenuItem2ActionPerformed
|
||||
}//GEN-LAST:event_saveMenuActionPerformed
|
||||
|
||||
private String addSaveExt(String path) {
|
||||
if (!path.matches(".*\\.(js|mls|symt)")) {
|
||||
path += ".symt";
|
||||
if (!path.matches(".*\\.(js|mls|symt|syjs|sypy|py)")) {
|
||||
if (pythonOption.isSelected()) {
|
||||
path += ".sypy";
|
||||
} else {
|
||||
path += ".syjs";
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
|
||||
private void saveAsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuActionPerformed
|
||||
isSaved = false; // Reset saved status, force dialog
|
||||
jMenuItem2ActionPerformed(evt);
|
||||
}//GEN-LAST:event_jMenuItem3ActionPerformed
|
||||
saveMenuActionPerformed(evt);
|
||||
}//GEN-LAST:event_saveAsMenuActionPerformed
|
||||
|
||||
private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
|
||||
private void runMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runMenuActionPerformed
|
||||
|
||||
}//GEN-LAST:event_jMenu2ActionPerformed
|
||||
}//GEN-LAST:event_runMenuActionPerformed
|
||||
|
||||
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
|
||||
CodeRunner cr = new CodeRunner();
|
||||
if (javascriptOption.isSelected()) {
|
||||
execCode("javascript");
|
||||
} else if (pythonOption.isSelected()) {
|
||||
execCode("python");
|
||||
}
|
||||
}//GEN-LAST:event_jMenuItem5ActionPerformed
|
||||
|
||||
private void execCode(String lang) {
|
||||
CodeRunner cr = new CodeRunner(lang);
|
||||
System.out.println(lang);
|
||||
System.out.println(codeBox.getText());
|
||||
Object result = cr.evalString(codeBox.getText());
|
||||
try {
|
||||
outputBox.append(result.toString() + "\n");
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_jMenuItem5ActionPerformed
|
||||
|
||||
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
|
||||
}
|
||||
private void clrOutputMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clrOutputMenuActionPerformed
|
||||
outputBox.setText("");
|
||||
}//GEN-LAST:event_jMenuItem6ActionPerformed
|
||||
}//GEN-LAST:event_clrOutputMenuActionPerformed
|
||||
|
||||
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
|
||||
CodeExport ce = new CodeExport(codeBox.getText());
|
||||
private void exportMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuActionPerformed
|
||||
String lang = "js";
|
||||
if (pythonOption.isSelected()) {
|
||||
lang = "python";
|
||||
}
|
||||
CodeExport ce = new CodeExport(codeBox.getText(), lang);
|
||||
MainGUI.loadFrame(ce);
|
||||
}//GEN-LAST:event_jMenuItem8ActionPerformed
|
||||
}//GEN-LAST:event_exportMenuActionPerformed
|
||||
|
||||
private void saveFile(String content, String path)
|
||||
throws IOException {
|
||||
@ -405,7 +454,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
if (p == JOptionPane.YES_OPTION) {
|
||||
dispose();
|
||||
} else {
|
||||
jMenuItem3ActionPerformed(null);
|
||||
saveMenuActionPerformed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -417,26 +466,30 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem clrOutputMenu;
|
||||
private javax.swing.JMenu codeLangMenu;
|
||||
private javax.swing.JMenu editMenu;
|
||||
private javax.swing.JMenuItem exportMenu;
|
||||
private javax.swing.JMenu fileMenu;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JMenu jMenu1;
|
||||
private javax.swing.JMenu jMenu2;
|
||||
private javax.swing.JMenu jMenu3;
|
||||
private javax.swing.JMenu jMenu4;
|
||||
private javax.swing.JMenu jMenu5;
|
||||
private javax.swing.JMenuBar jMenuBar1;
|
||||
private javax.swing.JMenuBar jMenuBar2;
|
||||
private javax.swing.JMenuItem jMenuItem1;
|
||||
private javax.swing.JMenuItem jMenuItem2;
|
||||
private javax.swing.JMenuItem jMenuItem3;
|
||||
private javax.swing.JMenuItem jMenuItem4;
|
||||
private javax.swing.JMenuItem jMenuItem5;
|
||||
private javax.swing.JMenuItem jMenuItem6;
|
||||
private javax.swing.JMenuItem jMenuItem8;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JRadioButtonMenuItem javascriptOption;
|
||||
private javax.swing.ButtonGroup langBtnGroup;
|
||||
private javax.swing.JMenuItem openMenu;
|
||||
private javax.swing.JTextArea outputBox;
|
||||
private javax.swing.JRadioButtonMenuItem pythonOption;
|
||||
private javax.swing.JMenu runMenu;
|
||||
private javax.swing.JMenuItem saveAsMenu;
|
||||
private javax.swing.JMenuItem saveMenu;
|
||||
private javax.swing.JScrollPane scrollPane;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ import syntaxhighlight.ParseResult;
|
||||
*/
|
||||
public class CodeExport extends javax.swing.JInternalFrame {
|
||||
|
||||
private String codeLang = "js";
|
||||
private String html;
|
||||
private final String origCode;
|
||||
private final JFileChooser fc = new JFileChooser();
|
||||
@ -65,7 +66,7 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
||||
/**
|
||||
* Creates new form CodeExport
|
||||
*
|
||||
* @param code
|
||||
* @param code The code.
|
||||
*/
|
||||
public CodeExport(String code) {
|
||||
origCode = code;
|
||||
@ -74,6 +75,17 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
||||
previewPane.setText(html);
|
||||
previewPane.setCaretPosition(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create CodeExport window with a set language for syntax highlighting.
|
||||
*
|
||||
* @param code The code.
|
||||
* @param lang Options are "js" or "python".
|
||||
*/
|
||||
public CodeExport(String code, String lang) {
|
||||
this(code);
|
||||
codeLang = lang;
|
||||
}
|
||||
|
||||
private String genHtml(String code) {
|
||||
String css = "";
|
||||
@ -107,7 +119,7 @@ public class CodeExport extends javax.swing.JInternalFrame {
|
||||
html += "<p class=\"header\">" + headerBox.getText() + "</p>";
|
||||
}
|
||||
PrettifyParser parser = new PrettifyParser();
|
||||
List<ParseResult> parseResults = parser.parse("js", code);
|
||||
List<ParseResult> parseResults = parser.parse(codeLang, code);
|
||||
html += PrettifyToHtml.toHtml(code, parseResults);
|
||||
html += "</body></html>";
|
||||
html = html.replace("\t", "<span class=\"tab\"> </span>");
|
||||
|
@ -29,6 +29,8 @@ package net.apocalypselabs.symat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import javax.script.*;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
@ -38,23 +40,60 @@ import javax.swing.JOptionPane;
|
||||
*/
|
||||
public class CodeRunner {
|
||||
|
||||
ScriptEngine jse = new ScriptEngineManager().getEngineByName("rhino");
|
||||
boolean isJava8 = false;
|
||||
private ScriptEngine se;
|
||||
|
||||
// If we need to wrap code around input to make everything nice.
|
||||
private boolean wrapRequired = false;
|
||||
// What codez are we speaking?
|
||||
private String scriptLang = "";
|
||||
|
||||
private boolean isShell = false;
|
||||
|
||||
public CodeRunner() {
|
||||
try {
|
||||
// Add custom functions.
|
||||
jse.eval("importClass(net.apocalypselabs.symat.Functions);"
|
||||
+ "SyMAT_Functions = new net.apocalypselabs.symat.Functions();");
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(null, "Error: "
|
||||
+ "Could not properly initialize scripting engine."
|
||||
+ "\n\nSome functions may not work.\n\n"
|
||||
+ "(" + ex.getMessage() + ")");
|
||||
ex.printStackTrace();
|
||||
this("javascript");
|
||||
}
|
||||
|
||||
public CodeRunner(String lang) {
|
||||
scriptLang = lang;
|
||||
switch (lang) {
|
||||
case "javascript":
|
||||
se = new ScriptEngineManager().getEngineByName("rhino");
|
||||
wrapRequired = true;
|
||||
try {
|
||||
// Add custom functions.
|
||||
se.eval("importClass(net.apocalypselabs.symat.Functions);"
|
||||
+ "SyMAT_Functions = new net.apocalypselabs.symat.Functions();"
|
||||
+ jsFunctions());
|
||||
} catch (Exception ex) {
|
||||
initError(ex);
|
||||
}
|
||||
break;
|
||||
case "python":
|
||||
se = new ScriptEngineManager().getEngineByName("python");
|
||||
try {
|
||||
se.eval("from net.apocalypselabs.symat import Functions\n_=Functions()\n");
|
||||
} catch (Exception ex) {
|
||||
initError(ex);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Script language " + lang + " not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
public CodeRunner(String lang, boolean shell) {
|
||||
this(lang);
|
||||
isShell = shell;
|
||||
}
|
||||
|
||||
private void initError(Exception ex) {
|
||||
JOptionPane.showMessageDialog(null, "Error: "
|
||||
+ "Could not properly initialize " + scriptLang + " scripting engine."
|
||||
+ "\n\nSome functions may not work.\n\n"
|
||||
+ "(" + ex.getMessage() + ")");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a String of JavaScript.
|
||||
*
|
||||
@ -63,7 +102,15 @@ public class CodeRunner {
|
||||
*/
|
||||
public Object evalString(String eval) {
|
||||
try {
|
||||
return jse.eval(wrapMath(eval));
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
se.getContext().setWriter(pw);
|
||||
Object res = se.eval(wrapMath(eval));
|
||||
if (res == null) {
|
||||
res = "";
|
||||
}
|
||||
String result = res + sw.getBuffer().toString().trim();
|
||||
return result;
|
||||
} catch (ScriptException ex) {
|
||||
return formatEx(ex);
|
||||
}
|
||||
@ -85,17 +132,20 @@ public class CodeRunner {
|
||||
* @return wrapped input
|
||||
*/
|
||||
private String wrapMath(String eval) {
|
||||
String with = "with(SyMAT_Functions){with(Math){" + eval + "}}";
|
||||
//System.out.println(with);
|
||||
return with;
|
||||
if (wrapRequired) {
|
||||
String with = "with(SyMAT_Functions){with(Math){" + eval + "}}";
|
||||
//System.out.println(with);
|
||||
return with;
|
||||
}
|
||||
return eval;
|
||||
}
|
||||
|
||||
public void setVar(String var, Object val) {
|
||||
jse.put(var, val);
|
||||
se.put(var, val);
|
||||
}
|
||||
|
||||
public Object getVar(String var) {
|
||||
return jse.get(var);
|
||||
return se.get(var);
|
||||
}
|
||||
|
||||
private String jsFunctions() {
|
||||
|
@ -39,13 +39,18 @@
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="cancelBtn" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="saveBtn" min="-2" pref="81" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -53,20 +58,19 @@
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jPanel1" max="32767" attributes="0"/>
|
||||
<Component id="jPanel2" max="32767" attributes="0"/>
|
||||
<Component id="jPanel3" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="15" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -102,7 +106,7 @@
|
||||
<Component id="themeLight" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="themeDark" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="51" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -142,10 +146,11 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="fontSizeBox" min="-2" pref="68" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="125" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jLabel1" max="32767" attributes="0"/>
|
||||
<Component id="fontSizeBox" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -153,11 +158,10 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="fontSizeBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="fontSizeBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -206,5 +210,42 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="Editor"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="advOptionsBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="advOptionsBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JCheckBox" name="advOptionsBox">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Advanced Options"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -27,6 +27,8 @@
|
||||
*/
|
||||
package net.apocalypselabs.symat;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Skylar
|
||||
@ -58,6 +60,8 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
saveBtn = new javax.swing.JButton();
|
||||
cancelBtn = new javax.swing.JButton();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
advOptionsBox = new javax.swing.JCheckBox();
|
||||
|
||||
setClosable(true);
|
||||
setIconifiable(true);
|
||||
@ -97,7 +101,7 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
.addComponent(themeLight)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(themeDark)
|
||||
.addContainerGap(51, Short.MAX_VALUE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Font"));
|
||||
@ -114,19 +118,19 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(fontSizeBox, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(125, Short.MAX_VALUE))
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(fontSizeBox, 0, 0, Short.MAX_VALUE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(fontSizeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(fontSizeBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
saveBtn.setText("Save");
|
||||
@ -143,6 +147,27 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
}
|
||||
});
|
||||
|
||||
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Editor"));
|
||||
|
||||
advOptionsBox.setText("Advanced Options");
|
||||
|
||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||
jPanel3.setLayout(jPanel3Layout);
|
||||
jPanel3Layout.setHorizontalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(advOptionsBox)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(advOptionsBox)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@ -152,27 +177,31 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(cancelBtn)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(saveBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(saveBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(42, 42, 42)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(saveBtn)
|
||||
.addComponent(cancelBtn)))
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(21, 21, 21)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(saveBtn)
|
||||
.addComponent(cancelBtn))
|
||||
.addContainerGap(15, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
@ -188,10 +217,6 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
}
|
||||
if (PrefStorage.isset("theme")) {
|
||||
switch (PrefStorage.getSetting("theme")) {
|
||||
case "light":
|
||||
themeLight.setSelected(true);
|
||||
themeDark.setSelected(false);
|
||||
break;
|
||||
case "dark":
|
||||
themeLight.setSelected(false);
|
||||
themeDark.setSelected(true);
|
||||
@ -201,6 +226,9 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
themeDark.setSelected(false);
|
||||
}
|
||||
}
|
||||
if (PrefStorage.isset("advancedcontrols")) {
|
||||
advOptionsBox.setSelected(true);
|
||||
}
|
||||
}//GEN-LAST:event_formComponentShown
|
||||
|
||||
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed
|
||||
@ -210,16 +238,30 @@ public class Display extends javax.swing.JInternalFrame {
|
||||
} else {
|
||||
PrefStorage.saveSetting("theme", "light");
|
||||
}
|
||||
if (advOptionsBox.isSelected()) {
|
||||
PrefStorage.saveSetting("advancedcontrols", "true");
|
||||
} else {
|
||||
PrefStorage.unset("advancedcontrols");
|
||||
}
|
||||
if (!PrefStorage.save()) {
|
||||
// Something dun goofed...
|
||||
JOptionPane.showInternalMessageDialog(this,
|
||||
"Error: Problem occured while saving settings. "
|
||||
+ "This error is outside the control of "
|
||||
+ "the application.");
|
||||
}
|
||||
MainGUI.updateDisplay();
|
||||
dispose();
|
||||
}//GEN-LAST:event_saveBtnActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JCheckBox advOptionsBox;
|
||||
private javax.swing.JButton cancelBtn;
|
||||
private javax.swing.JComboBox fontSizeBox;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JButton saveBtn;
|
||||
private javax.swing.JRadioButton themeDark;
|
||||
private javax.swing.ButtonGroup themeGroup;
|
||||
|
@ -54,14 +54,10 @@ public class Functions {
|
||||
return JOptionPane.showInternalInputDialog(MainGUI.mainPane, question);
|
||||
}
|
||||
|
||||
public void write(String content) {
|
||||
// TODO: enable output logging
|
||||
}
|
||||
|
||||
/*
|
||||
Math commands
|
||||
*/
|
||||
public String d(String function, String idv) {
|
||||
public String D(String function, String idv) {
|
||||
return util.evaluate("diff(" + function + "," + idv + ")").toString();
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@
|
||||
</Container>
|
||||
<Component class="javax.swing.JTextField" name="inputBox">
|
||||
<Events>
|
||||
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyPressed"/>
|
||||
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyTyped"/>
|
||||
</Events>
|
||||
</Component>
|
||||
|
@ -29,6 +29,7 @@ package net.apocalypselabs.symat;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.text.DefaultCaret;
|
||||
|
||||
/**
|
||||
@ -37,7 +38,9 @@ import javax.swing.text.DefaultCaret;
|
||||
*/
|
||||
public class Interpreter extends javax.swing.JInternalFrame {
|
||||
|
||||
private final CodeRunner cr = new CodeRunner();
|
||||
private final CodeRunner cr = new CodeRunner("javascript", true);
|
||||
private String[] history = new String[10]; // Command history buffer
|
||||
private int historyIndex = 0; // For going back in time and keeping things straight
|
||||
|
||||
/**
|
||||
* Creates new form Interpreter
|
||||
@ -102,6 +105,9 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
jScrollPane1.setViewportView(mainBox);
|
||||
|
||||
inputBox.addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyPressed(java.awt.event.KeyEvent evt) {
|
||||
inputBoxKeyPressed(evt);
|
||||
}
|
||||
public void keyTyped(java.awt.event.KeyEvent evt) {
|
||||
inputBoxKeyTyped(evt);
|
||||
}
|
||||
@ -152,9 +158,35 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
private void inputBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputBoxKeyTyped
|
||||
if (evt.getKeyChar() == '\n') {
|
||||
doRunCode();
|
||||
return;
|
||||
}
|
||||
}//GEN-LAST:event_inputBoxKeyTyped
|
||||
|
||||
private void inputBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputBoxKeyPressed
|
||||
switch (evt.getKeyCode()) {
|
||||
case KeyEvent.VK_UP:
|
||||
if (historyIndex < 9) {
|
||||
if (historyIndex < 0) {
|
||||
historyIndex++;
|
||||
}
|
||||
inputBox.setText(history[historyIndex]);
|
||||
historyIndex++;
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_DOWN:
|
||||
if (historyIndex >= 0) {
|
||||
historyIndex--;
|
||||
if (historyIndex < 0) {
|
||||
historyIndex = 0;
|
||||
inputBox.setText("");
|
||||
} else {
|
||||
inputBox.setText(history[historyIndex]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}//GEN-LAST:event_inputBoxKeyPressed
|
||||
|
||||
private void doRunCode() {
|
||||
String code = inputBox.getText();
|
||||
mainBox.append(" " + code + "\n");
|
||||
@ -164,7 +196,12 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
||||
|
||||
}
|
||||
mainBox.append(">>");
|
||||
for (int i = 9; i > 0; i--) {
|
||||
history[i] = history[i - 1];
|
||||
}
|
||||
history[0] = code;
|
||||
inputBox.setText("");
|
||||
historyIndex = -1;
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
@ -27,6 +27,9 @@
|
||||
*/
|
||||
package net.apocalypselabs.symat;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
@ -35,17 +38,18 @@ import java.util.prefs.Preferences;
|
||||
*/
|
||||
public class PrefStorage {
|
||||
|
||||
private static Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class);
|
||||
private static final Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class);
|
||||
|
||||
public static void saveSetting(String key, String value) {
|
||||
prefs.put(key, value);
|
||||
}
|
||||
|
||||
public static boolean isset(String key) {
|
||||
if (!getSetting(key, "NULL").equals("NULL")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !getSetting(key, "NULL").equals("NULL");
|
||||
}
|
||||
|
||||
public static void unset(String key) {
|
||||
prefs.remove(key);
|
||||
}
|
||||
|
||||
public static String getSetting(String key) {
|
||||
@ -55,6 +59,16 @@ public class PrefStorage {
|
||||
public static String getSetting(String key, String emptyResponse) {
|
||||
return prefs.get(key, emptyResponse);
|
||||
}
|
||||
|
||||
public static boolean save() {
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException ex) {
|
||||
System.err.println("Settings could not be saved!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// xkcd 221 compliance.
|
||||
int getRandomNumber() {
|
||||
|
@ -0,0 +1,3 @@
|
||||
function write(data) {
|
||||
console.log(data);
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
<p>Open a new shell by clicking the button.
|
||||
<br>Try typing commands, like "2*2" or "sin[.5]".
|
||||
<br>You can make variables too, try "x=.5" then "sin[x]".
|
||||
<br><br><i>Fun fact: You can use the Enter key OR the run button to run the command!</i></p>
|
||||
<br><br>SyMAT keeps track of the last few commands you enter in a shell.
|
||||
To run one again, use the up and down keys to navigate the history.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -7,7 +7,8 @@
|
||||
<p>
|
||||
<b>notify(var)</b> Creates a popup box with the given content.
|
||||
<br><b>ask(prompt)</b> Returns the entered text.
|
||||
<br><b>d("3*x", "x")</b> Returns the derivative of the function with respect to the second argument.
|
||||
<br><b>print(text)</b> Outputs the given text to the screen. Does not require special prefix in Python.
|
||||
<br><b>D("3*x", "x")</b> Returns the derivative of the function with respect to the second argument.
|
||||
<br><b>$("command")</b> Parses the given text with the Symja library.
|
||||
<br> <i>Aliases: sym</i>
|
||||
<br><b>replace("text", "find", "replace")</b> Returns "text" with all occurrences of "find" changed to "replace".
|
||||
|
@ -4,9 +4,19 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Code Editor</h1>
|
||||
<p>You can write code here. This code will be run all at once.
|
||||
<br>You can even open and save code files.
|
||||
<br>Press F5 to run your script.
|
||||
Whatever it spits out will appear in the Output box.</p>
|
||||
<p>The code editor allows you to make scripts that can do many things.
|
||||
<br>Scripts can be written in JavaScript or in Python.
|
||||
<br>To switch languages, use the Language option on the Edit menu.
|
||||
</p>
|
||||
<p><i><b>Note:</b>
|
||||
Python scripts require
|
||||
<span style="font-family: monospace;">_.</span>
|
||||
before SyMAT commands.</i></p>
|
||||
<h2>Exporting Code</h2>
|
||||
<p>You can export syntax-highlighted (colored) code to
|
||||
HTML or PDF with the Export tool. This is useful for generating
|
||||
reports or for publishing to the Internet.
|
||||
<br>The code will be formatted according to the currently selected
|
||||
language in the editor.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -44,6 +44,46 @@
|
||||
See the License for the specific language governing permissions and<br>
|
||||
limitations under the License.</p>
|
||||
<br>
|
||||
<p><b>Jython</b></p><br>
|
||||
<p>PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2<br>
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Jython") in source or binary form and
|
||||
its associated documentation.<br>
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF
|
||||
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
||||
license to reproduce, analyze, test, perform and/or display publicly,
|
||||
prepare derivative works, distribute, and otherwise use Jython alone
|
||||
or in any derivative version, provided, however, that PSF's License
|
||||
Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2007
|
||||
Python Software Foundation; All Rights Reserved" are retained in
|
||||
Jython alone or in any derivative version prepared by Licensee.<br>
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Jython or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Jython.<br>
|
||||
4. PSF is making Jython available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF JYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.<br>
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF JYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING JYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.<br>
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.<br>
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.<br>
|
||||
8. By copying, installing or otherwise using Jython, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.</p>
|
||||
<br>
|
||||
<p><b>HtmlCleaner</b></p><br>
|
||||
<p>Copyright (c) 2006-2014, HtmlCleaner team.<br>
|
||||
All rights reserved.<br>
|
||||
|
Loading…
x
Reference in New Issue
Block a user