Match() public method

public Match ( char buffer, int offset, int length, int &used ) : TermInfoStrings
buffer char
offset int
length int
used int
return TermInfoStrings
Esempio n. 1
0
        object GetKeyFromBuffer(bool cooked)
        {
            if (readpos >= writepos)
            {
                return(null);
            }

            int next = buffer [readpos];

            if (!cooked || !rootmap.StartsWith(next))
            {
                readpos++;
                AdjustBuffer();
                return(CreateKeyInfoFromInt(next));
            }

            int             used;
            TermInfoStrings str = rootmap.Match(buffer, readpos, writepos - readpos, out used);

            if ((int)str == -1)
            {
                return(null);
            }

            ConsoleKeyInfo key;

            if (keymap [str] != null)
            {
                key = (ConsoleKeyInfo)keymap [str];
            }
            else
            {
                readpos++;
                AdjustBuffer();
                return(CreateKeyInfoFromInt(next));
            }

            readpos += used;
            AdjustBuffer();
            return(key);
        }