Hello all! Been working on layoutz, a tiny, zero-dep combinator lib for making pretty, structured, terminal output: tables, trees, boxes, ANSI styled elements, etc.
Would love to hear how the API feels: Smooth? Any missing primitives youād expect? Many thanks!
8 Likes
The API certainly looks straightforward enough, and it is nice that it is implemented in some other languages too. Thanks for sharing, I hope to have the chance to play with it later in the week.
1 Like
Any missing primitives youād expect?
This looks pretty nice, and Iād have a use for it, except that thereās padding byString.length and I want to display a language with 2-byte graphemes.
Although since you provide a string, I can probably still use it. A funny thing Iām already doing with textwrap is to map my strings to āxā and ā ā, wrap that text, then map the āxās back to the corresponding grapheme.
This isnāt at all an easy thing to get right in general, especially since rendering outside of your control can affect how things are actually displayed.
1 Like
Many thanks! Let me know if anything feels janky
Thanks for taking a peek!
Spot on⦠and thanks for putting textwrap on my radar
So the Haskell and Scala APIās already have (more or less) proper realLength handling for such multi-byte and combined graphemes⦠(cf. pandoc creator suggestion)
After some tinkering and mulling, suspect that the ocaml version will be quite similar to the Haskell realLength under the hood, but maybe with surface feel of textwrap (love how natural the API is btw!)
Not sure if relevant but we do something low-tech in printbox: looping over with Uucp.Break.tty_width_hint
PrintBox_text.ml#L102
1 Like
This looks really nice. Would you ever consider form elements as primitives, or would that be out of scope since it isnāt output?
1 Like
There is an output part to form primitive, I guess it could be just this.
1 Like
thanks for putting this on my radar ⦠tangentially related, but love frame as a top-level widget in PrintBox (will link back if smth similar ends up being vendored into layoutz)
@roerick Thanks for taking a peek!
I guess a static form element would in a sense be āneither input nor outputā at this stage ⦠but what @EmileTrotignon said.
Currently tinkering on an Elm runtime to make your elements āanimatableā, and a form element will likely be part of the lib with that release. Until then though ⦠nothing is stopping the user from making their own āstaticā forms.
2 Likes