Add SyMAT Java functions to autocomplete and scripts
This commit is contained in:
parent
ddaecb8594
commit
5a9cbc9af6
@ -102,6 +102,10 @@ public class CodeCompleter {
|
||||
switch (fileid) {
|
||||
case "functions":
|
||||
String[] args = line.split("\\|");
|
||||
// Prefix symat to Java commands
|
||||
if (lang.equals("java")) {
|
||||
args[0] = "symat." + args[0];
|
||||
}
|
||||
if (args.length == 2) {
|
||||
provider.addCompletion(new BasicCompletion(provider, args[0], args[1]));
|
||||
} else if (args.length == 3) {
|
||||
|
@ -92,9 +92,11 @@ public class Editor extends javax.swing.JInternalFrame {
|
||||
private boolean fileChanged = false;
|
||||
|
||||
private CompletionProvider jscomp = new CodeCompleter("js").getProvider();
|
||||
private CompletionProvider javacomp = new CodeCompleter("java").getProvider();
|
||||
private CompletionProvider pycomp = new CodeCompleter("py").getProvider();
|
||||
private AutoCompletion jsac = new AutoCompletion(jscomp);
|
||||
private AutoCompletion pyac = new AutoCompletion(pycomp);
|
||||
private AutoCompletion javaac = new AutoCompletion(javacomp);
|
||||
|
||||
/**
|
||||
* The JavaScript language.
|
||||
@ -928,12 +930,14 @@ public class Editor extends javax.swing.JInternalFrame {
|
||||
private void javascriptOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javascriptOptionActionPerformed
|
||||
codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
|
||||
pyac.uninstall();
|
||||
javaac.uninstall();
|
||||
jsac.install(codeBox);
|
||||
}//GEN-LAST:event_javascriptOptionActionPerformed
|
||||
|
||||
private void pythonOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pythonOptionActionPerformed
|
||||
codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
|
||||
jsac.uninstall();
|
||||
javaac.uninstall();
|
||||
pyac.install(codeBox);
|
||||
}//GEN-LAST:event_pythonOptionActionPerformed
|
||||
|
||||
@ -1010,8 +1014,9 @@ public class Editor extends javax.swing.JInternalFrame {
|
||||
|
||||
private void javaOptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaOptionActionPerformed
|
||||
codeBox.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
//pyac.uninstall();
|
||||
//jsac.install(codeBox);
|
||||
pyac.uninstall();
|
||||
jsac.uninstall();
|
||||
javaac.install(codeBox);
|
||||
}//GEN-LAST:event_javaOptionActionPerformed
|
||||
|
||||
private void createShared(String id) {
|
||||
@ -1057,14 +1062,15 @@ public class Editor extends javax.swing.JInternalFrame {
|
||||
text += line + "\n";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
text = "Error: Could not open embedded sample file.";
|
||||
if (ext.startsWith("j")) {
|
||||
text = "/* " + text + " */";
|
||||
} else {
|
||||
text = "## " + text;
|
||||
}
|
||||
outputBox.setText("Error: Could not open embedded sample file.");
|
||||
// if (ext.startsWith("j")) {
|
||||
// text = "/* " + text + " */";
|
||||
// } else {
|
||||
// text = "## " + text;
|
||||
// }
|
||||
}
|
||||
openString(text, name + "." + ext, false);
|
||||
// Open it and remove the .txt ending on Java files
|
||||
openString(text, name + "." + ext.replace(".txt", ""), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,6 +95,7 @@ public class Update extends javax.swing.JInternalFrame {
|
||||
@Override
|
||||
public void run() {
|
||||
changelogBox.setText(html);
|
||||
changelogBox.setCaretPosition(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
String formula = ask("Enter formula:");
|
||||
plot(formula);
|
||||
plotname("Cool graph!");
|
||||
String formula = symat.ask("Enter formula:");
|
||||
symat.plot(formula);
|
||||
symat.plotname("Cool graph!");
|
@ -1,6 +1,9 @@
|
||||
public class HelloWorld {
|
||||
public static void main(String[] args) {
|
||||
print("Hello world");
|
||||
String message = "Hello World!";
|
||||
int x = 5;
|
||||
print(message);
|
||||
symat.notify(message + " X is " + x + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,162 +1,6 @@
|
||||
void notify(String msg) {
|
||||
SyMAT_Functions.notify(msg);
|
||||
}
|
||||
Object ask(String msg) {
|
||||
return SyMAT_Functions.ask(msg);
|
||||
}
|
||||
Object factorial(int n) {
|
||||
return SyMAT_Functions.factorial(n);
|
||||
}
|
||||
Object diff(String fun,String var) {
|
||||
return SyMAT_Functions.diff(fun,var);
|
||||
}
|
||||
Object integrate(String fun,String var) {
|
||||
return SyMAT_Functions.integrate(fun,var);
|
||||
}
|
||||
Object rad(double num) {
|
||||
return SyMAT_Functions.rad(num);
|
||||
}
|
||||
Object deg(double num) {
|
||||
return SyMAT_Functions.deg(num);
|
||||
}
|
||||
Object subs(String fun,String var) {
|
||||
return SyMAT_Functions.subs(fun,var);
|
||||
}
|
||||
void plot(String fun) {
|
||||
SyMAT_Functions.plot(fun);
|
||||
}
|
||||
void plot() {
|
||||
SyMAT_Functions.plot();
|
||||
}
|
||||
void plotname(String fun) {
|
||||
SyMAT_Functions.plotname(fun);
|
||||
}
|
||||
Object plotname() {
|
||||
return SyMAT_Functions.plotname();
|
||||
}
|
||||
void xlim(int min, int max) {
|
||||
SyMAT_Functions.xlim(min,max);
|
||||
}
|
||||
void plotclr() {
|
||||
SyMAT_Functions.plotclr();
|
||||
}
|
||||
void drawdot(int x, int y) {
|
||||
SyMAT_Functions.drawdot(x, y);
|
||||
}
|
||||
Object simplify(String expr) {
|
||||
return SyMAT_Functions.simplify(expr);
|
||||
}
|
||||
Object vpa(String expr) {
|
||||
return SyMAT_Functions.vpa(expr);
|
||||
}
|
||||
Object readfile(String path) {
|
||||
return SyMAT_Functions.readfile(path);
|
||||
}
|
||||
void savefile(String data,String path) {
|
||||
SyMAT_Functions.savefile(data,path);
|
||||
}
|
||||
Object mtimes(double[][] a, double[][] b) {
|
||||
return SyMAT_Functions.mtimes(a,b);
|
||||
}
|
||||
Object mpower(double[][] a, int b) {
|
||||
return SyMAT_Functions.mpower(a,b);
|
||||
}
|
||||
Object add(double a...) {
|
||||
return SyMAT_Functions.add(a);
|
||||
}
|
||||
Object subtract(double a...) {
|
||||
return SyMAT_Functions.subtract(a);
|
||||
}
|
||||
Object times(double a...) {
|
||||
return SyMAT_Functions.times(a);
|
||||
}
|
||||
Object divide(double a...) {
|
||||
return SyMAT_Functions.divide(a);
|
||||
}
|
||||
Object mod(double a...) {
|
||||
return SyMAT_Functions.mod(a);
|
||||
}
|
||||
Object rand(int min, int max) {
|
||||
return SyMAT_Functions.rand(min,max);
|
||||
}
|
||||
Object rand(int min) {
|
||||
return SyMAT_Functions.rand(min,1);
|
||||
}
|
||||
Object rand() {
|
||||
return SyMAT_Functions.rand(0,1);
|
||||
}
|
||||
Object randb() {
|
||||
return SyMAT_Functions.randb();
|
||||
}
|
||||
void sleep(int x) {
|
||||
SyMAT_Functions.sleep(x);
|
||||
}
|
||||
void pause(int x) {
|
||||
SyMAT_Functions.pause(x);
|
||||
}
|
||||
Object perms(double a...) {
|
||||
return SyMAT_Functions.perms(a);
|
||||
}
|
||||
Object md5sum(String a) {
|
||||
return SyMAT_Functions.md5sum(a);
|
||||
}
|
||||
Object save(String a, String b) {
|
||||
return SyMAT_Functions.save(a,b);
|
||||
}
|
||||
Object load(String a) {
|
||||
return SyMAT_Functions.load(a);
|
||||
}
|
||||
Object powermod(String a,String b,String m) {
|
||||
return SyMAT_Functions.powermod(a,b,m);
|
||||
}
|
||||
Object powermod(double a,double b,double m) {
|
||||
return SyMAT_Functions.powermod(a,b,m);
|
||||
}
|
||||
Object gcd(long a,long b) {
|
||||
return SyMAT_Functions.gcd(a,b);
|
||||
}
|
||||
Object solve(String a, String b, int c) {
|
||||
return SyMAT_Functions.solve(a,b,c);
|
||||
}
|
||||
Object solve(String a) {
|
||||
return SyMAT_Functions.solve(a,"x",0);
|
||||
}
|
||||
Object printa(Object a) {
|
||||
return SyMAT_Functions.printa(a);
|
||||
}
|
||||
Object sec(double a) {
|
||||
return SyMAT_Functions.sec(a);
|
||||
}
|
||||
Object csc(double a) {
|
||||
return SyMAT_Functions.csc(a);
|
||||
}
|
||||
Object cot(double a) {
|
||||
return SyMAT_Functions.cot(a);
|
||||
}
|
||||
Object asec(double a) {
|
||||
return SyMAT_Functions.asec(a);
|
||||
}
|
||||
Object acsc(double a) {
|
||||
return SyMAT_Functions.acsc(a);
|
||||
}
|
||||
Object acot(double a) {
|
||||
return SyMAT_Functions.acot(a);
|
||||
}
|
||||
Object sech(double a) {
|
||||
return SyMAT_Functions.sech(a);
|
||||
}
|
||||
Object csch(double a) {
|
||||
return SyMAT_Functions.csch(a);
|
||||
}
|
||||
Object coth(double a) {
|
||||
return SyMAT_Functions.coth(a);
|
||||
}
|
||||
Object filedialog() {
|
||||
return SyMAT_Functions.filedialog();
|
||||
}
|
||||
Object textbox() {
|
||||
return SyMAT_Functions.textbox();
|
||||
}
|
||||
Object browser() {
|
||||
return SyMAT_Functions.browser();
|
||||
}
|
||||
import net.apocalypselabs.symat.Functions;
|
||||
Functions symat = new Functions();
|
||||
public static final double E = java.lang.Math.E;
|
||||
public static final double PI = java.lang.Math.PI;
|
||||
public static final double SQRT1_2 = java.lang.Math.sqrt(0.5);
|
||||
public static final double SQRT2 = java.lang.Math.sqrt(2);
|
@ -1,8 +1,4 @@
|
||||
E
|
||||
PI
|
||||
LN2
|
||||
LN10
|
||||
LOG2E
|
||||
LOG10E
|
||||
SQRT1_2
|
||||
SQRT2
|
Loading…
x
Reference in New Issue
Block a user