Changeset 2121


Ignore:
Timestamp:
Nov 30, 2012, 12:13:59 AM (11 years ago)
Author:
sam
Message:

vslol: rename package to VsLol instead of VsLol.Sample and refactor
minor stuff.

Location:
trunk/tools/vslol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/vslol/CppKeywordClassifier.cs

    r2120 r2121  
    77using Microsoft.VisualStudio.Text;
    88using Microsoft.VisualStudio.Text.Classification;
     9using Microsoft.VisualStudio.Text.Formatting;
    910using Microsoft.VisualStudio.Language.StandardClassification;
    1011using Microsoft.VisualStudio.Utilities;
     
    1920    {
    2021        [Import]
    21         internal IClassificationTypeRegistryService m_class_registry = null; /* Set via MEF */
     22        internal IClassificationTypeRegistryService m_type_registry = null; /* Set via MEF */
    2223
    23         //[Import]
    24         //internal IClassificationFormatMapService m_lol = null;
     24        [Import]
     25        internal IClassificationFormatMapService m_format_map = null;
    2526
    2627        public IClassifier GetClassifier(ITextBuffer buffer)
    2728        {
    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);
    4230
    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); });
    4432        }
    4533    }
     
    6149                tmp += "attribute|varying|uniform|in|out|";
    6250            if (type.IsOfType("csharp"))
    63                 tmp += "var|string|internal|sealed|public|private|";
     51                tmp += "var|string|internal|sealed|public|private|protected|";
    6452            if (!type.IsOfType("csharp"))
    6553                tmp += "(f(16|128)||d|[ui](8|16||64)|r)(vec[234]|mat[234]|quat|cmplx)|";
     
    9280    }
    9381
     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
    94122    internal static class LolClassifierClassificationDefinition
    95123    {
     
    104132    [UserVisible(true)]
    105133    [Order(After = Priority.Default)] /* Override the Visual Studio classifiers */
    106     internal sealed class LolCppTypeFormat : ClassificationFormatDefinition
     134    internal sealed class LolCppTypeFormat : LolGenericFormat
    107135    {
    108136        public const string m_name = "LolCustomClass";
     
    110138        {
    111139            this.DisplayName = "C/C++ Types and Qualifiers";
    112             //this.BackgroundColor = Colors.BlueViolet;
    113140            this.ForegroundColor = Colors.Lime;
    114141            this.IsBold = true;
    115             //this.TextDecorations = System.Windows.TextDecorations.Underline;
     142            //CopyStyleColor("User Types");
    116143        }
    117144    }
  • trunk/tools/vslol/source.extension.vsixmanifest

    r2119 r2121  
    11<?xml version="1.0" encoding="utf-8"?>
    22<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">
    44    <Name>VsLol</Name>
    55    <Author>Lol</Author>
Note: See TracChangeset for help on using the changeset viewer.