use of org.eclipse.jface.text.source.IVerticalRulerExtension in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method setFont.
/**
* Sets the font for the given viewer sustaining selection and scroll position.
*
* @param sourceViewer the source viewer
* @param font the font
* @since 2.0
*/
private void setFont(ISourceViewer sourceViewer, Font font) {
if (sourceViewer.getDocument() != null) {
ISelectionProvider provider = sourceViewer.getSelectionProvider();
ISelection selection = provider.getSelection();
int topIndex = sourceViewer.getTopIndex();
StyledText styledText = sourceViewer.getTextWidget();
Control parent = styledText;
if (sourceViewer instanceof ITextViewerExtension) {
ITextViewerExtension extension = (ITextViewerExtension) sourceViewer;
parent = extension.getControl();
}
parent.setRedraw(false);
styledText.setFont(font);
if (fVerticalRuler instanceof IVerticalRulerExtension) {
IVerticalRulerExtension e = (IVerticalRulerExtension) fVerticalRuler;
e.setFont(font);
}
provider.setSelection(selection);
sourceViewer.setTopIndex(topIndex);
if (parent instanceof Composite) {
Composite composite = (Composite) parent;
composite.layout(true);
}
parent.setRedraw(true);
} else {
StyledText styledText = sourceViewer.getTextWidget();
styledText.setFont(font);
if (fVerticalRuler instanceof IVerticalRulerExtension) {
IVerticalRulerExtension e = (IVerticalRulerExtension) fVerticalRuler;
e.setFont(font);
}
}
}
Aggregations