internal static TmSnippet ReadSnippet(Stream stream) { var dict = PDictionary.FromStream(stream); string name = null; string content = null; string tabTrigger = null; var scopes = new List <StackMatchExpression> (); PObject val; if (dict.TryGetValue("name", out val)) { name = ((PString)val).Value; } if (dict.TryGetValue("content", out val)) { content = ((PString)val).Value; } if (dict.TryGetValue("tabTrigger", out val)) { tabTrigger = ((PString)val).Value; } if (dict.TryGetValue("scope", out val)) { foreach (var scope in ((PString)val).Value.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { scopes.Add(StackMatchExpression.Parse(scope)); } } return(new TmSnippet(name, scopes, content, tabTrigger)); }
public static EditorTheme LoadEditorTheme(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var dictionary = PDictionary.FromStream(stream); var name = (PString)dictionary ["name"]; var contentArray = dictionary ["settings"] as PArray; if (contentArray == null || contentArray.Count == 0) { return(new EditorTheme(name)); } var settings = new List <ThemeSetting> (); for (int i = 0; i < contentArray.Count; i++) { var dict = contentArray [i] as PDictionary; if (dict == null) { continue; } var themeSetting = LoadThemeSetting(dict); if (i == 0) { themeSetting = CalculateMissingDefaultColors(themeSetting); } settings.Add(themeSetting); } var uuid = (PString)dictionary ["uuid"]; var methodDecl = GetSetting(settings, EditorThemeColors.UserMethodDeclaration); var methodUsage = GetSetting(settings, EditorThemeColors.UserMethodUsage); if (methodUsage == null && methodDecl != null) { settings.Add(new ThemeSetting( "User Method(Usage)", new List <string> { EditorThemeColors.UserMethodUsage }, settings [0].Settings )); } ConvertSetting(settings, "storage.type", EditorThemeColors.UserTypesInterfaces); ConvertSetting(settings, "entity.name", EditorThemeColors.UserTypes); ConvertSetting(settings, "entity.name", EditorThemeColors.UserTypesEnums); ConvertSetting(settings, "entity.name", EditorThemeColors.UserTypesMutable); ConvertSetting(settings, "entity.name", EditorThemeColors.UserTypesDelegates); ConvertSetting(settings, "entity.name", EditorThemeColors.UserTypesValueTypes); ConvertSetting(settings, "entity.name", EditorThemeColors.UserTypesTypeParameters); ConvertSetting(settings, "support.constant", "markup.other"); ConvertSetting(settings, "constant.character", "meta.preprocessor"); settings.Add(new ThemeSetting("", new List <string> { "meta.preprocessor.region.name" }, settings [0].Settings)); // set all remaining semantic colors to default. var semanticColors = new [] { EditorThemeColors.UserTypes, EditorThemeColors.UserTypesValueTypes, EditorThemeColors.UserTypesInterfaces, EditorThemeColors.UserTypesEnums, EditorThemeColors.UserTypesTypeParameters, EditorThemeColors.UserTypesDelegates, EditorThemeColors.UserTypesMutable, EditorThemeColors.UserFieldDeclaration, EditorThemeColors.UserFieldUsage, EditorThemeColors.UserPropertyDeclaration, EditorThemeColors.UserPropertyUsage, EditorThemeColors.UserEventDeclaration, EditorThemeColors.UserEventUsage, EditorThemeColors.UserMethodDeclaration, EditorThemeColors.UserMethodUsage, EditorThemeColors.UserParameterDeclaration, EditorThemeColors.UserParameterUsage, EditorThemeColors.UserVariableDeclaration, EditorThemeColors.UserVariableUsage }; foreach (var semanticColor in semanticColors) { if (GetSetting(settings, semanticColor) == null) { settings.Add(new ThemeSetting("", new List <string> { semanticColor }, settings [0].Settings)); } } return(new EditorTheme(name, settings, uuid)); }
internal static SyntaxHighlightingDefinition ReadHighlighting(Stream stream) { var dictionary = PDictionary.FromStream(stream); return(ReadHighlighting(dictionary)); }
internal static TmSetting ReadPreferences(Stream stream) { var dict = PDictionary.FromStream(stream); return(ReadPreferences(dict)); }