public void InputAndOutputWrapping() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.LineEntered += ( s, lea ) => terminal.WriteOutput( "out: " + lea.Line ); terminal.CharsPerLine = m_prompt.Length + 5; "abcdefghijk\r".ForEach( c => terminal.CharTyped( c ) ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 50 ); var lines = CoreTestHelpers.GetLinesAsText( info ); Assert.AreEqual( 7, lines.Count, "Incorrect number of lines" ); Assert.AreEqual( m_prompt + "abcde", lines[ 0 ], "Incorrect input line 0" ); Assert.AreEqual( m_promptWrap + "fghi", lines[ 1 ], "Incorrect input line 1" ); Assert.AreEqual( m_promptWrap + "jk", lines[ 2 ], "Incorrect input line 2" ); Assert.AreEqual( m_promptOutput + "out: ab", lines[ 3 ], "Incorrect output line 3" ); Assert.AreEqual( m_promptOutputWrap + "cdefgh", lines[ 4 ], "Incorrect output line 4" ); Assert.AreEqual( m_promptOutputWrap + "ijk", lines[ 5 ], "Incorrect output line 5" ); Assert.AreEqual( m_prompt, lines[ 6 ], "Incorrect input line 6" ); }
public void Backspace() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.LineEntered += ( s, lea ) => terminal.WriteOutput( "out: " + lea.Line ); terminal.CharsPerLine = m_prompt.Length + 5; "abcd".ForEach( c => terminal.CharTyped( c ) ); terminal.CharTyped( '\b' ); terminal.CharTyped( '\b' ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 50 ); var lines = CoreTestHelpers.GetLinesAsText( info ); Assert.AreEqual( m_prompt + "ab", lines[ lines.Count - 1 ], "Backspace should have deleted the text" ); }
public void WriteOutput() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.CharsPerLine = 10; "ab\r".ForEach( c => terminal.CharTyped( c ) ); terminal.WriteOutput( "123" ); "cd".ForEach( c => terminal.CharTyped( c ) ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 5 ); var lines = CoreTestHelpers.GetLinesAsText( info ); Assert.AreEqual( 3, lines.Count, "Incorrect number of lines" ); Assert.AreEqual( m_prompt + "ab", lines[ 0 ] ); Assert.AreEqual( m_promptOutput + "123", lines[ 1 ] ); Assert.AreEqual( m_prompt + "cd", lines[ 2 ] ); }
public void Left() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.LineEntered += ( s, lea ) => terminal.WriteOutput( "out: " + lea.Line ); terminal.CharsPerLine = m_prompt.Length + 5; "abcd".ForEach( c => terminal.CharTyped( c ) ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 50 ); var lines = CoreTestHelpers.GetLinesAsText( info, true ); Assert.AreEqual( m_prompt + "ab|cd", lines[ lines.Count - 1 ], "Left navigation failed" ); }
public void AfterReturnTypeOutputAndNextInputLineShow() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.LineEntered += (s, lea) => terminal.WriteOutput( "out: " + lea.Line ); terminal.CharsPerLine = 10; "ab\r".ForEach( c => terminal.CharTyped( c ) ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 5 ); var lines = CoreTestHelpers.GetLinesAsText( info ); Assert.AreEqual( 3, lines.Count, "Incorrect number of lines" ); Assert.AreEqual( m_prompt + "ab", lines[ 0 ], "Incorrect input line" ); Assert.AreEqual( m_promptOutput + "out: ab", lines[ 1 ], "Incorrect outline" ); Assert.AreEqual( m_prompt, lines[ 2 ], "Incorrect next input line" ); }
public void Delete() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.LineEntered += ( s, lea ) => terminal.WriteOutput( "out: " + lea.Line ); terminal.CharsPerLine = m_prompt.Length + 5; "abcdefg".ForEach( c => terminal.CharTyped( c ) ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Delete, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Delete, TerminalKeyModifiers.None ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 50 ); var lines = CoreTestHelpers.GetLinesAsText( info ); Assert.AreEqual( 1, lines.Count, "Incorrect number of lines" ); Assert.AreEqual( m_prompt + "abcdg", lines[ 0 ], "Line 0 invalid" ); }
public void RightThroughWrap() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.LineEntered += ( s, lea ) => terminal.WriteOutput( "out: " + lea.Line ); terminal.CharsPerLine = m_prompt.Length + 5; "abcdefghijk".ForEach( c => terminal.CharTyped( c ) ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Left, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Right, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Right, TerminalKeyModifiers.None ); terminal.ControlKeyPressed( TerminalKey.Right, TerminalKeyModifiers.None ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 50 ); var lines = CoreTestHelpers.GetLinesAsText( info, true ); Assert.AreEqual( 3, lines.Count, "Incorrect number of lines" ); Assert.AreEqual( m_prompt + "abcde", lines[ 0 ], "Incorrect input line 0" ); Assert.AreEqual( m_promptWrap + "fg|hi", lines[ 1 ], "Incorrect input line 1" ); Assert.AreEqual( m_promptWrap + "jk", lines[ 2 ], "Incorrect input line 2" ); }
public void InputWrapping() { var view = new DummyTerminalView( s => new SizeD( s.Length, 1 ) ); var terminal = new TerminalController( view, new SizeD( 1, 1 ), int.MaxValue, m_promptSpan, m_promptWrapSpan, m_promptOutputSpan, m_promptOutputWrapSpan ); terminal.CharsPerLine = m_prompt.Length + 5; "abcdefghijk".ForEach( c => terminal.CharTyped( c ) ); DrawingInfo info = terminal.GetCurrentPageDrawingInfo( 5 ); var lines = CoreTestHelpers.GetLinesAsText( info ); Assert.AreEqual( 3, lines.Count, "Incorrect number of lines" ); Assert.AreEqual( m_prompt + "abcde", lines[ 0 ], "Incorrect input line" ); Assert.AreEqual( m_promptWrap + "fghi", lines[ 1 ], "Incorrect input line" ); Assert.AreEqual( m_promptWrap + "jk", lines[ 2 ], "Incorrect input line" ); }