Add per-task terminals over WebSocket with an xterm.js Terminal tab

This commit is contained in:
Ian Gulliver
2026-10-15 12:06:50 -07:00
parent 37bf1b60a7
commit ff22f33025
33 changed files with 1600 additions and 167 deletions
+10 -1
View File
@@ -5,7 +5,7 @@ export class ApiError extends Error {
this.status = status;
}
}
export async function request(method, path, opts = {}) {
function target(path, opts) {
const pathParams = (opts.path ?? {});
let url = path.replace(/\{(\w+)\}/g, (_, key) => {
const value = pathParams[key];
@@ -23,6 +23,10 @@ export async function request(method, path, opts = {}) {
if (query.size > 0) {
url += `?${query}`;
}
return url;
}
export async function request(method, path, opts = {}) {
const url = target(path, opts);
const init = { method: method.toUpperCase(), keepalive: opts.keepalive ?? false };
if (opts.body instanceof Blob) {
init.headers = { "Content-Type": opts.body.type || "application/octet-stream" };
@@ -50,6 +54,11 @@ export const get = (path, opts) => request("get", path, opts);
export const post = (path, opts) => request("post", path, opts);
export const put = (path, opts) => request("put", path, opts);
export const del = (path, opts) => request("delete", path, opts);
export function socket(path, opts) {
const ws = new WebSocket(`${location.protocol === "https:" ? "wss:" : "ws:"}//${location.host}${target(path, opts)}`);
ws.binaryType = "arraybuffer";
return ws;
}
const staleAfterMs = 40_000;
const retryAfterMs = 2_000;
export function subscribe(after, filter, onEvent, onState) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -8,10 +8,12 @@ import { openSwitcher } from "./navbar.js";
import { findTask, focusedProject, focusTab, on, onEach, state, tabs } from "./state.js";
import { mountProject } from "./project.js";
import { mountTranscript } from "./task.js";
import { mountTerminal } from "./terminal.js";
const views = {
transcript: { label: "Transcript", mount: mountTranscript },
changes: { label: "Changes", mount: (root) => mountChanges(root) },
files: { label: "Files", mount: mountFiles },
terminal: { label: "Terminal", mount: mountTerminal },
inbox: { label: "Inbox", mount: mountInbox },
project: { label: "Project", mount: mountProject },
};
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
import { get, put, subscribe } from "./api.js";
export const tabs = ["transcript", "changes", "files", "inbox", "project"];
export const tabs = ["transcript", "changes", "files", "terminal", "inbox", "project"];
export const state = {
me: undefined,
projects: [],
+1 -1
View File
File diff suppressed because one or more lines are too long
+165
View File
@@ -0,0 +1,165 @@
import { socket } from "./api.js";
import { errorText, h, replace } from "./dom.js";
import { findTask, onEach, state } from "./state.js";
const exitedCode = 4000;
const internalErrorCode = 1011;
const retryAfterMs = 2_000;
let loading;
function load() {
loading ??= (async () => {
document.head.append(h("link", { rel: "stylesheet", href: "/vendor/xterm.css" }));
const xtermUrl = "/vendor/xterm.mjs";
const fitUrl = "/vendor/addon-fit.mjs";
const [x, f] = (await Promise.all([import(xtermUrl), import(fitUrl)]));
await document.fonts.load(`13px ${getComputedStyle(document.documentElement).getPropertyValue("--font")}`);
return { Terminal: x.Terminal, FitAddon: f.FitAddon };
})();
return loading;
}
function attach(taskId, screen, show) {
const encoder = new TextEncoder();
let term;
let ws;
let observer;
let retry = 0;
let done = false;
const send = (data) => {
if (ws?.readyState === WebSocket.OPEN) {
ws.send(data);
}
};
const connect = () => {
if (!term || done) {
return;
}
clearTimeout(retry);
show("connecting…", false);
const t = term;
const s = socket("/api/tasks/{taskId}/terminal", { path: { taskId }, query: { cols: t.cols, rows: t.rows } });
ws = s;
s.onopen = () => {
t.reset();
show("", false);
};
s.onmessage = (e) => {
t.write(new Uint8Array(e.data));
};
s.onclose = (e) => {
if (ws !== s || done) {
return;
}
ws = undefined;
if (e.code === exitedCode) {
show(`shell ended: ${e.reason}`, true);
return;
}
if (e.code === internalErrorCode) {
show(e.reason, true);
return;
}
if (findTask(taskId)?.status !== "active") {
show("task closed", false);
return;
}
show("disconnected, reconnecting…", false);
retry = setTimeout(connect, retryAfterMs);
};
};
load()
.then(({ Terminal, FitAddon }) => {
if (done) {
return;
}
const css = getComputedStyle(document.documentElement);
const v = (name) => css.getPropertyValue(name).trim();
const t = new Terminal({
fontFamily: v("--font"),
fontSize: 13,
cursorBlink: true,
scrollback: 5000,
theme: {
background: v("--bg"),
foreground: v("--text"),
cursor: v("--accent"),
cursorAccent: v("--bg"),
selectionBackground: v("--accent-tint"),
},
});
const fit = new FitAddon();
t.loadAddon(fit);
t.open(screen);
fit.fit();
t.onData((data) => send(encoder.encode(data)));
t.onBinary((data) => send(Uint8Array.from(data, (c) => c.charCodeAt(0))));
t.onResize(({ cols, rows }) => {
if (ws?.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ cols, rows }));
}
});
observer = new ResizeObserver(() => fit.fit());
observer.observe(screen);
term = t;
t.focus();
connect();
})
.catch((err) => show(`terminal not loaded: ${errorText(err)}`, false));
return () => {
done = true;
clearTimeout(retry);
observer?.disconnect();
ws?.close();
term?.dispose();
};
}
export function mountTerminal(root) {
const status = h("span", { class: "terminal-status" });
const restart = h("button", { type: "button", hidden: true }, "New shell");
const screen = h("div", { class: "terminal-screen" });
let attached;
let detach = () => { };
const show = (text, exited) => {
status.textContent = text;
restart.hidden = !exited;
};
const open = () => {
detach();
detach = () => { };
attached = undefined;
replace(screen);
show("", false);
const taskId = state.selectedTaskId;
if (!taskId) {
replace(screen, h("div", { class: "empty" }, "No task selected."));
return;
}
if (findTask(taskId)?.status !== "active") {
replace(screen, h("div", { class: "empty" }, "The task is closed; its worktree is gone."));
return;
}
attached = taskId;
detach = attach(taskId, screen, show);
};
restart.onclick = open;
screen.addEventListener("keydown", (e) => {
if (e.ctrlKey && !e.metaKey) {
e.stopPropagation();
}
});
const offs = [
onEach(["selection"], open),
onEach(["tasks"], () => {
if (attached && findTask(attached)?.status !== "active") {
open();
}
}),
];
replace(root, h("div", { class: "terminal-view" }, h("header", { class: "terminal-header" }, h("span", { class: "terminal-title" }, "Shell in the task's worktree"), status, restart), screen));
open();
return () => {
detach();
for (const off of offs) {
off();
}
};
}
//# sourceMappingURL=terminal.js.map
+1
View File
File diff suppressed because one or more lines are too long
+19
View File
@@ -6,6 +6,8 @@
"": {
"name": "byre-web",
"devDependencies": {
"@xterm/addon-fit": "0.11.0",
"@xterm/xterm": "6.0.0",
"mermaid": "11.17.2",
"openapi-typescript": "^7.13.0",
"typescript": "^5.9.3"
@@ -449,6 +451,23 @@
"d3-transition": "^3.0.1"
}
},
"node_modules/@xterm/addon-fit": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@xterm/addon-fit/-/addon-fit-0.11.0.tgz",
"integrity": "sha512-jYcgT6xtVYhnhgxh3QgYDnnNMYTcf8ElbxxFzX0IZo+vabQqSPAjC3c1wJrKB5E19VwQei89QCiZZP86DCPF7g==",
"dev": true,
"license": "MIT"
},
"node_modules/@xterm/xterm": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-6.0.0.tgz",
"integrity": "sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg==",
"dev": true,
"license": "MIT",
"workspaces": [
"addons/*"
]
},
"node_modules/agent-base": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
+3 -1
View File
@@ -3,9 +3,11 @@
"private": true,
"type": "module",
"scripts": {
"generate": "openapi-typescript ../api/openapi.yaml --output src/api.gen.ts && rm -rf dist && tsc && tsc --project tsconfig.sw.json && mkdir -p vendor && cp node_modules/mermaid/dist/mermaid.min.js vendor/ && cp node_modules/mermaid/LICENSE vendor/mermaid.LICENSE"
"generate": "openapi-typescript ../api/openapi.yaml --output src/api.gen.ts && rm -rf dist && tsc && tsc --project tsconfig.sw.json && mkdir -p vendor && cp node_modules/mermaid/dist/mermaid.min.js vendor/ && cp node_modules/mermaid/LICENSE vendor/mermaid.LICENSE && cp node_modules/@xterm/xterm/lib/xterm.mjs node_modules/@xterm/xterm/css/xterm.css node_modules/@xterm/addon-fit/lib/addon-fit.mjs vendor/ && cp node_modules/@xterm/xterm/LICENSE vendor/xterm.LICENSE && cp node_modules/@xterm/addon-fit/LICENSE vendor/addon-fit.LICENSE"
},
"devDependencies": {
"@xterm/addon-fit": "0.11.0",
"@xterm/xterm": "6.0.0",
"mermaid": "11.17.2",
"openapi-typescript": "^7.13.0",
"typescript": "^5.9.3"
+50 -1
View File
@@ -456,6 +456,25 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/tasks/{taskId}/terminal": {
parameters: {
query?: never;
header?: never;
path: {
taskId: string;
};
cookie?: never;
};
/** @description A WebSocket attached to the task's terminal, a login shell in its worktree, started at cols by rows if none is running. The server first sends what the terminal has recently printed, then its output as it comes, all as binary messages. The client sends input as binary messages and resizes as text messages holding a TerminalSize. When the shell exits the server closes with code 4000 and the exit status as the reason. */
get: operations["getTaskTerminal"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/tasks/{taskId}/snapshots": {
parameters: {
query?: never;
@@ -1052,7 +1071,11 @@ export interface components {
focused: boolean;
};
/** @enum {string} */
TaskTab: "transcript" | "changes" | "files" | "inbox" | "project";
TaskTab: "transcript" | "changes" | "files" | "terminal" | "inbox" | "project";
TerminalSize: {
cols: number;
rows: number;
};
Status: {
/** @description Agent processes currently running. */
live_agents: number;
@@ -1897,6 +1920,32 @@ export interface operations {
409: components["responses"]["Error"];
};
};
getTaskTerminal: {
parameters: {
query: {
cols: number;
rows: number;
};
header?: never;
path: {
taskId: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Switched to the WebSocket protocol. */
101: {
headers: {
[name: string]: unknown;
};
content?: never;
};
400: components["responses"]["Error"];
404: components["responses"]["Error"];
409: components["responses"]["Error"];
};
};
listSnapshots: {
parameters: {
query?: never;
+15 -5
View File
@@ -52,11 +52,7 @@ export class ApiError extends Error {
}
}
export async function request<M extends Method, P extends PathsWith<M>>(
method: M,
path: P,
opts: Options<Op<P, M>> = {},
): Promise<Result<Op<P, M>>> {
function target(path: string, opts: { path?: unknown; query?: unknown }): string {
const pathParams = (opts.path ?? {}) as Record<string, unknown>;
let url: string = path.replace(/\{(\w+)\}/g, (_, key: string) => {
const value = pathParams[key];
@@ -75,7 +71,15 @@ export async function request<M extends Method, P extends PathsWith<M>>(
if (query.size > 0) {
url += `?${query}`;
}
return url;
}
export async function request<M extends Method, P extends PathsWith<M>>(
method: M,
path: P,
opts: Options<Op<P, M>> = {},
): Promise<Result<Op<P, M>>> {
const url = target(path, opts);
const init: RequestInit = { method: method.toUpperCase(), keepalive: opts.keepalive ?? false };
if (opts.body instanceof Blob) {
init.headers = { "Content-Type": opts.body.type || "application/octet-stream" };
@@ -105,6 +109,12 @@ export const post = <P extends PathsWith<"post">>(path: P, opts?: Options<Op<P,
export const put = <P extends PathsWith<"put">>(path: P, opts?: Options<Op<P, "put">>) => request("put", path, opts);
export const del = <P extends PathsWith<"delete">>(path: P, opts?: Options<Op<P, "delete">>) => request("delete", path, opts);
export function socket<P extends PathsWith<"get">>(path: P, opts: Options<Op<P, "get">>): WebSocket {
const ws = new WebSocket(`${location.protocol === "https:" ? "wss:" : "ws:"}//${location.host}${target(path, opts)}`);
ws.binaryType = "arraybuffer";
return ws;
}
const staleAfterMs = 40_000;
const retryAfterMs = 2_000;
+2
View File
@@ -8,11 +8,13 @@ import { openSwitcher } from "./navbar.js";
import { findTask, focusedProject, focusTab, on, onEach, state, tabs } from "./state.js";
import { mountProject } from "./project.js";
import { mountTranscript } from "./task.js";
import { mountTerminal } from "./terminal.js";
const views: Record<TaskTab, { label: string; mount: (root: HTMLElement) => () => void }> = {
transcript: { label: "Transcript", mount: mountTranscript },
changes: { label: "Changes", mount: (root) => mountChanges(root) },
files: { label: "Files", mount: mountFiles },
terminal: { label: "Terminal", mount: mountTerminal },
inbox: { label: "Inbox", mount: mountInbox },
project: { label: "Project", mount: mountProject },
};
+1 -1
View File
@@ -17,7 +17,7 @@ export type Topic =
| "lead.transcript"
| "lead.stream";
export const tabs: TaskTab[] = ["transcript", "changes", "files", "inbox", "project"];
export const tabs: TaskTab[] = ["transcript", "changes", "files", "terminal", "inbox", "project"];
export const state = {
me: undefined as User | undefined,
+185
View File
@@ -0,0 +1,185 @@
import type { FitAddon } from "@xterm/addon-fit";
import type { Terminal } from "@xterm/xterm";
import { socket, type Schemas } from "./api.js";
import { errorText, h, replace } from "./dom.js";
import { findTask, onEach, state } from "./state.js";
type Xterm = { Terminal: typeof Terminal; FitAddon: typeof FitAddon };
const exitedCode = 4000;
const internalErrorCode = 1011;
const retryAfterMs = 2_000;
let loading: Promise<Xterm> | undefined;
function load(): Promise<Xterm> {
loading ??= (async () => {
document.head.append(h("link", { rel: "stylesheet", href: "/vendor/xterm.css" }));
const xtermUrl = "/vendor/xterm.mjs";
const fitUrl = "/vendor/addon-fit.mjs";
const [x, f] = (await Promise.all([import(xtermUrl), import(fitUrl)])) as [{ Terminal: typeof Terminal }, { FitAddon: typeof FitAddon }];
await document.fonts.load(`13px ${getComputedStyle(document.documentElement).getPropertyValue("--font")}`);
return { Terminal: x.Terminal, FitAddon: f.FitAddon };
})();
return loading;
}
type Show = (text: string, exited: boolean) => void;
function attach(taskId: string, screen: HTMLElement, show: Show): () => void {
const encoder = new TextEncoder();
let term: Terminal | undefined;
let ws: WebSocket | undefined;
let observer: ResizeObserver | undefined;
let retry = 0;
let done = false;
const send = (data: Uint8Array) => {
if (ws?.readyState === WebSocket.OPEN) {
ws.send(data);
}
};
const connect = () => {
if (!term || done) {
return;
}
clearTimeout(retry);
show("connecting…", false);
const t = term;
const s = socket("/api/tasks/{taskId}/terminal", { path: { taskId }, query: { cols: t.cols, rows: t.rows } });
ws = s;
s.onopen = () => {
t.reset();
show("", false);
};
s.onmessage = (e: MessageEvent<ArrayBuffer>) => {
t.write(new Uint8Array(e.data));
};
s.onclose = (e) => {
if (ws !== s || done) {
return;
}
ws = undefined;
if (e.code === exitedCode) {
show(`shell ended: ${e.reason}`, true);
return;
}
if (e.code === internalErrorCode) {
show(e.reason, true);
return;
}
if (findTask(taskId)?.status !== "active") {
show("task closed", false);
return;
}
show("disconnected, reconnecting…", false);
retry = setTimeout(connect, retryAfterMs);
};
};
load()
.then(({ Terminal, FitAddon }) => {
if (done) {
return;
}
const css = getComputedStyle(document.documentElement);
const v = (name: string) => css.getPropertyValue(name).trim();
const t = new Terminal({
fontFamily: v("--font"),
fontSize: 13,
cursorBlink: true,
scrollback: 5000,
theme: {
background: v("--bg"),
foreground: v("--text"),
cursor: v("--accent"),
cursorAccent: v("--bg"),
selectionBackground: v("--accent-tint"),
},
});
const fit = new FitAddon();
t.loadAddon(fit);
t.open(screen);
fit.fit();
t.onData((data) => send(encoder.encode(data)));
t.onBinary((data) => send(Uint8Array.from(data, (c) => c.charCodeAt(0))));
t.onResize(({ cols, rows }) => {
if (ws?.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ cols, rows } satisfies Schemas["TerminalSize"]));
}
});
observer = new ResizeObserver(() => fit.fit());
observer.observe(screen);
term = t;
t.focus();
connect();
})
.catch((err: unknown) => show(`terminal not loaded: ${errorText(err)}`, false));
return () => {
done = true;
clearTimeout(retry);
observer?.disconnect();
ws?.close();
term?.dispose();
};
}
export function mountTerminal(root: HTMLElement): () => void {
const status = h("span", { class: "terminal-status" });
const restart = h("button", { type: "button", hidden: true }, "New shell");
const screen = h("div", { class: "terminal-screen" });
let attached: string | undefined;
let detach: () => void = () => {};
const show: Show = (text, exited) => {
status.textContent = text;
restart.hidden = !exited;
};
const open = () => {
detach();
detach = () => {};
attached = undefined;
replace(screen);
show("", false);
const taskId = state.selectedTaskId;
if (!taskId) {
replace(screen, h("div", { class: "empty" }, "No task selected."));
return;
}
if (findTask(taskId)?.status !== "active") {
replace(screen, h("div", { class: "empty" }, "The task is closed; its worktree is gone."));
return;
}
attached = taskId;
detach = attach(taskId, screen, show);
};
restart.onclick = open;
screen.addEventListener("keydown", (e) => {
if (e.ctrlKey && !e.metaKey) {
e.stopPropagation();
}
});
const offs = [
onEach(["selection"], open),
onEach(["tasks"], () => {
if (attached && findTask(attached)?.status !== "active") {
open();
}
}),
];
replace(root, h("div", { class: "terminal-view" }, h("header", { class: "terminal-header" }, h("span", { class: "terminal-title" }, "Shell in the task's worktree"), status, restart), screen));
open();
return () => {
detach();
for (const off of offs) {
off();
}
};
}
+28
View File
@@ -300,6 +300,7 @@ textarea {
.transcript-view,
.changes-view,
.files-view,
.terminal-view,
.inbox-view {
flex: 1;
min-height: 0;
@@ -1132,6 +1133,33 @@ pre.diff .meta {
overflow: auto;
}
.terminal-header {
display: flex;
align-items: baseline;
gap: 12px;
padding: 8px 16px;
border-bottom: 1px solid var(--border);
}
.terminal-title {
flex: 1;
color: var(--muted);
}
.terminal-status {
font-size: 11px;
color: var(--muted);
white-space: nowrap;
}
.terminal-screen {
flex: 1;
min-height: 0;
overflow: hidden;
padding: 6px 8px;
background: var(--bg);
}
.entries {
display: flex;
flex-direction: column;
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+18
View File
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
* @license MIT
*
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* @license MIT
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
*/
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var h=2,_=1,o=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(r.getPropertyValue("height")),a=Math.max(0,parseInt(r.getPropertyValue("width"))),i=window.getComputedStyle(this._terminal.element),n={top:parseInt(i.getPropertyValue("padding-top")),bottom:parseInt(i.getPropertyValue("padding-bottom")),right:parseInt(i.getPropertyValue("padding-right")),left:parseInt(i.getPropertyValue("padding-left"))},m=n.top+n.bottom,d=n.right+n.left,c=l-m,p=a-d-s;return{cols:Math.max(h,Math.floor(p/t.css.cell.width)),rows:Math.max(_,Math.floor(c/t.css.cell.height))}}};export{o as FitAddon};
//# sourceMappingURL=addon-fit.mjs.map
+21
View File
@@ -0,0 +1,21 @@
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+285
View File
@@ -0,0 +1,285 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
* @license MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*/
/**
* Default styles for xterm.js
*/
.xterm {
cursor: text;
position: relative;
user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}
.xterm.focus,
.xterm:focus {
outline: none;
}
.xterm .xterm-helpers {
position: absolute;
top: 0;
/**
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 5;
}
.xterm .xterm-helper-textarea {
padding: 0;
border: 0;
margin: 0;
/* Move textarea out of the screen to the far left, so that the cursor is not visible */
position: absolute;
opacity: 0;
left: -9999em;
top: 0;
width: 0;
height: 0;
z-index: -5;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
resize: none;
}
.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
color: #FFF;
display: none;
position: absolute;
white-space: nowrap;
z-index: 1;
}
.xterm .composition-view.active {
display: block;
}
.xterm .xterm-viewport {
/* On OS X this is required in order for the scroll bar to appear fully opaque */
background-color: #000;
overflow-y: scroll;
cursor: default;
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 0;
}
.xterm .xterm-screen {
position: relative;
}
.xterm .xterm-screen canvas {
position: absolute;
left: 0;
top: 0;
}
.xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
top: 0;
left: -9999em;
line-height: normal;
}
.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}
.xterm.xterm-cursor-pointer,
.xterm .xterm-cursor-pointer {
cursor: pointer;
}
.xterm.column-select.focus {
/* Column selection mode */
cursor: crosshair;
}
.xterm .xterm-accessibility:not(.debug),
.xterm .xterm-message {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 10;
color: transparent;
pointer-events: none;
}
.xterm .xterm-accessibility-tree:not(.debug) *::selection {
color: transparent;
}
.xterm .xterm-accessibility-tree {
font-family: monospace;
user-select: text;
white-space: pre;
}
.xterm .xterm-accessibility-tree > div {
transform-origin: left;
width: fit-content;
}
.xterm .live-region {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
.xterm-dim {
/* Dim should not apply to background, so the opacity of the foreground color is applied
* explicitly in the generated class and reset to 1 here */
opacity: 1 !important;
}
.xterm-underline-1 { text-decoration: underline; }
.xterm-underline-2 { text-decoration: double underline; }
.xterm-underline-3 { text-decoration: wavy underline; }
.xterm-underline-4 { text-decoration: dotted underline; }
.xterm-underline-5 { text-decoration: dashed underline; }
.xterm-overline {
text-decoration: overline;
}
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
.xterm-strikethrough {
text-decoration: line-through;
}
.xterm-screen .xterm-decoration-container .xterm-decoration {
z-index: 6;
position: absolute;
}
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
z-index: 7;
}
.xterm-decoration-overview-ruler {
z-index: 8;
position: absolute;
top: 0;
right: 0;
pointer-events: none;
}
.xterm-decoration-top {
z-index: 2;
position: relative;
}
/* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */
/* xterm.js customization: Override xterm's cursor style */
.xterm .xterm-scrollable-element > .scrollbar {
cursor: default;
}
/* Arrows */
.xterm .xterm-scrollable-element > .scrollbar > .scra {
cursor: pointer;
font-size: 11px !important;
}
.xterm .xterm-scrollable-element > .visible {
opacity: 1;
/* Background rule added for IE9 - to allow clicks on dom node */
background:rgba(0,0,0,0);
transition: opacity 100ms linear;
/* In front of peek view */
z-index: 11;
}
.xterm .xterm-scrollable-element > .invisible {
opacity: 0;
pointer-events: none;
}
.xterm .xterm-scrollable-element > .invisible.fade {
transition: opacity 800ms linear;
}
/* Scrollable Content Inset Shadow */
.xterm .xterm-scrollable-element > .shadow {
position: absolute;
display: none;
}
.xterm .xterm-scrollable-element > .shadow.top {
display: block;
top: 0;
left: 3px;
height: 3px;
width: 100%;
box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;
}
.xterm .xterm-scrollable-element > .shadow.left {
display: block;
top: 3px;
left: 0;
height: 100%;
width: 3px;
box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
}
.xterm .xterm-scrollable-element > .shadow.top-left-corner {
display: block;
top: 0;
left: 0;
height: 3px;
width: 3px;
}
.xterm .xterm-scrollable-element > .shadow.top.left {
box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
}
+53
View File
File diff suppressed because one or more lines are too long