Browse Source

Improve selected-text highlighting in the decompiler view

Ports icsharpcode/ILSpy#2938. Selected text kept the run's syntax colours by leaving the AvaloniaEdit TextArea SelectionForeground unset, and the selection is drawn as a flat, translucent highlight (square corners) rather than an opaque recolour. The brush is theme-aware -- #007ACC at 30% on the light editor background, a brighter #3794FF at 35% so it still reads on the dark one.
pull/3755/head
Siegfried Pammer 1 month ago
parent
commit
85965d05dc
  1. 6
      ILSpy/App.axaml
  2. 11
      ILSpy/TextView/DecompilerTextView.axaml

6
ILSpy/App.axaml

@ -38,6 +38,9 @@ @@ -38,6 +38,9 @@
surfaces a reader spends most time looking at. -->
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ILSpy.EditorBackground" Color="#FFFFE1" />
<!-- Translucent selection so selected text keeps its syntax colours (the
TextArea style leaves SelectionForeground unset). -->
<SolidColorBrush x:Key="ILSpy.EditorSelectionBrush" Color="#007ACC" Opacity="0.3" />
<SolidColorBrush x:Key="ILSpy.EditorWaitAdornerBackground" Color="#80FFFFFF" />
<SolidColorBrush x:Key="ILSpy.ToolbarBackground" Color="White" />
<SolidColorBrush x:Key="ILSpy.ToolbarBorder" Color="#FFA9B0B7" />
@ -86,6 +89,9 @@ @@ -86,6 +89,9 @@
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ILSpy.EditorBackground" Color="#1E1E1E" />
<!-- Brighter, slightly stronger so the translucent selection still reads on the
dark editor background. -->
<SolidColorBrush x:Key="ILSpy.EditorSelectionBrush" Color="#3794FF" Opacity="0.35" />
<SolidColorBrush x:Key="ILSpy.EditorWaitAdornerBackground" Color="#A0000000" />
<SolidColorBrush x:Key="ILSpy.ToolbarBackground" Color="#2D2D30" />
<SolidColorBrush x:Key="ILSpy.ToolbarBorder" Color="#3F3F46" />

11
ILSpy/TextView/DecompilerTextView.axaml

@ -3,12 +3,23 @@ @@ -3,12 +3,23 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ae="using:AvaloniaEdit"
xmlns:aeediting="using:AvaloniaEdit.Editing"
xmlns:textView="using:ILSpy.TextView"
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="400"
Name="self"
x:Class="ILSpy.TextView.DecompilerTextView"
x:DataType="textView:DecompilerTabPageModel">
<!-- Selected-text highlighting (ports icsharpcode/ILSpy#2938): keep the syntax colours of
selected text by leaving SelectionForeground unset, and draw a flat, translucent
highlight (square corners, no border) instead of recolouring the run. -->
<UserControl.Styles>
<Style Selector="aeediting|TextArea">
<Setter Property="SelectionCornerRadius" Value="0" />
<Setter Property="SelectionBrush" Value="{DynamicResource ILSpy.EditorSelectionBrush}" />
</Style>
</UserControl.Styles>
<!-- Wait-adorner: a translucent overlay above the editor with a centred title +
progress bar + cancel button while a decompilation is in flight. -->
<Grid>

Loading…
Cancel
Save