From 43f81e16d4ad9807a115cf5b0a93ce6d6a5048c2 Mon Sep 17 00:00:00 2001 From: weilirs Date: Wed, 8 Jan 2025 14:54:46 -0500 Subject: [PATCH 1/2] work with cmd+N but not clicking the "terminal" button --- frontend/app/store/keymodel.ts | 12 ++++++++++++ frontend/types/gotypes.d.ts | 3 +++ pkg/wconfig/metaconsts.go | 3 +++ pkg/wconfig/settingsconfig.go | 3 +++ 4 files changed, 21 insertions(+) diff --git a/frontend/app/store/keymodel.ts b/frontend/app/store/keymodel.ts index 59dd55d123..f7d2b672dd 100644 --- a/frontend/app/store/keymodel.ts +++ b/frontend/app/store/keymodel.ts @@ -8,6 +8,7 @@ import { getAllBlockComponentModels, getApi, getBlockComponentModel, + getSettingsKeyAtom, globalStore, refocusNode, WOS, @@ -162,12 +163,23 @@ function globalRefocus() { } async function handleCmdN() { + const termAutoClose = globalStore.get(getSettingsKeyAtom("term:autoclose")) as boolean | undefined; + const termAutoCloseOnError = globalStore.get(getSettingsKeyAtom("term:autocloseonerror")) as boolean | undefined; + const termAutoCloseDelay = globalStore.get(getSettingsKeyAtom("term:autoclosedelay")) as number | undefined; + const termBlockDef: BlockDef = { meta: { view: "term", controller: "shell", + "cmd:closeonexitforce": termAutoCloseOnError ?? false, + "cmd:closeonexitdelay": termAutoCloseDelay ?? 2000, }, }; + if (termAutoClose && !termAutoCloseOnError) { + termBlockDef.meta["cmd:closeonexitforce"] = false; + termBlockDef.meta["cmd:closeonexitdelay"] = termAutoCloseDelay ?? 2000; + termBlockDef.meta["cmd:closeonexit"] = true; + } const layoutModel = getLayoutModelForStaticTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode != null) { diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 4354af5cdc..5e964a3686 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -601,6 +601,9 @@ declare global { "term:copyonselect"?: boolean; "term:transparency"?: number; "term:allowbracketedpaste"?: boolean; + "term:autoclose"?: boolean; + "term:autocloseonerror"?: boolean; + "term:autoclosedelay"?: number; "editor:minimapenabled"?: boolean; "editor:stickyscrollenabled"?: boolean; "editor:wordwrap"?: boolean; diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go index 4e95a33734..ab89775531 100644 --- a/pkg/wconfig/metaconsts.go +++ b/pkg/wconfig/metaconsts.go @@ -35,6 +35,9 @@ const ( ConfigKey_TermCopyOnSelect = "term:copyonselect" ConfigKey_TermTransparency = "term:transparency" ConfigKey_TermAllowBracketedPaste = "term:allowbracketedpaste" + ConfigKey_TermAutoClose = "term:autoclose" + ConfigKey_TermAutoCloseOnError = "term:autocloseonerror" + ConfigKey_TermAutoCloseDelay = "term:autoclosedelay" ConfigKey_EditorMinimapEnabled = "editor:minimapenabled" ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled" diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 354975b786..fa3c14bcb3 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -62,6 +62,9 @@ type SettingsType struct { TermCopyOnSelect *bool `json:"term:copyonselect,omitempty"` TermTransparency *float64 `json:"term:transparency,omitempty"` TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"` + TermAutoClose *bool `json:"term:autoclose,omitempty"` + TermAutoCloseOnError *bool `json:"term:autocloseonerror,omitempty"` + TermAutoCloseDelay *float64 `json:"term:autoclosedelay,omitempty"` EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"` EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"` From 6fcb5a004d3f75da856fd2723bad9735a64dc1ea Mon Sep 17 00:00:00 2001 From: weilirs Date: Wed, 8 Jan 2025 16:32:46 -0500 Subject: [PATCH 2/2] feat: configurable autoclose when shell exits --- frontend/app/store/keymodel.ts | 6 +----- pkg/wconfig/defaultconfig/settings.json | 5 ++++- pkg/wconfig/defaultconfig/widgets.json | 5 ++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/app/store/keymodel.ts b/frontend/app/store/keymodel.ts index f7d2b672dd..5c94087c8a 100644 --- a/frontend/app/store/keymodel.ts +++ b/frontend/app/store/keymodel.ts @@ -175,11 +175,7 @@ async function handleCmdN() { "cmd:closeonexitdelay": termAutoCloseDelay ?? 2000, }, }; - if (termAutoClose && !termAutoCloseOnError) { - termBlockDef.meta["cmd:closeonexitforce"] = false; - termBlockDef.meta["cmd:closeonexitdelay"] = termAutoCloseDelay ?? 2000; - termBlockDef.meta["cmd:closeonexit"] = true; - } + const layoutModel = getLayoutModelForStaticTab(); const focusedNode = globalStore.get(layoutModel.focusedNode); if (focusedNode != null) { diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json index 3da7e6fd21..92b505fb6e 100644 --- a/pkg/wconfig/defaultconfig/settings.json +++ b/pkg/wconfig/defaultconfig/settings.json @@ -21,5 +21,8 @@ "window:confirmclose": true, "window:savelastwindow": true, "telemetry:enabled": true, - "term:copyonselect": true + "term:copyonselect": true, + "term:autoclose": true, + "term:autocloseonerror": false, + "term:autoclosedelay": 2000 } diff --git a/pkg/wconfig/defaultconfig/widgets.json b/pkg/wconfig/defaultconfig/widgets.json index 97a3d26c10..067e76b363 100644 --- a/pkg/wconfig/defaultconfig/widgets.json +++ b/pkg/wconfig/defaultconfig/widgets.json @@ -6,7 +6,10 @@ "blockdef": { "meta": { "view": "term", - "controller": "shell" + "controller": "shell", + "cmd:closeonexit": true, + "cmd:closeonexitforce": false, + "cmd:closeonexitdelay": 2000 } } },