diff --git a/src/net/apocalypselabs/symat/CodeEditor.java b/src/net/apocalypselabs/symat/CodeEditor.java index 863f52c..7383add 100644 --- a/src/net/apocalypselabs/symat/CodeEditor.java +++ b/src/net/apocalypselabs/symat/CodeEditor.java @@ -27,6 +27,8 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JScrollPane; @@ -67,11 +69,12 @@ public class CodeEditor extends javax.swing.JInternalFrame { int font_size = 12; try { font_size = Integer.valueOf(PrefStorage.getSetting("editor-fontsize")); - } catch (Exception ex) { } + } catch (Exception ex) { + } codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); TabStop[] tabs = new TabStop[30]; for (int i = 0; i < tabs.length; i++) { - tabs[i] = new TabStop(15*i, TabStop.ALIGN_RIGHT, TabStop.LEAD_NONE); + tabs[i] = new TabStop(15 * i, TabStop.ALIGN_RIGHT, TabStop.LEAD_NONE); } TabSet tabset = new TabSet(tabs); StyleContext sc = StyleContext.getDefaultStyleContext(); @@ -278,14 +281,29 @@ public class CodeEditor extends javax.swing.JInternalFrame { File f = fc.getSelectedFile(); codeBox.setText(readFile(f.toString(), StandardCharsets.UTF_8)); isSaved = true; + lastSaved = codeBox.getText(); setTitle("Editor - " + f.getName()); } catch (IOException ex) { - JOptionPane.showInternalMessageDialog(this, "Error: Cannot load file: " + ex.getMessage()); + JOptionPane.showInternalMessageDialog(this, + "Error: Cannot load file: " + ex.getMessage()); } } codeBox.setCaretPosition(0); }//GEN-LAST:event_jMenuItem1ActionPerformed + public void openFileFromString(String file) { + try { + File f = new File(file); + codeBox.setText(readFile(f.toString(), StandardCharsets.UTF_8)); + isSaved = true; + lastSaved = codeBox.getText(); + setTitle("Editor - " + f.getName()); + } catch (IOException ex) { + JOptionPane.showInternalMessageDialog(this, + "Error: Cannot load file: " + ex.getMessage()); + } + } + private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed if (!isSaved) { int r = fc.showSaveDialog(this); @@ -342,7 +360,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { JOptionPane.QUESTION_MESSAGE)); if (size >= 8 && size <= 36) { codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size)); - PrefStorage.saveSetting("editor-fontsize", size+""); + PrefStorage.saveSetting("editor-fontsize", size + ""); } } catch (Exception ex) { diff --git a/src/net/apocalypselabs/symat/MainGUI.java b/src/net/apocalypselabs/symat/MainGUI.java index cc77a80..95b1e50 100644 --- a/src/net/apocalypselabs/symat/MainGUI.java +++ b/src/net/apocalypselabs/symat/MainGUI.java @@ -32,8 +32,9 @@ import javax.swing.JInternalFrame; */ public class MainGUI extends javax.swing.JFrame { - public static final String APP_NAME = "SyMAT 0.5.1"; - public static final double APP_CODE = 0.51; + public static final String APP_NAME = "SyMAT 0.5.3"; + public static final double APP_CODE = 0.53; + public static String argfile = ""; /** * Creates new form MainGUI @@ -52,7 +53,7 @@ public class MainGUI extends javax.swing.JFrame { is.close(); double version = Double.parseDouble(line); if (version > APP_CODE) { - if (PrefStorage.getSetting("update-ignore").equals(APP_CODE+"|"+version)) { + if (PrefStorage.getSetting("update-ignore").equals(APP_CODE + "|" + version)) { System.err.println("An update was found, but has been ignored by the user."); } else { loadFrame(new Update(version)); @@ -60,10 +61,19 @@ public class MainGUI extends javax.swing.JFrame { } } catch (IOException | NumberFormatException e) { System.err.println("Fail: Cannot check update server. \n" - + " Assuming local copy up-to-date."); + + " Assuming local copy up-to-date."); + } + + // Open shell unless prog was run with argument + if (argfile.equals("")) { + Interpreter sh = new Interpreter(); + loadFrame(sh); + } else { + CodeEditor ed = new CodeEditor(); + loadFrame(ed); + ed.openFileFromString(argfile); + argfile = ""; } - Interpreter sh = new Interpreter(); - loadFrame(sh); } /** @@ -247,6 +257,11 @@ public class MainGUI extends javax.swing.JFrame { new MainGUI().setVisible(true); } }); + + // Trigger open passed script file + if (args.length == 1) { + argfile = args[0]; + } } // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/src/net/apocalypselabs/symat/help/welcome.html b/src/net/apocalypselabs/symat/help/welcome.html index a468f9a..f7871ec 100644 --- a/src/net/apocalypselabs/symat/help/welcome.html +++ b/src/net/apocalypselabs/symat/help/welcome.html @@ -6,7 +6,7 @@
SyMAT is a Java-based algebra and calculus system. Scripts and commands are in JavaScript.
-License:
- SyMAT is licensed under the GNU Lesser General Public License.
Copyright:
+ SyMAT is copyright © 2014 Apocalypse Laboratories.