Collapsed #region

SyntaxEditor for WPF Forum

Posted 6 years ago by Horst Noll
Version: 17.2.0661
Avatar

Hi,

how can display a text instead of "..." when I collapse a region?

For example...

#region BlockA
{code}
#endregion

shall look like when its collapsed

BlockA

 and not "..."

Thanks in advance.

Regards...

Comments (2)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Our .NET Languages Add-on does region text like this in a custom OutliningNodeDefinition:

public override object GetCollapsedContent(IOutliningNode node) {
	if (node != null) {
		// Get the node's snapshot range
		TextSnapshotRange snapshotRange = node.SnapshotRange;
			
		// Get the end offset of the start line
		int lineEndOffset = snapshotRange.StartLine.EndOffset;

		// Get the start line's text
		string text = snapshotRange.Snapshot.GetSubstring(new TextRange(snapshotRange.StartOffset, Math.Min(snapshotRange.EndOffset, lineEndOffset)));

		// If the text starts with '#region'...
		if (text.StartsWith("#region", StringComparison.OrdinalIgnoreCase)) {
			// If there is any non-whitespace text remaining, use that
			text = text.Substring("#region".Length).Trim();
			if (!string.IsNullOrEmpty(text))
				return text;
		}
	}

	// Fallback to default
	return base.GetCollapsedContent(node);
}


Actipro Software Support

Posted 6 years ago by Horst Noll
Avatar

This worked like a charm.

Thanks a lot.

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.