Download src/components/PromptInput/inputModes.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 731 Bytes
-
https://huggingface.co/chenbhao/codev/resolve/main/src/components/PromptInput/inputModes.ts
- Command line
-
hf download hf://chenbhao/codev/src/components/PromptInput/inputModes.ts
-
curl -L -o inputModes.ts https://huggingface.co/chenbhao/codev/resolve/main/src/components/PromptInput/inputModes.ts
731 Bytes
| import type { HistoryMode } from 'src/hooks/useArrowKeyHistory.js' | |
| import type { PromptInputMode } from 'src/types/textInputTypes.js' | |
| export function prependModeCharacterToInput( | |
| input: string, | |
| mode: PromptInputMode, | |
| ): string { | |
| switch (mode) { | |
| case 'bash': | |
| return `!${input}` | |
| default: | |
| return input | |
| } | |
| } | |
| export function getModeFromInput(input: string): HistoryMode { | |
| if (input.startsWith('!')) { | |
| return 'bash' | |
| } | |
| return 'prompt' | |
| } | |
| export function getValueFromInput(input: string): string { | |
| const mode = getModeFromInput(input) | |
| if (mode === 'prompt') { | |
| return input | |
| } | |
| return input.slice(1) | |
| } | |
| export function isInputModeCharacter(input: string): boolean { | |
| return input === '!' | |
| } | |