mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
This commit is contained in:
parent
680027cd4b
commit
49f732d1ee
@ -4,7 +4,6 @@ import * as monaco from "monaco-editor";
|
|||||||
|
|
||||||
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
|
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
|
||||||
type ITextModel = monaco.editor.ITextModel;
|
type ITextModel = monaco.editor.ITextModel;
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
|
||||||
import { OptionsModal } from "./OptionsModal";
|
import { OptionsModal } from "./OptionsModal";
|
||||||
import { Options } from "./Options";
|
import { Options } from "./Options";
|
||||||
import { isValidFilePath } from "../../Terminal/DirectoryHelpers";
|
import { isValidFilePath } from "../../Terminal/DirectoryHelpers";
|
||||||
@ -153,13 +152,13 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
function keydown(event: KeyboardEvent): void {
|
function keydown(event: KeyboardEvent): void {
|
||||||
if (Settings.DisableHotkeys) return;
|
if (Settings.DisableHotkeys) return;
|
||||||
//Ctrl + b
|
//Ctrl + b
|
||||||
if (event.key == KEY.B && (event.ctrlKey || event.metaKey)) {
|
if (event.code == "KeyB" && (event.ctrlKey || event.metaKey)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
Router.toTerminal();
|
Router.toTerminal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// CTRL/CMD + S
|
// CTRL/CMD + S
|
||||||
if (event.key == KEY.S && (event.ctrlKey || event.metaKey)) {
|
if (event.code == "KeyS" && (event.ctrlKey || event.metaKey)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
save();
|
save();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
import { KEYCODE } from "../../utils/helpers/keyCodes";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { styled, Theme, CSSObject } from "@mui/material/styles";
|
import { styled, Theme, CSSObject } from "@mui/material/styles";
|
||||||
import createStyles from "@mui/styles/createStyles";
|
import createStyles from "@mui/styles/createStyles";
|
||||||
@ -275,53 +275,53 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
|||||||
function handleShortcuts(this: Document, event: KeyboardEvent): void {
|
function handleShortcuts(this: Document, event: KeyboardEvent): void {
|
||||||
if (Settings.DisableHotkeys) return;
|
if (Settings.DisableHotkeys) return;
|
||||||
if ((Player.currentWork && Player.focus) || Router.page() === Page.BitVerse) return;
|
if ((Player.currentWork && Player.focus) || Router.page() === Page.BitVerse) return;
|
||||||
if (event.key === KEY.T && event.altKey) {
|
if (event.code === KEYCODE.T && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickTerminal();
|
clickTerminal();
|
||||||
} else if (event.key === KEY.C && event.altKey) {
|
} else if (event.code === KEYCODE.C && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickStats();
|
clickStats();
|
||||||
} else if (event.key === KEY.E && event.altKey) {
|
} else if (event.code === KEYCODE.E && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickScriptEditor();
|
clickScriptEditor();
|
||||||
} else if (event.key === KEY.S && event.altKey) {
|
} else if (event.code === KEYCODE.S && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickActiveScripts();
|
clickActiveScripts();
|
||||||
} else if (event.key === KEY.H && event.altKey) {
|
} else if (event.code === KEYCODE.H && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickHacknet();
|
clickHacknet();
|
||||||
} else if (event.key === KEY.W && event.altKey) {
|
} else if (event.code === KEYCODE.W && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickCity();
|
clickCity();
|
||||||
} else if (event.key === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey && canJob) {
|
} else if (event.code === KEYCODE.J && event.altKey && !event.ctrlKey && !event.metaKey && canJob) {
|
||||||
// ctrl/cmd + alt + j is shortcut to open Chrome dev tools
|
// ctrl/cmd + alt + j is shortcut to open Chrome dev tools
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickJob();
|
clickJob();
|
||||||
} else if (event.key === KEY.R && event.altKey) {
|
} else if (event.code === KEYCODE.R && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickTravel();
|
clickTravel();
|
||||||
} else if (event.key === KEY.P && event.altKey) {
|
} else if (event.code === KEYCODE.P && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickCreateProgram();
|
clickCreateProgram();
|
||||||
} else if (event.key === KEY.F && event.altKey) {
|
} else if (event.code === KEYCODE.F && event.altKey) {
|
||||||
if (props.page == Page.Terminal && Settings.EnableBashHotkeys) {
|
if (props.page == Page.Terminal && Settings.EnableBashHotkeys) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickFactions();
|
clickFactions();
|
||||||
} else if (event.key === KEY.A && event.altKey) {
|
} else if (event.code === KEYCODE.A && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickAugmentations();
|
clickAugmentations();
|
||||||
} else if (event.key === KEY.U && event.altKey) {
|
} else if (event.code === KEYCODE.U && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickTutorial();
|
clickTutorial();
|
||||||
} else if (event.key === KEY.O && event.altKey) {
|
} else if (event.code === KEYCODE.O && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickOptions();
|
clickOptions();
|
||||||
} else if (event.key === KEY.B && event.altKey && Player.bladeburner) {
|
} else if (event.code === KEYCODE.B && event.altKey && Player.bladeburner) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickBladeburner();
|
clickBladeburner();
|
||||||
} else if (event.key === KEY.G && event.altKey && Player.gang) {
|
} else if (event.code === KEYCODE.G && event.altKey && Player.gang) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
clickGang();
|
clickGang();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import Paper from "@mui/material/Paper";
|
|||||||
import Popper from "@mui/material/Popper";
|
import Popper from "@mui/material/Popper";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
|
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
import { KEY, KEYCODE } from "../../utils/helpers/keyCodes";
|
||||||
import { Terminal } from "../../Terminal";
|
import { Terminal } from "../../Terminal";
|
||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
import { determineAllPossibilitiesForTabCompletion } from "../determineAllPossibilitiesForTabCompletion";
|
import { determineAllPossibilitiesForTabCompletion } from "../determineAllPossibilitiesForTabCompletion";
|
||||||
@ -316,63 +316,63 @@ export function TerminalInput(): React.ReactElement {
|
|||||||
|
|
||||||
// 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.key === KEY.C && event.ctrlKey && ref && ref.selectionStart === ref.selectionEnd) {
|
if (event.code === KEYCODE.C && event.ctrlKey && ref && ref.selectionStart === ref.selectionEnd) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
Terminal.print(`[${Player.getCurrentServer().hostname} ~${Terminal.cwd()}]> ${value}`);
|
Terminal.print(`[${Player.getCurrentServer().hostname} ~${Terminal.cwd()}]> ${value}`);
|
||||||
modifyInput("clearall");
|
modifyInput("clearall");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.A && event.ctrlKey) {
|
if (event.code === KEYCODE.A && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("home");
|
moveTextCursor("home");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.E && event.ctrlKey) {
|
if (event.code === KEYCODE.E && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("end");
|
moveTextCursor("end");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.B && event.ctrlKey) {
|
if (event.code === KEYCODE.B && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("prevchar");
|
moveTextCursor("prevchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.B && event.altKey) {
|
if (event.code === KEYCODE.B && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("prevword");
|
moveTextCursor("prevword");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.F && event.ctrlKey) {
|
if (event.code === KEYCODE.F && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("nextchar");
|
moveTextCursor("nextchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.F && event.altKey) {
|
if (event.code === KEYCODE.F && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
moveTextCursor("nextword");
|
moveTextCursor("nextword");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((event.key === KEY.H || event.key === KEY.D) && event.ctrlKey) {
|
if ((event.code === KEYCODE.H || event.code === KEYCODE.D) && event.ctrlKey) {
|
||||||
modifyInput("backspace");
|
modifyInput("backspace");
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.W && event.ctrlKey) {
|
if (event.code === KEYCODE.W && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
modifyInput("deletewordbefore");
|
modifyInput("deletewordbefore");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.D && event.altKey) {
|
if (event.code === KEYCODE.D && event.altKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
modifyInput("deletewordafter");
|
modifyInput("deletewordafter");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.U && event.ctrlKey) {
|
if (event.code === KEYCODE.U && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
modifyInput("clearbefore");
|
modifyInput("clearbefore");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === KEY.K && event.ctrlKey) {
|
if (event.code === KEYCODE.K && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
modifyInput("clearafter");
|
modifyInput("clearafter");
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/** Keyboard key codes */
|
/** Keyboard key codes as returned by event.key */
|
||||||
export enum KEY {
|
export enum KEY {
|
||||||
//SHIFT: 16, // Check by `&& event.shiftKey`
|
//SHIFT: 16, // Check by `&& event.shiftKey`
|
||||||
//CTRL: 17, // Check by `&& event.ctrlKey`
|
//CTRL: 17, // Check by `&& event.ctrlKey`
|
||||||
@ -69,3 +69,67 @@ export enum KEY {
|
|||||||
Y = "y",
|
Y = "y",
|
||||||
Z = "z",
|
Z = "z",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Keyboard key codes as returned by event.code */
|
||||||
|
export enum KEYCODE {
|
||||||
|
//SHIFT: 16, // Check by `&& event.shiftKey`
|
||||||
|
//CTRL: 17, // Check by `&& event.ctrlKey`
|
||||||
|
//ALT: 18, // Check by `&& event.altKey`
|
||||||
|
ENTER = "Enter",
|
||||||
|
ESC = "Escape",
|
||||||
|
TAB = "Tab",
|
||||||
|
SPACE = "Space",
|
||||||
|
BACKSPACE = "Backspace",
|
||||||
|
UP_ARROW = "ArrowUp",
|
||||||
|
DOWN_ARROW = "ArrowDown",
|
||||||
|
LEFT_ARROW = "ArrowLeft",
|
||||||
|
RIGHT_ARROW = "ArrowRight",
|
||||||
|
|
||||||
|
BACKWARD_SLASH = "Backslash",
|
||||||
|
BACKQUOTE = "Backquote",
|
||||||
|
COMMA = "Comma",
|
||||||
|
DOT = "Period",
|
||||||
|
EQUAL = "Equal",
|
||||||
|
FORWARD_SLASH = "Slash",
|
||||||
|
HYPHEN = "Minus",
|
||||||
|
SEMICOLON = "Semicolon",
|
||||||
|
QUOTE = "Quote",
|
||||||
|
|
||||||
|
k0 = "Digit0",
|
||||||
|
k1 = "Digit1",
|
||||||
|
k2 = "Digit2",
|
||||||
|
k3 = "Digit3",
|
||||||
|
k4 = "Digit4",
|
||||||
|
k5 = "Digit5",
|
||||||
|
k6 = "Digit6",
|
||||||
|
k7 = "Digit7",
|
||||||
|
k8 = "Digit8",
|
||||||
|
k9 = "Digit9",
|
||||||
|
|
||||||
|
A = "KeyA",
|
||||||
|
B = "KeyB",
|
||||||
|
C = "KeyC",
|
||||||
|
D = "KeyD",
|
||||||
|
E = "KeyE",
|
||||||
|
F = "KeyF",
|
||||||
|
G = "KeyG",
|
||||||
|
H = "KeyH",
|
||||||
|
I = "KeyI",
|
||||||
|
J = "KeyJ",
|
||||||
|
K = "KeyK",
|
||||||
|
L = "KeyL",
|
||||||
|
M = "KeyM",
|
||||||
|
N = "KeyN",
|
||||||
|
O = "KeyO",
|
||||||
|
P = "KeyP",
|
||||||
|
Q = "KeyQ",
|
||||||
|
R = "KeyR",
|
||||||
|
S = "KeyS",
|
||||||
|
T = "KeyT",
|
||||||
|
U = "KeyU",
|
||||||
|
V = "KeyV",
|
||||||
|
W = "KeyW",
|
||||||
|
X = "KeyX",
|
||||||
|
Y = "KeyY",
|
||||||
|
Z = "KeyZ",
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user