Fix bug when using print() in Shell, add tag to Shell window title indicating selected language

This commit is contained in:
Skylar 2015-06-02 13:16:40 -06:00
parent 8a5cdb94d1
commit ceaa9be060
2 changed files with 849 additions and 840 deletions

View File

@ -231,6 +231,7 @@ public class CodeRunner {
res = ""; res = "";
} }
String result = res + sw.getBuffer().toString().trim(); String result = res + sw.getBuffer().toString().trim();
sw.getBuffer().setLength(0);
return result; return result;
} catch (ScriptException ex) { } catch (ScriptException ex) {
return formatEx(ex); return formatEx(ex);

View File

@ -75,6 +75,8 @@ public class Interpreter extends javax.swing.JInternalFrame {
private AutoCompletion jsac = new AutoCompletion(jscomp); private AutoCompletion jsac = new AutoCompletion(jscomp);
private AutoCompletion pyac = new AutoCompletion(pycomp); private AutoCompletion pyac = new AutoCompletion(pycomp);
private Interpreter thisobject;
/** /**
* Creates new form Interpreter * Creates new form Interpreter
* *
@ -82,6 +84,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
* "default". * "default".
*/ */
public Interpreter(String useLang) { public Interpreter(String useLang) {
thisobject = this;
initComponents(); initComponents();
// Setup code runner // Setup code runner
@ -96,8 +99,10 @@ public class Interpreter extends javax.swing.JInternalFrame {
javascriptMenu.setSelected(false); javascriptMenu.setSelected(false);
pythonMenu.setSelected(true); pythonMenu.setSelected(true);
pyac.install(inputBox); pyac.install(inputBox);
setTitle("Shell [python]");
} else { } else {
jsac.install(inputBox); jsac.install(inputBox);
setTitle("Shell [javascript]");
} }
// Set font // Set font
@ -439,8 +444,11 @@ public class Interpreter extends javax.swing.JInternalFrame {
private boolean doSpecialCommands() { private boolean doSpecialCommands() {
switch (code) { switch (code) {
case "clc": case "clc":
case "clear":
clrOutput(); clrOutput();
return false; return false;
case "exit":
thisobject.dispose();
} }
// Implement ans command // Implement ans command