(options: FileOptionsReq)
| 2633 | }) |
| 2634 | |
| 2635 | const handleFileProcess = (options: FileOptionsReq) => { |
| 2636 | return Effect.fnUntraced(function*(input: Terminal.UserInput, state: FileState) { |
| 2637 | // Navigation is bound to ctrl chords rather than bare `j`/`k`, so that every |
| 2638 | // printable character reaches the filter input. |
| 2639 | if (input.key.ctrl) { |
| 2640 | switch (input.key.name) { |
| 2641 | case "u": { |
| 2642 | if (showConfirmation(state.confirm)) { |
| 2643 | return Action.Beep() |
| 2644 | } |
| 2645 | return yield* processFileClear(state) |
| 2646 | } |
| 2647 | case "p": |
| 2648 | case "k": { |
| 2649 | return yield* processFileCursorUp(state) |
| 2650 | } |
| 2651 | case "n": { |
| 2652 | return yield* processFileCursorDown(state) |
| 2653 | } |
| 2654 | default: { |
| 2655 | return Action.Beep() |
| 2656 | } |
| 2657 | } |
| 2658 | } |
| 2659 | switch (input.key.name) { |
| 2660 | case "up": { |
| 2661 | return yield* processFileCursorUp(state) |
| 2662 | } |
| 2663 | case "down": |
| 2664 | case "tab": { |
| 2665 | return yield* processFileCursorDown(state) |
| 2666 | } |
| 2667 | case "backspace": { |
| 2668 | if (showConfirmation(state.confirm)) { |
| 2669 | return Action.Beep() |
| 2670 | } |
| 2671 | return yield* processFileBackspace(state) |
| 2672 | } |
| 2673 | case "enter": |
| 2674 | case "return": { |
| 2675 | return yield* processSelection(state, options) |
| 2676 | } |
| 2677 | case "y": |
| 2678 | case "t": { |
| 2679 | if (showConfirmation(state.confirm)) { |
| 2680 | const path = yield* Path.Path |
| 2681 | const currentPath = yield* resolveCurrentPath(state.path, options) |
| 2682 | const selectedPath = state.files[state.cursor] |
| 2683 | const resolvedPath = path.resolve(currentPath, selectedPath) |
| 2684 | const files = yield* getFileList(resolvedPath, options) |
| 2685 | return Action.NextFrame({ |
| 2686 | state: { |
| 2687 | cursor: 0, |
| 2688 | files, |
| 2689 | allFiles: files, |
| 2690 | query: "", |
| 2691 | path: Option.some(resolvedPath), |
| 2692 | confirm: FileConfirm.Hide() |
no test coverage detected