Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr committed Jan 8, 2018
2 parents 0197ee5 + fe39dcd commit 7cdc5ac
Show file tree
Hide file tree
Showing 28 changed files with 265 additions and 31 deletions.
1 change: 1 addition & 0 deletions src/Viasfora.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static class Constants {
public const String CSharp = "CSharp";
public const String XLang = "XLANGs";
public const String Css = "CSS";
public const String Fortran = "Fortran";
public const String FSharp = "FSharp";
public const String JS = "JScript";
public const String Json = "JSON";
Expand Down
1 change: 1 addition & 0 deletions src/Viasfora.Core/Guids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class Guids {
public const String CppOptions = "fa1cd8f0-2e7f-455d-bafe-594315674d7e";
public const String JScriptOptions = "f65ed695-72d7-430e-a734-efb5690f9663";
public const String VBOptions = "52787c4e-2f7f-47de-b645-82779f648a04";
public const String FortranOptions = "0fab2139-9de9-48bc-b484-054bc49ffd2e";
public const String FSharpOptions = "4accae10-98db-4b60-9463-26a6ba9313da";
public const String SqlOptions = "ea0d3217-2fed-4fa6-a47a-f88951a799fc";
public const String USqlOptions = "ebacc073-f3ab-40c3-8ffa-869ac0e9b143";
Expand Down
3 changes: 0 additions & 3 deletions src/Viasfora.Core/ReSharper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
Expand Down
8 changes: 3 additions & 5 deletions src/Viasfora.Core/Tags/OutliningGlyphTag.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using Microsoft.VisualStudio.Text.Editor;

namespace Winterdom.Viasfora.Tags
{
public class OutliningGlyphTag : IGlyphTag
{
}
namespace Winterdom.Viasfora.Tags {
public class OutliningGlyphTag : IGlyphTag {
}
}
12 changes: 6 additions & 6 deletions src/Viasfora.Core/Text/TextObfuscation.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
using Winterdom.Viasfora.Tags;
using Microsoft.VisualStudio.Text;
using Winterdom.Viasfora.Util;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Classification;

namespace Winterdom.Viasfora.Text {
[Export(typeof(IViewTaggerProvider))]
Expand Down
3 changes: 0 additions & 3 deletions src/Viasfora.Core/Util/ITextChars.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Winterdom.Viasfora.Util {
public interface ITextChars {
Expand Down
3 changes: 0 additions & 3 deletions src/Viasfora.Core/Util/ITokenizer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Winterdom.Viasfora.Util {
public interface ITokenizer {
Expand Down
2 changes: 0 additions & 2 deletions src/Viasfora.Core/VsSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.IO;
using Winterdom.Viasfora.Compatibility;
using Winterdom.Viasfora.Contracts;
using Winterdom.Viasfora.Settings;

namespace Winterdom.Viasfora {
Expand Down
3 changes: 0 additions & 3 deletions src/Viasfora.Core/XLangSupport/FakeContentTypeDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.VisualStudio.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;

namespace Winterdom.Viasfora.XLangSupport {
internal static class FakeContentTypeDefinitions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;

namespace Winterdom.Viasfora.XLangSupport {
[Export(typeof(IWpfTextViewCreationListener))]
Expand Down
76 changes: 76 additions & 0 deletions src/Viasfora.Languages/BraceScanners/FortranBraceScanner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Winterdom.Viasfora.Rainbow;
using Winterdom.Viasfora.Util;

namespace Winterdom.Viasfora.Languages.BraceScanners {
public class FortranBraceScanner : IBraceScanner {
const int stText = 0;
const int stStringSingle = 1;
const int stStringDouble = 2;
private int status = stText;

public string BraceList => "()";

public void Reset(int state) {
this.status = stText;
}

public bool Extract(ITextChars tc, ref CharPos pos) {
while ( !tc.EndOfLine ) {
switch ( this.status ) {
case stStringSingle: ParseStringSingle(tc); break;
case stStringDouble: ParseStringDouble(tc); break;
default:
return ParseText(tc, ref pos);
}
}
return false;
}

private bool ParseText(ITextChars tc, ref CharPos pos) {
while ( !tc.EndOfLine ) {
if ( tc.Char() == '!' ) {
// single line comment
tc.SkipRemainder();
} else if ( tc.Char() == '\'' ) {
this.status = stStringSingle;
tc.Next();
ParseStringSingle(tc);
} else if ( tc.Char() == '"' ) {
this.status = stStringDouble;
tc.Next();
ParseStringDouble(tc);
} else if ( this.BraceList.IndexOf(tc.Char()) >= 0 ) {
pos = new CharPos(tc.Char(), tc.AbsolutePosition);
tc.Next();
return true;
} else {
tc.Next();
}
}
return false;
}

private void ParseStringSingle(ITextChars tc) => ParseString(tc, '\'');
private void ParseStringDouble(ITextChars tc) => ParseString(tc, '"');

private void ParseString(ITextChars tc, char quote) {
while ( !tc.EndOfLine ) {
if ( tc.Char() == quote && tc.NChar() == quote ) {
// double quote, meaning a single literal quote, skip
tc.Skip(2);
} else if ( tc.Char() == quote ) {
tc.Next();
break;
} else {
tc.Next();
}
}
this.status = stText;
}
}
}
39 changes: 39 additions & 0 deletions src/Viasfora.Languages/Fortran.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.ComponentModel.Composition;
using Winterdom.Viasfora.Contracts;
using Winterdom.Viasfora.Languages.BraceScanners;
using Winterdom.Viasfora.Rainbow;
using Winterdom.Viasfora.Settings;

namespace Winterdom.Viasfora.Languages {
[Export(typeof(ILanguage))]
public class Fortran : LanguageInfo, ILanguage {
public const String ContentType = "Fortran";
protected override String[] SupportedContentTypes
=> new String[] { ContentType };
public ILanguageSettings Settings { get; private set; }

[ImportingConstructor]
public Fortran(ITypedSettingsStore store) {
this.Settings = new FortranSettings(store);
}

protected override IBraceScanner NewBraceScanner()
=> new FortranBraceScanner();
}

class FortranSettings : LanguageSettings {
protected override String[] ControlFlowDefaults => new String[] {
"if", "then", "end if", "endif", "else", "call", "return",
"do", "end do", "enddo", "while", "select", "end select"
};
protected override String[] LinqDefaults => EMPTY;
protected override String[] VisibilityDefaults => new String[] {
"public", "private"
};

public FortranSettings(ITypedSettingsStore store)
: base (Constants.Fortran, store) {
}
}
}
2 changes: 1 addition & 1 deletion src/Viasfora.Languages/Sql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Sql(ITypedSettingsStore store) {
this.Settings = new SqlSettings(store);
// the SQL classifier will return text spans that include
// trailing spaces (such as "IF ")
this.NormalizationFunction = text => text.Trim();
this.NormalizationFunction = text => text.Trim();
}

protected override IBraceScanner NewBraceScanner()
Expand Down
6 changes: 6 additions & 0 deletions src/Viasfora.Languages/USql.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Classification;
using Winterdom.Viasfora.Contracts;
using Winterdom.Viasfora.Languages.BraceScanners;
using Winterdom.Viasfora.Languages.Sequences;
Expand All @@ -24,9 +25,14 @@ public USql(ITypedSettingsStore store) {
protected override IBraceScanner NewBraceScanner() {
return new USqlBraceScanner();
}

public override IStringScanner NewStringScanner(String classificationName, String text) {
return new CSharpStringScanner(text, classificationName);
}

public override bool IsKeywordClassification(IClassificationType classificationType) {
return classificationType.Classification.EndsWith("keyword", StringComparison.OrdinalIgnoreCase);
}
}

class USqlSettings : LanguageSettings {
Expand Down
2 changes: 2 additions & 0 deletions src/Viasfora.Languages/Viasfora.Languages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<Compile Include="BraceScanners\CSharpBraceScanner.cs" />
<Compile Include="BraceScanners\CssBraceScanner.cs" />
<Compile Include="BraceScanners\DefaultBraceScanner.cs" />
<Compile Include="BraceScanners\FortranBraceScanner.cs" />
<Compile Include="BraceScanners\FSharpBraceScanner.cs" />
<Compile Include="BraceScanners\JScriptBraceScanner.cs" />
<Compile Include="BraceScanners\PsBraceScanner.cs" />
Expand All @@ -159,6 +160,7 @@
<Compile Include="CSharp.cs" />
<Compile Include="Css.cs" />
<Compile Include="DefaultLanguage.cs" />
<Compile Include="Fortran.cs" />
<Compile Include="FSharp.cs" />
<Compile Include="JScript.cs" />
<Compile Include="Json.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/Viasfora.Rainbow/IRainbowSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface IRainbowSettings : IUpdatableSettings {
bool RainbowColorize { get; set; }
long RainbowCtrlTimer { get; set; }
RainbowHighlightMode RainbowHighlightMode { get; set; }
RainbowHighlightKey RainbowHighlightKey { get; set; }
bool RainbowToolTipsEnabled { get; set; }
RainbowColoringMode RainbowColoringMode { get; set; }
void Save();
Expand Down
9 changes: 9 additions & 0 deletions src/Viasfora.Rainbow/RainbowHighlightKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using System.Windows.Input;

namespace Winterdom.Viasfora.Rainbow {
public enum RainbowHighlightKey {
LeftCtrl = (int)Key.LeftCtrl,
RightCtrl = (int)Key.RightCtrl
}
}
2 changes: 1 addition & 1 deletion src/Viasfora.Rainbow/RainbowKeyProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public RainbowKeyProcessor(ITextView textView, IRainbowSettings settings) {
// as a work around.
public override void PreviewKeyDown(KeyEventArgs args) {
ITextView actualView = GetViewFromEvent(args);
if ( args.Key == Key.LeftCtrl ) {
if ( args.Key == (Key)(this.settings.RainbowHighlightKey)) {
if ( timer.IsRunning ) {
if ( timer.Elapsed >= pressTime ) {
timer.Stop();
Expand Down
4 changes: 4 additions & 0 deletions src/Viasfora.Rainbow/Settings/RainbowSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public RainbowHighlightMode RainbowHighlightMode {
get { return this.Store.GetEnum(nameof(RainbowHighlightMode), RainbowHighlightMode.TrackNextScope); }
set { this.Store.SetValue(nameof(RainbowHighlightMode), value); }
}
public RainbowHighlightKey RainbowHighlightKey {
get { return this.Store.GetEnum(nameof(RainbowHighlightKey), RainbowHighlightKey.LeftCtrl); }
set { this.Store.SetValue(nameof(RainbowHighlightKey), value); }
}
public bool RainbowToolTipsEnabled {
get { return this.Store.GetBoolean(nameof(RainbowToolTipsEnabled), true); }
set { this.Store.SetValue(nameof(RainbowToolTipsEnabled), value); }
Expand Down
1 change: 1 addition & 0 deletions src/Viasfora.Rainbow/Viasfora.Rainbow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<Compile Include="BracePos.cs" />
<Compile Include="RainbowColoringMode.cs" />
<Compile Include="PerBraceStacker.cs" />
<Compile Include="RainbowHighlightKey.cs" />
<Compile Include="UnifiedBraceStacker.cs" />
<Compile Include="CharPos.cs" />
<Compile Include="Classifications\RainbowClassifications.cs" />
Expand Down
47 changes: 47 additions & 0 deletions src/Viasfora/Options/FortranOptionsPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using Winterdom.Viasfora.Contracts;

namespace Winterdom.Viasfora.Options {
[Guid(Guids.FortranOptions)]
public class FortranOptionsPage : DialogPage {
private ILanguage language = SettingsContext.GetLanguage(Constants.Fortran);

public override void SaveSettingsToStorage() {
base.SaveSettingsToStorage();
language.Settings.ControlFlow = ControlFlowKeywords.ToArray();
language.Settings.Visibility = VisibilityKeywords.ToArray();
language.Settings.Enabled = Enabled;
language.Settings.Save();
}
public override void LoadSettingsFromStorage() {
base.LoadSettingsFromStorage();
ControlFlowKeywords = language.Settings.ControlFlow.ToList();
VisibilityKeywords = language.Settings.Visibility.ToList();
Enabled = language.Settings.Enabled;
}

[LocDisplayName("Enabled")]
[Description("Enabled or disables all Viasfora features for this language")]
public bool Enabled { get; set; }

[LocDisplayName("Control Flow")]
[Description("Control Flow keywords to highlight")]
[Category("Fortran")]
[Editor(Constants.STRING_COLLECTION_EDITOR, typeof(UITypeEditor))]
[TypeConverter(typeof(Design.StringListConverter))]
public List<String> ControlFlowKeywords { get; set; }

[LocDisplayName("Visibility")]
[Description("Visibility keywords to highlight")]
[Category("Fortran")]
[Editor(Constants.STRING_COLLECTION_EDITOR, typeof(UITypeEditor))]
[TypeConverter(typeof(Design.StringListConverter))]
public List<String> VisibilityKeywords { get; set; }
}
}
7 changes: 7 additions & 0 deletions src/Viasfora/Options/RainbowOptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public override void SaveSettingsToStorage() {
rainbowSettings.RainbowToolTipsEnabled = RainbowToolTipsEnabled;
rainbowSettings.RainbowHighlightMode = RainbowHighlightMode;
rainbowSettings.RainbowColoringMode = RainbowColoringMode;
rainbowSettings.RainbowHighlightKey = RainbowHighlightKey;
rainbowSettings.Save();

colors.Save();
Expand All @@ -32,6 +33,7 @@ public override void LoadSettingsFromStorage() {
RainbowHighlightMode = rainbowSettings.RainbowHighlightMode;
RainbowToolTipsEnabled = rainbowSettings.RainbowToolTipsEnabled;
RainbowColoringMode = rainbowSettings.RainbowColoringMode;
RainbowHighlightKey = rainbowSettings.RainbowHighlightKey;

this.colors = new ClassificationList(new ColorStorage(this.Site));
colors.Load(
Expand Down Expand Up @@ -78,6 +80,11 @@ public int RainbowDepth {
[Category("Rainbow Braces")]
public RainbowHighlightMode RainbowHighlightMode { get; set; }

[LocDisplayName("Rainbow Highlight Key")]
[Description("Controls what key triggers Rainbow Hilights.")]
[Category("Rainbow Braces")]
public RainbowHighlightKey RainbowHighlightKey { get; set; }

[LocDisplayName("Enable Rainbow ToolTips")]
[Description("Show a tooltip highlighting matching braces when you hover the mouse over a rainbow brace")]
[Category("Rainbow Braces")]
Expand Down
Loading

0 comments on commit 7cdc5ac

Please sign in to comment.