示例#1
0
            private void flushOutputBuffer()
            {
                // save the line currently pointed to by cursor,
                // remove it from Console and write it back after the output buffer flush.
                // this is done in order to avoid deletion of user input from console,
                // in case user was in the middle of typing.
                // it is assumed that user input spans at most one line in console.
                bool restoreInputToConsoleFlag = false;

                // cursor doesn't point to beginning of line, user might be in the middle of typing
                if (!ConsoleIOUtils.IsCursorPointingToBeginningOfLine())
                {
                    // clear the current console line (holding user input)
                    ConsoleGraphicsHandler.ClearConsoleInputLine();

                    // restore user input after flush
                    restoreInputToConsoleFlag = true;
                }

                // write all entries in output buffer to Console
                // in insert order.
                while (outputBuffer.Count > 0)
                {
                    string outPutEntry = outputBuffer.Dequeue();
                    WriteOutput(outPutEntry);
                }

                // restore input
                if (restoreInputToConsoleFlag)
                {
                    writeInputToConsole();
                }
            }
示例#2
0
 /// <summary>
 /// handles left arrow key user key press.
 /// </summary>
 private static void handleInputLeftArrowKey()
 {
     // if not at beginning of line, move cursor one character backwards
     if (!ConsoleIOUtils.IsCursorPointingToBeginningOfLine())
     {
         ConsoleIOUtils.MoveCursorHorizontal(-1);
     }
 }