Add script opening from arguments, upgrade to version 0.5.3
This commit is contained in:
parent
5e12bb58d5
commit
36e10a7af8
@ -27,6 +27,8 @@ import java.nio.charset.Charset;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
@ -67,11 +69,12 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
|||||||
int font_size = 12;
|
int font_size = 12;
|
||||||
try {
|
try {
|
||||||
font_size = Integer.valueOf(PrefStorage.getSetting("editor-fontsize"));
|
font_size = Integer.valueOf(PrefStorage.getSetting("editor-fontsize"));
|
||||||
} catch (Exception ex) { }
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size));
|
codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size));
|
||||||
TabStop[] tabs = new TabStop[30];
|
TabStop[] tabs = new TabStop[30];
|
||||||
for (int i = 0; i < tabs.length; i++) {
|
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);
|
TabSet tabset = new TabSet(tabs);
|
||||||
StyleContext sc = StyleContext.getDefaultStyleContext();
|
StyleContext sc = StyleContext.getDefaultStyleContext();
|
||||||
@ -278,14 +281,29 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
|||||||
File f = fc.getSelectedFile();
|
File f = fc.getSelectedFile();
|
||||||
codeBox.setText(readFile(f.toString(), StandardCharsets.UTF_8));
|
codeBox.setText(readFile(f.toString(), StandardCharsets.UTF_8));
|
||||||
isSaved = true;
|
isSaved = true;
|
||||||
|
lastSaved = codeBox.getText();
|
||||||
setTitle("Editor - " + f.getName());
|
setTitle("Editor - " + f.getName());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
JOptionPane.showInternalMessageDialog(this, "Error: Cannot load file: " + ex.getMessage());
|
JOptionPane.showInternalMessageDialog(this,
|
||||||
|
"Error: Cannot load file: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeBox.setCaretPosition(0);
|
codeBox.setCaretPosition(0);
|
||||||
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
}//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
|
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
|
||||||
if (!isSaved) {
|
if (!isSaved) {
|
||||||
int r = fc.showSaveDialog(this);
|
int r = fc.showSaveDialog(this);
|
||||||
@ -342,7 +360,7 @@ public class CodeEditor extends javax.swing.JInternalFrame {
|
|||||||
JOptionPane.QUESTION_MESSAGE));
|
JOptionPane.QUESTION_MESSAGE));
|
||||||
if (size >= 8 && size <= 36) {
|
if (size >= 8 && size <= 36) {
|
||||||
codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size));
|
codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size));
|
||||||
PrefStorage.saveSetting("editor-fontsize", size+"");
|
PrefStorage.saveSetting("editor-fontsize", size + "");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
@ -32,8 +32,9 @@ import javax.swing.JInternalFrame;
|
|||||||
*/
|
*/
|
||||||
public class MainGUI extends javax.swing.JFrame {
|
public class MainGUI extends javax.swing.JFrame {
|
||||||
|
|
||||||
public static final String APP_NAME = "SyMAT 0.5.1";
|
public static final String APP_NAME = "SyMAT 0.5.3";
|
||||||
public static final double APP_CODE = 0.51;
|
public static final double APP_CODE = 0.53;
|
||||||
|
public static String argfile = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form MainGUI
|
* Creates new form MainGUI
|
||||||
@ -52,7 +53,7 @@ public class MainGUI extends javax.swing.JFrame {
|
|||||||
is.close();
|
is.close();
|
||||||
double version = Double.parseDouble(line);
|
double version = Double.parseDouble(line);
|
||||||
if (version > APP_CODE) {
|
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.");
|
System.err.println("An update was found, but has been ignored by the user.");
|
||||||
} else {
|
} else {
|
||||||
loadFrame(new Update(version));
|
loadFrame(new Update(version));
|
||||||
@ -60,10 +61,19 @@ public class MainGUI extends javax.swing.JFrame {
|
|||||||
}
|
}
|
||||||
} catch (IOException | NumberFormatException e) {
|
} catch (IOException | NumberFormatException e) {
|
||||||
System.err.println("Fail: Cannot check update server. \n"
|
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);
|
new MainGUI().setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Trigger open passed script file
|
||||||
|
if (args.length == 1) {
|
||||||
|
argfile = args[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<h1>Welcome to SyMAT!</h1>
|
<h1>Welcome to SyMAT!</h1>
|
||||||
<p>SyMAT is a Java-based algebra and calculus system.
|
<p>SyMAT is a Java-based algebra and calculus system.
|
||||||
Scripts and commands are in JavaScript.</p>
|
Scripts and commands are in JavaScript.</p>
|
||||||
<p><b>License:</b><br>
|
<p><b>Copyright:</b><br>
|
||||||
SyMAT is licensed under the GNU Lesser General Public License.</p>
|
SyMAT is copyright © 2014 Apocalypse Laboratories.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user