mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-24 09:18:27 +00:00
parent
aec7d085d4
commit
c34fa963a7
1 changed files with 14 additions and 6 deletions
|
|
@ -16,6 +16,13 @@ import * as jotai from "jotai";
|
|||
const simpleControlShiftAtom = jotai.atom(false);
|
||||
const globalKeyMap = new Map<string, (waveEvent: WaveKeyboardEvent) => boolean>();
|
||||
|
||||
function getFocusedBlockInActiveTab() {
|
||||
const activeTabId = globalStore.get(atoms.activeTabId);
|
||||
const layoutModel = getLayoutModelForTabById(activeTabId);
|
||||
const focusedNode = globalStore.get(layoutModel.focusedNode);
|
||||
return focusedNode.data?.blockId;
|
||||
}
|
||||
|
||||
function getSimpleControlShiftAtom() {
|
||||
return simpleControlShiftAtom;
|
||||
}
|
||||
|
|
@ -161,12 +168,6 @@ function appHandleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
|
|||
const blockId = focusedNode?.data?.blockId;
|
||||
if (blockId != null && shouldDispatchToBlock(waveEvent)) {
|
||||
const bcm = getBlockComponentModel(blockId);
|
||||
if (bcm.openSwitchConnection != null) {
|
||||
if (keyutil.checkKeyPressed(waveEvent, "Cmd:g")) {
|
||||
bcm.openSwitchConnection();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const viewModel = bcm?.viewModel;
|
||||
if (viewModel?.keyDownHandler) {
|
||||
const handledByBlock = viewModel.keyDownHandler(waveEvent);
|
||||
|
|
@ -262,6 +263,13 @@ function registerGlobalKeys() {
|
|||
switchBlockInDirection(tabId, NavigateDirection.Right);
|
||||
return true;
|
||||
});
|
||||
globalKeyMap.set("Cmd:g", () => {
|
||||
const bcm = getBlockComponentModel(getFocusedBlockInActiveTab());
|
||||
if (bcm.openSwitchConnection != null) {
|
||||
bcm.openSwitchConnection();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
for (let idx = 1; idx <= 9; idx++) {
|
||||
globalKeyMap.set(`Cmd:${idx}`, () => {
|
||||
switchTabAbs(idx);
|
||||
|
|
|
|||
Loading…
Reference in a new issue