(options: TextOptionsReq)
| 3676 | } |
| 3677 | |
| 3678 | const handleTextProcess = (options: TextOptionsReq) => { |
| 3679 | return (input: Terminal.UserInput, state: TextState) => { |
| 3680 | if (input.key.ctrl) { |
| 3681 | switch (input.key.name) { |
| 3682 | case "u": { |
| 3683 | return processTextClear(state) |
| 3684 | } |
| 3685 | case "a": { |
| 3686 | return processTextCursorStart(state) |
| 3687 | } |
| 3688 | case "e": { |
| 3689 | return processTextCursorEnd(state) |
| 3690 | } |
| 3691 | default: { |
| 3692 | return Effect.succeed(Action.Beep()) |
| 3693 | } |
| 3694 | } |
| 3695 | } |
| 3696 | switch (input.key.name) { |
| 3697 | case "backspace": { |
| 3698 | return processTextBackspace(state) |
| 3699 | } |
| 3700 | case "left": { |
| 3701 | return processTextCursorLeft(state) |
| 3702 | } |
| 3703 | case "right": { |
| 3704 | return processTextCursorRight(state) |
| 3705 | } |
| 3706 | case "home": { |
| 3707 | return processTextCursorStart(state) |
| 3708 | } |
| 3709 | case "end": { |
| 3710 | return processTextCursorEnd(state) |
| 3711 | } |
| 3712 | case "enter": |
| 3713 | case "return": { |
| 3714 | const value = state.value |
| 3715 | return Effect.match(options.validate(value), { |
| 3716 | onFailure: (error) => |
| 3717 | Action.NextFrame({ |
| 3718 | state: { ...state, value, error: Option.some(error) } |
| 3719 | }), |
| 3720 | onSuccess: (value) => Action.Submit({ value }) |
| 3721 | }) |
| 3722 | } |
| 3723 | case "tab": { |
| 3724 | return processTab(state, options) |
| 3725 | } |
| 3726 | default: { |
| 3727 | return defaultTextProcessor(Option.getOrElse(input.input, () => ""), state) |
| 3728 | } |
| 3729 | } |
| 3730 | } |
| 3731 | } |
| 3732 | |
| 3733 | const handleTextClear = (options: TextOptionsReq) => { |
| 3734 | return (state: TextState, _: Action<TextState, string>) => { |
no test coverage detected