You can only use PatternMatcherEvent
in a class implementing IPatternMatchListener
which has been added to the console as a pattern match listener.
If you are not using a listener, then you have to find the offset of where you want to put the hyperlink by searching the console text.
You should be able to get the console text using:
IDocument document = myConsole.getDocument();
String text = document.get();
Find the text you want to use for the link:
String hyperlinkText = .... text you want to add the hyperlink to ...
int offset = text.indexOf(hyperlinkText);
Add the link if the text was found:
if (offset >= 0) {
myconsole.addHyperlink(fileLink, offset, hyperlinkText.length());
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…