mirror of
https://github.com/wavetermdev/backup.git
synced 2026-04-22 15:26:58 -07:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ffcc18a74f | |||
| 14b5101f6a | |||
| 09e5b1842d | |||
| 19410b0024 | |||
| 898594f7c1 |
@@ -53,6 +53,12 @@ Install modules (we use yarn):
|
||||
yarn
|
||||
```
|
||||
|
||||
Electron also requires specific builds of node_modules to work (because Electron embeds a specific node.js version that might not match your development node.js version). We use a special electron command to cross-compile those modules:
|
||||
|
||||
```
|
||||
scripthaus run electron-rebuild
|
||||
```
|
||||
|
||||
## Running WebPack
|
||||
|
||||
We use webpack to build both the React and Electron App Wrapper code. They are both run together using:
|
||||
|
||||
@@ -20,7 +20,7 @@ Wave isn't just another terminal emulator; it's a rethink on how terminals are b
|
||||
- CodeEdit, to edit local and remote files with a VSCode-like inline editor
|
||||
- AI Integration with ChatGPT (or ChatGPT compatible APIs) to help write commands and get answers inline
|
||||
|
||||

|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ The license disclaimers for the backend are generated using the [go-licenses](ht
|
||||
|
||||
The license disclaimers for the frontend are generated using the [`yarn licenses` tool](https://classic.yarnpkg.com/lang/en/docs/cli/licenses/). This outputs to the file [`frontend.md`](./disclaimers/frontend.md).
|
||||
|
||||
These disclaimer files linked above will be periodically regenerated to reflect new dependencies.
|
||||
These three disclaimer files linked above will be periodically regenerated to reflect new dependencies.
|
||||
|
||||
The [`scripthaus.md` file](../scripthaus.md) contains scripts to generate the disclaimers and package them. To manually generate the disclaimers, run the following from the repository root directory:
|
||||
The [`scripthaus.md` file](../scripthaus.md) contains scripts to genrate the disclaimers and package them. To manually generate the disclaimers, run the following from the repository root directory:
|
||||
|
||||
```bash
|
||||
scripthaus run generate-license-disclaimers
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -39,14 +39,6 @@
|
||||
"command": "app:openTabSearchModal",
|
||||
"keys": ["Cmd:p"]
|
||||
},
|
||||
{
|
||||
"command": "app:openConnectionsView",
|
||||
"keys": []
|
||||
},
|
||||
{
|
||||
"command": "app:openSettingsView",
|
||||
"keys": []
|
||||
},
|
||||
{
|
||||
"command": "app:newTab",
|
||||
"keys": ["Cmd:t"]
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 306 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 217 KiB |
@@ -220,4 +220,6 @@
|
||||
--modal-header-bottom-border-color: rgba(241, 246, 243, 0.15);
|
||||
|
||||
--logo-button-hover-bg-color: #1e1e1e;
|
||||
|
||||
--xterm-viewport-border-color: rgba(241, 246, 243, 0.15);
|
||||
}
|
||||
|
||||
@@ -74,4 +74,6 @@
|
||||
--toggle-thumb-color: var(--app-bg-color);
|
||||
|
||||
--logo-button-hover-bg-color: #f0f0f0;
|
||||
|
||||
--xterm-viewport-border-color: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
:root {
|
||||
/*
|
||||
* term colors (16 + 5) form the base terminal theme
|
||||
* term colors (16 + 2) form the base terminal theme
|
||||
* for consistency these colors should be used by plugins/applications
|
||||
*/
|
||||
--term-black: #000000;
|
||||
@@ -27,5 +27,4 @@
|
||||
--term-cmdtext: #ffffff;
|
||||
--term-foreground: #d3d7cf;
|
||||
--term-background: #000000;
|
||||
--term-selection-background: #ffffff40;
|
||||
}
|
||||
|
||||
@@ -6,5 +6,4 @@
|
||||
--term-foreground: #000000;
|
||||
--term-background: #fefefe;
|
||||
--term-cmdtext: #000000;
|
||||
--term-selection-background: #00000018;
|
||||
}
|
||||
|
||||
@@ -90,12 +90,25 @@
|
||||
margin-top: 5px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
border: 1px solid var(--app-border-color);
|
||||
border-radius: 6px;
|
||||
padding: 6px 10px;
|
||||
|
||||
.terminal-connectelem {
|
||||
height: 163px !important; // Needed to override plugin height
|
||||
|
||||
.xterm-viewport {
|
||||
display: flex;
|
||||
padding: 6px 10px;
|
||||
gap: 8px;
|
||||
align-items: flex-start;
|
||||
align-self: stretch;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--xterm-viewport-border-color);
|
||||
background: #080a08;
|
||||
height: 163px !important; // Needed to override plugin height
|
||||
}
|
||||
|
||||
.xterm-screen {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
-1
@@ -355,6 +355,13 @@ function createMainWindow(clientData: ClientDataType | null): Electron.BrowserWi
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:i")) {
|
||||
e.preventDefault();
|
||||
if (!input.alt) {
|
||||
win.webContents.send("i-cmd", mods);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:r")) {
|
||||
e.preventDefault();
|
||||
win.webContents.send("r-cmd", mods);
|
||||
@@ -370,6 +377,16 @@ function createMainWindow(clientData: ClientDataType | null): Electron.BrowserWi
|
||||
win.webContents.send("w-cmd", mods);
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:h")) {
|
||||
win.webContents.send("h-cmd", mods);
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:p")) {
|
||||
win.webContents.send("p-cmd", mods);
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:ArrowUp") || checkKeyPressed(waveEvent, "Cmd:ArrowDown")) {
|
||||
if (checkKeyPressed(waveEvent, "Cmd:ArrowUp")) {
|
||||
win.webContents.send("meta-arrowup");
|
||||
@@ -388,7 +405,7 @@ function createMainWindow(clientData: ClientDataType | null): Electron.BrowserWi
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (input.code.startsWith("Digit") && input.meta && !input.control) {
|
||||
if (input.code.startsWith("Digit") && input.meta) {
|
||||
const digitNum = parseInt(input.code.substring(5));
|
||||
if (isNaN(digitNum) || digitNum < 1 || digitNum > 9) {
|
||||
return;
|
||||
|
||||
@@ -21,8 +21,11 @@ contextBridge.exposeInMainWorld("api", {
|
||||
getAppUpdateStatus: () => ipcRenderer.sendSync("get-app-update-status"),
|
||||
onAppUpdateStatus: (callback) => ipcRenderer.on("app-update-status", (_, val) => callback(val)),
|
||||
onTCmd: (callback) => ipcRenderer.on("t-cmd", callback),
|
||||
onICmd: (callback) => ipcRenderer.on("i-cmd", callback),
|
||||
onLCmd: (callback) => ipcRenderer.on("l-cmd", callback),
|
||||
onHCmd: (callback) => ipcRenderer.on("h-cmd", callback),
|
||||
onWCmd: (callback) => ipcRenderer.on("w-cmd", callback),
|
||||
onPCmd: (callback) => ipcRenderer.on("p-cmd", callback),
|
||||
onRCmd: (callback) => ipcRenderer.on("r-cmd", callback),
|
||||
onZoomChanged: (callback) => ipcRenderer.on("zoom-changed", callback),
|
||||
onMetaArrowUp: (callback) => ipcRenderer.on("meta-arrowup", callback),
|
||||
|
||||
@@ -304,10 +304,6 @@ class CommandRunner {
|
||||
GlobalModel.clientSettingsViewModel.showClientSettingsView();
|
||||
}
|
||||
|
||||
syncShellState() {
|
||||
GlobalModel.submitCommand("sync", null, null, { nohist: "1" }, false);
|
||||
}
|
||||
|
||||
historyView(params: HistorySearchParams) {
|
||||
let kwargs = { nohist: "1" };
|
||||
kwargs["offset"] = String(params.offset);
|
||||
|
||||
+57
-132
@@ -36,7 +36,6 @@ import { Cmd } from "./cmd";
|
||||
import { GlobalCommandRunner } from "./global";
|
||||
import { clearMonoFontCache, getMonoFontSize } from "@/util/textmeasure";
|
||||
import type { TermWrap } from "@/plugins/terminal/term";
|
||||
import * as util from "@/util/util";
|
||||
|
||||
type SWLinePtr = {
|
||||
line: LineType;
|
||||
@@ -144,9 +143,6 @@ class Model {
|
||||
});
|
||||
this.ws.reconnect();
|
||||
this.keybindManager = new KeybindManager();
|
||||
this.readConfigKeybindings();
|
||||
this.initSystemKeybindings();
|
||||
this.initAppKeybindings();
|
||||
this.inputModel = new InputModel(this);
|
||||
this.pluginsModel = new PluginsModel(this);
|
||||
this.bookmarksModel = new BookmarksModel(this);
|
||||
@@ -175,8 +171,18 @@ class Model {
|
||||
}
|
||||
return fontSize;
|
||||
});
|
||||
this.keybindManager.registerKeybinding("system", "electron", "any", (waveEvent) => {
|
||||
if (this.keybindManager.checkKeyPressed(waveEvent, "system:toggleDeveloperTools")) {
|
||||
getApi().toggleDeveloperTools();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
getApi().onTCmd(this.onTCmd.bind(this));
|
||||
getApi().onICmd(this.onICmd.bind(this));
|
||||
getApi().onLCmd(this.onLCmd.bind(this));
|
||||
getApi().onHCmd(this.onHCmd.bind(this));
|
||||
getApi().onPCmd(this.onPCmd.bind(this));
|
||||
getApi().onWCmd(this.onWCmd.bind(this));
|
||||
getApi().onRCmd(this.onRCmd.bind(this));
|
||||
getApi().onZoomChanged(this.onZoomChanged.bind(this));
|
||||
@@ -202,68 +208,6 @@ class Model {
|
||||
};
|
||||
}
|
||||
|
||||
readConfigKeybindings() {
|
||||
const url = new URL(this.getBaseHostPort() + "/config/keybindings.json");
|
||||
let prtn = fetch(url, { method: "get", body: null, headers: this.getFetchHeaders() });
|
||||
prtn.then((resp) => {
|
||||
if (resp.status == 404) {
|
||||
return [];
|
||||
} else if (!resp.ok) {
|
||||
util.handleNotOkResp(resp, url);
|
||||
}
|
||||
return resp.json();
|
||||
}).then((userKeybindings) => {
|
||||
this.keybindManager.setUserKeybindings(userKeybindings);
|
||||
});
|
||||
}
|
||||
|
||||
initSystemKeybindings() {
|
||||
this.keybindManager.registerKeybinding("system", "electron", "system:toggleDeveloperTools", (waveEvent) => {
|
||||
getApi().toggleDeveloperTools();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
initAppKeybindings() {
|
||||
for (let index = 1; index <= 9; index++) {
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:selectWorkspace-" + index, (waveEvent) => {
|
||||
this.onSwitchSessionCmd(index);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:focusCmdInput", (waveEvent) => {
|
||||
console.log("focus cmd input callback");
|
||||
this.onFocusCmdInputPressed();
|
||||
return true;
|
||||
});
|
||||
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:bookmarkActiveLine", (waveEvent) => {
|
||||
this.onBookmarkViewPressed();
|
||||
return true;
|
||||
});
|
||||
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:openHistory", (waveEvent) => {
|
||||
this.onOpenHistoryPressed();
|
||||
return true;
|
||||
});
|
||||
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:openTabSearchModal", (waveEvent) => {
|
||||
this.onOpenTabSearchModalPressed();
|
||||
return true;
|
||||
});
|
||||
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:openConnectionsView", (waveEvent) => {
|
||||
this.onOpenConnectionsViewPressed();
|
||||
return true;
|
||||
});
|
||||
|
||||
this.keybindManager.registerKeybinding("app", "model", "app:openSettingsView", (waveEvent) => {
|
||||
this.onOpenSettingsViewPressed();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static getInstance(): Model {
|
||||
if (!(window as any).GlobalModel) {
|
||||
(window as any).GlobalModel = new Model();
|
||||
@@ -505,49 +449,56 @@ class Model {
|
||||
}
|
||||
if (this.activeMainView.get() == "bookmarks") {
|
||||
this.bookmarksModel.handleDocKeyDown(e);
|
||||
return;
|
||||
}
|
||||
if (this.activeMainView.get() == "history") {
|
||||
this.historyViewModel.handleDocKeyDown(e);
|
||||
return;
|
||||
}
|
||||
if (this.activeMainView.get() == "connections") {
|
||||
this.historyViewModel.handleDocKeyDown(e);
|
||||
return;
|
||||
}
|
||||
if (this.activeMainView.get() == "clientsettings") {
|
||||
this.historyViewModel.handleDocKeyDown(e);
|
||||
} else {
|
||||
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||
e.preventDefault();
|
||||
if (this.activeMainView.get() == "webshare") {
|
||||
this.showSessionView();
|
||||
return;
|
||||
}
|
||||
if (this.clearModals()) {
|
||||
return;
|
||||
}
|
||||
const inputModel = this.inputModel;
|
||||
inputModel.toggleInfoMsg();
|
||||
if (inputModel.inputMode.get() != null) {
|
||||
inputModel.resetInputMode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Escape")) {
|
||||
e.preventDefault();
|
||||
if (this.activeMainView.get() == "webshare") {
|
||||
this.showSessionView();
|
||||
return;
|
||||
}
|
||||
if (this.activeMainView.get() == "session" && checkKeyPressed(waveEvent, "Cmd:Ctrl:s")) {
|
||||
e.preventDefault();
|
||||
const activeScreen = this.getActiveScreen();
|
||||
if (activeScreen != null) {
|
||||
const isSidebarOpen = activeScreen.isSidebarOpen();
|
||||
if (isSidebarOpen) {
|
||||
GlobalCommandRunner.screenSidebarClose();
|
||||
} else {
|
||||
GlobalCommandRunner.screenSidebarOpen();
|
||||
}
|
||||
if (this.clearModals()) {
|
||||
return;
|
||||
}
|
||||
const inputModel = this.inputModel;
|
||||
inputModel.toggleInfoMsg();
|
||||
if (inputModel.inputMode.get() != null) {
|
||||
inputModel.resetInputMode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:b")) {
|
||||
e.preventDefault();
|
||||
GlobalCommandRunner.bookmarksView();
|
||||
}
|
||||
if (this.activeMainView.get() == "session" && checkKeyPressed(waveEvent, "Cmd:Ctrl:s")) {
|
||||
e.preventDefault();
|
||||
const activeScreen = this.getActiveScreen();
|
||||
if (activeScreen != null) {
|
||||
const isSidebarOpen = activeScreen.isSidebarOpen();
|
||||
if (isSidebarOpen) {
|
||||
GlobalCommandRunner.screenSidebarClose();
|
||||
} else {
|
||||
GlobalCommandRunner.screenSidebarOpen();
|
||||
}
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:d")) {
|
||||
const ranDelete = this.deleteActiveLine();
|
||||
if (ranDelete) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Cmd:d")) {
|
||||
const ranDelete = this.deleteActiveLine();
|
||||
if (ranDelete) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
this.keybindManager.processKeyEvent(e, waveEvent);
|
||||
@@ -747,22 +698,8 @@ class Model {
|
||||
GlobalCommandRunner.createNewScreen();
|
||||
}
|
||||
|
||||
onBookmarkViewPressed() {
|
||||
GlobalCommandRunner.bookmarksView();
|
||||
}
|
||||
|
||||
onFocusCmdInputPressed() {
|
||||
if (this.activeMainView.get() != "session") {
|
||||
mobx.action(() => {
|
||||
this.activeMainView.set("session");
|
||||
setTimeout(() => {
|
||||
// allows for the session view to load
|
||||
this.inputModel.giveFocus();
|
||||
}, 100);
|
||||
})();
|
||||
} else {
|
||||
this.inputModel.giveFocus();
|
||||
}
|
||||
onICmd(e: any, mods: KeyModsType) {
|
||||
this.inputModel.giveFocus();
|
||||
}
|
||||
|
||||
onLCmd(e: any, mods: KeyModsType) {
|
||||
@@ -772,22 +709,14 @@ class Model {
|
||||
}
|
||||
}
|
||||
|
||||
onOpenHistoryPressed() {
|
||||
onHCmd(e: any, mods: KeyModsType) {
|
||||
this.historyViewModel.reSearch();
|
||||
}
|
||||
|
||||
onOpenTabSearchModalPressed() {
|
||||
onPCmd(e: any, mods: KeyModsType) {
|
||||
this.modalsModel.pushModal(appconst.TAB_SWITCHER);
|
||||
}
|
||||
|
||||
onOpenConnectionsViewPressed() {
|
||||
this.activeMainView.set("connections");
|
||||
}
|
||||
|
||||
onOpenSettingsViewPressed() {
|
||||
this.activeMainView.set("clientsettings");
|
||||
}
|
||||
|
||||
getFocusedLine(): LineFocusType {
|
||||
if (this.inputModel.hasFocus()) {
|
||||
return { cmdInputFocus: true };
|
||||
@@ -854,12 +783,11 @@ class Model {
|
||||
}
|
||||
}
|
||||
|
||||
onSwitchSessionCmd(digit: number) {
|
||||
console.log("switching to ", digit);
|
||||
GlobalCommandRunner.switchSession(String(digit));
|
||||
}
|
||||
|
||||
onDigitCmd(e: any, arg: { digit: number }, mods: KeyModsType) {
|
||||
if (mods.meta && mods.ctrl) {
|
||||
GlobalCommandRunner.switchSession(String(arg.digit));
|
||||
return;
|
||||
}
|
||||
GlobalCommandRunner.switchScreen(String(arg.digit));
|
||||
}
|
||||
|
||||
@@ -1086,9 +1014,6 @@ class Model {
|
||||
this.activeMainView.set("session");
|
||||
this.deactivateScreenLines();
|
||||
this.ws.watchScreen(newActiveSessionId, newActiveScreenId);
|
||||
setTimeout(() => {
|
||||
GlobalCommandRunner.syncShellState();
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
console.warn("unknown update", genUpdate);
|
||||
@@ -1373,7 +1298,7 @@ class Model {
|
||||
};
|
||||
/**
|
||||
console.log(
|
||||
"CMD"
|
||||
"CMD",
|
||||
pk.metacmd + (pk.metasubcmd != null ? ":" + pk.metasubcmd : ""),
|
||||
pk.args,
|
||||
pk.kwargs,
|
||||
@@ -1601,7 +1526,7 @@ class Model {
|
||||
.then((resp) => {
|
||||
if (!resp.ok) {
|
||||
badResponseStr = sprintf(
|
||||
"Bad fetch response for /apiread-file: %d %s",
|
||||
"Bad fetch response for /api/read-file: %d %s",
|
||||
resp.status,
|
||||
resp.statusText
|
||||
);
|
||||
|
||||
@@ -57,7 +57,6 @@ function getThemeFromCSSVars(): ITheme {
|
||||
theme.brightMagenta = rootStyle.getPropertyValue("--term-bright-magenta");
|
||||
theme.brightCyan = rootStyle.getPropertyValue("--term-bright-cyan");
|
||||
theme.brightWhite = rootStyle.getPropertyValue("--term-bright-white");
|
||||
theme.selectionBackground = rootStyle.getPropertyValue("--term-selection-background");
|
||||
return theme;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
@@ -896,7 +896,10 @@ declare global {
|
||||
getAppUpdateStatus: () => AppUpdateStatusType;
|
||||
onAppUpdateStatus: (callback: (status: AppUpdateStatusType) => void) => void;
|
||||
onTCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onICmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onLCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onHCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onPCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onRCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onWCmd: (callback: (mods: KeyModsType) => void) => void;
|
||||
onZoomChanged: (callback: () => void) => void;
|
||||
|
||||
+42
-64
@@ -1,10 +1,8 @@
|
||||
import * as React from "react";
|
||||
import * as mobx from "mobx";
|
||||
import * as electron from "electron";
|
||||
import { parse } from "node:path";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import defaultKeybindingsFile from "../../assets/default-keybindings.json";
|
||||
const defaultKeybindings: KeybindConfig = defaultKeybindingsFile;
|
||||
import keybindings from "../../assets/keybindings.json";
|
||||
|
||||
type KeyPressDecl = {
|
||||
mods: {
|
||||
@@ -24,7 +22,6 @@ const KeyTypeKey = "key";
|
||||
const KeyTypeCode = "code";
|
||||
|
||||
type KeybindCallback = (event: WaveKeyboardEvent) => boolean;
|
||||
type KeybindConfig = Array<{ command: string; keys: Array<string> }>;
|
||||
|
||||
type Keybind = {
|
||||
domain: string;
|
||||
@@ -39,64 +36,6 @@ class KeybindManager {
|
||||
levelMap: Map<string, Array<Keybind>>;
|
||||
levelArray: Array<string>;
|
||||
keyDescriptionsMap: Map<string, Array<string>>;
|
||||
userKeybindings: KeybindConfig;
|
||||
userKeybindingError: OV<string>;
|
||||
|
||||
constructor() {
|
||||
this.levelMap = new Map();
|
||||
this.domainCallbacks = new Map();
|
||||
this.levelArray = KeybindLevels;
|
||||
for (let index = 0; index < this.levelArray.length; index++) {
|
||||
let curLevel = this.levelArray[index];
|
||||
this.levelMap.set(curLevel, new Array<Keybind>());
|
||||
}
|
||||
this.userKeybindingError = mobx.observable.box(null, {
|
||||
name: "keyutil-userKeybindingError",
|
||||
});
|
||||
this.initKeyDescriptionsMap();
|
||||
}
|
||||
|
||||
initKeyDescriptionsMap() {
|
||||
mobx.action(() => {
|
||||
this.userKeybindingError.set(null);
|
||||
})();
|
||||
let newKeyDescriptions = new Map();
|
||||
for (let index = 0; index < defaultKeybindings.length; index++) {
|
||||
let curKeybind = defaultKeybindings[index];
|
||||
newKeyDescriptions.set(curKeybind.command, curKeybind.keys);
|
||||
}
|
||||
let curUserCommand = "";
|
||||
if (this.userKeybindings != null && this.userKeybindings instanceof Array) {
|
||||
try {
|
||||
for (let index = 0; index < this.userKeybindings.length; index++) {
|
||||
let curKeybind = this.userKeybindings[index];
|
||||
if (curKeybind == null) {
|
||||
throw new Error("keybind entry is null");
|
||||
}
|
||||
curUserCommand = curKeybind.command;
|
||||
if (typeof curKeybind.command != "string") {
|
||||
throw new Error("invalid keybind command");
|
||||
}
|
||||
if (curKeybind.keys == null || !(curKeybind.keys instanceof Array)) {
|
||||
throw new Error("invalid keybind keys");
|
||||
}
|
||||
for (let key of curKeybind.keys) {
|
||||
if (typeof key != "string") {
|
||||
throw new Error("invalid keybind key");
|
||||
}
|
||||
}
|
||||
newKeyDescriptions.set(curKeybind.command, curKeybind.keys);
|
||||
}
|
||||
} catch (e) {
|
||||
let userError = `${curUserCommand} is invalid: error: ${e}`;
|
||||
console.log(userError);
|
||||
mobx.action(() => {
|
||||
this.userKeybindingError.set(userError);
|
||||
})();
|
||||
}
|
||||
}
|
||||
this.keyDescriptionsMap = newKeyDescriptions;
|
||||
}
|
||||
|
||||
processLevel(nativeEvent: any, event: WaveKeyboardEvent, keybindsArray: Array<Keybind>): boolean {
|
||||
// iterate through keybinds in backwards order
|
||||
@@ -257,11 +196,50 @@ class KeybindManager {
|
||||
this.domainCallbacks.set(domain, callback);
|
||||
}
|
||||
|
||||
setUserKeybindings(userKeybindings) {
|
||||
this.userKeybindings = userKeybindings;
|
||||
constructor() {
|
||||
this.levelMap = new Map();
|
||||
this.domainCallbacks = new Map();
|
||||
this.levelArray = KeybindLevels;
|
||||
for (let index = 0; index < this.levelArray.length; index++) {
|
||||
let curLevel = this.levelArray[index];
|
||||
this.levelMap.set(curLevel, new Array<Keybind>());
|
||||
}
|
||||
this.initKeyDescriptionsMap();
|
||||
}
|
||||
|
||||
initKeyDescriptionsMap() {
|
||||
this.keyDescriptionsMap = new Map();
|
||||
for (let index = 0; index < keybindings.length; index++) {
|
||||
let curKeybind = keybindings[index];
|
||||
this.keyDescriptionsMap.set(curKeybind.command, curKeybind.keys);
|
||||
}
|
||||
let error = false;
|
||||
let numberedTabKeybinds = [];
|
||||
for (let index = 1; index <= 9; index++) {
|
||||
let curKeybind = this.keyDescriptionsMap.get("app:selectTab-" + index);
|
||||
if (curKeybind == null) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
numberedTabKeybinds = numberedTabKeybinds.concat(curKeybind);
|
||||
}
|
||||
if (!error) {
|
||||
this.keyDescriptionsMap.set("app:selectNumberedTab", numberedTabKeybinds);
|
||||
}
|
||||
let numberedWorkspaceKeybinds = [];
|
||||
for (let index = 1; index <= 9; index++) {
|
||||
let curKeybind = this.keyDescriptionsMap.get("app:selectTab-" + index);
|
||||
if (curKeybind == null) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
numberedWorkspaceKeybinds = numberedWorkspaceKeybinds.concat(curKeybind);
|
||||
}
|
||||
if (!error) {
|
||||
this.keyDescriptionsMap.set("app:selectNumberedTab", numberedWorkspaceKeybinds);
|
||||
}
|
||||
}
|
||||
|
||||
checkKeyPressed(event: WaveKeyboardEvent, keyDescription: string): boolean {
|
||||
if (keyDescription == "any") {
|
||||
return true;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user