diff --git a/frontend/app/view/term/termwrap.ts b/frontend/app/view/term/termwrap.ts index eb098b0f9..55c68fbda 100644 --- a/frontend/app/view/term/termwrap.ts +++ b/frontend/app/view/term/termwrap.ts @@ -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 { diff --git a/frontend/app/view/webview/webview.less b/frontend/app/view/webview/webview.less index a9b8e86ce..2d42f320e 100644 --- a/frontend/app/view/webview/webview.less +++ b/frontend/app/view/webview/webview.less @@ -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; } diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index c84901570..a3e6eba1b 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -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; diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index 49e886c7a..b5c821ecf 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -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 } diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index e7a2a2c5e..57518e734 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -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" diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index cdd63d8c4..699d28187 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -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"`