예제 #1
0
        private static List<Switch> processLine(ConsoleColor[] line, char[] text)
        {
            List<Switch> res = new List<Switch>();

            // current values
            int at = 0;
            ConsoleColor current;

            while (at < line.Length)
            {
                current = line[at];

                // Check how long the same color is used
                int length = line.Skip(at).TakeWhile((c, i) => c == current || text[i + at] == '\0' || text[i + at] == ' ').Count();

                char[] rText = new char[length];
                Array.Copy(text, at, rText, 0, length);

                res.Add(new Switch { Text = new string(rText), Color = current });

                // Skip forward
                at += length;
            }
            return res;
        }