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

master
skylarmt 10 years ago
parent 000ab2153f
commit 05b6677096

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.mac = ${running.on.mac}" level="verbose"/>
<echo message="running.on.unix = ${running.on.unix}" level="verbose"/> <echo message="running.on.unix = ${running.on.unix}" level="verbose"/>
<echo message="running.on.windows = ${running.on.windows}" level="verbose"/> <echo message="running.on.windows = ${running.on.windows}" level="verbose"/>
</target> </target>
<!-- Check availability of JavaFX SDK deployment support (ant-javafx.jar) --> <!-- 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"> <condition property="javafx.sdk.defined">
<and> <and>
<isset property="javafx.sdk"/> <isset property="javafx.sdk"/>
<not> <not><contains string="${javafx.sdk}" substring="$${platform" casesensitive="false"/></not>
<contains string="${javafx.sdk}" substring="$${platform" casesensitive="false"/>
</not>
</and> </and>
</condition> </condition>
<condition property="javafx.sdk.missing+default"> <condition property="javafx.sdk.missing+default">
<and> <and>
<equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/> <equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/>
<not> <not><isset property="javafx.sdk.defined"/></not>
<isset property="javafx.sdk.defined"/>
</not>
</and> </and>
</condition> </condition>
<condition property="javafx.sdk.missing-default"> <condition property="javafx.sdk.missing-default">
<and> <and>
<not> <not><equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/></not>
<equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/> <not><isset property="javafx.sdk.defined"/></not>
</not>
<not>
<isset property="javafx.sdk.defined"/>
</not>
</and> </and>
</condition> </condition>
<echo message="javafx.sdk.defined = ${javafx.sdk.defined}" level="verbose"/> <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"> <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"> <condition property="do.set.ant-javafx.in.fxsdk.lib">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${javafx.sdk}${file.separator}lib${file.separator}ant-javafx.jar"/> <available file="${javafx.sdk}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </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"> <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"> <condition property="do.set.ant-javafx.in.fxsdk.tools">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${javafx.sdk}${file.separator}tools${file.separator}ant-javafx.jar"/> <available file="${javafx.sdk}${file.separator}tools${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -146,9 +134,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<target name="-check-ant-javafx-in-platform-home-lib" if="platform.home"> <target name="-check-ant-javafx-in-platform-home-lib" if="platform.home">
<condition property="do.set.ant-javafx.in.platform.home.lib"> <condition property="do.set.ant-javafx.in.platform.home.lib">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${platform.home}${file.separator}lib${file.separator}ant-javafx.jar"/> <available file="${platform.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -159,9 +145,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<target name="-check-ant-javafx-in-platform-home-tools" if="platform.home"> <target name="-check-ant-javafx-in-platform-home-tools" if="platform.home">
<condition property="do.set.ant-javafx.in.platform.home.tools"> <condition property="do.set.ant-javafx.in.platform.home.tools">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${platform.home}${file.separator}tools${file.separator}ant-javafx.jar"/> <available file="${platform.home}${file.separator}tools${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -172,9 +156,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<target name="-check-ant-javafx-in-probjdk-lib" unless="ant-javafx.jar.location"> <target name="-check-ant-javafx-in-probjdk-lib" unless="ant-javafx.jar.location">
<condition property="do.set.ant-javafx.in.probjdk.lib"> <condition property="do.set.ant-javafx.in.probjdk.lib">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${java.home}${file.separator}..${file.separator}lib${file.separator}ant-javafx.jar"/> <available file="${java.home}${file.separator}..${file.separator}lib${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -185,9 +167,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<target name="-check-ant-javafx-in-probjdk-tools" unless="ant-javafx.jar.location"> <target name="-check-ant-javafx-in-probjdk-tools" unless="ant-javafx.jar.location">
<condition property="do.set.ant-javafx.in.probjdk.tools"> <condition property="do.set.ant-javafx.in.probjdk.tools">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${java.home}${file.separator}..${file.separator}tools${file.separator}ant-javafx.jar"/> <available file="${java.home}${file.separator}..${file.separator}tools${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -198,9 +178,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<target name="-check-ant-javafx-in-macjdk-lib" unless="ant-javafx.jar.location"> <target name="-check-ant-javafx-in-macjdk-lib" unless="ant-javafx.jar.location">
<condition property="do.set.ant-javafx.in.macjdk.lib"> <condition property="do.set.ant-javafx.in.macjdk.lib">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${java.home}${file.separator}lib${file.separator}ant-javafx.jar"/> <available file="${java.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -212,9 +190,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<property environment="env"/> <property environment="env"/>
<condition property="do.set.ant-javafx.in.envjdk.lib"> <condition property="do.set.ant-javafx.in.envjdk.lib">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${env.JAVA_HOME}${file.separator}lib${file.separator}ant-javafx.jar"/> <available file="${env.JAVA_HOME}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -226,9 +202,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<property environment="env"/> <property environment="env"/>
<condition property="do.set.ant-javafx.in.envjdk.tools"> <condition property="do.set.ant-javafx.in.envjdk.tools">
<and> <and>
<not> <not><isset property="ant-javafx.jar.location"/></not>
<isset property="ant-javafx.jar.location"/>
</not>
<available file="${env.JAVA_HOME}${file.separator}tools${file.separator}ant-javafx.jar"/> <available file="${env.JAVA_HOME}${file.separator}tools${file.separator}ant-javafx.jar"/>
</and> </and>
</condition> </condition>
@ -240,9 +214,7 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<condition property="do.check.ant-javafx.version"> <condition property="do.check.ant-javafx.version">
<and> <and>
<isset property="ant-javafx.jar.location"/> <isset property="ant-javafx.jar.location"/>
<not> <not><isset property="ant-javafx-version-already-checked-in-jfximpl"/></not>
<isset property="ant-javafx-version-already-checked-in-jfximpl"/>
</not>
</and> </and>
</condition> </condition>
</target> </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="ant-javafx.jar.location = ${ant-javafx.jar.location}" level="verbose"/>
<echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/> <echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/>
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml" <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant" uri="javafx:com.sun.javafx.tools.ant"
classpath="${javafx.ant.classpath}"/> classpath="${javafx.ant.classpath}"/>
<condition property="have-fx-ant-init"> <condition property="have-fx-ant-init">
<typefound name="javafx:com.sun.javafx.tools.ant:init-ant"/> <typefound name="javafx:com.sun.javafx.tools.ant:init-ant"/>
</condition> </condition>
@ -397,23 +369,13 @@ Portions Copyrighted 2013 Sun Microsystems, Inc.
<echo message="exec-error:${exec-error}" level="verbose"/> <echo message="exec-error:${exec-error}" level="verbose"/>
<echo message="exec-result:${exec-result}" level="verbose"/> <echo message="exec-result:${exec-result}" level="verbose"/>
<condition property="missing.Inno"> <condition property="missing.Inno">
<not> <not><and>
<and> <contains string="${exec-output}" substring="Inno Setup"/>
<contains string="${exec-output}" substring="Inno Setup"/> <not><contains string="${exec-output}" substring="Inno Setup 1"/></not>
<not> <not><contains string="${exec-output}" substring="Inno Setup 2"/></not>
<contains string="${exec-output}" substring="Inno Setup 1"/> <not><contains string="${exec-output}" substring="Inno Setup 3"/></not>
</not> <not><contains string="${exec-output}" substring="Inno Setup 4"/></not>
<not> </and></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> </condition>
</target> </target>
<target name="-check-WiX-presence" depends="-check-native-bundling-type" if="need.WiX.presence"> <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-error:${exec-error}" level="verbose"/>
<echo message="exec-result:${exec-result}" level="verbose"/> <echo message="exec-result:${exec-result}" level="verbose"/>
<condition property="missing.WiX"> <condition property="missing.WiX">
<not> <not><and>
<and> <contains string="${exec-output}" substring="Windows Installer Xml Compiler version"/>
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version"/> <not><contains string="${exec-output}" substring="Windows Installer Xml Compiler version 1"/></not>
<not> <not><contains string="${exec-output}" substring="Windows Installer Xml Compiler version 2"/></not>
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version 1"/> </and></not>
</not>
<not>
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version 2"/>
</not>
</and>
</not>
</condition> </condition>
</target> </target>
<target name="-check-dpkg-presence" depends="-check-native-bundling-type" if="need.dpkg.presence"> <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"/> <arg line="-v dpkg"/>
</exec> </exec>
<condition property="missing.dpkg"> <condition property="missing.dpkg">
<not> <not><and>
<and> <isset property="exec.which.dpkg.result"/>
<isset property="exec.which.dpkg.result"/> <equals arg1="${exec.which.dpkg.result}" arg2="0"/>
<equals arg1="${exec.which.dpkg.result}" arg2="0"/> <isset property="exec.which.dpkg.output"/>
<isset property="exec.which.dpkg.output"/> <not><equals arg1="${exec.which.dpkg.output}" arg2=""/></not>
<not> </and></not>
<equals arg1="${exec.which.dpkg.output}" arg2=""/>
</not>
</and>
</not>
</condition> </condition>
</target> </target>
<target name="-check-rpmbuild-presence" depends="-check-native-bundling-type" if="need.rpmbuild.presence"> <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"/> <arg line="-v rpmbuild"/>
</exec> </exec>
<condition property="missing.rpmbuild"> <condition property="missing.rpmbuild">
<not> <not><and>
<and> <isset property="exec.which.rpmbuild.result"/>
<isset property="exec.which.rpmbuild.result"/> <equals arg1="${exec.which.rpmbuild.result}" arg2="0"/>
<equals arg1="${exec.which.rpmbuild.result}" arg2="0"/> <isset property="exec.which.rpmbuild.output"/>
<isset property="exec.which.rpmbuild.output"/> <not><equals arg1="${exec.which.rpmbuild.output}" arg2=""/></not>
<not> </and></not>
<equals arg1="${exec.which.rpmbuild.output}" arg2=""/>
</not>
</and>
</not>
</condition> </condition>
</target> </target>
<target name="-check-native-packager-external-tools" depends="-check-Inno-presence, -check-WiX-presence, -check-dpkg-presence, -check-rpmbuild-presence"> <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=""/> <map from="${basedir}${file.separator}${dist.jar}" to=""/>
<scriptmapper language="javascript"> <scriptmapper language="javascript">
self.addMappedName( self.addMappedName(
(source.indexOf("jfxrt.jar") >= 0) || (source.indexOf("jfxrt.jar") >= 0) ||
(source.indexOf("deploy.jar") >= 0) || (source.indexOf("deploy.jar") >= 0) ||
(source.indexOf("javaws.jar") >= 0) || (source.indexOf("javaws.jar") >= 0) ||
(source.indexOf("plugin.jar") >= 0) (source.indexOf("plugin.jar") >= 0)
? "" : source ? "" : source
); );
</scriptmapper> </scriptmapper>
</pathconvert> </pathconvert>

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.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 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.title=SyMAT
application.vendor=Apocalypse Laboratories application.vendor=Apocalypse Laboratories
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml 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.JavaPrettify-1.2.1.jar=lib/JavaPrettify-1.2.1.jar
file.reference.js-engine.jar=lib/js-engine.jar file.reference.js-engine.jar=lib/js-engine.jar
file.reference.js.jar=lib/js.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.log4j-1.2.11.jar=lib/log4j-1.2.11.jar
file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar
includes=** includes=**
@ -49,7 +50,8 @@ javac.classpath=\
${file.reference.iText-4.2.0-com.itextpdf.jar}:\ ${file.reference.iText-4.2.0-com.itextpdf.jar}:\
${file.reference.htmlcleaner-2.10.jar}:\ ${file.reference.htmlcleaner-2.10.jar}:\
${file.reference.js-engine.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 # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false

@ -25,14 +25,16 @@
</Menu> </Menu>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.ButtonGroup" name="langBtnGroup">
</Component>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1"> <Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<SubComponents> <SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu1"> <Menu class="javax.swing.JMenu" name="fileMenu">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="File"/> <Property name="text" type="java.lang.String" value="File"/>
</Properties> </Properties>
<SubComponents> <SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1"> <MenuItem class="javax.swing.JMenuItem" name="openMenu">
<Properties> <Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+O"/> <KeyStroke key="Ctrl+O"/>
@ -40,10 +42,10 @@
<Property name="text" type="java.lang.String" value="Open..."/> <Property name="text" type="java.lang.String" value="Open..."/>
</Properties> </Properties>
<Events> <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> </Events>
</MenuItem> </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2"> <MenuItem class="javax.swing.JMenuItem" name="saveMenu">
<Properties> <Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+S"/> <KeyStroke key="Ctrl+S"/>
@ -51,10 +53,10 @@
<Property name="text" type="java.lang.String" value="Save..."/> <Property name="text" type="java.lang.String" value="Save..."/>
</Properties> </Properties>
<Events> <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> </Events>
</MenuItem> </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3"> <MenuItem class="javax.swing.JMenuItem" name="saveAsMenu">
<Properties> <Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Shift+Ctrl+S"/> <KeyStroke key="Shift+Ctrl+S"/>
@ -62,25 +64,28 @@
<Property name="text" type="java.lang.String" value="Save as..."/> <Property name="text" type="java.lang.String" value="Save as..."/>
</Properties> </Properties>
<Events> <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> </Events>
</MenuItem> </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem8"> <MenuItem class="javax.swing.JMenuItem" name="exportMenu">
<Properties> <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..."/> <Property name="text" type="java.lang.String" value="Export..."/>
</Properties> </Properties>
<Events> <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> </Events>
</MenuItem> </MenuItem>
</SubComponents> </SubComponents>
</Menu> </Menu>
<Menu class="javax.swing.JMenu" name="jMenu5"> <Menu class="javax.swing.JMenu" name="editMenu">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Edit"/> <Property name="text" type="java.lang.String" value="Edit"/>
</Properties> </Properties>
<SubComponents> <SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem6"> <MenuItem class="javax.swing.JMenuItem" name="clrOutputMenu">
<Properties> <Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+W"/> <KeyStroke key="Ctrl+W"/>
@ -88,17 +93,41 @@
<Property name="text" type="java.lang.String" value="Clear output"/> <Property name="text" type="java.lang.String" value="Clear output"/>
</Properties> </Properties>
<Events> <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> </Events>
</MenuItem> </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> </SubComponents>
</Menu> </Menu>
<Menu class="javax.swing.JMenu" name="jMenu2"> <Menu class="javax.swing.JMenu" name="runMenu">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Run"/> <Property name="text" type="java.lang.String" value="Run"/>
</Properties> </Properties>
<Events> <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> </Events>
<SubComponents> <SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5"> <MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">

@ -1,7 +1,7 @@
/* /*
* Apocalypse Laboratories * Apocalypse Laboratories
* Open Source License * Open Source License
* *
* Source code can be used for any purpose, as long as: * Source code can be used for any purpose, as long as:
* - Compiled binaries are rebranded and trademarks are not * - Compiled binaries are rebranded and trademarks are not
* visible by the end user at any time, except to give * visible by the end user at any time, except to give
@ -14,7 +14,7 @@
* - and you provide your modified source code for download, * - and you provide your modified source code for download,
* under the terms of the GNU LGPL v3 or a comparable * under the terms of the GNU LGPL v3 or a comparable
* license. * license.
* *
* Compiled binaries cannot be redistributed or mirrored, * Compiled binaries cannot be redistributed or mirrored,
* unless: * unless:
* - You have written permission from Apocalypse Laboratories; * - You have written permission from Apocalypse Laboratories;
@ -22,7 +22,7 @@
* not even behind a paywall or other blocking mechanism; * not even behind a paywall or other blocking mechanism;
* - or you have received a multi-computer license, in which * - or you have received a multi-computer license, in which
* case you should take measures to prevent unauthorized * 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. * Internet.
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
@ -68,12 +68,19 @@ public class CodeEditor extends javax.swing.JInternalFrame {
*/ */
public CodeEditor() { public CodeEditor() {
initComponents(); 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.setFileFilter(filter);
fc.addChoosableFileFilter(filter); fc.addChoosableFileFilter(filter);
filter = new FileNameExtensionFilter("SyMAT Python (.sypy)", "sypy");
fc.addChoosableFileFilter(filter);
filter = new FileNameExtensionFilter("JavaScript file (.js)", "js"); filter = new FileNameExtensionFilter("JavaScript file (.js)", "js");
fc.addChoosableFileFilter(filter); fc.addChoosableFileFilter(filter);
filter = new FileNameExtensionFilter("MeetLeeb script (.mls)", "mls"); filter = new FileNameExtensionFilter("Python script (.py)", "py");
fc.addChoosableFileFilter(filter); fc.addChoosableFileFilter(filter);
int font_size = 12; int font_size = 12;
try { try {
@ -132,6 +139,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
jMenuBar2 = new javax.swing.JMenuBar(); jMenuBar2 = new javax.swing.JMenuBar();
jMenu3 = new javax.swing.JMenu(); jMenu3 = new javax.swing.JMenu();
jMenu4 = new javax.swing.JMenu(); jMenu4 = new javax.swing.JMenu();
langBtnGroup = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel();
jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane1 = new javax.swing.JSplitPane();
scrollPane = new JScrollPane(codeBox); scrollPane = new JScrollPane(codeBox);
@ -140,14 +148,17 @@ public class CodeEditor extends javax.swing.JInternalFrame {
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
outputBox = new javax.swing.JTextArea(); outputBox = new javax.swing.JTextArea();
jMenuBar1 = new javax.swing.JMenuBar(); jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu(); fileMenu = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem(); openMenu = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem(); saveMenu = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem(); saveAsMenu = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem(); exportMenu = new javax.swing.JMenuItem();
jMenu5 = new javax.swing.JMenu(); editMenu = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem(); clrOutputMenu = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu(); 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(); jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem4.setText("jMenuItem4"); 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) .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)); openMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText("Open..."); openMenu.setText("Open...");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() { openMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { 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)); saveMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem2.setText("Save..."); saveMenu.setText("Save...");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() { saveMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { 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)); saveAsMenu.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..."); saveAsMenu.setText("Save as...");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() { saveAsMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt); saveAsMenuActionPerformed(evt);
} }
}); });
jMenu1.add(jMenuItem3); fileMenu.add(saveAsMenu);
jMenuItem8.setText("Export..."); exportMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem8.addActionListener(new java.awt.event.ActionListener() { exportMenu.setText("Export...");
exportMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { 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)); clrOutputMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem6.setText("Clear output"); clrOutputMenu.setText("Clear output");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() { clrOutputMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt); clrOutputMenuActionPerformed(evt);
} }
}); });
jMenu5.add(jMenuItem6); editMenu.add(clrOutputMenu);
codeLangMenu.setText("Language");
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(jMenu5); jMenuBar1.add(editMenu);
jMenu2.setText("Run"); runMenu.setText("Run");
jMenu2.addActionListener(new java.awt.event.ActionListener() { runMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { 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); jMenuItem5ActionPerformed(evt);
} }
}); });
jMenu2.add(jMenuItem5); runMenu.add(jMenuItem5);
jMenuBar1.add(jMenu2); jMenuBar1.add(runMenu);
setJMenuBar(jMenuBar1); setJMenuBar(jMenuBar1);
@ -299,7 +324,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </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); int r = fc.showOpenDialog(this);
if (r == JFileChooser.APPROVE_OPTION) { if (r == JFileChooser.APPROVE_OPTION) {
try { try {
@ -314,7 +339,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
} }
} }
codeBox.setCaretPosition(0); codeBox.setCaretPosition(0);
}//GEN-LAST:event_jMenuItem1ActionPerformed }//GEN-LAST:event_openMenuActionPerformed
public void openFileFromString(String file) { public void openFileFromString(String file) {
try { try {
@ -323,13 +348,20 @@ public class CodeEditor extends javax.swing.JInternalFrame {
isSaved = true; isSaved = true;
lastSaved = codeBox.getText(); lastSaved = codeBox.getText();
setTitle("Editor - " + f.getName()); 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) { } catch (IOException ex) {
JOptionPane.showInternalMessageDialog(this, JOptionPane.showInternalMessageDialog(this,
"Error: Cannot load file: " + ex.getMessage()); "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) { if (!isSaved) {
int r = fc.showSaveDialog(this); int r = fc.showSaveDialog(this);
if (r == JFileChooser.APPROVE_OPTION) { 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()); JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage());
} }
} }
}//GEN-LAST:event_jMenuItem2ActionPerformed }//GEN-LAST:event_saveMenuActionPerformed
private String addSaveExt(String path) { private String addSaveExt(String path) {
if (!path.matches(".*\\.(js|mls|symt)")) { if (!path.matches(".*\\.(js|mls|symt|syjs|sypy|py)")) {
path += ".symt"; if (pythonOption.isSelected()) {
path += ".sypy";
} else {
path += ".syjs";
}
} }
return path; 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 isSaved = false; // Reset saved status, force dialog
jMenuItem2ActionPerformed(evt); saveMenuActionPerformed(evt);
}//GEN-LAST:event_jMenuItem3ActionPerformed }//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 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()); Object result = cr.evalString(codeBox.getText());
try { try {
outputBox.append(result.toString() + "\n"); outputBox.append(result.toString() + "\n");
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
} }
}//GEN-LAST:event_jMenuItem5ActionPerformed }
private void clrOutputMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clrOutputMenuActionPerformed
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
outputBox.setText(""); outputBox.setText("");
}//GEN-LAST:event_jMenuItem6ActionPerformed }//GEN-LAST:event_clrOutputMenuActionPerformed
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed private void exportMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuActionPerformed
CodeExport ce = new CodeExport(codeBox.getText()); String lang = "js";
if (pythonOption.isSelected()) {
lang = "python";
}
CodeExport ce = new CodeExport(codeBox.getText(), lang);
MainGUI.loadFrame(ce); MainGUI.loadFrame(ce);
}//GEN-LAST:event_jMenuItem8ActionPerformed }//GEN-LAST:event_exportMenuActionPerformed
private void saveFile(String content, String path) private void saveFile(String content, String path)
throws IOException { throws IOException {
@ -405,7 +454,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
if (p == JOptionPane.YES_OPTION) { if (p == JOptionPane.YES_OPTION) {
dispose(); dispose();
} else { } else {
jMenuItem3ActionPerformed(null); saveMenuActionPerformed(null);
} }
} }
} }
@ -417,26 +466,30 @@ public class CodeEditor extends javax.swing.JInternalFrame {
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // 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.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4; private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuBar jMenuBar2; 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 jMenuItem4;
private javax.swing.JMenuItem jMenuItem5; private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSplitPane jSplitPane1; 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.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; private javax.swing.JScrollPane scrollPane;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

@ -58,6 +58,7 @@ import syntaxhighlight.ParseResult;
*/ */
public class CodeExport extends javax.swing.JInternalFrame { public class CodeExport extends javax.swing.JInternalFrame {
private String codeLang = "js";
private String html; private String html;
private final String origCode; private final String origCode;
private final JFileChooser fc = new JFileChooser(); private final JFileChooser fc = new JFileChooser();
@ -65,7 +66,7 @@ public class CodeExport extends javax.swing.JInternalFrame {
/** /**
* Creates new form CodeExport * Creates new form CodeExport
* *
* @param code * @param code The code.
*/ */
public CodeExport(String code) { public CodeExport(String code) {
origCode = code; origCode = code;
@ -74,6 +75,17 @@ public class CodeExport extends javax.swing.JInternalFrame {
previewPane.setText(html); previewPane.setText(html);
previewPane.setCaretPosition(0); 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) { private String genHtml(String code) {
String css = ""; String css = "";
@ -107,7 +119,7 @@ public class CodeExport extends javax.swing.JInternalFrame {
html += "<p class=\"header\">" + headerBox.getText() + "</p>"; html += "<p class=\"header\">" + headerBox.getText() + "</p>";
} }
PrettifyParser parser = new PrettifyParser(); PrettifyParser parser = new PrettifyParser();
List<ParseResult> parseResults = parser.parse("js", code); List<ParseResult> parseResults = parser.parse(codeLang, code);
html += PrettifyToHtml.toHtml(code, parseResults); html += PrettifyToHtml.toHtml(code, parseResults);
html += "</body></html>"; html += "</body></html>";
html = html.replace("\t", "<span class=\"tab\">&nbsp;&nbsp;&nbsp;&nbsp;</span>"); html = html.replace("\t", "<span class=\"tab\">&nbsp;&nbsp;&nbsp;&nbsp;</span>");

@ -29,6 +29,8 @@ package net.apocalypselabs.symat;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.script.*; import javax.script.*;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -38,23 +40,60 @@ import javax.swing.JOptionPane;
*/ */
public class CodeRunner { public class CodeRunner {
ScriptEngine jse = new ScriptEngineManager().getEngineByName("rhino"); private ScriptEngine se;
boolean isJava8 = false;
// 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() { public CodeRunner() {
try { this("javascript");
// Add custom functions. }
jse.eval("importClass(net.apocalypselabs.symat.Functions);"
+ "SyMAT_Functions = new net.apocalypselabs.symat.Functions();"); public CodeRunner(String lang) {
} catch (Exception ex) { scriptLang = lang;
JOptionPane.showMessageDialog(null, "Error: " switch (lang) {
+ "Could not properly initialize scripting engine." case "javascript":
+ "\n\nSome functions may not work.\n\n" se = new ScriptEngineManager().getEngineByName("rhino");
+ "(" + ex.getMessage() + ")"); wrapRequired = true;
ex.printStackTrace(); 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. * Parse a String of JavaScript.
* *
@ -63,7 +102,15 @@ public class CodeRunner {
*/ */
public Object evalString(String eval) { public Object evalString(String eval) {
try { 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) { } catch (ScriptException ex) {
return formatEx(ex); return formatEx(ex);
} }
@ -85,17 +132,20 @@ public class CodeRunner {
* @return wrapped input * @return wrapped input
*/ */
private String wrapMath(String eval) { private String wrapMath(String eval) {
String with = "with(SyMAT_Functions){with(Math){" + eval + "}}"; if (wrapRequired) {
//System.out.println(with); String with = "with(SyMAT_Functions){with(Math){" + eval + "}}";
return with; //System.out.println(with);
return with;
}
return eval;
} }
public void setVar(String var, Object val) { public void setVar(String var, Object val) {
jse.put(var, val); se.put(var, val);
} }
public Object getVar(String var) { public Object getVar(String var) {
return jse.get(var); return se.get(var);
} }
private String jsFunctions() { private String jsFunctions() {

@ -39,13 +39,18 @@
<Component id="jPanel1" min="-2" max="-2" attributes="0"/> <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="cancelBtn" min="-2" max="-2" attributes="0"/> <Component id="cancelBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="saveBtn" min="-2" pref="81" max="-2" attributes="0"/> <Component id="saveBtn" min="-2" pref="81" max="-2" attributes="0"/>
</Group> </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> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -53,20 +58,19 @@
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0"> <Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/> <Component id="jPanel2" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/> <Component id="jPanel3" max="32767" 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> </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>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -102,7 +106,7 @@
<Component id="themeLight" min="-2" max="-2" attributes="0"/> <Component id="themeLight" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="themeDark" min="-2" 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>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -142,10 +146,11 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Component id="jLabel1" max="32767" attributes="0"/>
<Component id="fontSizeBox" min="-2" pref="68" max="-2" attributes="0"/> <Component id="fontSizeBox" pref="0" max="32767" attributes="0"/>
<EmptySpace pref="125" max="32767" attributes="0"/> </Group>
<EmptySpace max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -153,11 +158,10 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Component id="jLabel1" min="-2" max="-2" 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>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
<Component id="fontSizeBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -206,5 +210,42 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
</Events> </Events>
</Component> </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> </SubComponents>
</Form> </Form>

@ -27,6 +27,8 @@
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
import javax.swing.JOptionPane;
/** /**
* *
* @author Skylar * @author Skylar
@ -58,6 +60,8 @@ public class Display extends javax.swing.JInternalFrame {
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
saveBtn = new javax.swing.JButton(); saveBtn = new javax.swing.JButton();
cancelBtn = new javax.swing.JButton(); cancelBtn = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
advOptionsBox = new javax.swing.JCheckBox();
setClosable(true); setClosable(true);
setIconifiable(true); setIconifiable(true);
@ -97,7 +101,7 @@ public class Display extends javax.swing.JInternalFrame {
.addComponent(themeLight) .addComponent(themeLight)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(themeDark) .addComponent(themeDark)
.addContainerGap(51, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Font")); 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) jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(fontSizeBox, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(fontSizeBox, 0, 0, Short.MAX_VALUE))
.addContainerGap(125, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
jPanel2Layout.setVerticalGroup( jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1)
.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)) .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)) .addContainerGap())
); );
saveBtn.setText("Save"); 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()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( 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) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .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() .addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(cancelBtn) .addComponent(cancelBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .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()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(42, 42, 42) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGap(21, 21, 21)
.addComponent(saveBtn) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelBtn))) .addComponent(saveBtn)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(cancelBtn))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(15, Short.MAX_VALUE))
); );
pack(); pack();
@ -188,10 +217,6 @@ public class Display extends javax.swing.JInternalFrame {
} }
if (PrefStorage.isset("theme")) { if (PrefStorage.isset("theme")) {
switch (PrefStorage.getSetting("theme")) { switch (PrefStorage.getSetting("theme")) {
case "light":
themeLight.setSelected(true);
themeDark.setSelected(false);
break;
case "dark": case "dark":
themeLight.setSelected(false); themeLight.setSelected(false);
themeDark.setSelected(true); themeDark.setSelected(true);
@ -201,6 +226,9 @@ public class Display extends javax.swing.JInternalFrame {
themeDark.setSelected(false); themeDark.setSelected(false);
} }
} }
if (PrefStorage.isset("advancedcontrols")) {
advOptionsBox.setSelected(true);
}
}//GEN-LAST:event_formComponentShown }//GEN-LAST:event_formComponentShown
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed
@ -210,16 +238,30 @@ public class Display extends javax.swing.JInternalFrame {
} else { } else {
PrefStorage.saveSetting("theme", "light"); 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(); MainGUI.updateDisplay();
dispose(); dispose();
}//GEN-LAST:event_saveBtnActionPerformed }//GEN-LAST:event_saveBtnActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox advOptionsBox;
private javax.swing.JButton cancelBtn; private javax.swing.JButton cancelBtn;
private javax.swing.JComboBox fontSizeBox; private javax.swing.JComboBox fontSizeBox;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JButton saveBtn; private javax.swing.JButton saveBtn;
private javax.swing.JRadioButton themeDark; private javax.swing.JRadioButton themeDark;
private javax.swing.ButtonGroup themeGroup; private javax.swing.ButtonGroup themeGroup;

@ -54,14 +54,10 @@ public class Functions {
return JOptionPane.showInternalInputDialog(MainGUI.mainPane, question); return JOptionPane.showInternalInputDialog(MainGUI.mainPane, question);
} }
public void write(String content) {
// TODO: enable output logging
}
/* /*
Math commands Math commands
*/ */
public String d(String function, String idv) { public String D(String function, String idv) {
return util.evaluate("diff(" + function + "," + idv + ")").toString(); return util.evaluate("diff(" + function + "," + idv + ")").toString();
} }

@ -82,6 +82,7 @@
</Container> </Container>
<Component class="javax.swing.JTextField" name="inputBox"> <Component class="javax.swing.JTextField" name="inputBox">
<Events> <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"/> <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputBoxKeyTyped"/>
</Events> </Events>
</Component> </Component>

@ -29,6 +29,7 @@ package net.apocalypselabs.symat;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.KeyEvent;
import javax.swing.text.DefaultCaret; import javax.swing.text.DefaultCaret;
/** /**
@ -37,7 +38,9 @@ import javax.swing.text.DefaultCaret;
*/ */
public class Interpreter extends javax.swing.JInternalFrame { 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 * Creates new form Interpreter
@ -102,6 +105,9 @@ public class Interpreter extends javax.swing.JInternalFrame {
jScrollPane1.setViewportView(mainBox); jScrollPane1.setViewportView(mainBox);
inputBox.addKeyListener(new java.awt.event.KeyAdapter() { 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) { public void keyTyped(java.awt.event.KeyEvent evt) {
inputBoxKeyTyped(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 private void inputBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputBoxKeyTyped
if (evt.getKeyChar() == '\n') { if (evt.getKeyChar() == '\n') {
doRunCode(); doRunCode();
return;
} }
}//GEN-LAST:event_inputBoxKeyTyped }//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() { private void doRunCode() {
String code = inputBox.getText(); String code = inputBox.getText();
mainBox.append(" " + code + "\n"); mainBox.append(" " + code + "\n");
@ -164,7 +196,12 @@ public class Interpreter extends javax.swing.JInternalFrame {
} }
mainBox.append(">>"); mainBox.append(">>");
for (int i = 9; i > 0; i--) {
history[i] = history[i - 1];
}
history[0] = code;
inputBox.setText(""); inputBox.setText("");
historyIndex = -1;
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables

@ -27,6 +27,9 @@
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
/** /**
@ -35,17 +38,18 @@ import java.util.prefs.Preferences;
*/ */
public class PrefStorage { 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) { public static void saveSetting(String key, String value) {
prefs.put(key, value); prefs.put(key, value);
} }
public static boolean isset(String key) { public static boolean isset(String key) {
if (!getSetting(key, "NULL").equals("NULL")) { return !getSetting(key, "NULL").equals("NULL");
return true; }
}
return false; public static void unset(String key) {
prefs.remove(key);
} }
public static String getSetting(String key) { public static String getSetting(String key) {
@ -55,6 +59,16 @@ public class PrefStorage {
public static String getSetting(String key, String emptyResponse) { public static String getSetting(String key, String emptyResponse) {
return prefs.get(key, 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. // xkcd 221 compliance.
int getRandomNumber() { 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. <p>Open a new shell by clicking the button.
<br>Try typing commands, like "2*2" or "sin[.5]". <br>Try typing commands, like "2*2" or "sin[.5]".
<br>You can make variables too, try "x=.5" then "sin[x]". <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> </body>
</html> </html>

@ -7,7 +7,8 @@
<p> <p>
<b>notify(var)</b> Creates a popup box with the given content. <b>notify(var)</b> Creates a popup box with the given content.
<br><b>ask(prompt)</b> Returns the entered text. <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><b>$("command")</b> Parses the given text with the Symja library.
<br>&nbsp;&nbsp;&nbsp;<i>Aliases: sym</i> <br>&nbsp;&nbsp;&nbsp;<i>Aliases: sym</i>
<br><b>replace("text", "find", "replace")</b> Returns "text" with all occurrences of "find" changed to "replace". <br><b>replace("text", "find", "replace")</b> Returns "text" with all occurrences of "find" changed to "replace".

@ -4,9 +4,19 @@
</head> </head>
<body> <body>
<h1>Code Editor</h1> <h1>Code Editor</h1>
<p>You can write code here. This code will be run all at once. <p>The code editor allows you to make scripts that can do many things.
<br>You can even open and save code files. <br>Scripts can be written in JavaScript or in Python.
<br>Press F5 to run your script. <br>To switch languages, use the Language option on the Edit menu.
Whatever it spits out will appear in the Output box.</p> </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> </body>
</html> </html>

@ -44,6 +44,46 @@
See the License for the specific language governing permissions and<br> See the License for the specific language governing permissions and<br>
limitations under the License.</p> limitations under the License.</p>
<br> <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
(&quot;PSF&quot;), and the Individual or Organization (&quot;Licensee&quot;) accessing and
otherwise using this software (&quot;Jython&quot;) 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., &quot;Copyright (c) 2007
Python Software Foundation; All Rights Reserved&quot; 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 &quot;AS IS&quot;
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><b>HtmlCleaner</b></p><br>
<p>Copyright (c) 2006-2014, HtmlCleaner team.<br> <p>Copyright (c) 2006-2014, HtmlCleaner team.<br>
All rights reserved.<br> All rights reserved.<br>

Loading…
Cancel
Save