static public List <NewFolding> GetFoldingRanges(TextDocument document, List <NewFolding> list) { Stack <Match> stack = new Stack <Match>(); foreach (Match m in PragmaRegion.Matches(document.Text)) { if (m.Groups[1].Value == "#region") { TextRange range = TextRange.FromMatch(m); int len = m.Groups[1].Index - m.Groups[0].Index; stack.Push(m); } else { TextRange range = TextRange.FromMatch(m); Match peeek = stack.Peek(); TextRange peek = TextRange.FromMatch(peeek); int len = peeek.Groups[1].Index - peeek.Groups[0].Index; XLog.WriteG("Position: ", "{0}", peek.Position); peek.ShrinkRight(len); NewFolding nf = new NewFolding((int)peek.Position, (int)range.EndPosition); nf.DefaultClosed = true; if (peeek.Groups[2].Value == string.Empty) { nf.Name = "‘…’"; } else { nf.Name = string.Format("Pragma Region “{0}”", peeek.Groups[2].Value.Trim()); } // Global.statG(); XLog.WriteC("folding", "{0}, {1}", nf.StartOffset, nf.EndOffset); if (document.GetLineByOffset(nf.StartOffset) == document.GetLineByOffset(nf.EndOffset)) { continue; } else { list.Add(nf); } stack.Pop(); } } list.Sort(SortRange); // if (list.Count >0) list.Remove(list[list.Count-1]); return(list); }
// SO ITSANEXAMPLE;_ //http://webdesign.about.com/od/localization/l/blhtmlcodes-ascii.htm public CharacterEntityConversions() { this.Add("…", "…"); this.Add("‘", "‘"); this.Add("’", "’"); this.Add("“", "“"); this.Add("”", "”"); this.Add("–", "–"); this.Add("—", "—"); this.Add("«", "«"); this.Add("¬", "¬"); this.Add("®", "®"); this.Add("¯", "¯"); this.Add("°", "°"); this.Add("±", "±"); XLog.WriteC("entities loaded\n", ""); // ConversionChars.Add("","&#;"); }