How to change the font in my custom CVS merge viewer? [message #251118] |
Wed, 09 June 2004 18:20 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: mark.melvin.dspfactory.com
Hi Everyone,
I have created my own 'MergeViewer' (extending TextMergeViewer), so that
my source code is highlighted when I view it in the Team Synchronize
view. I did this by extending the extension point
"org.eclipse.compare.contentMergeViewers" for my particular file types.
Right now, my source viewer is dead simple with only partitioning and
syntax highlighting going on. All of the colors and stuff are
hard-coded as I have not implemented Preference Pages yet. This all
works great - I get colored source code in the CVS compare viewer - and
it really didn't take much effort (nice!).
The problem is - it is presented in a variable width font, and doesn't
seem to be affected by any of the preference settings in the Workbench >
Colors and Fonts preference settings. Not even the Text Compare
settings. My code to set up my viewer is simple and is as follows:
protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
if (fSourceViewerConfiguration == null) {
fSourceViewerConfiguration = new MySourceViewerConfiguration(new
ColorManager());
}
((SourceViewer) textViewer).configure(getSourceViewerConfiguration());
}
}
I've tried setting the Font directly in the textViewer with something like:
textViewer.getTextWidget().setFont(new
Font(textViewer.getControl().getDisplay(), new FontData("Courier", 14,
SWT.NORMAL)));
But it seems to do nothing. Can anyone point me in the right direction
to set the font in my MergeViewer?
Thanks,
Mark.
|
|
|
Re: How to change the font in my custom CVS merge viewer? [message #251167 is a reply to message #251118] |
Wed, 09 June 2004 19:34 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: mark.melvin.dspfactory.com
Well - after digging around a bit I found that TextMergeViewer tries to
pull a font out of the font registry who key is my classname (weird?).
Anyway - I managed to get my own Font to work by inserting the following
at the end of configureTextViewer():
JFaceResources.getFontRegistry().put(getClass().getName(),
new FontData[] {new FontData("Courier New", 10, SWT.NORMAL)});
This strikes me as a bit of a *hack*. I assume this will all work once
I start implementing preference pages for my source viewer (which is
coming later in my schedule) - but if someone knows the right way to do
this or would like to comment on the magnitude on the "hack-o-meter" of
the above line of code, please feel free. ;o)
Thanks,
Mark.
Mark Melvin wrote:
> Hi Everyone,
>
> I have created my own 'MergeViewer' (extending TextMergeViewer), so that
> my source code is highlighted when I view it in the Team Synchronize
> view. I did this by extending the extension point
> "org.eclipse.compare.contentMergeViewers" for my particular file types.
> Right now, my source viewer is dead simple with only partitioning and
> syntax highlighting going on. All of the colors and stuff are
> hard-coded as I have not implemented Preference Pages yet. This all
> works great - I get colored source code in the CVS compare viewer - and
> it really didn't take much effort (nice!).
>
> The problem is - it is presented in a variable width font, and doesn't
> seem to be affected by any of the preference settings in the Workbench >
> Colors and Fonts preference settings. Not even the Text Compare
> settings. My code to set up my viewer is simple and is as follows:
>
>
> protected void configureTextViewer(TextViewer textViewer) {
> if (textViewer instanceof SourceViewer) {
> if (fSourceViewerConfiguration == null) {
> fSourceViewerConfiguration = new
> MySourceViewerConfiguration(new ColorManager());
> }
> ((SourceViewer)
> textViewer).configure(getSourceViewerConfiguration());
> }
> }
>
> I've tried setting the Font directly in the textViewer with something like:
>
> textViewer.getTextWidget().setFont(new
> Font(textViewer.getControl().getDisplay(), new FontData("Courier", 14,
> SWT.NORMAL)));
>
> But it seems to do nothing. Can anyone point me in the right direction
> to set the font in my MergeViewer?
>
> Thanks,
> Mark.
|
|
|
Powered by
FUDForum. Page generated in 0.04354 seconds