mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
implement copy on select for terminal (#1029)
This commit is contained in:
parent
31535404f5
commit
a15b339f39
@ -5,7 +5,7 @@ import { getFileSubject } from "@/app/store/wps";
|
||||
import { sendWSCommand } from "@/app/store/ws";
|
||||
import { RpcApi } from "@/app/store/wshclientapi";
|
||||
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
||||
import { PLATFORM, WOS, atoms, fetchWaveFile, globalStore, openLink } from "@/store/global";
|
||||
import { PLATFORM, WOS, atoms, fetchWaveFile, getSettingsKeyAtom, globalStore, openLink } from "@/store/global";
|
||||
import * as services from "@/store/services";
|
||||
import * as util from "@/util/util";
|
||||
import { base64ToArray, fireAndForget } from "@/util/util";
|
||||
@ -134,7 +134,19 @@ export class TermWrap {
|
||||
}
|
||||
|
||||
async initTerminal() {
|
||||
const copyOnSelectAtom = getSettingsKeyAtom("term:copyonselect");
|
||||
this.terminal.onData(this.handleTermData.bind(this));
|
||||
this.terminal.onSelectionChange(
|
||||
debounce(50, () => {
|
||||
if (!globalStore.get(copyOnSelectAtom)) {
|
||||
return;
|
||||
}
|
||||
const selectedText = this.terminal.getSelection();
|
||||
if (selectedText.length > 0) {
|
||||
navigator.clipboard.writeText(selectedText);
|
||||
}
|
||||
})
|
||||
);
|
||||
this.mainFileSubject = getFileSubject(this.blockId, TermFileName);
|
||||
this.mainFileSubject.subscribe(this.handleNewFileSubjectData.bind(this));
|
||||
try {
|
||||
|
@ -9,4 +9,9 @@
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
// try to force pixel alignment to prevent
|
||||
// subpixel rendering artifacts
|
||||
transform: translate3d(0, 0, 0);
|
||||
will-change: transform;
|
||||
}
|
||||
|
1
frontend/types/gotypes.d.ts
vendored
1
frontend/types/gotypes.d.ts
vendored
@ -445,6 +445,7 @@ declare global {
|
||||
"term:localshellpath"?: string;
|
||||
"term:localshellopts"?: string[];
|
||||
"term:scrollback"?: number;
|
||||
"term:copyonselect"?: boolean;
|
||||
"editor:minimapenabled"?: boolean;
|
||||
"editor:stickyscrollenabled"?: boolean;
|
||||
"web:*"?: boolean;
|
||||
|
@ -11,5 +11,6 @@
|
||||
"web:defaulturl": "https://github.com/wavetermdev/waveterm",
|
||||
"web:defaultsearch": "https://www.google.com/search?q={query}",
|
||||
"window:tilegapsize": 3,
|
||||
"telemetry:enabled": true
|
||||
"telemetry:enabled": true,
|
||||
"term:copyonselect": true
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ const (
|
||||
ConfigKey_TermLocalShellPath = "term:localshellpath"
|
||||
ConfigKey_TermLocalShellOpts = "term:localshellopts"
|
||||
ConfigKey_TermScrollback = "term:scrollback"
|
||||
ConfigKey_TermCopyOnSelect = "term:copyonselect"
|
||||
|
||||
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
|
||||
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"
|
||||
|
@ -60,6 +60,7 @@ type SettingsType struct {
|
||||
TermLocalShellPath string `json:"term:localshellpath,omitempty"`
|
||||
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"`
|
||||
TermScrollback *int64 `json:"term:scrollback,omitempty"`
|
||||
TermCopyOnSelect *bool `json:"term:copyonselect,omitempty"`
|
||||
|
||||
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
|
||||
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user