public static HslColor GetColorFromScope(EditorTheme style, string scope, string key) { HslColor result; if (!style.TryGetColor(scope, key, out result)) { DefaultColorStyle.TryGetColor(scope, key, out result); } return(result); }
public static bool FitsIdeTheme(this EditorTheme editorTheme, Theme theme) { Components.HslColor bgColor; editorTheme.TryGetColor(EditorThemeColors.Background, out bgColor); if (theme == Theme.Dark) { return(bgColor.L <= 0.5); } return(bgColor.L > 0.5); }
public void Remove(EditorTheme style) { for (int i = 0; i < editorThemes.Count; i++) { if (style == editorThemes [i]) { editorThemes.RemoveAt(i); break; } } }
internal static bool IsSettingMatch(ScopeStack scopes, StackMatchExpression expr) { string cs = null; int d = 0; if (EditorTheme.IsCompatibleScope(expr, scopes, ref cs, ref d)) { return(true); } return(false); }
public static EditorTheme GetIdeFittingTheme(EditorTheme userTheme = null) { try { if (userTheme == null || !userTheme.FitsIdeTheme(Ide.IdeApp.Preferences.UserInterfaceTheme)) { return(GetDefaultColorStyle(Ide.IdeApp.Preferences.UserInterfaceTheme)); } } catch (Exception e) { LoggingService.LogError("Error while getting the color style : " + Ide.IdeApp.Preferences.ColorScheme + " in ide theme : " + Ide.IdeApp.Preferences.UserInterfaceTheme, e); } return(userTheme); }
internal static ChunkStyle GetChunkStyle(EditorTheme style, string key) { HslColor result; if (!style.TryGetColor(key, out result)) { DefaultColorStyle.TryGetColor(key, out result); } return(new ChunkStyle() { Foreground = result }); }
static ThemeSetting GetSetting(List <ThemeSetting> settings, string scope, bool exact = true) { ThemeSetting result = null; string cs = null; int d = 0; var stack = new ScopeStack(scope); foreach (var s in settings.Skip(1)) { if (s.Scopes.Any(a => EditorTheme.IsCompatibleScope(a, stack, ref cs, ref d))) { result = s; } } return(result); }
public EditorTheme GetEditorTheme() { if (theme != null) { return(theme); } try { using (var stream = getStreamProvider().Open()) { theme = LoadTheme(stream); } return(theme); } catch (Exception e) { LoggingService.LogError("Error while loading theme :" + Name, e); return(null); } }
public static void Save(TextWriter writer, EditorTheme theme) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); writer.WriteLine("<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"); writer.WriteLine("<plist version=\"1.0\">"); writer.WriteLine("<dict>"); writer.WriteLine("\t<key>name</key>"); writer.WriteLine("\t<string>" + Ambience.EscapeText(theme.Name) + "</string>"); writer.WriteLine("\t<key>settings</key>"); writer.WriteLine("\t<array>"); foreach (var setting in theme.Settings) { writer.WriteLine("\t\t<dict>"); if (setting.Name != null) { writer.WriteLine("\t\t\t<key>name</key>"); writer.WriteLine("\t\t\t<string>" + Ambience.EscapeText(setting.Name) + "</string>"); } if (setting.Scopes.Count > 0) { writer.WriteLine("\t\t\t<key>scope</key>"); writer.WriteLine("\t\t\t<string>" + Ambience.EscapeText(string.Join(", ", setting.Scopes)) + "</string>"); } if (setting.Settings.Count > 0) { writer.WriteLine("\t\t\t<key>settings</key>"); writer.WriteLine("\t\t\t<dict>"); foreach (var kv in setting.Settings) { writer.WriteLine("\t\t\t\t<key>" + Ambience.EscapeText(kv.Key) + "</key>"); writer.WriteLine("\t\t\t\t<string>" + Ambience.EscapeText(kv.Value) + "</string>"); } writer.WriteLine("\t\t\t</dict>"); } writer.WriteLine("\t\t</dict>"); } writer.WriteLine("\t</array>"); writer.WriteLine("\t<key>uuid</key>"); writer.WriteLine("\t<string>" + theme.Uuid + "</string>"); writer.WriteLine("</dict>"); writer.WriteLine("</plist>"); }
public EditorTheme GetEditorTheme() { if (theme != null) { return(theme); } try { using (var stream = getStreamProvider().Open()) { theme = LoadTheme(stream); } return(theme); } catch (Exception e) { if (faultedThemes.Add(Name)) { MessageService.ShowError(GettextCatalog.GetString("Error while loading theme :" + Name), e); LoggingService.LogError("Error while loading theme :" + Name, e); } return(null); } }
internal static void Remove(EditorTheme style) { userThemeBundle.Remove(style); }
internal static void Remove(EditorTheme style) { InitializeStylesAndModes(); userThemeBundle.Remove(style); }
internal static void Remove(EditorTheme style) { builtInBundle.Remove(style); }
internal static string GenerateRtf(List <List <ClipboardColoredText> > chunks, MonoDevelop.Ide.Editor.Highlighting.EditorTheme style, ITextEditorOptions options) { var rtfText = new StringBuilder(); var colorList = new List <Cairo.Color> (); bool isItalic = false; bool isBold = false; int curColor = -1; foreach (var line in chunks) { bool appendSpace = false; foreach (var chunk in line) { var chunkStyle = style.GetChunkStyle(chunk.ScopeStack); if (isBold != (chunkStyle.FontWeight == Xwt.Drawing.FontWeight.Bold)) { isBold = chunkStyle.FontWeight == Xwt.Drawing.FontWeight.Bold; rtfText.Append(isBold ? @"\b" : @"\b0"); appendSpace = true; } if (isItalic != (chunkStyle.FontStyle == Xwt.Drawing.FontStyle.Italic)) { isItalic = chunkStyle.FontStyle == Xwt.Drawing.FontStyle.Italic; rtfText.Append(isItalic ? @"\i" : @"\i0"); appendSpace = true; } var foreground = chunkStyle.Foreground; if (!colorList.Contains(foreground)) { colorList.Add(foreground); } int color = colorList.IndexOf(foreground); if (curColor != color) { curColor = color; rtfText.Append(@"\cf").Append(curColor + 1); appendSpace = true; } AppendRtfText(rtfText, chunk.Text, ref appendSpace); } rtfText.AppendLine(@"\line"); } var rtf = new StringBuilder(); rtf.AppendLine(@"{\rtf1\ansi\deff0\adeflang1025"); rtf.AppendLine(@"{\fonttbl"); rtf.Append(@"{\f0\fnil\fprq1\fcharset128 ").Append(options.Font.Family).AppendLine(";}"); rtf.AppendLine("}"); rtf.Append(CreateColorTable(colorList)); rtf.AppendLine(@"\viewkind4\uc1\pard"); rtf.AppendLine(@"\f0"); try { string fontName = options.Font.ToString(); double fontSize = Double.Parse(fontName.Substring(fontName.LastIndexOf(' ') + 1), System.Globalization.CultureInfo.InvariantCulture) * 2; rtf.Append(@"\fs"); rtf.Append(fontSize); } catch (Exception) {}; rtf.AppendLine(@"\cf1"); rtf.Append(rtfText.ToString()); rtf.Append("}"); return(rtf.ToString()); }
public void Remove(EditorTheme style) { editorThemes.Remove(style); }
public void Add(EditorTheme theme) { editorThemes.Add(theme); }