I'm guessing that performance of this relative to xterm right now isn't... the best, mainly because the way you're grabbing the viewport seems expensive. I'm curious though if you did any benchmarks?
One thing you probably really want to expose is the new RenderState API: https://github.com/ghostty-org/ghostty/blob/main/src/termina... You're doing per row line grabbing currently which is probably pretty slow. The RenderState API is stateful and produces the state necessary to create a high-performance, delta update renderer. It's what our production GPU renderers are now built on (but the API itself is compatible with any kind of renderer). It'd be better for you.
After all that, I'm very curious even at this rudimentary level what the performance on various benchmarks look like compared to xterm.js.
Excellent work!
I'll swap it over to the new RenderState API and post some benchmarks!
Many kudos to y'all, we were shocked how simple it was to hack this together.
Terminal emulators are all approximations of terminals, regardless of the programming language.
https://ghostty-web.wasmer.app/
How to try it locally:
npx @ghostty-web/demo@next # The preferred way
# OR
wasmer run wasmer/ghostty-web
-> Go to http://localhost:8080/
Source code: https://github.com/wasmerio/webassembly.sh (updated from xterm into ghostty-web without any issue!)Currently you need the command-line to try it, which is an unfortunate UX.
We are releasing soon a new version of wasmer-js, so it should be very easy to use it with webassembly.sh (note webassembly.sh and wasmer.sh share the same code)
https://github.com/wasmerio/wasmer-js/tree/main/examples/was...
When users reattach to their session we render the terminal state and output from ghostty. Super cool and works really well. It’s basically tmux-lite in 1k LoC
Maybe I’ll try the session name thing, I just foresee it being annoying. Do you see your tool as a shpool replacement?
I wonder if https://github.com/zed-industries/zed/discussions/18129 is still accurate. Would love to be able to use Ghostty as my Zed terminal.
Search had been a blocker, but that's coming soon; beyond that not sure that there's any reason other than inertia. Alacritty is totally fine, but excited for the Ghostty focus on performance (obviously), and the font rendering stuff looks excellent (though TBD how much of that we can "just use" vs needing to copy-pasta)
(Edit) Download it here: https://github.com/ghostty-org/ghostty/releases/tag/tip
i can't recall why i made the transition (maybe just to try it out, and it became default?). i can't think of any practical consequences of this transition.
why do you care about whether zed uses alacritty or ghostty under the hood?
I have reported font rendering issues to Alacritty in the past and let's just say the developer was not exactly receptive to fixing them since they occur on macOS and not his preferred OS of Linux.
Currently it uses Xterm.js - but I'll have to try swapping Xterm out for ghostty-web!
The nice thing about this is that you do not need an OS / backend of any kind - everything runs in the browser - similar to webcontainers but without even needing a container.
# Use 17 for Ctrl, 18 for Alt, 91 or 224 for Meta, 0 for none.
- name: ui.key.accelKey
type: uint32_t
#ifdef XP_MACOSX
value: 224
#else
value: 17
#endif
// user.js
user_pref("ui.key.accelKey", 91);Unless you actually need/want those features (which, although I am a terminal aficionado, I must admit are niche as fuck), pick whichever terminal makes you happy. Features that are important to some people are performance, Unicode support, and OS support.
The most decidedly non-ELI5 feature comparison: https://www.jeffquast.com/post/state-of-terminal-emulation-2... and https://ucs-detect.readthedocs.io/results.html
With no config at all, ghostty looks nicer than my alacritty setup. The rendering is just real nice. I could probably get alacritty to look as nice or nicer, but ghostty just worked this way with no config needed.
So you could consider aesthetics and rendering quality, and simplicity of setup both as features, which people may need/want (or not).
Problem is, we don't all agree with what the OOBE should be. I, for example, always strip out menus, tabs, and other UI features. For me, the terminal that requires the least lines in the config file is probably going to be the winner (assuming no unfixable defects that effect me).
For instance if you're a cloud provider, and you want people to be able to "drop in a shell" on a machine, but make that available through the web, you could use this
Stellar work, Kyle! Cheers
Considering the native Ghostty does, I _think_ the answer would be yes? I might tinker around with this and let you know.
We'd have to look and see if these support WebGL/GPU. The next problem would be making all that fit into the wasm blob.
Or, we may be able to skip most of this is the OpenGL syntax we use is already compatible. Then no transpiling necessary...
We can easily make a browser shell that let's people run basic commands, but presumably most want to try `vim` and other commands they'd typically invoke.
`npx @ghostty-web/demo@next` starts an HTTP server on `localhost:8080`, so you could just wrap a basic Dockerfile with NPM installed (and maybe a variety of fun Linux tooling, ala vim).
Feel free to shoot me an email: kyle@coder.com. I'll happily add it to the README.
Ghostty has much better VT100 compatibility. It should have much better performance as well once we optimize.
(Seems slightly better in the actual Ghostty app, but not in any usable way: here was my comparison last year https://shreevatsa.net/post/terminal-indic/ and Ghostty is comparable to the other terminal apps, better than some, worse than some. Anyway the fact that it works in Ghostty but not in ghostty-web casts doubt on “Ghostty's emulator is the same battle-tested code that runs the native Ghostty app”. Do you understand what is going on?)
Thank you for letting me know!