public SyntaxTextBox() { InitializeComponent(); Style commandStyle = new Style(); commandStyle.Foreground = Color.DarkRed; Style keywordStyle = new Style(); keywordStyle.FontSize = 8; keywordStyle.Foreground = Color.DarkGreen; IndicatorStyles.Add('@', commandStyle); Keywords.Add("hello", keywordStyle); Keywords.Add("blubber", keywordStyle); }
//returns word-offset private int HighlightAt(int index, Style style) { int offset; for (offset = 0; textChars[index + (offset+1)] == ' '; offset++) { } this.Select(index, index + offset); this.SelectionBackColor = style.Background; this.SelectionColor = style.Foreground; this.SelectionFont = new Font(style.Fontfamily, style.FontSize, style.Fontstyle); return offset; }