mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 499374 - Extend the preview code on the Syntax Coloring preference page
The code now includes a template parameter and a task tag, so their respective colorings can be seen in the preview window. Change-Id: Ie74a0af04b016ef506d665a9472775aa8f6d757c
This commit is contained in:
parent
4ed57293e6
commit
52299c9124
2 changed files with 14 additions and 2 deletions
|
@ -23,6 +23,7 @@ import org.eclipse.jface.layout.PixelConverter;
|
||||||
import org.eclipse.jface.preference.ColorSelector;
|
import org.eclipse.jface.preference.ColorSelector;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.preference.PreferenceConverter;
|
import org.eclipse.jface.preference.PreferenceConverter;
|
||||||
|
import org.eclipse.jface.preference.PreferenceStore;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.text.Document;
|
import org.eclipse.jface.text.Document;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
@ -62,6 +63,7 @@ import org.eclipse.ui.texteditor.ChainedPreferenceStore;
|
||||||
|
|
||||||
import com.ibm.icu.text.Collator;
|
import com.ibm.icu.text.Collator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.text.ICPartitions;
|
import org.eclipse.cdt.ui.text.ICPartitions;
|
||||||
|
@ -816,7 +818,16 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
|
||||||
|
|
||||||
private Control createPreviewer(Composite parent) {
|
private Control createPreviewer(Composite parent) {
|
||||||
IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
|
IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
|
||||||
IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), generalTextStore });
|
// Task tags can have their own coloring, and to demonstrate this, the preview code
|
||||||
|
// contains a "TODO" task tag. In order for the comment scanner to recognize this
|
||||||
|
// as a task tag and apply the coloring, "TODO" needs to be present under the
|
||||||
|
// TODO_TASK_TAGS preference key. Normally this is contained in the core preference
|
||||||
|
// store, but since the user can override the set of task tags, we provide a custom
|
||||||
|
// preference store that always has "TODO" under that key.
|
||||||
|
IPreferenceStore taskTagPreferenceStore= new PreferenceStore();
|
||||||
|
taskTagPreferenceStore.setValue(CCorePreferenceConstants.TODO_TASK_TAGS, "TODO"); //$NON-NLS-1$
|
||||||
|
IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(),
|
||||||
|
taskTagPreferenceStore, generalTextStore });
|
||||||
fPreviewViewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
|
fPreviewViewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
|
||||||
SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
|
SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
|
||||||
fPreviewViewer.configure(configuration);
|
fPreviewViewer.configure(configuration);
|
||||||
|
|
|
@ -10,6 +10,7 @@ int static myfunc(uint parameter) {
|
||||||
return parameter - 1;
|
return parameter - 1;
|
||||||
}
|
}
|
||||||
void mutator(int&);
|
void mutator(int&);
|
||||||
|
template <typename Item>
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public:
|
public:
|
||||||
enum Number { ZERO, ONE, TWO };
|
enum Number { ZERO, ONE, TWO };
|
||||||
|
@ -21,7 +22,7 @@ public:
|
||||||
label: myfunc(local);
|
label: myfunc(local);
|
||||||
vmethod();
|
vmethod();
|
||||||
staticMethod();
|
staticMethod();
|
||||||
problem();
|
problem(); // TODO: fix
|
||||||
mutator(local);
|
mutator(local);
|
||||||
}
|
}
|
||||||
static void staticMethod();
|
static void staticMethod();
|
||||||
|
|
Loading…
Add table
Reference in a new issue