Exemplo n.º 1
0
        } // end Write()

        private int _HandleControlSequence(string s, int escIndex)
        {
            m_state.Begin(); // we may actually be continuing...

            char c;
            int  curIndex = escIndex;

            while (++curIndex < s.Length)
            {
                c = s[curIndex];
                if ((c >= '0') && (c <= '9'))
                {
                    m_state.Accum(((int)c) - 0x30);
                    continue;
                }
                else if (';' == c)
                {
                    m_state.Enter();
                    continue;
                }
                else if ((c >= '@') && (c <= '~'))
                {
                    List <int> args = m_state.Finish();
                    _ProcessCommand(c, args);
                    return(curIndex + 1);
                }
                else
                {
                    // You're supposed to be able to have anonther character, like a space
                    // (0x20) before the command code character, but I'm not going to do that.
                    throw new ArgumentException(String.Format("Invalid command sequence character at position {0} (0x{1:x}).", curIndex, (int)c));
                }
            }
            // Finished parsing the whole string--the control sequence must be broken across
            // strings.
            return(curIndex);
        } // end _HandleControlSequence()