Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr committed Dec 14, 2017
2 parents d54435c + e7c8f28 commit 0197ee5
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 50 deletions.
5 changes: 4 additions & 1 deletion Viasfora.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.25824.0
VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1038A55E-607B-4449-924E-1861530C2C56}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -76,4 +76,7 @@ Global
{3274163B-E647-40E2-8D9F-6DF7E7C50411} = {567EF174-A312-43D2-9955-2396CEA9E6DA}
{944758A5-90A4-4DE7-8EF6-4FB2E7F4EFB3} = {567EF174-A312-43D2-9955-2396CEA9E6DA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A9497739-5303-4008-905D-EDFF9FC38583}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public static class CodeClassificationDefinitions {
[Export, Name(Constants.STRING_ESCAPE_CLASSIF_NAME)]
internal static ClassificationTypeDefinition StringEscapeSequenceClassificationType = null;

[Export, Name(Constants.STRING_ESCAPE_ERROR_NAME)]
internal static ClassificationTypeDefinition StringEscapeSequenceErrorClassificationType = null;

[Export, Name(Constants.FORMAT_SPECIFIER_NAME)]
internal static ClassificationTypeDefinition FormatSpecifierClassificationType = null;

Expand Down
2 changes: 2 additions & 0 deletions src/Viasfora.Core/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ public static class CommonExtensions {
public static bool Has<T>(this IPropertyOwner owner) {
return owner.Properties.ContainsProperty(typeof(T));
}

public static T Get<T>(this IPropertyOwner owner) where T : class {
T t;
if ( owner.Properties.TryGetProperty(typeof(T), out t) ) {
return t;
}
return null;
}

public static void Set<T>(this IPropertyOwner owner, T value) {
owner.Properties.AddProperty(typeof(T), value);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Viasfora.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public static class Constants {
public const String LINQ_CLASSIF_NAME = "viasfora.keyword.linq";
public const String VISIBILITY_CLASSIF_NAME = "viasfora.keyword.visibility";
public const String STRING_ESCAPE_CLASSIF_NAME = "viasfora.string.escape_sequence";
public const String STRING_ESCAPE_ERROR_NAME = "viasfora.string.escape_sequence.error";
public const String FORMAT_SPECIFIER_NAME = "viasfora.string.format.specifier";
public const String LINE_HIGHLIGHT = "viasfora.line.current";
public const String COLUMN_HIGHLIGHT = "viasfora.column.current";
Expand All @@ -15,6 +16,7 @@ public static class Constants {

public const String STRING_COLLECTION_EDITOR = "System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
public static int S_OK = 0;
public static int E_NOTIMPL = unchecked((int)0x80004001);

// Languages
public const String Cpp = "Cpp";
Expand Down
19 changes: 19 additions & 0 deletions src/Viasfora.Core/EditorFormats/StringEscapeSequenceErrorFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.ComponentModel.Composition;
using System.Windows.Media;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;

namespace Winterdom.Viasfora.EditorFormats {
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = Constants.STRING_ESCAPE_ERROR_NAME)]
[Name(Constants.STRING_ESCAPE_ERROR_NAME)]
[UserVisible(true)]
[Order(After = Priority.High)]
public sealed class StringEscapeSequenceErrorFormat : ClassificationFormatDefinition {
public StringEscapeSequenceErrorFormat() {
this.DisplayName = "Viasfora Invalid String Escape Sequence";
this.ForegroundColor = Color.FromRgb(255, 160, 0);
}
}
}
3 changes: 3 additions & 0 deletions src/Viasfora.Core/IVsfSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
namespace Winterdom.Viasfora {
public interface IVsfSettings : IUpdatableSettings {
bool KeywordClassifierEnabled { get; set; }
bool FlowControlKeywordsEnabled { get; set; }
bool VisibilityKeywordsEnabled { get; set; }
bool QueryKeywordsEnabled { get; set; }
bool FlowControlUseItalics { get; set; }
bool EscapeSequencesEnabled { get; set; }

Expand Down
12 changes: 12 additions & 0 deletions src/Viasfora.Core/Settings/VsfSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ public bool KeywordClassifierEnabled {
get { return this.Store.GetBoolean(nameof(KeywordClassifierEnabled), true); }
set { this.Store.SetValue(nameof(KeywordClassifierEnabled), value); }
}
public bool FlowControlKeywordsEnabled {
get { return this.Store.GetBoolean(nameof(FlowControlKeywordsEnabled), true); }
set { this.Store.SetValue(nameof(FlowControlKeywordsEnabled), value); }
}
public bool VisibilityKeywordsEnabled {
get { return this.Store.GetBoolean(nameof(VisibilityKeywordsEnabled), true); }
set { this.Store.SetValue(nameof(VisibilityKeywordsEnabled), value); }
}
public bool QueryKeywordsEnabled {
get { return this.Store.GetBoolean(nameof(QueryKeywordsEnabled), true); }
set { this.Store.SetValue(nameof(QueryKeywordsEnabled), value); }
}
public bool FlowControlUseItalics {
get { return this.Store.GetBoolean(nameof(FlowControlUseItalics), false); }
set { this.Store.SetValue(nameof(FlowControlUseItalics), value); }
Expand Down
11 changes: 8 additions & 3 deletions src/Viasfora.Core/Text/KeywordTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class KeywordTagger : ITagger<KeywordTag>, IDisposable {
private KeywordTag linqClassification;
private KeywordTag visClassification;
private KeywordTag stringEscapeClassification;
private KeywordTag stringEscapeErrorClassification;
private KeywordTag formatSpecClassification;
private ITagAggregator<IClassificationTag> aggregator;
private ILanguageFactory langFactory;
Expand All @@ -35,6 +36,7 @@ internal KeywordTagger(ITextBuffer buffer, KeywordTaggerProvider provider) {
linqClassification = provider.GetTag(Constants.LINQ_CLASSIF_NAME);
visClassification = provider.GetTag(Constants.VISIBILITY_CLASSIF_NAME);
stringEscapeClassification = provider.GetTag(Constants.STRING_ESCAPE_CLASSIF_NAME);
stringEscapeErrorClassification = provider.GetTag(Constants.STRING_ESCAPE_ERROR_NAME);
formatSpecClassification = provider.GetTag(Constants.FORMAT_SPECIFIER_NAME);

this.settings = provider.Settings;
Expand Down Expand Up @@ -154,11 +156,11 @@ void OnSettingsChanged(object sender, EventArgs e) {
private ITagSpan<KeywordTag> IsInterestingKeyword(ILanguage lang, SnapshotSpan cs) {
if ( cs.IsEmpty ) return null;
String text = cs.GetText();
if ( lang.IsControlFlowKeyword(text) ) {
if ( this.settings.FlowControlKeywordsEnabled && lang.IsControlFlowKeyword(text) ) {
return new TagSpan<KeywordTag>(cs, keywordClassification);
} else if ( lang.IsVisibilityKeyword(text) ) {
} else if ( this.settings.VisibilityKeywordsEnabled && lang.IsVisibilityKeyword(text) ) {
return new TagSpan<KeywordTag>(cs, visClassification);
} else if ( lang.IsLinqKeyword(text) ) {
} else if ( this.settings.QueryKeywordsEnabled && lang.IsLinqKeyword(text) ) {
return new TagSpan<KeywordTag>(cs, linqClassification);
}
return null;
Expand All @@ -184,6 +186,9 @@ private IEnumerable<ITagSpan<KeywordTag>> ProcessEscapeSequences(
case StringPartType.FormatSpecifier:
yield return new TagSpan<KeywordTag>(sspan, formatSpecClassification);
break;
case StringPartType.EscapeSequenceError:
yield return new TagSpan<KeywordTag>(sspan, stringEscapeErrorClassification);
break;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Viasfora.Core/TextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public static String GetFileName(ITextBuffer buffer) {
uint formatIndex;
try {
int hr = pff.GetCurFile(out filename, out formatIndex);
// some windows will return E_NOTIMPL
if ( hr == Constants.E_NOTIMPL )
return null;
CheckError(hr, "GetCurFile");
} catch ( NotImplementedException ) {
// Lovely stuff: SecondaryVsTextBuffer will
Expand Down Expand Up @@ -216,4 +219,4 @@ private static void CheckError(int hr, String operation) {
}

}
}
}
5 changes: 4 additions & 1 deletion src/Viasfora.Core/Util/StringPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ private char GetTypeChar() {
return 'E';
case StringPartType.FormatSpecifier:
return 'F';
case StringPartType.EscapeSequenceError:
return 'S';
default:
return 'U';
}
Expand All @@ -57,6 +59,7 @@ private char GetTypeChar() {

public enum StringPartType {
EscapeSequence = 0,
FormatSpecifier = 1
FormatSpecifier = 1,
EscapeSequenceError = 2,
}
}
1 change: 1 addition & 0 deletions src/Viasfora.Core/Viasfora.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<Compile Include="EditorFormats\FormatSpecifierFormat.cs" />
<Compile Include="EditorFormats\LinqKeywordFormat.cs" />
<Compile Include="EditorFormats\ObfuscatedTextFormat.cs" />
<Compile Include="EditorFormats\StringEscapeSequenceErrorFormat.cs" />
<Compile Include="EditorFormats\StringEscapeSequenceFormat.cs" />
<Compile Include="EditorFormats\VisibilityKeywordFormat.cs" />
<Compile Include="Guids.cs" />
Expand Down
7 changes: 6 additions & 1 deletion src/Viasfora.Languages/Sequences/FSharpStringScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public FSharpStringScanner(String theText) {
}

private bool TryParseEscapeSequence(ref StringPart part) {
int start = this.text.Position;
text.Next();
if ( escapeChar.IndexOf(text.Char()) >= 0 ) {
text.Next();
Expand Down Expand Up @@ -73,7 +74,11 @@ private bool TryParseEscapeSequence(ref StringPart part) {
}
text.BackToMark();
}
return false;
// unrecognized sequence, return it as error
text.Next();
int length = text.Position - start;
part = new StringPart(new Span(start, length), StringPartType.EscapeSequenceError);
return true;
}

private Span? TryParseShortUnicode() {
Expand Down
5 changes: 4 additions & 1 deletion src/Viasfora.Rainbow/Util/ToolTipWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public object GetWindow(SnapshotPoint bufferPosition) {
CreateTipView();
}
this.pointToDisplay = bufferPosition;
this.tipView.Set(new ViewTipProperty(bufferPosition));
var viewTipProp = this.tipView.Get<ViewTipProperty>();
viewTipProp.Position = bufferPosition;

return this.wrapper;
}
Expand Down Expand Up @@ -143,6 +144,8 @@ private void CreateTipView() {
this.tipView.ZoomLevel = GetSourceZoomFactor() * ZoomFactor * 100;
this.wrapper = new Border();
this.wrapper.Child = this.tipView.VisualElement;

this.tipView.Set(new ViewTipProperty());
}

private double GetSourceZoomFactor() {
Expand Down
5 changes: 2 additions & 3 deletions src/Viasfora.Rainbow/Util/ViewTipProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

namespace Winterdom.Viasfora.Util {
public class ViewTipProperty {
public SnapshotPoint Position { get; private set; }
public ViewTipProperty(SnapshotPoint position) {
this.Position = position;
public SnapshotPoint Position { get; set; }
public ViewTipProperty() {
}
}
}
25 changes: 22 additions & 3 deletions src/Viasfora/Options/GeneralOptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using Winterdom.Viasfora.Rainbow;
using System.Drawing;
using Winterdom.Viasfora.Text;

Expand All @@ -13,13 +12,15 @@ public class GeneralOptionsPage : DialogPage {

public override void SaveSettingsToStorage() {
var settings = SettingsContext.GetSettings();
var rainbowSettings = SettingsContext.GetService<IRainbowSettings>();

settings.CurrentLineHighlightEnabled = CurrentLineHighlightEnabled;
settings.CurrentColumnHighlightEnabled = CurrentColumnHighlightEnabled;
settings.CurrentColumnHighlightStyle = CurrentColumnHighlightStyle;
settings.HighlightLineWidth = HighlightLineWidth;
settings.KeywordClassifierEnabled = KeywordClassifierEnabled;
settings.FlowControlKeywordsEnabled = FlowControlKeywordsEnabled;
settings.VisibilityKeywordsEnabled = VisibilityKeywordsEnabled;
settings.QueryKeywordsEnabled = QueryKeywordsEnabled;
settings.FlowControlUseItalics = FlowControlUseItalics;
settings.EscapeSequencesEnabled = EscapeSeqHighlightEnabled;
settings.DeveloperMarginEnabled = DevMarginEnabled;
Expand All @@ -40,6 +41,9 @@ public override void LoadSettingsFromStorage() {
CurrentColumnHighlightStyle = settings.CurrentColumnHighlightStyle;
highlightLineWidth = settings.HighlightLineWidth;
KeywordClassifierEnabled = settings.KeywordClassifierEnabled;
FlowControlKeywordsEnabled = settings.FlowControlKeywordsEnabled;
VisibilityKeywordsEnabled = settings.VisibilityKeywordsEnabled;
QueryKeywordsEnabled = settings.QueryKeywordsEnabled;
FlowControlUseItalics = settings.FlowControlUseItalics;
EscapeSeqHighlightEnabled = settings.EscapeSequencesEnabled;
DevMarginEnabled = settings.DeveloperMarginEnabled;
Expand Down Expand Up @@ -80,10 +84,25 @@ public override void LoadSettingsFromStorage() {

// Text Editor Extensions
[LocDisplayName("Enable Keyword Classifier")]
[Description("Enable custom keyword highlighting for C#, CPP and JS")]
[Description("Enable custom keyword highlighting for all languages")]
[Category("Keyword Highlight")]
public bool KeywordClassifierEnabled { get; set; }

[LocDisplayName("Enable Flow Control Keywords")]
[Description("Enable custom keyword highlighting for all languages")]
[Category("Keyword Highlight")]
public bool FlowControlKeywordsEnabled { get; set; }

[LocDisplayName("Enable Visibility Keywords")]
[Description("Enable custom keyword highlighting for all languages")]
[Category("Keyword Highlight")]
public bool VisibilityKeywordsEnabled { get; set; }

[LocDisplayName("Enable Query Keywords")]
[Description("Enable custom keyword highlighting for all languages")]
[Category("Keyword Highlight")]
public bool QueryKeywordsEnabled { get; set; }

[LocDisplayName("Use italics on Flow Control Keywords")]
[Description("Use italics on text highlighted by the Keyword Classifier")]
[Category("Text Editor")]
Expand Down
70 changes: 35 additions & 35 deletions src/Viasfora/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
<PackageManifest Version="2.0.0"
xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011"
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="Winterdom.Viasfora.f7a33795-2b40-4125-856c-89b0bd8cd5ab"
Version="3.6"
Language="en-US"
Publisher="Tomas Restrepo" />
<DisplayName>Viasfora</DisplayName>
<Description>Add color to your Visual Studio Text Editor!</Description>
<MoreInfo>http://viasfora.com/</MoreInfo>
<License>license.txt</License>
<Icon>viasfora-icon.png</Icon>
<PreviewImage>viasfora-preview.png</PreviewImage>
<Tags >rainbow braces, text editor, xml editor, colorization, outlining</Tags>
</Metadata>
<Installation>
<InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Community" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Pro" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.IntegratedShell" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Ultimate" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Premium" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Languages" Path="|Viasfora.Languages|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Core" Path="|Viasfora.Core|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Xml" Path="|Viasfora.Xml|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Rainbow" Path="|Viasfora.Rainbow|" />
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,16.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Metadata>
<Identity Id="Winterdom.Viasfora.f7a33795-2b40-4125-856c-89b0bd8cd5ab"
Version="3.7"
Language="en-US"
Publisher="Tomas Restrepo" />
<DisplayName>Viasfora</DisplayName>
<Description xml:space="preserve">Add color to your Visual Studio Text Editor!</Description>
<MoreInfo>http://viasfora.com/</MoreInfo>
<License>license.txt</License>
<Icon>viasfora-icon.png</Icon>
<PreviewImage>viasfora-preview.png</PreviewImage>
<Tags >rainbow braces, text editor, xml editor, colorization, outlining</Tags>
</Metadata>
<Installation>
<InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Community" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Pro" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.IntegratedShell" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Ultimate" />
<InstallationTarget Version="[11.0,16.0)" Id="Microsoft.VisualStudio.Premium" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Languages" Path="|Viasfora.Languages|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Core" Path="|Viasfora.Core|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Xml" Path="|Viasfora.Xml|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Viasfora.Rainbow" Path="|Viasfora.Rainbow|" />
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,16.0)" DisplayName="Visual Studio core editor" />
</Prerequisites>
</PackageManifest>
Loading

0 comments on commit 0197ee5

Please sign in to comment.