Skip to content

Commit

Permalink
allow to configure xterm.js options through the xterm property
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Dec 16, 2023
1 parent 1cd905f commit 922ee66
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
23 changes: 12 additions & 11 deletions frontend/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export type Config = {
theme?: string
themeDark?: string
env: Record<string, string>
defaultProfile: string
profiles: Record<string, Profile>
}
theme?: string;
themeDark?: string;
xterm: Record<string, unknown>;
env: Record<string, string>;
defaultProfile: string;
profiles: Record<string, Profile>;
};

export type Profile = {
command: string
args?: string[]
env?: Record<string, string>
favicon?: string
}
command: string;
args?: string[];
env?: Record<string, string>;
favicon?: string;
};
5 changes: 5 additions & 0 deletions frontend/src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async function main() {
for (const row of rows) {
terminal.writeln(row);
}
terminal.scrollToTop();
return;
}

Expand All @@ -93,6 +94,7 @@ async function main() {
theme: window.matchMedia("(prefers-color-scheme: dark)").matches
? darkTheme
: lightTheme,
...config.xterm,
});

const fitAddon = new FitAddon();
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit 922ee66

Please sign in to comment.