Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Terminate paused console output of a batch file called as external tool
Terminate paused console output of a batch file called as external tool [message #326929] Thu, 03 April 2008 10:50 Go to next message
Eclipse UserFriend
Originally posted by: ups_genius.gmx.net

Hi everyone!

I am calling batch files via the External Tools option and parse the
output written to console with implementing IPatternMatchListenerDelegate.

Everything works fine until there is a "pause" command in the batch file.
The console output of course is paused and continues only when pressing
enter within the console window. In my case this is pretty annoying,
because the pause command is located at the end of a lot of batch files
used for building my project.

Unfortunately I cannot modify the batch files, so I tried to add another
IPatternMatchListenerDelegate listening to the command issued when the
pause command is reached ("Press any button to continue ..." or something
like that). I planned in this case to simply write "\r\n" to the very same
console, but am actually having problems with it.

I tried the following:

ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
conMan.addConsoles(new IConsole[] { console });

final IDocument doc = console.getDocument();

Display.getDefault().syncExec(
new Runnable() {
public void run(){
doc.set("\r\n");
}
});



The problem is, that this only writes to the console, and does not append
the required string. Rewriting the whole console plus the new string also
does not work since the IPatternMatchListenerDelegate is then invoked
again.

Can anyone help? Is there maybe an easier approach?

Thanks in advance!
Christian
Re: Terminate paused console output of a batch file called as external tool [message #327031 is a reply to message #326929] Mon, 07 April 2008 11:50 Go to previous message
Eclipse UserFriend
Originally posted by: ChristianOpitz.gmx.net

I found a solution, and it was easier than I expected:
1. Use the org.eclipse.ui.console.consolePatternMatchListeners extension
point to create a listener using the regex "Sie eine beliebige Taste|press
any key to continue|nyomjon meg egy billentyut". I used the output of the
pause command in different languages (there is probably a neater way to
determine it, but this works for me)

2. Use the following code in the matchFound method:

public void matchFound(PatternMatchEvent event) {

final IDocument doc = console.getDocument();
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
// Append the newline
doc.replace(doc.getLength(), 0, "\r\n");
} catch (BadLocationException e) {
e.printStackTrace();
}
}
});
}


Thats it!
Previous Topic:selectionchanged on CommonNavigator
Next Topic:Re: Fixed Size of views
Goto Forum:
  


Current Time: Thu Jul 25 13:57:16 GMT 2024

Powered by FUDForum. Page generated in 0.03284 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top