/ src / hooks / useExitOnCtrlCDWithKeybindings.ts
useExitOnCtrlCDWithKeybindings.ts
 1  import { useKeybindings } from '../keybindings/useKeybinding.js'
 2  import { type ExitState, useExitOnCtrlCD } from './useExitOnCtrlCD.js'
 3  
 4  export type { ExitState }
 5  
 6  /**
 7   * Convenience hook that wires up useExitOnCtrlCD with useKeybindings.
 8   *
 9   * This is the standard way to use useExitOnCtrlCD in components.
10   * The separation exists to avoid import cycles - useExitOnCtrlCD.ts
11   * doesn't import from the keybindings module directly.
12   *
13   * @param onExit - Optional custom exit handler
14   * @param onInterrupt - Optional callback for features to handle interrupt (ctrl+c).
15   *                      Return true if handled, false to fall through to double-press exit.
16   * @param isActive - Whether the keybinding is active (default true).
17   */
18  export function useExitOnCtrlCDWithKeybindings(
19    onExit?: () => void,
20    onInterrupt?: () => boolean,
21    isActive?: boolean,
22  ): ExitState {
23    return useExitOnCtrlCD(useKeybindings, onInterrupt, onExit, isActive)
24  }