Skip to content

Commit

Permalink
Merge pull request #877 from kkebo/add-alt-del
Browse files Browse the repository at this point in the history
Add support for Alt-DEL and fix Ctrl-W behavior
  • Loading branch information
holzschu authored Jan 2, 2025
2 parents 8b3e910 + 2674da7 commit 5be6d3a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ function setupHterm() {
// move cursor back to beginning of the line
io.print(`\x1b[${window.promptMessage.length + 1}G`);
break;
case String.fromCharCode(23): // Ctrl+W: kill the word behind point
case String.fromCharCode(27) + String.fromCharCode(127): // Alt-delete key from iOS keyboard: kill the word behind point
disableAutocompleteMenu();
deleteBackward();
while (currentCommandCursorPosition > 0) {
Expand All @@ -1276,6 +1276,17 @@ function setupHterm() {
deleteBackward();
}
break;
case String.fromCharCode(23): // Ctrl+W: kill the word behind point, using white space as a word boundary
disableAutocompleteMenu();
deleteBackward();
while (currentCommandCursorPosition > 0) {
const currentChar = io.currentCommand[currentCommandCursorPosition - 1];
if (currentChar === ' ') {
break;
}
deleteBackward();
}
break;
case String.fromCharCode(12): // Ctrl-L: clear screen
disableAutocompleteMenu();
// erase display, move cursor to (1,1)
Expand Down

0 comments on commit 5be6d3a

Please sign in to comment.