MCPcopy
hub / github.com/gdamore/tcell

github.com/gdamore/tcell @v3.4.0 sqlite

repository ↗ · DeepWiki ↗ · release v3.4.0 ↗
1,409 symbols 5,851 edges 106 files 782 documented · 56%
README

WASM for Tcell

You can build Tcell project into a webpage by compiling it slightly differently. This will result in a Tcell project you can embed into another html page, or use as a standalone page.

Building your project

WASM needs special build flags in order to work. You can build it by executing

GOOS=js GOARCH=wasm go build -o yourfile.wasm

Additional files

You also need the supporting web files in the same directory as the wasm. The files tcell.html, tcell.js, termstyle.css, and beep.wav, plus the ghostty-web directory, are provided in the webfiles directory. The last file, wasm_exec.js, can be copied from GOROOT into the current directory by executing

cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" ./

The web frontend uses ghostty-web. The required browser runtime files are vendored in webfiles/ghostty-web and must be copied alongside tcell.js; no npm, bundler, or external CDN is required. The vendored ghostty-web files are MIT licensed; see webfiles/ghostty-web/LICENSE.

cp -R webfiles/ghostty-web /path/to/dir/to/serve/

The vendored ghostty-web.js is intentionally browser-only. Its upstream Node readFile fallback import is removed so browser-oriented servers and bundlers such as Vite do not try to resolve a Node file-system shim; the bundled code loads ghostty-vt.wasm with fetch.

For example:

mkdir -p /tmp/tcell-wasm
cp webfiles/tcell.html webfiles/tcell.js webfiles/termstyle.css webfiles/beep.wav /tmp/tcell-wasm/
cp -R webfiles/ghostty-web /tmp/tcell-wasm/
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" /tmp/tcell-wasm/
GOOS=js GOARCH=wasm go build -o /tmp/tcell-wasm/main.wasm ./demos/unicode
python3 -m http.server -d /tmp/tcell-wasm 8080

In tcell.js, you also need to change the constant

const wasmFilePath = "yourfile.wasm"

to the file you outputted to when building.

Displaying your project

Standalone

You can see the project (with an white background around the terminal) by serving the directory. You can do this using any framework, including another golang project:

// server.go

package main

import (
    "log"
    "net/http"
)

func main() {
    log.Fatal(http.ListenAndServe(":8080",
        http.FileServer(http.Dir("/path/to/dir/to/serve")),
    ))
}

To see the webpage with this example, you can type in localhost:8080/tcell.html into your browser while server.go is running.

Embedding

It is recommended to use an iframe if you want to embed the app into a webpage:

<iframe src="https://github.com/gdamore/tcell/raw/v3.4.0/tcell.html" title="Tcell app"></iframe>

Sizing

By default the web terminal fits itself to the size of the #terminal element and reacts to container resizes. The bundled termstyle.css makes this full-page by default.

You can override the terminal cell dimensions explicitly in HTML:

<pre id="terminal" data-cols="100" data-rows="30"></pre>

If only one of data-cols or data-rows is set, the other dimension remains reactive.

Other considerations

Accessing files

io.Open(filename) and other related functions for reading file systems do not work; use http.Get(filename) instead.

Keyboard shortcuts

The browser may reserve some key combinations before JavaScript can see or cancel them. This is especially common for Meta/Command shortcuts on macOS, such as Command-L. Standalone Meta key events can be reported, but Meta-modified key combinations are browser-dependent and should not be relied upon in WASM web mode.

Extension points exported contracts — how you extend this code

Tty (Interface)
Tty is an abstraction of a tty (traditionally "teletype"). This allows applications to provide for alternate backends, [6 …
tty/tty.go
Resizer (Interface)
Resizer adds notifications when the window size changes. [7 implementers]
vt/backend.go
Event (Interface)
Event is a generic interface used for passing around Events. Concrete types follow. [3 implementers]
event.go
MockOpt (Interface)
MockOpt is an interface by which options can change the behavior of the mocked terminal. This is intended to permit easi [2 …
vt/mock.go
Emulator (Interface)
Emulator is a terminal emulator API. It implements the state machinery (escape parsing and so forth) associated with bei [1 …
vt/emulate.go
Screen (Interface)
Screen represents the physical (or emulated) screen. This can be a terminal window or a physical console. Platforms imp
screen.go
TerminfoScreenOption (Interface)
(no doc)
tscreen.go
Backend (Interface)
Backend describes the backend of a terminal. This can be used to create a real emulator, while allowing the processor fr [2 …
vt/backend.go

Core symbols most depended-on inside this repo

CheckContent
called by 725
vt/tests/util.go
WriteF
called by 668
vt/tests/util.go
NewMockTerm
called by 143
vt/mock.go
CheckPos
called by 121
vt/tests/util.go
KeyTap
called by 119
vt/mock.go
MustClose
called by 113
vt/tests/util.go
MustStart
called by 113
vt/tests/util.go
VerifyF
called by 105
vt/tests/util.go

Shape

Method 837
Function 423
Struct 60
TypeAlias 37
Class 32
Interface 20

Languages

Go80%
TypeScript20%

Modules by API surface

webfiles/ghostty-web/ghostty-web.js253 symbols
vt/emulate.go168 symbols
tscreen.go102 symbols
screen.go92 symbols
vt/mock.go91 symbols
vt/tests/emulate_test.go55 symbols
input.go40 symbols
vt/tests/mock_test.go39 symbols
tscreen_test.go39 symbols
input_test.go38 symbols
style.go32 symbols
webfiles/tcell.js28 symbols

Dependencies from manifests, versioned

github.com/clipperhouse/displaywidthv0.11.0 · 1×
github.com/clipperhouse/uax29/v2v2.7.0 · 1×
github.com/gdamore/encodingv1.0.1 · 1×
github.com/lucasb-eyer/go-colorfulv1.4.0 · 1×
golang.org/x/sysv0.44.0 · 1×
golang.org/x/termv0.43.0 · 1×
golang.org/x/textv0.37.0 · 1×

For agents

$ claude mcp add tcell \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact