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 DownShowsNextInHistory_CantGoPastLast() { 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; "aa\r".ForEach(c => terminal.CharTyped(c)); "bb\r".ForEach(c => terminal.CharTyped(c)); "cc\r".ForEach(c => terminal.CharTyped(c)); "dd".ForEach(c => terminal.CharTyped(c)); //current line terminal.ControlKeyPressed(TerminalKey.Up, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Up, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); terminal.ControlKeyPressed(TerminalKey.Down, TerminalKeyModifiers.None); DrawingInfo info = terminal.GetCurrentPageDrawingInfo(50); var lines = CoreTestHelpers.GetLinesAsText(info); Assert.AreEqual(m_prompt + "cc", lines[lines.Count - 1], "Incorrect history item shown"); }
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"); }
protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); var state = TerminalKeyModifiers.None; switch (e.KeyCode) { case Keys.End: m_terminal.ControlKeyPressed(TerminalKey.End, state); break; case Keys.Home: m_terminal.ControlKeyPressed(TerminalKey.Home, state); break; case Keys.Left: m_terminal.ControlKeyPressed(TerminalKey.Left, state); break; case Keys.Up: m_terminal.ControlKeyPressed(TerminalKey.Up, state); break; case Keys.Right: m_terminal.ControlKeyPressed(TerminalKey.Right, state); break; case Keys.Down: m_terminal.ControlKeyPressed(TerminalKey.Down, state); break; case Keys.Insert: m_terminal.ControlKeyPressed(TerminalKey.Insert, state); break; case Keys.Delete: m_terminal.ControlKeyPressed(TerminalKey.Delete, state); break; } Invalidate(true); }