Skip to content

Commit 84d4191

Browse files
authored
ctrl-shift state fix + add new keybindings to docs (#1792)
1 parent 385d011 commit 84d4191

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

docs/docs/keybindings.mdx

+8-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ replace "Cmd" with "Alt" (note that "Ctrl" is "Ctrl" on both Mac, Windows, and L
3838
| <Kbd k="Cmd:]"/> | Switch tab right |
3939
| <Kbd k="Cmd:Ctrl:1-9"/> | Switch to workspace number |
4040
| <Kbd k="Cmd:Shift:r"/> | Refresh the UI |
41+
| <Kbd k="Ctrl:Shift:i"/> | Toggle terminal multi-input mode |
4142

4243
## File Preview Keybindings
4344

@@ -64,6 +65,7 @@ replace "Cmd" with "Alt" (note that "Ctrl" is "Ctrl" on both Mac, Windows, and L
6465
| <Kbd k="Cmd:r"/> | Reload webpage |
6566
| <Kbd k="Cmd:ArrowLeft"/> | Back |
6667
| <Kbd k="Cmd:ArrowRight"/> | Forward |
68+
| <Kbd k="Cmd:f"/> | Find in webpage |
6769

6870
## WaveAI Keybindings
6971

@@ -73,11 +75,12 @@ replace "Cmd" with "Alt" (note that "Ctrl" is "Ctrl" on both Mac, Windows, and L
7375

7476
## Terminal Keybindings
7577

76-
| Key | Function |
77-
| ----------------------- | -------------- |
78-
| <Kbd k="Ctrl:Shift:c"/> | Copy |
79-
| <Kbd k="Ctrl:Shift:v"/> | Paste |
80-
| <Kbd k="Cmd:k"/> | Clear Terminal |
78+
| Key | Function |
79+
| ----------------------- | ---------------- |
80+
| <Kbd k="Ctrl:Shift:c"/> | Copy |
81+
| <Kbd k="Ctrl:Shift:v"/> | Paste |
82+
| <Kbd k="Cmd:k"/> | Clear Terminal |
83+
| <Kbd k="Cmd:f"/> | Find in Terminal |
8184

8285
## Customizeable Systemwide Global Hotkey
8386

emain/emain-util.ts

+9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ import { getWebServerEndpoint } from "../frontend/util/endpoints";
66

77
export const WaveAppPathVarName = "WAVETERM_APP_PATH";
88

9+
// not necessarily exact, but we use this to help get us unstuck in certain cases
10+
let lastCtrlShiftSate: boolean = false;
11+
912
export function delay(ms): Promise<void> {
1013
return new Promise((resolve) => setTimeout(resolve, ms));
1114
}
1215

1316
function setCtrlShift(wc: Electron.WebContents, state: boolean) {
17+
lastCtrlShiftSate = state;
1418
wc.send("control-shift-state-update", state);
1519
}
1620

@@ -30,6 +34,11 @@ export function handleCtrlShiftState(sender: Electron.WebContents, waveEvent: Wa
3034
setCtrlShift(sender, true);
3135
}
3236
}
37+
if (lastCtrlShiftSate) {
38+
if (!waveEvent.control || !waveEvent.shift) {
39+
setCtrlShift(sender, false);
40+
}
41+
}
3342
return;
3443
}
3544
if (waveEvent.type == "keydown") {

frontend/app/app.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
PLATFORM,
1313
removeFlashError,
1414
} from "@/store/global";
15-
import { appHandleKeyDown } from "@/store/keymodel";
15+
import { appHandleKeyDown, keyboardMouseDownHandler } from "@/store/keymodel";
1616
import { getElemAsStr } from "@/util/focusutil";
1717
import * as keyutil from "@/util/keyutil";
1818
import * as util from "@/util/util";
@@ -193,9 +193,11 @@ const AppKeyHandlers = () => {
193193
useEffect(() => {
194194
const staticKeyDownHandler = keyutil.keydownWrapper(appHandleKeyDown);
195195
document.addEventListener("keydown", staticKeyDownHandler);
196+
document.addEventListener("mousedown", keyboardMouseDownHandler);
196197

197198
return () => {
198199
document.removeEventListener("keydown", staticKeyDownHandler);
200+
document.removeEventListener("mousedown", keyboardMouseDownHandler);
199201
};
200202
}, []);
201203
return null;

frontend/app/store/keymodel.ts

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ import * as jotai from "jotai";
2626
const simpleControlShiftAtom = jotai.atom(false);
2727
const globalKeyMap = new Map<string, (waveEvent: WaveKeyboardEvent) => boolean>();
2828

29+
export function keyboardMouseDownHandler(e: MouseEvent) {
30+
if (!e.ctrlKey || !e.shiftKey) {
31+
unsetControlShift();
32+
}
33+
}
34+
2935
function getFocusedBlockInStaticTab() {
3036
const tabId = globalStore.get(atoms.staticTabId);
3137
const layoutModel = getLayoutModelForTabById(tabId);

0 commit comments

Comments
 (0)