(options: AutoCompleteOptionsReq<A>)
| 3421 | } |
| 3422 | |
| 3423 | const handleAutoCompleteProcess = <A>(options: AutoCompleteOptionsReq<A>) => { |
| 3424 | return (input: Terminal.UserInput, state: AutoCompleteState) => { |
| 3425 | if (input.key.ctrl) { |
| 3426 | if (input.key.name === "u") { |
| 3427 | return processAutoCompleteClear(state, options) |
| 3428 | } |
| 3429 | return Effect.succeed(Action.Beep()) |
| 3430 | } |
| 3431 | switch (input.key.name) { |
| 3432 | case "k": |
| 3433 | case "up": { |
| 3434 | return processAutoCompleteCursorUp(state) |
| 3435 | } |
| 3436 | case "j": |
| 3437 | case "down": { |
| 3438 | return processAutoCompleteCursorDown(state) |
| 3439 | } |
| 3440 | case "tab": { |
| 3441 | return processAutoCompleteNext(state) |
| 3442 | } |
| 3443 | case "backspace": { |
| 3444 | return processAutoCompleteBackspace(state, options) |
| 3445 | } |
| 3446 | case "enter": |
| 3447 | case "return": { |
| 3448 | if (state.filtered.length === 0) { |
| 3449 | return Effect.succeed(Action.Beep()) |
| 3450 | } |
| 3451 | const selected = options.choices[state.index] |
| 3452 | if (selected.disabled) { |
| 3453 | return Effect.succeed(Action.Beep()) |
| 3454 | } |
| 3455 | return Effect.succeed(Action.Submit({ value: selected.value })) |
| 3456 | } |
| 3457 | default: { |
| 3458 | return processAutoCompleteInput(Option.getOrElse(input.input, () => ""), state, options) |
| 3459 | } |
| 3460 | } |
| 3461 | } |
| 3462 | } |
| 3463 | |
| 3464 | interface TextOptionsReq extends Required<TextOptions> { |
| 3465 | /** |
no test coverage detected