term scrollback size and reduce cache frequency (#978)

This commit is contained in:
Mike Sawka 2024-10-07 09:51:23 -07:00 committed by GitHub
parent d9d19f8368
commit 92fd371fc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 22 additions and 1 deletions

View File

@ -304,6 +304,19 @@ const TerminalView = ({ blockId, model }: TerminalViewProps) => {
const termTheme = computeTheme(fullConfig, blockData?.meta?.["term:theme"]); const termTheme = computeTheme(fullConfig, blockData?.meta?.["term:theme"]);
const themeCopy = { ...termTheme }; const themeCopy = { ...termTheme };
themeCopy.background = "#00000000"; themeCopy.background = "#00000000";
let termScrollback = 1000;
if (termSettings?.["term:scrollback"]) {
termScrollback = Math.floor(termSettings["term:scrollback"]);
}
if (blockData?.meta?.["term:scrollback"]) {
termScrollback = Math.floor(blockData.meta["term:scrollback"]);
}
if (termScrollback < 0) {
termScrollback = 0;
}
if (termScrollback > 10000) {
termScrollback = 10000;
}
const termWrap = new TermWrap( const termWrap = new TermWrap(
blockId, blockId,
connectElemRef.current, connectElemRef.current,
@ -315,6 +328,7 @@ const TerminalView = ({ blockId, model }: TerminalViewProps) => {
fontWeight: "normal", fontWeight: "normal",
fontWeightBold: "bold", fontWeightBold: "bold",
allowTransparency: true, allowTransparency: true,
scrollback: termScrollback,
}, },
{ {
keydownHandler: handleTerminalKeydown, keydownHandler: handleTerminalKeydown,

View File

@ -21,6 +21,7 @@ const dlog = debug("wave:termwrap");
const TermFileName = "term"; const TermFileName = "term";
const TermCacheFileName = "cache:term:full"; const TermCacheFileName = "cache:term:full";
const MinDataProcessedForCache = 100 * 1024;
// detect webgl support // detect webgl support
function detectWebGLSupport(): boolean { function detectWebGLSupport(): boolean {
@ -250,7 +251,7 @@ export class TermWrap {
} }
processAndCacheData() { processAndCacheData() {
if (this.dataBytesProcessed < 10 * 1024) { if (this.dataBytesProcessed < MinDataProcessedForCache) {
return; return;
} }
const serializedOutput = this.serializeAddon.serialize(); const serializedOutput = this.serializeAddon.serialize();

View File

@ -305,6 +305,7 @@ declare global {
"term:theme"?: string; "term:theme"?: string;
"term:localshellpath"?: string; "term:localshellpath"?: string;
"term:localshellopts"?: string[]; "term:localshellopts"?: string[];
"term:scrollback"?: number;
count?: number; count?: number;
}; };
@ -423,6 +424,7 @@ declare global {
"term:disablewebgl"?: boolean; "term:disablewebgl"?: boolean;
"term:localshellpath"?: string; "term:localshellpath"?: string;
"term:localshellopts"?: string[]; "term:localshellopts"?: string[];
"term:scrollback"?: number;
"editor:minimapenabled"?: boolean; "editor:minimapenabled"?: boolean;
"editor:stickyscrollenabled"?: boolean; "editor:stickyscrollenabled"?: boolean;
"web:*"?: boolean; "web:*"?: boolean;

View File

@ -62,6 +62,7 @@ const (
MetaKey_TermTheme = "term:theme" MetaKey_TermTheme = "term:theme"
MetaKey_TermLocalShellPath = "term:localshellpath" MetaKey_TermLocalShellPath = "term:localshellpath"
MetaKey_TermLocalShellOpts = "term:localshellopts" MetaKey_TermLocalShellOpts = "term:localshellopts"
MetaKey_TermScrollback = "term:scrollback"
MetaKey_Count = "count" MetaKey_Count = "count"
) )

View File

@ -63,6 +63,7 @@ type MetaTSType struct {
TermTheme string `json:"term:theme,omitempty"` TermTheme string `json:"term:theme,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"` // matches settings TermLocalShellPath string `json:"term:localshellpath,omitempty"` // matches settings
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` // matches settings TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` // matches settings
TermScrollback *int `json:"term:scrollback,omitempty"`
Count int `json:"count,omitempty"` // temp for cpu plot. will remove later Count int `json:"count,omitempty"` // temp for cpu plot. will remove later
} }

View File

@ -20,6 +20,7 @@ const (
ConfigKey_TermDisableWebGl = "term:disablewebgl" ConfigKey_TermDisableWebGl = "term:disablewebgl"
ConfigKey_TermLocalShellPath = "term:localshellpath" ConfigKey_TermLocalShellPath = "term:localshellpath"
ConfigKey_TermLocalShellOpts = "term:localshellopts" ConfigKey_TermLocalShellOpts = "term:localshellopts"
ConfigKey_TermScrollback = "term:scrollback"
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled" ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled" ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"

View File

@ -54,6 +54,7 @@ type SettingsType struct {
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"` TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"` TermLocalShellPath string `json:"term:localshellpath,omitempty"`
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` TermLocalShellOpts []string `json:"term:localshellopts,omitempty"`
TermScrollback *int64 `json:"term:scrollback,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"` EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"` EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`