1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Patch for Anton Leherbauer bug 81555. Use a CDT specific partitioning for (almost) all C documents.

This commit is contained in:
Doug Schaefer 2006-04-04 18:46:38 +00:00
parent acd5b19ae7
commit 9c893eb485
5 changed files with 50 additions and 14 deletions

View file

@ -30,8 +30,10 @@ import org.eclipse.compare.internal.TokenComparator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@ -127,7 +129,12 @@ public class CMergeViewer extends TextMergeViewer {
private CSourceViewerConfiguration getSourceViewerConfiguration() {
if (fSourceViewerConfiguration == null) {
CTextTools tools= CUIPlugin.getDefault().getTextTools();
fSourceViewerConfiguration = new CSourceViewerConfiguration(tools, null);
fSourceViewerConfiguration = new CSourceViewerConfiguration(tools, null) {
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
return IDocumentExtension3.DEFAULT_PARTITIONING;
}
};
}
return fSourceViewerConfiguration;
}
@ -146,7 +153,6 @@ public class CMergeViewer extends TextMergeViewer {
protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
CTextTools tools= CUIPlugin.getDefault().getTextTools();
((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
}
}

View file

@ -29,7 +29,6 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@ -289,9 +288,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo
String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
IDocument document = new Document(content);
IDocumentPartitioner partitioner = fCTextTools.createDocumentPartitioner();
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
fCTextTools.setupCDocument(document);
fPreviewViewer.setDocument(document);

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter;
@ -70,9 +71,11 @@ public class CTemplatePreferencePage extends TemplatePreferencePage {
protected SourceViewer createViewer(Composite parent) {
SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
CTextTools tools= CUIPlugin.getDefault().getTextTools();
IDocument document = new Document();
tools.setupCDocument(document);
viewer.configure(new CSourceViewerConfiguration(tools, null));
viewer.setEditable(false);
viewer.setDocument(new Document());
viewer.setDocument(document);
viewer.getTextWidget().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);

View file

@ -151,6 +151,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler= new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
RuleBasedScanner scanner;
@ -470,6 +471,13 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
return detectors;
}
/*
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
*/
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
return fTextTools.getDocumentPartitioning();
}
/**
* Creates control for outline presentation in editor.
* @param editor Editor.

View file

@ -42,6 +42,8 @@ public class CTextTools {
}
}
private static final String DEFAULT_PARTITIONING = "__c_partitioning"; //$NON-NLS-1$
/** The color manager */
private CColorManager fColorManager;
/** The C source code scanner */
@ -63,7 +65,8 @@ public class CTextTools {
private Preferences fCorePreferenceStore;
/** The preference change listener */
private PreferenceListener fPreferenceListener= new PreferenceListener();
/** The document partitioning used for the C partitioner */
private String fDocumentPartitioning = DEFAULT_PARTITIONING;
/**
* Creates a new C text tools collection and eagerly creates
@ -273,7 +276,26 @@ public class CTextTools {
* @since 3.0
*/
public void setupCDocument(IDocument document) {
setupCDocumentPartitioner(document, IDocumentExtension3.DEFAULT_PARTITIONING);
setupCDocumentPartitioner(document, fDocumentPartitioning);
}
/**
* Get the document partitioning used for the C partitioner.
*
* @return the document partitioning used for the C partitioner
* @since 3.1
*/
public String getDocumentPartitioning() {
return fDocumentPartitioning;
}
/**
* Set the document partitioning to be used for the C partitioner.
*
* @since 3.1
*/
public void setDocumentPartitioning(String documentPartitioning) {
fDocumentPartitioning = documentPartitioning;
}
}