Hi,
Editor.Document.CurrentSnapshot.GetText() returns the current text where new lines are \n characters rather than the usual \r\n.
Is there a specific reason for this behavior? Is it possible to act on some parameter to restore the usual behavior?
Thanks,
marc.
Using the visual studio,when the mouse over the code folding button,the code including region line will become thick.
look at the attachment.
How to realize for the RadSyntaxEditor?
Hey,
I'm looking to have a RadSyntaxEditor's horizontal scroll bar react to a trackpad or mouse wheel input.
Vertical scrolling works just fine, so I can hide the verticalscrollbar but I need to select the horizontal one to move horizontally.
Is there a way to set it for horizontal as well? Did I miss a setting somewhere?
I tried this solution : Horizontal Scrolling w/ Mouse Wheel/Trackpad in UI for WPF | Telerik Forums but it didn't work for me.
I don't know if it's because this solution is in a window and I'm in an usercontrol.
Thanks in advance !
Hello,
I'm currently using a RadSyntaxEditor for user text inputs. The problem I'm facing happens when a user tries to write anything using an Asian IME, for example the Japanese IME with Hiragana input. Instead of having a predictive text dropdown open at the point of the caret, it opens a little input box in the corner of the screen and the predictive text dropdown opens at that position.
Is there a way to have the predictive text dropdown open at the position of the caret in the SyntaxEditor?
For reference, I have reproduced the issue in the Telerik UI for WPF SDK Samples Browser, the "Custom Language Highlighting" demo and attached the screenshot of the observed behaviour.
Any help would be appreciated, thank you.
Hi,
I'm using the RadSyntaxEditor with the XmlTaggers.
Unfortunately, when I switch from Light theme to Dark theme, the background color change in black but the text don't became white.
So we haven't a lot of contrast between background and text.
I use implicit style :
<ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.SyntaxEditor.xaml"/>
I try to force it : <telerik:RadSyntaxEditor x:Name="SyntaxEditor" Margin="10,10,0,10" telerik:StyleManager.Theme="VisualStudio2013">.
Nothing change. You will find attached two pictures describing the situation.
Oh, and I'm using Telerik 2020.1.115.45.
Regards,
Florian
Hello,
Where can I download this demo source code? Is it available?
Thank you,
Alberto
Hi,
editor.TextFormatDefinitions.AddLast("Brace", new TextFormatDefinition(null, Brushes.Black));
...
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(new ClassificationType("Brace"))));
Nothing special - RadSyntaxEditor and those two lines in WPF. Foreground is working very well - I can highlight any part of my text as I wish. But border and background does not working ... And also unwanted behavior - foreground of other highlighting is reset when I try highlight by background change... Even just border highlighting would be sufficient ... (I want highlight closest braces.)
Update:
Working brace content highlighter:
internal class ExpressionTagger : CSharpTagger
{
const string
openBraces = "([{",
closeBraces = ")]}";
new RadSyntaxEditor Editor => (RadSyntaxEditor)base.Editor;
public ExpressionTagger(RadSyntaxEditor editor) : base(editor)
{
editor.TextFormatDefinitions.AddLast("Class", new TextFormatDefinition(new SolidColorBrush(Color.FromRgb(43, 145, 175))));
editor.TextFormatDefinitions.AddLast("Brace", new TextFormatDefinition(new SolidColorBrush(Color.FromRgb(155, 83, 105))));
AddWord("Field", new ClassificationType("Class"));
AddWord("Custom", new ClassificationType("Class"));
AddWord("Triggers", new ClassificationType("Class"));
StringMatchingRegex = String.Empty; // Nemá smysl, neumí najít co chceme.
editor.CaretPosition.PositionChanged += CaretPosition_PositionChanged;
editor.KeyDown += CaretPosition_PositionChanged;
editor.KeyUp += CaretPosition_PositionChanged;
}
private void CaretPosition_PositionChanged(object sender, EventArgs e)
{
if (Editor.CaretPosition.Index < Document.CurrentSnapshot.Span.End)
{
char currentChar = Document.CurrentSnapshot.GetText(new Span(Editor.CaretPosition.Index, 1))[0];
if (MultilineTags.Any(tag => tag.Tag.ClassificationType.Name == "Brace") ||
(KeyboardModifiers.IsAltDown && (openBraces.Contains(currentChar) || closeBraces.Contains(currentChar))))
{
InvalidateMultilineTags();
}
}
}
protected override void RebuildMultilineTags()
{
base.RebuildMultilineTags();
string text = Editor.Document.CurrentSnapshot.GetText();
foreach (Match literal in Regex.Matches(text, "\"(?:[^\"]|\"{2})*\""))
{
TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(Document.CurrentSnapshot,
new Span(literal.Groups[0].Index, literal.Groups[0].Length));
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(ClassificationTypes.StringLiteral)));
}
if (KeyboardModifiers.IsAltDown)
{
int
startIndex = Editor.CaretPosition.Index,
searchIndex = 1,
closeIndex = 0;
char currentChar = Document.CurrentSnapshot.GetText(new Span(Editor.CaretPosition.Index, 1))[0];
int braceIndex = openBraces.IndexOf(currentChar);
if (braceIndex > -1)
{
char
openBrace = currentChar,
closeBrace = closeBraces[braceIndex];
closeIndex = startIndex + 1;
while (searchIndex > 0 && closeIndex < text.Length)
{
currentChar = text[closeIndex];
if (currentChar == openBrace)
{
searchIndex++;
}
if (currentChar == closeBrace)
{
searchIndex--;
}
closeIndex++;
}
closeIndex--;
currentChar = char.MinValue; // reset
}
braceIndex = closeBraces.IndexOf(currentChar);
if (braceIndex > -1)
{
char
openBrace = openBraces[braceIndex],
closeBrace = currentChar;
closeIndex = startIndex;
startIndex--;
while (searchIndex > 0 && startIndex > 0)
{
currentChar = text[startIndex];
if (currentChar == closeBrace)
{
searchIndex++;
}
if (currentChar == openBrace)
{
searchIndex--;
}
startIndex--;
}
startIndex++;
}
if (searchIndex == 0) // Found
{
TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(Document.CurrentSnapshot,
new Span(startIndex, closeIndex - startIndex + 1));
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(new ClassificationType("Brace"))));
}
}
}
}
Hi,
I'm currently trying to use RadSyntaxEditor in my solution but I cannot use my mouse to select a position in it.
I've got a TabControlItem containing some DockPanel. Most of them are TextBlock (Label) + TextBox (Value) or TextBlock (Label) + ComboBox (value) and the last is composed of a TextBlock (Still Label) and a RadSyntaxEditor.
It contains a TextDocument and use xmlTaggers.
Everything works except that I cannot click inside to select a position. I only can double-click to select a block of text and move it.
If I use mouse click inside or outside, the only way to go back inside is to use Tab to switch accross all other control...
When I'm inside, I can write, add tabulation, click enter, everything ! but only with keyboard. One click with the mouse and I have to use Tab to get back in.
Can you help me to resolve this ?