public IDisposable StartStyle(SyntaxStyle style, object context) { IDisposable disposeAction = null; switch (style) { case SyntaxStyle.Added: disposeAction = WriteColor("green"); break; case SyntaxStyle.Removed: string extraStyle = this.StrikeOutRemoved ? " text-decoration:line-through;" : ""; disposeAction = WriteColor("red", extraStyle); break; case SyntaxStyle.InheritedMember: case SyntaxStyle.InterfaceMember: case SyntaxStyle.Comment: disposeAction = WriteColor("gray"); break; case SyntaxStyle.NotCompatible: disposeAction = WriteBackground("yellow", context); break; default: throw new NotSupportedException("Style not supported!"); } Contract.Assert(disposeAction != null); return new DisposeAction(() => disposeAction.Dispose()); }
public IDisposable StartStyle(SyntaxStyle style, object context) { var convertedStyle = ConvertStyle(style); _styleStack.Push(convertedStyle); return(new DisposeAction(() => _styleStack.Pop())); }
public IDisposable StartStyle(SyntaxStyle style, object context) { IDisposable disposeAction = null; switch (style) { case SyntaxStyle.Added: disposeAction = WriteColor("green"); break; case SyntaxStyle.Removed: string extraStyle = this.StrikeOutRemoved ? " text-decoration:line-through;" : ""; disposeAction = WriteColor("red", extraStyle); break; case SyntaxStyle.InheritedMember: case SyntaxStyle.InterfaceMember: case SyntaxStyle.Comment: disposeAction = WriteColor("gray"); break; case SyntaxStyle.NotCompatible: disposeAction = WriteBackground("yellow", context); break; default: throw new NotSupportedException("Style not supported!"); } Contract.Assert(disposeAction != null); return(new DisposeAction(() => disposeAction.Dispose())); }
public IDisposable StartStyle(SyntaxStyle style, object context) { IDisposable disposeAction = null; switch (style) { case SyntaxStyle.Added: disposeAction = WriteVersion("2"); break; case SyntaxStyle.Removed: disposeAction = WriteVersion("1"); break; case SyntaxStyle.InterfaceMember: case SyntaxStyle.InheritedMember: case SyntaxStyle.Comment: disposeAction = null; break; case SyntaxStyle.NotCompatible: disposeAction = null; break; default: throw new NotSupportedException("Style not supported!"); } if (disposeAction == null) { return(new DisposeAction(() => { })); } return(new DisposeAction(() => disposeAction.Dispose())); }
public IDisposable StartStyle(SyntaxStyle style, object context) { IDisposable disposeAction = null; switch (style) { case SyntaxStyle.Added: disposeAction = WriteVersion("2"); break; case SyntaxStyle.Removed: disposeAction = WriteVersion("1"); break; case SyntaxStyle.InterfaceMember: case SyntaxStyle.InheritedMember: case SyntaxStyle.Comment: disposeAction = null; break; case SyntaxStyle.NotCompatible: disposeAction = null; break; default: throw new NotSupportedException("Style not supported!"); } if (disposeAction == null) return new DisposeAction(() => { }); return new DisposeAction(() => disposeAction.Dispose()); }
public IDisposable StartStyle(SyntaxStyle style, object context) { IDisposable disposeAction = null; switch (style) { case SyntaxStyle.Added: disposeAction = _styles.SetColor("green"); break; case SyntaxStyle.Removed: disposeAction = _styles.SetColor("red"); break; case SyntaxStyle.InheritedMember: case SyntaxStyle.InterfaceMember: case SyntaxStyle.Comment: disposeAction = _styles.SetColor("gray"); break; case SyntaxStyle.NotCompatible: disposeAction = _styles.SetBgColor("yellow"); break; default: throw new NotSupportedException("Style not supported!"); } Contract.Assert(disposeAction != null); return new DisposeAction(() => disposeAction.Dispose()); }
public IDisposable StartStyle(SyntaxStyle style, object context) { IDisposable disposeAction = null; switch (style) { case SyntaxStyle.Added: disposeAction = _styles.SetColor("green"); break; case SyntaxStyle.Removed: disposeAction = _styles.SetColor("red"); break; case SyntaxStyle.InheritedMember: case SyntaxStyle.InterfaceMember: case SyntaxStyle.Comment: disposeAction = _styles.SetColor("gray"); break; case SyntaxStyle.NotCompatible: disposeAction = _styles.SetBgColor("yellow"); break; default: throw new NotSupportedException("Style not supported!"); } Contract.Assert(disposeAction != null); return(new DisposeAction(() => disposeAction.Dispose())); }
public void SaveConfig(string path, bool stylesOnly = false) { path = path ?? ConfigPath; try { var d = Path.GetDirectoryName(path); if (Directory.Exists(d) == false) { Directory.CreateDirectory(d); } object o; if (stylesOnly) { o = new { Version = CurrentVersion, Styles = GetCustomizedStyles() }; } else { o = this; Version = CurrentVersion; Styles = GetCustomizedStyles().ToList(); } File.WriteAllText(path, JsonConvert.SerializeObject( o, Formatting.Indented, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, NullValueHandling = NullValueHandling.Ignore, Converters = { new Newtonsoft.Json.Converters.StringEnumConverter() } })); if (path == ConfigPath) { _LastSaved = _LastLoaded = DateTime.Now; //_ConfigManager?.MarkVersioned(); Debug.WriteLine("Config saved"); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } finally { Styles = null; } IEnumerable <SyntaxStyle> GetCustomizedStyles() { return(FormatStore.GetStyles() .Where(i => i.Value?.IsSet == true) .Select(i => { var s = new SyntaxStyle(i.Key); i.Value.CopyTo(s); return s; })); } }
public static StyleBase GetOrCreateStyle(IClassificationType classificationType) { var c = classificationType.Classification; lock (_syncRoot) { if (_SyntaxStyleCache.TryGetValue(c, out var r)) { return(r); } else { r = new SyntaxStyle(c); _SyntaxStyleCache.Add(c, r); return(r); } } }
private static DiffStyle ConvertStyle(SyntaxStyle style) { switch (style) { case SyntaxStyle.Added: return(DiffStyle.Added); case SyntaxStyle.Removed: return(DiffStyle.Removed); case SyntaxStyle.InterfaceMember: return(DiffStyle.InterfaceMember); case SyntaxStyle.InheritedMember: return(DiffStyle.InheritedMember); case SyntaxStyle.NotCompatible: return(DiffStyle.NotCompatible); default: throw new ArgumentOutOfRangeException("style"); } }
public static IDisposable StartStyle(this IStyleSyntaxWriter writer, SyntaxStyle style) { return writer.StartStyle(style, null); }
public IDisposable StartStyle(SyntaxStyle style, object context) { _currentStyle = style; return new DisposeAction(() => { }); }
public static IDisposable StartStyle(this IStyleSyntaxWriter writer, SyntaxStyle style) { return(writer.StartStyle(style, null)); }
public IDisposable StartStyle(SyntaxStyle style, object context) { _currentStyle = style; return(new DisposeAction(() => { })); }