MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / runCode

Method runCode

ij/src/main/java/ij/plugin/frame/Recorder.java:953–995  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

951 public void imageClosed(ImagePlus imp) { }
952
953 void runCode() {
954 if (instance==null || !recordingEnabled())
955 return;
956 String name = fileName.getText();
957 if (name==null)
958 return;
959 int start = textArea.getSelectionStart();
960 int end = textArea.getSelectionEnd();
961 if (start==0 && end==0) {
962 IJ.error("Run", "Executes the selected text or the line\ncontaining the cursor. Type ctrl+r as a shortcut.");
963 return;
964 }
965 if (start==end) {
966 String text = textArea.getText();
967 while (start>0) {
968 start--;
969 if (text.charAt(start)=='\n') {
970 start++;
971 break;
972 }
973 }
974 if (end<text.length() && text.charAt(end)=='\n')
975 end--;
976 while (end<text.length()-1) {
977 end++;
978 if (text.charAt(end)=='\n')
979 break;
980 }
981 textArea.setSelectionStart(start);
982 textArea.setSelectionEnd(end);
983 }
984 String text = textArea.getSelectedText();
985 if (text==null)
986 return;
987 if (name.endsWith("js"))
988 (new Macro_Runner()).runJavaScript(text, "");
989 else if (name.endsWith("bsh") || name.endsWith("java"))
990 Macro_Runner.runBeanShell(text,"");
991 else if (name.endsWith("py"))
992 Macro_Runner.runPython(text,"");
993 else
994 IJ.runMacro(text, "");
995 }
996
997 void showHelp() {
998 IJ.showMessage("Recorder",

Callers 2

keyPressedMethod · 0.95
actionPerformedMethod · 0.95

Calls 11

recordingEnabledMethod · 0.95
errorMethod · 0.95
runBeanShellMethod · 0.95
runPythonMethod · 0.95
runMacroMethod · 0.95
charAtMethod · 0.80
runJavaScriptMethod · 0.80
lengthMethod · 0.65
getTextMethod · 0.45
getSelectionStartMethod · 0.45
getSelectionEndMethod · 0.45

Tested by

no test coverage detected