Changeset 2121
- Timestamp:
- Nov 30, 2012, 12:13:59 AM (11 years ago)
- Location:
- trunk/tools/vslol
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/vslol/CppKeywordClassifier.cs
r2120 r2121 7 7 using Microsoft.VisualStudio.Text; 8 8 using Microsoft.VisualStudio.Text.Classification; 9 using Microsoft.VisualStudio.Text.Formatting; 9 10 using Microsoft.VisualStudio.Language.StandardClassification; 10 11 using Microsoft.VisualStudio.Utilities; … … 19 20 { 20 21 [Import] 21 internal IClassificationTypeRegistryService m_ class_registry = null; /* Set via MEF */22 internal IClassificationTypeRegistryService m_type_registry = null; /* Set via MEF */ 22 23 23 //[Import]24 //internal IClassificationFormatMapService m_lol= null;24 [Import] 25 internal IClassificationFormatMapService m_format_map = null; 25 26 26 27 public IClassifier GetClassifier(ITextBuffer buffer) 27 28 { 28 //var test = m_lol.GetClassificationFormatMap("Text Editor"); 29 //string[] foo = { "Comment", "Keyword", "C/C++ User Keywords", "Call Return", "HTML Comment" }; 30 //foreach (var s in foo) 31 //{ 32 // var type = m_class_registry.GetClassificationType(s); 33 // if (type == null) 34 // continue; 35 // var prop = test.GetExplicitTextProperties(type); 36 // if (prop == null) 37 // continue; 38 // var c1 = prop.ForegroundBrush as SolidColorBrush; 39 // var c2 = prop.BackgroundBrush as SolidColorBrush; 40 // Logger.Info("[" + s + "]: " + c1.ToString() + " " + c2.ToString() + "\n"); 41 //} 29 LolGenericFormat.SetRegistry(m_type_registry, m_format_map); 42 30 43 return buffer.Properties.GetOrCreateSingletonProperty<CppKeywordClassifier>(delegate { return new CppKeywordClassifier(m_ class_registry, buffer.ContentType); });31 return buffer.Properties.GetOrCreateSingletonProperty<CppKeywordClassifier>(delegate { return new CppKeywordClassifier(m_type_registry, buffer.ContentType); }); 44 32 } 45 33 } … … 61 49 tmp += "attribute|varying|uniform|in|out|"; 62 50 if (type.IsOfType("csharp")) 63 tmp += "var|string|internal|sealed|public|private| ";51 tmp += "var|string|internal|sealed|public|private|protected|"; 64 52 if (!type.IsOfType("csharp")) 65 53 tmp += "(f(16|128)||d|[ui](8|16||64)|r)(vec[234]|mat[234]|quat|cmplx)|"; … … 92 80 } 93 81 82 internal class LolGenericFormat : ClassificationFormatDefinition 83 { 84 static IClassificationTypeRegistryService m_type_registry; 85 static IClassificationFormatMapService m_format_map; 86 87 public static void SetRegistry(IClassificationTypeRegistryService type_registry, 88 IClassificationFormatMapService format_map) 89 { 90 m_type_registry = type_registry; 91 m_format_map = format_map; 92 } 93 94 protected void CopyStyleColor(string category) 95 { 96 if (m_type_registry == null || m_format_map == null) 97 return; 98 99 var map = m_format_map.GetClassificationFormatMap("Text Editor"); 100 if (map == null) 101 return; 102 103 //string[] foo = { "Comment", "Keyword", "C/C++ User Keywords", "Call Return", "HTML Comment" , "User Types", "User Types (Type parameters)", "User Types (Value types)"}; 104 105 var type = m_type_registry.GetClassificationType(category); 106 if (type == null) 107 return; 108 109 var prop = map.GetExplicitTextProperties(type); 110 if (prop == null) 111 return; 112 113 var c1 = prop.ForegroundBrush as SolidColorBrush; 114 if (c1 != null && c1.Color != Colors.Transparent) 115 this.ForegroundColor = c1.Color; 116 var c2 = prop.BackgroundBrush as SolidColorBrush; 117 if (c2 != null && c2.Color != Colors.Transparent) 118 this.BackgroundColor = c1.Color; 119 } 120 } 121 94 122 internal static class LolClassifierClassificationDefinition 95 123 { … … 104 132 [UserVisible(true)] 105 133 [Order(After = Priority.Default)] /* Override the Visual Studio classifiers */ 106 internal sealed class LolCppTypeFormat : ClassificationFormatDefinition134 internal sealed class LolCppTypeFormat : LolGenericFormat 107 135 { 108 136 public const string m_name = "LolCustomClass"; … … 110 138 { 111 139 this.DisplayName = "C/C++ Types and Qualifiers"; 112 //this.BackgroundColor = Colors.BlueViolet;113 140 this.ForegroundColor = Colors.Lime; 114 141 this.IsBold = true; 115 // this.TextDecorations = System.Windows.TextDecorations.Underline;142 //CopyStyleColor("User Types"); 116 143 } 117 144 } -
trunk/tools/vslol/source.extension.vsixmanifest
r2119 r2121 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Vsix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010"> 3 <Identifier Id="VsLol .Sample">3 <Identifier Id="VsLol"> 4 4 <Name>VsLol</Name> 5 5 <Author>Lol</Author>
Note: See TracChangeset
for help on using the changeset viewer.