Add additional readline-like keybindings. (#524)

Adds the following conventional readline-like keybindings:

  - `Ctrl+H`: Delete the previous character.
  - `Ctrl+D`: Delete the next character.

Additionally, remaps the Debug Console command from Ctrl+D to Ctrl+O, which had been first introduced in PR #486.
This commit is contained in:
DeWitt Clinton 2025-05-23 22:13:57 -07:00 committed by GitHub
parent 30080b9f4e
commit 7a3a9066f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 5 deletions

View File

@ -84,8 +84,7 @@ export const App = ({
[consoleMessages], [consoleMessages],
); );
useInput((input: string, key: InkKeyType) => { useInput((input: string, key: InkKeyType) => {
// Check for Ctrl+D key press if (key.ctrl && input === 'o') {
if (key.ctrl && (input === 'd' || input === 'D')) {
setShowErrorDetails((prev) => !prev); setShowErrorDetails((prev) => !prev);
refreshStatic(); refreshStatic();
} }

View File

@ -27,7 +27,7 @@ export const ConsoleSummaryDisplay: React.FC<ConsoleSummaryDisplayProps> = ({
{errorCount > 0 && ( {errorCount > 0 && (
<Text color={Colors.AccentRed}> <Text color={Colors.AccentRed}>
{errorIcon} {errorCount} error{errorCount > 1 ? 's' : ''}{' '} {errorIcon} {errorCount} error{errorCount > 1 ? 's' : ''}{' '}
<Text color={Colors.SubtleComment}>(CTRL-D for details)</Text> <Text color={Colors.SubtleComment}>(CTRL-O for details)</Text>
</Text> </Text>
)} )}
</Box> </Box>

View File

@ -33,7 +33,7 @@ export const DetailedMessagesDisplay: React.FC<
<Box marginBottom={1}> <Box marginBottom={1}>
<Text bold color={Colors.Foreground}> <Text bold color={Colors.Foreground}>
Debug Console{' '} Debug Console{' '}
<Text color={Colors.SubtleComment}>(CTRL-D to close)</Text> <Text color={Colors.SubtleComment}>(CTRL-O to close)</Text>
</Text> </Text>
</Box> </Box>
{messages.map((msg, index) => { {messages.map((msg, index) => {

View File

@ -1186,10 +1186,11 @@ export function useTextBuffer({
else if ( else if (
key['backspace'] || key['backspace'] ||
input === '\x7f' || input === '\x7f' ||
(key['ctrl'] && input === 'h') ||
(key['delete'] && !key['shift']) (key['delete'] && !key['shift'])
) )
backspace(); backspace();
else if (key['delete']) del(); else if (key['delete'] || (key['ctrl'] && input === 'd')) del();
else if (input && !key['ctrl'] && !key['meta']) { else if (input && !key['ctrl'] && !key['meta']) {
// Heuristic for paste: if input is longer than 1 char (potential paste) // Heuristic for paste: if input is longer than 1 char (potential paste)
// strip ANSI escape codes. // strip ANSI escape codes.