Exemplo n.º 1
0
        public void ParseModeline(int numLine)
        {
            ITextBuffer buffer   = this.theView.TextBuffer;
            var         snapshot = buffer.CurrentSnapshot;

            if (snapshot.LineCount <= numLine)
            {
                return;
            }
            ILanguage language = langFactory.TryCreateLanguage(snapshot);

            if (language == null)
            {
                return;
            }

            var firstLine = snapshot.GetLineFromLineNumber(numLine);

            ITextChars tc          = new LineChars(firstLine);
            var        svc         = language.GetService <IFirstLineCommentParser>();
            String     commentText = svc.Parse(tc);

            if (String.IsNullOrEmpty(commentText))
            {
                return;
            }
            PkgSource.LogInfo("Found possible modeline: {0}", commentText);

            var modelineParser = new ModeLineParser();
            var options        = modelineParser.Parse(commentText);

            ApplyModelines(options);
        }
Exemplo n.º 2
0
 public void Load()
 {
     if (File.Exists(filePath))
     {
         try {
             XDocument doc = XDocument.Load(filePath);
             foreach (var element in doc.Root.Elements())
             {
                 settings[element.Name.LocalName] = element.Value;
             }
         } catch (XmlException ex) {
             PkgSource.LogInfo("Error loading '{0}': {1}", filePath, ex);
         }
     }
 }
Exemplo n.º 3
0
        private void ApplyModeLine(String key, String value)
        {
            PkgSource.LogInfo("Modeline: {0}={1}", key, value);
            if (String.IsNullOrEmpty(value))
            {
                // assume this is a boolean option
                value = key.StartsWith("no") ? "false" : "true";
            }
            Action <IWpfTextView, String> option;

            if (optionMap.TryGetValue(key, out option))
            {
                option(theView, value);
            }
        }