()
| 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", |
no test coverage detected