mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 16:52:55 +02:00
few more event key. constant refactors
This commit is contained in:
@@ -97,7 +97,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "deletewordbefore": // Delete rest of word before the cursor
|
||||
for (let delStart = start - 1; delStart > -2; --delStart) {
|
||||
if ((inputText.charAt(delStart) === " " || delStart === -1) && delStart !== start - 1) {
|
||||
if ((inputText.charAt(delStart) === KEY.SPACE || delStart === -1) && delStart !== start - 1) {
|
||||
saveValue(inputText.substr(0, delStart + 1) + inputText.substr(start), () => {
|
||||
// Move cursor to correct location
|
||||
// foo bar |baz bum --> foo |baz bum
|
||||
@@ -110,7 +110,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "deletewordafter": // Delete rest of word after the cursor, including trailing space
|
||||
for (let delStart = start + 1; delStart <= value.length + 1; ++delStart) {
|
||||
if (inputText.charAt(delStart) === " " || delStart === value.length + 1) {
|
||||
if (inputText.charAt(delStart) === KEY.SPACE || delStart === value.length + 1) {
|
||||
saveValue(inputText.substr(0, start) + inputText.substr(delStart + 1), () => {
|
||||
// Move cursor to correct location
|
||||
// foo bar |baz bum --> foo bar |bum
|
||||
@@ -151,7 +151,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "prevword":
|
||||
for (let i = start - 2; i >= 0; --i) {
|
||||
if (ref.value.charAt(i) === " ") {
|
||||
if (ref.value.charAt(i) === KEY.SPACE) {
|
||||
ref.setSelectionRange(i + 1, i + 1);
|
||||
return;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "nextword":
|
||||
for (let i = start + 1; i <= inputLength; ++i) {
|
||||
if (ref.value.charAt(i) === " ") {
|
||||
if (ref.value.charAt(i) === KEY.SPACE) {
|
||||
ref.setSelectionRange(i, i);
|
||||
return;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Select previous command.
|
||||
if (event.key === KEY.UPARROW || (Settings.EnableBashHotkeys && event.key === "p" && event.ctrlKey)) {
|
||||
if (event.key === KEY.UP_ARROW || (Settings.EnableBashHotkeys && event.key === KEY.P && event.ctrlKey)) {
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@@ -290,7 +290,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Select next command
|
||||
if (event.key === KEY.DOWNARROW || (Settings.EnableBashHotkeys && event.key === "m" && event.ctrlKey)) {
|
||||
if (event.key === KEY.DOWN_ARROW || (Settings.EnableBashHotkeys && event.key === KEY.M && event.ctrlKey)) {
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user