Bracket Highlighting [message #254402] |
Mon, 21 June 2004 17:17  |
Eclipse User |
|
|
|
Originally posted by: strykeleader.hotmail.com
When you have bracket highlighting on, and it highlights beginning or ending
braces and parentheses in the Java editor, what is the actual editor plug-in
doing to perform the highlighting (not the JavaPairMatcher, since that's
only locating the braces), i.e. is it some widget or graphic tool thing to
make the box outline appear, and if so how could I employ this or something
similar to it for a different purpose?
- Parhaum
|
|
|
Re: Bracket Highlighting [message #254412 is a reply to message #254402] |
Mon, 21 June 2004 18:02   |
Eclipse User |
|
|
|
Parhaum Toofanian wrote:
> When you have bracket highlighting on, and it highlights beginning or ending
> braces and parentheses in the Java editor, what is the actual editor plug-in
> doing to perform the highlighting (not the JavaPairMatcher, since that's
> only locating the braces), i.e. is it some widget or graphic tool thing to
> make the box outline appear, and if so how could I employ this or something
> similar to it for a different purpose?
>
> - Parhaum
>
>
I wrote an editor where i define my bracket highliting,
you need a MatchingCharacterPainter and you have to implement
a class : SomePairMatcher implements ICharacterPairMatcher
where you say what you want to match with highlighting.
Here is an example :
public class SomeEditor extends TextEditor {
protected PaintManager fPaintManager;
protected MatchingCharacterPainter fBracketPainter;
protected boolean isBracketHighlightingEnabled() {
return true;
}
private void startBracketHighlighting() {
if (fBracketPainter == null) {
fBracketPainter = new
MatchingCharacterPainter(fSourceViewer,new SomePairMatcher());
fBracketPainter.setColor(new Color(Display.getCurrent(), new RGB(
127, 0, 85)));
fPaintManager.addPainter(fBracketPainter);
}
}
protected void createActions() {
super.createActions();
.......
fPaintManager = new PaintManager(fSource);
if (isBracketHighlightingEnabled()) {
startBracketHighlighting();
}
......
}
private void stopBracketHighlighting() {
if (fBracketPainter != null) {
fPaintManager.removePainter(fBracketPainter);
fBracketPainter.deactivate(true);
fBracketPainter.dispose();
fBracketPainter = null;
}
}
and it works.
|
|
|
Re: Bracket Highlighting [message #254733 is a reply to message #254412] |
Tue, 22 June 2004 13:17   |
Eclipse User |
|
|
|
Originally posted by: strykeleader.hotmail.com
Would something like this work if I wanted to just highlight different
things? I.e. I don't want to do any pair anything highlighting, I just want
a way to change graphical appearances around characters and such without
affecting the code itself, and the bracket highlighting seems to relate to
that. I wanted to know if there's something (JFace, SWT, etc) that has
different editor window effects.
- Parhaum
"LIM erwin" <erwin@freesurf.fr> wrote in message
news:cb7lsk$c0l$1@eclipse.org...
> Parhaum Toofanian wrote:
>
> > When you have bracket highlighting on, and it highlights beginning or
ending
> > braces and parentheses in the Java editor, what is the actual editor
plug-in
> > doing to perform the highlighting (not the JavaPairMatcher, since that's
> > only locating the braces), i.e. is it some widget or graphic tool thing
to
> > make the box outline appear, and if so how could I employ this or
something
> > similar to it for a different purpose?
> >
> > - Parhaum
> >
> >
>
> I wrote an editor where i define my bracket highliting,
> you need a MatchingCharacterPainter and you have to implement
> a class : SomePairMatcher implements ICharacterPairMatcher
> where you say what you want to match with highlighting.
>
> Here is an example :
>
> public class SomeEditor extends TextEditor {
>
> protected PaintManager fPaintManager;
>
> protected MatchingCharacterPainter fBracketPainter;
>
>
> protected boolean isBracketHighlightingEnabled() {
> return true;
> }
>
>
> private void startBracketHighlighting() {
> if (fBracketPainter == null) {
> fBracketPainter = new
> MatchingCharacterPainter(fSourceViewer,new SomePairMatcher());
> fBracketPainter.setColor(new Color(Display.getCurrent(), new RGB(
> 127, 0, 85)));
> fPaintManager.addPainter(fBracketPainter);
> }
> }
>
>
> protected void createActions() {
> super.createActions();
>
> .......
>
> fPaintManager = new PaintManager(fSource);
>
> if (isBracketHighlightingEnabled()) {
> startBracketHighlighting();
> }
> ......
> }
>
> private void stopBracketHighlighting() {
> if (fBracketPainter != null) {
> fPaintManager.removePainter(fBracketPainter);
> fBracketPainter.deactivate(true);
> fBracketPainter.dispose();
> fBracketPainter = null;
> }
> }
>
>
> and it works.
|
|
|
Re: Bracket Highlighting [message #254869 is a reply to message #254733] |
Wed, 23 June 2004 03:40  |
Eclipse User |
|
|
|
You could use Annotations - this is what's used to do the occurrences
highlighting and linked editing boxes.
See the org.eclipse.ui.editors.markerAnnotationSpecification extension
point to see how to contribute custom annotations.
-tom
Parhaum Toofanian wrote:
> Would something like this work if I wanted to just highlight different
> things? I.e. I don't want to do any pair anything highlighting, I just want
> a way to change graphical appearances around characters and such without
> affecting the code itself, and the bracket highlighting seems to relate to
> that. I wanted to know if there's something (JFace, SWT, etc) that has
> different editor window effects.
>
> - Parhaum
>
>
> "LIM erwin" <erwin@freesurf.fr> wrote in message
> news:cb7lsk$c0l$1@eclipse.org...
>
>>Parhaum Toofanian wrote:
>>
>>
>>>When you have bracket highlighting on, and it highlights beginning or
>
> ending
>
>>>braces and parentheses in the Java editor, what is the actual editor
>
> plug-in
>
>>>doing to perform the highlighting (not the JavaPairMatcher, since that's
>>>only locating the braces), i.e. is it some widget or graphic tool thing
>
> to
>
>>>make the box outline appear, and if so how could I employ this or
>
> something
>
>>>similar to it for a different purpose?
>>>
>>>- Parhaum
>>>
>>>
>>
>>I wrote an editor where i define my bracket highliting,
>>you need a MatchingCharacterPainter and you have to implement
>> a class : SomePairMatcher implements ICharacterPairMatcher
>>where you say what you want to match with highlighting.
>>
>>Here is an example :
>>
>>public class SomeEditor extends TextEditor {
>>
>> protected PaintManager fPaintManager;
>>
>> protected MatchingCharacterPainter fBracketPainter;
>>
>>
>> protected boolean isBracketHighlightingEnabled() {
>> return true;
>> }
>>
>>
>>private void startBracketHighlighting() {
>> if (fBracketPainter == null) {
>> fBracketPainter = new
>>MatchingCharacterPainter(fSourceViewer,new SomePairMatcher());
>>fBracketPainter.setColor(new Color(Display.getCurrent(), new RGB(
>> 127, 0, 85)));
>> fPaintManager.addPainter(fBracketPainter);
>> }
>> }
>>
>>
>>protected void createActions() {
>> super.createActions();
>>
>> .......
>>
>> fPaintManager = new PaintManager(fSource);
>>
>> if (isBracketHighlightingEnabled()) {
>> startBracketHighlighting();
>> }
>>......
>> }
>>
>>private void stopBracketHighlighting() {
>> if (fBracketPainter != null) {
>> fPaintManager.removePainter(fBracketPainter);
>> fBracketPainter.deactivate(true);
>> fBracketPainter.dispose();
>> fBracketPainter = null;
>> }
>> }
>>
>>
>>and it works.
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06730 seconds