Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions VSPackage/Color/Colors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

namespace OpenCppCoverage.VSPackage.VSColor
{
using System;
using Microsoft.VisualStudio.Shell;

internal sealed class VSColors
{
#region Autogenerated resource keys
// These resource keys are generated by Visual Studio Extension Color Editor, and should be replaced when new colors are added to this category.
public static readonly Guid Category = new Guid("77cc3bec-cf72-42fa-8b0c-47e8f1bbbbbd");

private static ThemeResourceKey _CodeCoveredColorKey;
private static ThemeResourceKey _CodeCoveredBrushKey;
public static ThemeResourceKey CodeCoveredColorKey { get { return _CodeCoveredColorKey ?? (_CodeCoveredColorKey = new ThemeResourceKey(Category, "Code Covered", ThemeResourceKeyType.BackgroundColor)); } }
public static ThemeResourceKey CodeCoveredBrushKey { get { return _CodeCoveredBrushKey ?? (_CodeCoveredBrushKey = new ThemeResourceKey(Category, "Code Covered", ThemeResourceKeyType.BackgroundBrush)); } }

private static ThemeResourceKey _CodeNotCoveredColorKey;
private static ThemeResourceKey _CodeNotCoveredBrushKey;
public static ThemeResourceKey CodeNotCoveredColorKey { get { return _CodeNotCoveredColorKey ?? (_CodeNotCoveredColorKey = new ThemeResourceKey(Category, "Code Not Covered", ThemeResourceKeyType.BackgroundColor)); } }
public static ThemeResourceKey CodeNotCoveredBrushKey { get { return _CodeNotCoveredBrushKey ?? (_CodeNotCoveredBrushKey = new ThemeResourceKey(Category, "Code Not Covered", ThemeResourceKeyType.BackgroundBrush)); } }
#endregion
}
}
11 changes: 11 additions & 0 deletions VSPackage/Color/Colors.pkgdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[$RootKey$\Themes\{de3dbbcd-f642-433c-8353-8f1df4370aba}\OpenCppCoverage]
"Data"=hex:50,00,00,00,0b,00,00,00,01,00,00,00,ec,3b,cc,77,72,cf,fa,42,8b,0c,47,e8,f1,bb,bb,bd,02,00,00,00,0c,00,00,00,43,6f,64,65,20,43,6f,76,65,72,65,64,01,ee,ff,c1,ff,00,10,00,00,00,43,6f,64,65,20,4e,6f,74,20,43,6f,76,65,72,65,64,01,ff,da,d2,ff,00

[$RootKey$\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}\OpenCppCoverage]
"Data"=hex:50,00,00,00,0b,00,00,00,01,00,00,00,ec,3b,cc,77,72,cf,fa,42,8b,0c,47,e8,f1,bb,bb,bd,02,00,00,00,0c,00,00,00,43,6f,64,65,20,43,6f,76,65,72,65,64,01,12,52,00,ff,00,10,00,00,00,43,6f,64,65,20,4e,6f,74,20,43,6f,76,65,72,65,64,01,65,10,00,ff,00

[$RootKey$\Themes\{a4d6a176-b948-4b29-8c66-53c97a1ed7d0}\OpenCppCoverage]
"Data"=hex:50,00,00,00,0b,00,00,00,01,00,00,00,ec,3b,cc,77,72,cf,fa,42,8b,0c,47,e8,f1,bb,bb,bd,02,00,00,00,0c,00,00,00,43,6f,64,65,20,43,6f,76,65,72,65,64,01,ee,ff,c1,ff,00,10,00,00,00,43,6f,64,65,20,4e,6f,74,20,43,6f,76,65,72,65,64,01,ff,da,d2,ff,00

[$RootKey$\Themes\{a5c004b4-2d4b-494e-bf01-45fc492522c7}\OpenCppCoverage]
"Data"=hex:50,00,00,00,0b,00,00,00,01,00,00,00,ec,3b,cc,77,72,cf,fa,42,8b,0c,47,e8,f1,bb,bb,bd,02,00,00,00,0c,00,00,00,43,6f,64,65,20,43,6f,76,65,72,65,64,01,80,dc,74,ff,00,10,00,00,00,43,6f,64,65,20,4e,6f,74,20,43,6f,76,65,72,65,64,01,ff,72,57,ff,00
16 changes: 14 additions & 2 deletions VSPackage/CoverageTree/CoverageViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Formatting;
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.PlatformUI;
using OpenCppCoverage.VSPackage.CoverageRateBuilder;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -60,6 +61,8 @@ public void TextViewCreated(IWpfTextView textView)
(sender, e) => OnTextChanged(textView, e);
onTextChangedHanlders.Add(textView, onTextChanged);
textView.TextBuffer.Changed += onTextChanged;

VSColorTheme.ThemeChanged += OnColorThemeChanged;
}

//---------------------------------------------------------------------
Expand Down Expand Up @@ -172,9 +175,11 @@ void AddNewHighlightCoverage(

if (coverage.TryGetValue(lineNumber, out lineCoverage))
{
var color = lineCoverage.HasBeenExecuted ? CoveredBrush : UncoveredBrush;
var color = lineCoverage.HasBeenExecuted ? VSColorTheme.GetThemedColor(VSColor.VSColors.CodeCoveredBrushKey)
: VSColorTheme.GetThemedColor(VSColor.VSColors.CodeNotCoveredBrushKey);
var brush = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, color.B));

AddAdornment(adornmentLayer, textView, line, color);
AddAdornment(adornmentLayer, textView, line, brush);
}
}
}
Expand Down Expand Up @@ -225,5 +230,12 @@ void OnTextChanged(IWpfTextView textView, TextContentChangedEventArgs e)
RemoveHighlight(textView);
}
}

void OnColorThemeChanged(ThemeChangedEventArgs e)
{
this.RemoveHighlightForAllViews();
if (this.showCoverage)
this.AddHighlightCoverageForExistingViews();
}
}
}
6 changes: 5 additions & 1 deletion VSPackage/VSPackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.VCProjectEngine, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
Expand Down Expand Up @@ -147,6 +147,7 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Color\Colors.cs" />
<Compile Include="CommandLineBuilder.cs" />
<Compile Include="ConfigurationManager.cs" />
<Compile Include="CoverageData\CoverageData.cs" />
Expand Down Expand Up @@ -258,6 +259,9 @@
<None Include="Resources\Images.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Color\Colors.pkgdef">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="gpl-3.0.txt">
<IncludeInVSIX>true</IncludeInVSIX>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down