TextBox Pattern Highlighting #17077
-
** Edit: I've updated the sample to also include a simple implementation of I recently released a demo for Renderingprotected void RenderHighlightRanges(DrawingContext context, Point origin)
{
if (_highlightRangeCache is null || Highlight is null)
return;
foreach (var range in _highlightRangeCache)
{
var rects = TextLayout.HitTestTextRange(range.Index, range.Length);
using (context.PushTransform(Matrix.CreateTranslation(origin)))
{
foreach (var rect in rects)
{
context.FillRectangle(Highlight, PixelRect.FromRect(rect, 1).ToRect(1));
}
}
}
}
protected override void RenderTextLayout(DrawingContext context, Point origin)
{
RenderHighlightRanges(context, origin);
base.RenderTextLayout(context, origin);
} However, this is not the case for
I'm looking for clues on how to implement this or the scope of an acceptable PR. My current preferred app-side implementation route would be: 1. derive from Exposing some pre/post rendering callbacks would work, too, but aren't really in the style of Avalonia. I could also copy/paste |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You may refer to SyntaxHighlightingTextBox.cs which is currently used by ULogViewer. |
Beta Was this translation helpful? Give feedback.
You may refer to SyntaxHighlightingTextBox.cs which is currently used by ULogViewer.