diff --git a/example/wasm-vt/README.md b/example/wasm-vt/README.md new file mode 100644 index 000000000..92e928405 --- /dev/null +++ b/example/wasm-vt/README.md @@ -0,0 +1,39 @@ +# WebAssembly VT Terminal Example + +This example demonstrates how to use the Ghostty VT library from WebAssembly +to initialize a terminal, write VT-encoded data to it, and format the +terminal contents as plain text. + +## Building + +First, build the WebAssembly module: + +```bash +zig build -Demit-lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall +``` + +This will create `zig-out/bin/ghostty-vt.wasm`. + +## Running + +**Important:** You must serve this via HTTP, not open it as a file directly. +Browsers block loading WASM files from `file://` URLs. + +From the **root of the ghostty repository**, serve with a local HTTP server: + +```bash +# Using Python (recommended) +python3 -m http.server 8000 + +# Or using Node.js +npx serve . + +# Or using PHP +php -S localhost:8000 +``` + +Then open your browser to: + +``` +http://localhost:8000/example/wasm-vt/ +``` diff --git a/example/wasm-vt/index.html b/example/wasm-vt/index.html new file mode 100644 index 000000000..7ed1f7b9d --- /dev/null +++ b/example/wasm-vt/index.html @@ -0,0 +1,318 @@ + + +
+ + +This example demonstrates initializing a terminal, writing VT-encoded data to it, and formatting the output using the Ghostty VT WebAssembly module.
+ +Use \x1b for ESC, \r\n for CR+LF. Press "Run" to process.
+ +Note: This example must be served via HTTP (not opened directly as a file). See the README for instructions.
+ + + +