eclipse-platform / eclipse-platform/eclipse.platform
Improve interoperability of IConsoleLineTrackers with consoles with ANSI-escaped print-out
- Dominant language
- Java
- Stars
- 165
- Forks
- 174
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 22
Description
In M2E we use an implementation of the `IConsoleLineTracker`, which registered via the `org.eclipse.debug.ui.consoleLineTrackers` extension point, to track the console output for Maven specific printout to attach links to the console's text and to perform some actions on certain print-out (i.e. launch a debugger).
The new (great) support of ANSI escape sequences for colored console print-out brings the problem that such line-trackers are usually not aware of those escape sequences and actually operate on the text without escape sequences. For example to make the [MavenConsoleLineTracker](https://github.com/eclipse-m2e/m2e-core/blob/master/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenConsoleLineTracker.java) work with colored console print-out the text obtained for the `IRegion` of the console's `IDocument` has to be filtered for those escape sequences: https://github.com/eclipse-m2e/m2e-core/pull/535
It would be better if the console itself would provide means to do that so that other parts of the code can be made 'colored-print-out' ready more easily.
This could either be achieved by providing means to obtain the unescaped text of a given 'raw' region and to add a link with an unescaped region. But this would probably also involve the `eclipse.platform.text` code. Furthermore not only obtaining the text, but also the addition of links would require special handling.
An alternative could be to just pass the unescaped text to the console document, to create all regions passed to the trackers based on the unescaped text and also create the links based on offset respectively the unescaped text. Given that the console has to detect the escape sequences any way this could also be more performant (but I'm not familiar with the details). Furthermore it would not require any adjustments of existing `IConsoleLineTracker` implementations because they could continue to work as they are.
If one really wants the raw text the console could provide methods like `getRawDocument()`, `addRawLink()` or `getRawRegion(IRegion)` that operate on the raw uninterpreted text that contains the escape sequences (but I don't know why anything besides the color-interpreter would want that).
If this is done on a basic level maybe even existing `IPatternMatchListener` can benefit from.
Contributor guide
Assessment
This issue has not been assessed yet.