From 922ee6603a0a9b14f08916d501329a32a526620e Mon Sep 17 00:00:00 2001 From: pomdtr Date: Sat, 16 Dec 2023 13:18:52 +0100 Subject: [PATCH] allow to configure xterm.js options through the xterm property --- README.md | 5 +++++ config.go | 1 + frontend/src/config.ts | 23 ++++++++++++----------- frontend/src/terminal.ts | 5 +++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d05a3c7..4758148 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,9 @@ custom path. "$schema": "https://github.com/pomdtr/tweety/releases/latest/download/config.schema.json", "theme": "Tomorrow", "themeDark": "Tomorrow Night", + "xterm": { + "fontSize": 14, + }, "env": { "EDITOR": "kak" }, @@ -123,6 +126,8 @@ custom path. } ``` +The `xterm` section is passed directly to xterm.js, see the [documentation](https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/). + ## Endpoints - `/` - open the default profile diff --git a/config.go b/config.go index 9a4e462..966d69c 100644 --- a/config.go +++ b/config.go @@ -16,6 +16,7 @@ import ( type Config struct { Theme string `json:"theme"` ThemeDark string `json:"themeDark"` + XTerm map[string]any `json:"xterm"` Env map[string]string `json:"env,omitempty"` DefaultProfile string `json:"defaultProfile"` Profiles map[string]Profile `json:"profiles"` diff --git a/frontend/src/config.ts b/frontend/src/config.ts index ca19dc4..80e9314 100644 --- a/frontend/src/config.ts +++ b/frontend/src/config.ts @@ -1,14 +1,15 @@ export type Config = { - theme?: string - themeDark?: string - env: Record - defaultProfile: string - profiles: Record -} + theme?: string; + themeDark?: string; + xterm: Record; + env: Record; + defaultProfile: string; + profiles: Record; +}; export type Profile = { - command: string - args?: string[] - env?: Record - favicon?: string -} + command: string; + args?: string[]; + env?: Record; + favicon?: string; +}; diff --git a/frontend/src/terminal.ts b/frontend/src/terminal.ts index f64bb35..394e075 100644 --- a/frontend/src/terminal.ts +++ b/frontend/src/terminal.ts @@ -74,6 +74,7 @@ async function main() { for (const row of rows) { terminal.writeln(row); } + terminal.scrollToTop(); return; } @@ -93,6 +94,7 @@ async function main() { theme: window.matchMedia("(prefers-color-scheme: dark)").matches ? darkTheme : lightTheme, + ...config.xterm, }); const fitAddon = new FitAddon(); @@ -197,6 +199,9 @@ async function main() { } websocketUrl.searchParams.set("profile", profileID); + if (params.has("input")) { + websocketUrl.searchParams.set("input", params.get("input")!); + } const ws = new WebSocket(websocketUrl); ws.onclose = () => { if (params.has("reload")) {