Readit News logoReadit News
Posted by u/shiomiru 9 months ago
Show HN: Chawan TUI web browserchawan.net/news/chawan-0-...
A terminal-based web browser in Nim.[1] Has acceptable (YMMV) CSS rendering, some JS support, and inline images (sixel/kitty). It can also use various protocols other than http(s) such as (s)ftp, gopher, gemini, ...

Chawan started out as a w3m clone, and the UI still resembles it. However, the architecture has turned out quite different, with pages loaded in separate processes, and protocol/file type handling separated out into external binaries. An interesting result is that you can even register decoders for custom inline image formats, although practical use cases of this are rather minimal.

There is a gallery showcasing some websites being rendered here: https://chawan.net/gallery/index.html

[1]: https://nim-lang.org

eMPee584 · 9 months ago
Thanks, always appreciate ways of not using another blink engine for a brief research side quest! looking forward to test after school ; )

As it hasn't been brought up yet, a really great hack (esp. for us without sixel) is this terminal port of chromium: https://github.com/fathyb/carbonyl .. but the original creator hasn't had time to get back to it. So it is very bare bones & lacks a lot of features, like keyboard shortcuts, file saving.. but obviously it brings full web compatibility and is just very cool. Wishing for someone with rust skills to pick it up again, last time I looked (couple of months ago) none of the forks had any momentum.

Imustaskforhelp · 9 months ago
Side note but on the carbonyl github post, everyone keeps asking about the author's health as if he's safe or not, given he is palestinian.

I hope the author is safe. His work was really good,I must say. Fuck wars in general.

eMPee584 · 9 months ago
Well his github profile says he's in France, so let's hope he's kinda safe.. But yeah, fuck wars in general. Also, fuck the generals.. and their commanders. Oh, and the whole military-industrial complex as well. We urgently need a transition towards a planetary non-commercial commons-based economy..
onetom · 9 months ago
@shiomiru

What's the best resource (paid or free) in your opinion for learning about these TTY related concepts?

I'm aware of https://www.linusakesson.net/programming/tty/index.php for example, but that doesn't go into termcap/terminfo/curses.

one of the comments mentions http://www.amazon.com/termcap-terminfo-OReilly-Nutshell-Lind... though (online https://www.scribd.com/document/831486848/Termcap-and-Termin...)

shiomiru · 9 months ago
chawan has a custom terminal module, so my knowledge about the standard X/Open curses is not that great.

That said, for the actual escape sequences, XTerm's ctlseqs.ms[1] is an invaluable resource. I also took many ideas from nick black's notcurses[2], and I especially recommend his notes on "sprixels".[3]

[1]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

[2]: https://nick-black.com/dankwiki/index.php/Notcurses

[3]: https://nick-black.com/dankwiki/index.php/Theory_and_Practic...

noufalibrahim · 9 months ago
This is beautifully done. I'm going to use this for some of my daily work and see how far I can get with it. HN looks exceptionally good. Thank you!
dotancohen · 9 months ago
Good of you! Don't forget to file the bugs you find.
isaacvando · 9 months ago
This is super cool! Bravo. Awesome to see it written in Nim too.

When I do `cha example.com` I can't figure out how to use any of the commands (hjkl, etc). The only keys I've found that have any effect are typing numbers which show up in the bottom left. Haven't figured out how to do anything with those. Am I missing something obvious about how to use this or could this be a bug?

I built from source on MacOS Sequoia 15.5 Apple Silicon using Nim 2.24. Pages load correctly, I just can't get the commands to work. Thanks!

isaacvando · 9 months ago
I tried it in Ghostty, iTerm2, and Terminal.app and they all behaved the same.
shiomiru · 9 months ago
It's a bug, thanks for reporting. I've created a ticket: https://todo.sr.ht/~bptato/chawan/63

Could you please pull the macos-input branch from https://git.sr.ht/~bptato/chawan and report back on what the `a` file includes after opening a site and typing some commands? (Should be created in the current working directory.)

FerretFred · 9 months ago
Very nice! I compiled this from source on my Lenovo M8 4h gen running termux: I only had to install nim. It even installed nicely despite there being no "root" user.
etaioinshrdlu · 9 months ago
I rabbit-holed a little and apparently Chrome and Safari no longer even fully pass Acid2 and Acid3?
ataylor32 · 9 months ago
Here is a relevant discussion: https://news.ycombinator.com/item?id=15256890
mariusor · 9 months ago
I've always tried to make my websites look good in Links and now it looks like I have a new candidate.

Having support for some CSS makes it a bit more difficult, as spacing between elements is now an issue, where previously links would ignore margins and padding all together which were used to display cleaner inline list elements (for menus and such).

shiomiru · 9 months ago
The intention is that it should "just work"... I'm aware sometimes it doesn't, you can consider that a bug :)

But if you really want custom CSS for grid displays, chawan does support the standard "grid" media feature: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/grid

mariusor · 9 months ago
I have implemented changes based on your advice of using @media: grid, and everything looks better now. You can check it here: https://brutalinks.tech (it's a link aggregator similar to HN).
mariusor · 9 months ago
I had no idea this CSS API existed. I'll add that to my CSS, thank you! :)

I'll check if the issue tracker has anything related to supporting titled alternate stylesheets (and eventually allowing users to pick one of them), because on the website where I made efforts for the markup to look reasonable on links, I also have a "simple" style that removes most of the CSS fanciness.

higon · 9 months ago
Long time w3m user here. Tried it and I can love it. Very nice.

Is that your design choice not having "Open URL"(Address bar) feature?

shiomiru · 9 months ago
The address bar should open by pressing C-l (control + L).