mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-19 14:13:48 +01:00
Merge pull request #3881 from evil-tim/ctrl-c-bash-hotkey
UI: Fix #3854 ctrl+c does not clear terminal input
This commit is contained in:
commit
d2c92c4116
@ -128,6 +128,9 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
case "clearbefore": // Deletes everything before cursor
|
case "clearbefore": // Deletes everything before cursor
|
||||||
saveValue(inputText.substr(start), () => moveTextCursor("home"));
|
saveValue(inputText.substr(start), () => moveTextCursor("home"));
|
||||||
break;
|
break;
|
||||||
|
case "clearall": // Deletes everything in the input
|
||||||
|
saveValue("");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +199,8 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): Promise<void> {
|
async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): Promise<void> {
|
||||||
|
const ref = terminalInput.current;
|
||||||
|
|
||||||
// Run command.
|
// Run command.
|
||||||
if (event.key === KEY.ENTER && value !== "") {
|
if (event.key === KEY.ENTER && value !== "") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -282,7 +287,6 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
}
|
}
|
||||||
const prevCommand = terminal.commandHistory[terminal.commandHistoryIndex];
|
const prevCommand = terminal.commandHistory[terminal.commandHistoryIndex];
|
||||||
saveValue(prevCommand);
|
saveValue(prevCommand);
|
||||||
const ref = terminalInput.current;
|
|
||||||
if (ref) {
|
if (ref) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
ref.selectionStart = ref.selectionEnd = 10000;
|
ref.selectionStart = ref.selectionEnd = 10000;
|
||||||
@ -318,6 +322,12 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
|
|
||||||
// Extra Bash Emulation Hotkeys, must be enabled through options
|
// Extra Bash Emulation Hotkeys, must be enabled through options
|
||||||
if (Settings.EnableBashHotkeys) {
|
if (Settings.EnableBashHotkeys) {
|
||||||
|
if (event.code === KEYCODE.C && event.ctrlKey && ref && ref.selectionStart === ref.selectionEnd) {
|
||||||
|
event.preventDefault();
|
||||||
|
terminal.print(`[${player.getCurrentServer().hostname} ~${terminal.cwd()}]> ${value}`);
|
||||||
|
modifyInput("clearall");
|
||||||
|
}
|
||||||
|
|
||||||
if (event.code === KEYCODE.A && event.ctrlKey) {
|
if (event.code === KEYCODE.A && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("home");
|
moveTextCursor("home");
|
||||||
|
Loading…
Reference in New Issue
Block a user