EraseCurrentLine() 공개 메소드

public EraseCurrentLine ( ) : void
리턴 void
예제 #1
0
        private void InitializeHistory(LowLevelToAbstractConsoleAdapter adapter)
        {
            var keyMap = new Dictionary<ConsoleKey, Func<HistoryEntry>>
                             {
                                 { ConsoleKey.UpArrow, () => _history.GetNextEntry() },
                                 { ConsoleKey.DownArrow, () => _history.GetPreviousEntry() }
                             };

            adapter.KeyStrokes
                .Select(keyInfo => keyInfo.Key)
                .Where(key => key == ConsoleKey.UpArrow || key == ConsoleKey.DownArrow)
                .Select(key => keyMap[key])
                .Subscribe(func =>
                               {
                                   adapter.EraseCurrentLine();
                                   var historyEntry = func();

                                   if (historyEntry != null)
                                   {
                                       adapter.Write(historyEntry.Value);
                                   }
                               });
        }
        public void ErasesCurrentLineAndResetsCursor()
        {
            var inputSequence = "Hello".ToInputSequence();

            var lowLevelConsole = new LowLevelTestConsole(inputSequence);
            var adapter = new LowLevelToAbstractConsoleAdapter(lowLevelConsole) { Prompt = "(S) " };

            adapter.ReadUntilSequenceIsOver(inputSequence);

            Assert.AreEqual("(S) Hello", lowLevelConsole.ReadInLineFromTo(0, 0, 8));
            Assert.AreEqual(9, lowLevelConsole.CursorLeft);

            adapter.EraseCurrentLine();

            Assert.AreEqual("(S)      ", lowLevelConsole.ReadInLineFromTo(0, 0, 8));
            Assert.AreEqual(4, lowLevelConsole.CursorLeft);
        }