public void HighlightSyntax(SyntaxDescriptor desc, Range range) { //set style order range.tb.ClearStylesBuffer(); for (int i = 0; i < desc.styles.Count; i++) { range.tb.Styles[i] = desc.styles[i]; } //brackets range.tb.LeftBracket = desc.leftBracket; range.tb.RightBracket = desc.rightBracket; range.tb.LeftBracket2 = desc.leftBracket2; range.tb.RightBracket2 = desc.rightBracket2; //clear styles of range range.ClearStyle(desc.styles.ToArray()); //highlight syntax foreach (var rule in desc.rules) { range.SetStyle(rule.style, rule.Regex); } //clear folding range.ClearFoldingMarkers(); //folding markers foreach (var folding in desc.foldings) { range.SetFoldingMarkers(folding.startMarkerRegex, folding.finishMarkerRegex, folding.options); } }
public virtual void TASSyntaxHighlight(Range range) { RichText tb = range.tb; tb.CommentPrefix = "#"; tb.LeftBracket = '\x0'; tb.RightBracket = '\x0'; tb.LeftBracket2 = '\x0'; tb.RightBracket2 = '\x0'; //clear style of changed range range.ClearStyle(GrayStyle, GreenStyle, RedStyle, BlueStyle, PinkStyle); int start = range.Start.iLine; int end = range.End.iLine; if (start > end) { int temp = start; start = end; end = temp; } while (start <= end) { int charEnd = tb[start].Count; Range line = new Range(tb, 0, start, charEnd, start); InputRecord input = new InputRecord(line.Text); if (input.Frames == 0 && input.Actions == Actions.None) { line.SetStyle(GreenStyle); } else { Range sub = new Range(tb, 0, start, 4, start); sub.SetStyle(RedStyle); int charStart = 4; while (charStart < charEnd) { sub = new Range(tb, charStart, start, charStart + 1, start); if (char.IsDigit(tb[start][charStart].c)) { sub.SetStyle(PinkStyle); } else if ((charStart & 1) == 0) { sub.SetStyle(GrayStyle); } else { sub.SetStyle(BlueStyle); } charStart++; } } start++; } }