ShellMe.CommandLine.Console.LowLevel.LowLevelToAbstractConsoleAdapter.ReadFromCoordinatesToEndOfLine C# (CSharp) Method

ReadFromCoordinatesToEndOfLine() private method

private ReadFromCoordinatesToEndOfLine ( int leftStart, int topStart, bool shortCircutEndOfLine ) : IEnumerable
leftStart int
topStart int
shortCircutEndOfLine bool
return IEnumerable
        private IEnumerable<char> ReadFromCoordinatesToEndOfLine(int leftStart, int topStart, bool shortCircutEndOfLine)
        {
            var chars = new List<char>();

            //thats the point from where we start to read
            var cursorTop = topStart;
            var initialCursorTop = topStart;
            var cursorLeft = leftStart;

            //if the prompt is the last written character, short circut
            if (shortCircutEndOfLine && LineEnd.CursorLeft == _console.CursorLeft && LineEnd.CursorTop == _console.CursorTop)
                return Enumerable.Empty<char>();

            while (LineEnd.CursorTop >= cursorTop)
            {
                var beginOfLineCursor = cursorTop > initialCursorTop ? 0 : cursorLeft;
                var endOfLineCursor = cursorTop < LineEnd.CursorTop ? _console.MaxColumn : LineEnd.CursorLeft;

                for (int i = beginOfLineCursor; i <= endOfLineCursor; i++)
                {
                    var val = _console.ReadCharacterAt(i, cursorTop);
                    if (val.HasValue)
                        chars.Add(val.Value);
                    else
                        break;
                }
                cursorTop++;
            }
            return chars;
        }