source dump of claude code
at main 33 lines 731 B view raw
1import type { HistoryMode } from 'src/hooks/useArrowKeyHistory.js' 2import type { PromptInputMode } from 'src/types/textInputTypes.js' 3 4export function prependModeCharacterToInput( 5 input: string, 6 mode: PromptInputMode, 7): string { 8 switch (mode) { 9 case 'bash': 10 return `!${input}` 11 default: 12 return input 13 } 14} 15 16export function getModeFromInput(input: string): HistoryMode { 17 if (input.startsWith('!')) { 18 return 'bash' 19 } 20 return 'prompt' 21} 22 23export function getValueFromInput(input: string): string { 24 const mode = getModeFromInput(input) 25 if (mode === 'prompt') { 26 return input 27 } 28 return input.slice(1) 29} 30 31export function isInputModeCharacter(input: string): boolean { 32 return input === '!' 33}