public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { if (cki.Key != ConsoleKey.DownArrow) { return; } var inputBuffer = ctx.Get <InputBuffer>(); var inputHistory = ctx.Get <InputHistory>(); var current = inputBuffer.GetInput(); if (current.Length != 0) { inputHistory.Update(current); } current = inputHistory.Next(); if (current == null) { return; } inputBuffer.ForceSetInput(current); inputBuffer.ForceSetCursorPos(current.Length); }
public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { if (cki.Key != ConsoleKey.Enter) { return; } var current = ctx.Get <InputBuffer>().GetInput(); if (current.Length == 0) { return; } var inputHistory = ctx.Get <InputHistory>(); inputHistory.Last(); if (inputHistory.Pre() == current) { inputHistory.Next(); return; } inputHistory.Next(); inputHistory.Update(current); inputHistory.Enqueue(string.Empty); }
public override void OnRegist(ContextContainer ctx) { if (ctx.Get <InputHistory>() == null) { ctx.Set(new InputHistory(100)); } }
public void MustContainContextAfterInclude() { var c1 = new Mock <FakeContext>(); _sut.Include(c1.Object); var c1ByType = _sut.Get <FakeContext>(); var c1ByNamespace = _sut.Get <FakeContext>(typeof(FakeContext).FullName); Assert.Equal(c1.Object, c1ByType); Assert.Equal(c1.Object, c1ByNamespace); }
public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { ctx.Get <InputBuffer>().CursorLeftMove(); }
public void MustThrowExceptionWhenFullQualifiedNamespaceOfTypeDoesntExist() => FluentActions.Invoking(() => _sut.Get <int>("not.a.real.namespace")).Should().Throw <KeyNotFoundException>();
public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { ctx.Get <InputBuffer>()?.Delete(); }
public override void OnReadKey(ConsoleKeyInfo cki, ContextContainer ctx) { ctx.Get <InputBuffer>()?.Insert(cki.KeyChar); }