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 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" ); }