コード例 #1
0
 public PffColorizer()
 {
     HighlightWordReader hwr = new HighlightWordReader(HighlightWordReader.PffFilename);
     _typeWords = hwr.ReadWordBlock(true);
     _headingWords = hwr.ReadWordBlock(true);
     _attributeWords = hwr.ReadWordBlock(true);
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: CSProDevelopment/helps
        private void GenerateNotepadFile(bool silent)
        {
            try
            {
                string templateFilename = HelperFunctions.ReferenceFileLocate("userDefineLang-template.xml");
                string outFilename = Path.Combine(Path.GetDirectoryName(templateFilename),"userDefineLang.xml");

                // read in the template file
                string[] fileLines = File.ReadAllLines(templateFilename);

                // read in the words
                List<SortedSet<string>> words = new List<SortedSet<string>>();

                HighlightWordReader hwr = new HighlightWordReader(HighlightWordReader.LogicFilename);
                words.Add(hwr.ReadWordBlock(false));

                hwr = new HighlightWordReader(HighlightWordReader.PffFilename);
                words.Add(hwr.ReadWordBlock(true));
                words.Add(hwr.ReadWordBlock(true));
                words.Add(hwr.ReadWordBlock(true));

                string[] templateWords = new string[]
                {
                    "%template-logic%", "%template-pff1%", "%template-pff2%", "%template-pff3%"
                };

                // write out the file
                using( TextWriter tw = new StreamWriter(outFilename,false,Encoding.UTF8) )
                {
                    foreach( string fileLine in fileLines )
                    {
                        string outLine = fileLine;

                        // see if we need to replace a chunk
                        int templateIndex = 0;
                        int startReplacementPos = 0;

                        foreach( string template in templateWords )
                        {
                            startReplacementPos = fileLine.IndexOf(template);

                            if( startReplacementPos >= 0 )
                                break;

                            templateIndex++;
                        }

                        if( templateIndex < templateWords.Length )
                        {
                            // generate the word list
                            StringBuilder sb = new StringBuilder();

                            foreach( string word in words[templateIndex] )
                                sb.AppendFormat("{0}{1}",sb.Length > 0 ? " " : "",word);

                            // replace the template
                            outLine = String.Concat(outLine.Substring(0,startReplacementPos),
                                sb,outLine.Substring(startReplacementPos + templateWords[templateIndex].Length));
                        }

                        tw.WriteLine(outLine);
                    }
                }

                if( !silent )
                    MessageBox.Show("Successfully wrote the Notepad++ colorization file to:\n\n" + outFilename);
            }

            catch( Exception exception )
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #3
0
 public LogicColorizer()
 {
     HighlightWordReader hwr = new HighlightWordReader(HighlightWordReader.LogicFilename);
     _reservedWords = hwr.ReadWordBlock(false);
 }