public static Task RightArrow(ConsoleKeyInfo keyInfo, IShellState state, CancellationToken cancellationToken) { state = state ?? throw new ArgumentNullException(nameof(state)); string line = state.InputManager.GetCurrentBuffer(); if (state.InputManager.CaretPosition < line.Length) { if (!keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) { state.MoveCarets(1); } else { ICoreParseResult parseResult = state.CommandDispatcher.Parser.Parse(line, state.InputManager.CaretPosition); int targetSection = parseResult.SelectedSection + 1; if (targetSection >= parseResult.Sections.Count) { state.MoveCarets(line.Length - state.InputManager.CaretPosition); } else { int desiredPosition = parseResult.SectionStartLookup[targetSection]; state.MoveCarets(desiredPosition - state.InputManager.CaretPosition); } } } return(Task.CompletedTask); }
public static Task Home(ConsoleKeyInfo keyInfo, IShellState state, CancellationToken cancellationToken) { state = state ?? throw new ArgumentNullException(nameof(state)); state.MoveCarets(-state.InputManager.CaretPosition); return(Task.CompletedTask); }
private static Task End(ConsoleKeyInfo keyInfo, IShellState state, CancellationToken cancellationToken) { state.MoveCarets(state.InputManager.GetCurrentBuffer().Length - state.InputManager.CaretPosition); return(Task.CompletedTask); }