pragmaMarkInfo = pragma.getPragmaMarkInfo();
+ String display = pragmaMarkInfo.map(PragmaMarkInfo::getMarkName).orElseGet(() -> pragma.getElementName());
+ int displayOffset = fBuffer.length();
+ fBuffer.append(display);
+ if (pragmaMarkInfo.isPresent()) {
+ if (getFlag(flags, CElementLabels.COLORIZE)) {
+ Styler styler = new Styler() {
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ textStyle.font = JFaceResources.getFont(PreferenceConstants.OUTLINE_MARK_TEXT_FONT);
+ ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme()
+ .getColorRegistry();
+ textStyle.foreground = new Color(
+ colorRegistry.getRGB(PreferenceConstants.OUTLINE_MARK_TEXT_COLOR));
+ }
+ };
+ fBuffer.setStyle(displayOffset, fBuffer.length() - displayOffset, styler);
+ }
+ }
+
+ if (getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+ IPath path = pragma.getPath();
+ if (path != null) {
+ int offset = fBuffer.length();
+ fBuffer.append(CElementLabels.CONCAT_STRING);
+ fBuffer.append(path.toString());
+ if (getFlag(flags, CElementLabels.COLORIZE)) {
+ fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+ }
+ }
+ }
+ }
+
/**
* Appends the label for a method declaration to a StringBuilder.
* @param method a method declaration
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCOutlineLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCOutlineLabelProvider.java
new file mode 100644
index 00000000000..95825d28109
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCOutlineLabelProvider.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Kichwa Coders Canada Inc. and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.cdt.internal.ui.cview.DividerLine;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Specialization of the C label provider that allows drawing divider lines used
+ * in Outline view and information control
+ */
+public class DecoratingCOutlineLabelProvider extends DecoratingCLabelProvider {
+
+ private static final int MAXIMUM_REASONABLE_WIDTH = 4000;
+
+ public DecoratingCOutlineLabelProvider(CUILabelProvider labelProvider) {
+ super(labelProvider, true);
+ }
+
+ @Override
+ protected void measure(Event event, Object element) {
+ if (!isOwnerDrawEnabled())
+ return;
+ if (element instanceof DividerLine) {
+ GC gc = event.gc;
+ if (gc == null) {
+ // If there is no gc (can this happen?) default to a reasonably wide measurement
+ event.width = MAXIMUM_REASONABLE_WIDTH;
+ } else {
+ // Use the clipping area of the event to know how wide the tree control
+ // is so that we can make a line exactly the right size.
+ // This has the side effect the tree can never become narrower than this
+ // width as the width of the tree is in part based on the width of its
+ // widest item. Therefore if the view becomes smaller, a horizontal
+ // scroll bar is created
+ // We use a max of MAXIMUM_REASONABLE_WIDTH here to ensure that we don't
+ // end up in a loop that the item asks for a wider width, so the tree gets wider, etc.
+ Rectangle clipping = gc.getClipping();
+ event.width = Math.min(clipping.width - event.x, MAXIMUM_REASONABLE_WIDTH);
+ }
+ } else {
+ super.measure(event, element);
+ }
+ }
+
+ @Override
+ protected void paint(Event event, Object element) {
+ if (!isOwnerDrawEnabled())
+ return;
+ if (element instanceof DividerLine) {
+ int y = event.y + event.height / 2;
+ ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme()
+ .getColorRegistry();
+ event.gc.setForeground(new Color(colorRegistry.getRGB(PreferenceConstants.OUTLINE_MARK_DIVIDER_COLOR)));
+ // draw a line as wide as possible, we can't use event.width here as that doesn't take into account
+ // our declared width in measure. On Windows this is clipped to the size we measured above, but
+ // on GTK and macOS this is clipped to the containing tree control.
+ event.gc.drawLine(0, y, event.x + MAXIMUM_REASONABLE_WIDTH, y);
+ } else {
+ super.paint(event, element);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
index d309556f2db..08180632a8c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
@@ -214,6 +214,9 @@ public class CDTSharedImages {
public static final String IMG_VIEW_PIN_ACTION_B = "icons/obj16/toolbar_pinned_b.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION_MULTI = "icons/obj16/toolbar_pinned_multi.gif"; //$NON-NLS-1$
+ /** @since 7.3*/
+ public static final String IMG_OUTLINE_MARK = "icons/obj16/outline_mark.png"; //$NON-NLS-1$
+
private static SharedImagesFactory imagesFactory = new SharedImagesFactory(CUIPlugin.getDefault());
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
index 979f4f92984..6e567e6df84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
@@ -97,7 +97,7 @@ public class CElementContentProvider extends BaseCElementContentProvider
* Creates a new content provider for C elements.
*/
public CElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
- super(provideMembers, provideWorkingCopy);
+ super(provideMembers, provideWorkingCopy, false, () -> false);
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
index 42d615b7390..25ad5dd52e0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
@@ -560,6 +560,24 @@ public class PreferenceConstants {
*/
public final static String EDITOR_TEXT_FONT = "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$
+ /**
+ * The symbolic font name for the C/C++ outline pragma mark or pragma region text font.
+ * @since 7.3
+ */
+ public final static String OUTLINE_MARK_TEXT_FONT = "org.eclipse.cdt.ui.outline.mark.textfont"; //$NON-NLS-1$
+
+ /**
+ * The color preference for the C/C++ outline pragma mark or pragma region text font color.
+ * @since 7.3
+ */
+ public final static String OUTLINE_MARK_TEXT_COLOR = "org.eclipse.cdt.ui.outline.mark.textcolor"; //$NON-NLS-1$
+
+ /**
+ * The color preference for the C/C++ outline pragma mark or pragma region divider color.
+ * @since 7.3
+ */
+ public final static String OUTLINE_MARK_DIVIDER_COLOR = "org.eclipse.cdt.ui.outline.mark.dividercolor"; //$NON-NLS-1$
+
/**
* A named preference that controls whether the cview's selection is linked to the active
* editor.
@@ -766,6 +784,14 @@ public class PreferenceConstants {
*/
public static final String OUTLINE_LINK_TO_EDITOR = "org.eclipse.cdt.ui.outline.linktoeditor"; //$NON-NLS-1$
+ /**
+ * A named preference that controls whether the Outline view should hide pragma mark directives.
+ *
+ * Value is of type {@code Boolean}.
+ * @since 7.3
+ */
+ public static final String OUTLINE_HIDE_PRAGMA_MARK = "org.eclipse.cdt.ui.outline.hidePragmaMark"; //$NON-NLS-1$
+
/**
* A named preference that controls whether include directives should be grouped in
* the C/C++ Projects view and the Project Explorer view.