Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gdamore/tcell
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.
https://github.com/gdamore/tcell
Last synced: 3 days ago
JSON representation
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.
- Host: GitHub
- URL: https://github.com/gdamore/tcell
- Owner: gdamore
- License: apache-2.0
- Created: 2015-09-27T06:37:33.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-11-18T20:41:24.000Z (24 days ago)
- Last Synced: 2024-11-25T09:03:05.597Z (17 days ago)
- Language: Go
- Size: 2.26 MB
- Stars: 4,622
- Watchers: 74
- Forks: 310
- Open Issues: 28
-
Metadata Files:
- Readme: README-wasm.md
- Changelog: CHANGESv2.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
- Authors: AUTHORS
Awesome Lists containing this project
- awesome-trevor - TCell - alternate terminal package, similar in some ways to termbox (Programming / Golang)
- awesome-starred - tcell - Tcell is an alternate terminal package, similar in some ways to termbox, but better in others. (Go)
- my-awesome - gdamore/tcell - 11 star:4.6k fork:0.3k Tcell is an alternate terminal package, similar in some ways to termbox, but better in others. (Go)
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
```sh
GOOS=js GOARCH=wasm go build -o yourfile.wasm
```## Additional files
You also need 5 other files in the same directory as the wasm. Four (`tcell.html`, `tcell.js`, `termstyle.css`, and `beep.wav`) are provided in the `webfiles` directory. The last one, `wasm_exec.js`, can be copied from GOROOT into the current directory by executing
```sh
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./
```In `tcell.js`, you also need to change the constant
```js
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:
```golang
// server.gopackage 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:
```html```
## Other considerations
### Accessing files
`io.Open(filename)` and other related functions for reading file systems do not work; use `http.Get(filename)` instead.