Run shell command; return to text area
Submitted by Monday, 29 November, 2010 - 00:28
on
I'm having trouble writing a macro that runs a shell command and returns to the text area. The ultimate goal is to have a macro that saves all the buffers (without confirmation), runs the current buffer in an appropriate interpreter (python, e.g.), and returns to the text area. Really, if focus could simply remain in the text area, that would be great.
The trouble I'm having is that the view.prevTextArea() call is either being executed too early or it's simply not working the way I understood. The focus ends up in the System shell area. My code is below. I think the only important lines are the three last ones, but I'm including it all, just in case.
The trouble I'm having is that the view.prevTextArea() call is either being executed too early or it's simply not working the way I understood. The focus ends up in the System shell area. My code is below. I think the only important lines are the three last ones, but I'm including it all, just in case.
// This is a recorded macro. First, check over the // commands to make sure this is what you intended. Then, // save this buffer, and the macro should appear in the // Macros menu. filetypeToCompilers = new java.util.HashMap(); filetypeToCompilers.put(".py", "python -tt"); filetypeToCompilers.put(".java", "javac"); fileExtensionPattern = java.util.regex.Pattern.compile("(\\.[^.]*)$"); matcher = fileExtensionPattern.matcher(buffer.getName()); if (matcher.find()) { extension = matcher.group(1); } else { Macros.error(view, "Unable to determine file type (missing extension?)."); return; } compiler = filetypeToCompilers.get(extension); if (compiler == null) { Macros.message(view, "No compiler/interpreter defined for extension '" + extension + "'"); return; } runCommandInConsole(view,"System",compiler + ' ' + buffer.getPath()); waitForConsole(view); view.prevTextArea();Any thoughts?