Example #1
0
        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 if (input.HasActions(Actions.State))
                {
                    line.SetStyle(BlueStyle);
                }
                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++;
            }
        }