1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add terminal shortcut for mac os (#2316)

Signed-off-by: vshakirova <vshakirova@mirantis.com>
This commit is contained in:
Violetta 2021-03-15 16:22:30 +04:00 committed by GitHub
parent 817f01321d
commit 8e1583a59c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import { dockStore, TabId } from "./dock.store";
import { TerminalApi } from "../../api/terminal-api"; import { TerminalApi } from "../../api/terminal-api";
import { themeStore } from "../../theme.store"; import { themeStore } from "../../theme.store";
import { autobind } from "../../utils"; import { autobind } from "../../utils";
import { isMac } from "../../../common/vars";
export class Terminal { export class Terminal {
static spawningPool: HTMLElement; static spawningPool: HTMLElement;
@ -182,7 +183,7 @@ export class Terminal {
}; };
keyHandler = (evt: KeyboardEvent): boolean => { keyHandler = (evt: KeyboardEvent): boolean => {
const { code, ctrlKey, type } = evt; const { code, ctrlKey, type, metaKey } = evt;
// Handle custom hotkey bindings // Handle custom hotkey bindings
if (ctrlKey) { if (ctrlKey) {
@ -199,6 +200,15 @@ export class Terminal {
} }
} }
//Ctrl+K: clear the entire buffer, making the prompt line the new first line on mac os
if (isMac && metaKey) {
switch (code) {
case "KeyK":
this.onClear();
break;
}
}
// Pass the event above in DOM for <Dock/> to handle common actions // Pass the event above in DOM for <Dock/> to handle common actions
if (!evt.defaultPrevented) { if (!evt.defaultPrevented) {
this.elem.dispatchEvent(new KeyboardEvent(type, evt)); this.elem.dispatchEvent(new KeyboardEvent(type, evt));