(options: TextOptionsReq)
| 3940 | } |
| 3941 | |
| 3942 | const handleTextProcess = (options: TextOptionsReq) => { |
| 3943 | return (input: Terminal.UserInput, state: TextState) => { |
| 3944 | if (input.key.ctrl) { |
| 3945 | switch (input.key.name) { |
| 3946 | case "u": { |
| 3947 | return processTextClear(state) |
| 3948 | } |
| 3949 | case "a": { |
| 3950 | return processTextCursorStart(state) |
| 3951 | } |
| 3952 | case "e": { |
| 3953 | return processTextCursorEnd(state) |
| 3954 | } |
| 3955 | default: { |
| 3956 | return Effect.succeed(Action.Beep()) |
| 3957 | } |
| 3958 | } |
| 3959 | } |
| 3960 | switch (input.key.name) { |
| 3961 | case "backspace": { |
| 3962 | return processTextBackspace(state) |
| 3963 | } |
| 3964 | case "left": { |
| 3965 | return processTextCursorLeft(state) |
| 3966 | } |
| 3967 | case "right": { |
| 3968 | return processTextCursorRight(state) |
| 3969 | } |
| 3970 | case "home": { |
| 3971 | return processTextCursorStart(state) |
| 3972 | } |
| 3973 | case "end": { |
| 3974 | return processTextCursorEnd(state) |
| 3975 | } |
| 3976 | case "enter": |
| 3977 | case "return": { |
| 3978 | const value = state.value |
| 3979 | return Effect.match(options.validate(value), { |
| 3980 | onFailure: (error) => |
| 3981 | Action.NextFrame({ |
| 3982 | state: { ...state, value, error: Option.some(error) } |
| 3983 | }), |
| 3984 | onSuccess: (value) => Action.Submit({ value }) |
| 3985 | }) |
| 3986 | } |
| 3987 | case "tab": { |
| 3988 | return processTab(state, options) |
| 3989 | } |
| 3990 | default: { |
| 3991 | return defaultTextProcessor(Option.getOrElse(input.input, () => ""), state) |
| 3992 | } |
| 3993 | } |
| 3994 | } |
| 3995 | } |
| 3996 | |
| 3997 | const handleTextClear = (options: TextOptionsReq) => { |
| 3998 | return (state: TextState, _: Action<TextState, string>) => { |
no test coverage detected