Replies: 12 comments 25 replies
-
@qexat Ping received 😅 Waiting for the TODO to be filled in! |
Beta Was this translation helpful? Give feedback.
-
By the way, I'm also interested in your thoughts license-wise. Ansifmt is currently MIT by default, but if you convince me of a better choice I'm fine with changing :P |
Beta Was this translation helpful? Give feedback.
-
MIT is the most permissive licence, meaning that everyone can copy your code inside their libraries and change it or use it however they want. In the OSS world, not much you can do about it anyway, no matter the license. I'm using MPL-2.0 in some projects because it requires people to copy the entire original source code if they want to modify it. Kinda like an extra hassle to motivate people to contribute more instead of just copying the code. Also, people will most likely make it worse because my code is perfect, so at least all the readers will be able to compare. But recently I enjoyed the freedom of the MIT permissiveness and the ability to just copy the code from libraries. OSS maintainers do their job in free time, and not everyone wants to spend their free time addressing issues and working with contributors. So they might just let everyone do what they want with the code. |
Beta Was this translation helpful? Give feedback.
-
Hey @qexat, I've now seen your update about the design and I checked the
Could you elaborate a bit more on this? I checked this module and it seems to be supporting quite a lot of ANSI escape sequences already: |
Beta Was this translation helpful? Give feedback.
-
I'll start by writing my use case in GitHub TUI. Programs should solve problems. And if we have vastly different problems that it's impossible to unify them under a single design, making this library too generic can hurt its goals. So let's make sure we align. In GitHub TUI, I have the following use cases for ANSI escape sequences:
I have other use cases in mind that would be nice to have but I haven't implemented them yet. So I'll describe them separately, since this message is already pretty big. |
Beta Was this translation helpful? Give feedback.
-
I'll describe in a separate message my future use cases in GitHub TUI, so we can discuss whether they make sense.
|
Beta Was this translation helpful? Give feedback.
-
Ansifmt 0.2.0 is in the process of being released: ocaml/opam-repository#27357 This update brings your efforts from #5, #6 and #7 as a release installable with opam! |
Beta Was this translation helpful? Give feedback.
-
Since we reached a milestone, I'll take some time to clean up the repository a bit, adding better issue labels, using the milestone feature etc |
Beta Was this translation helpful? Give feedback.
-
@qexat Sounds great! I'll now try switching GitHub TUI to Ansifmt (it might take some time). I learned a lot about this library and potential design space, so this collaboration experience was valuable for me! If I notice something I missed during the initial design phase, I'll create new issues in the process, and we can discuss in detail all future developments under corresponding issues if anything comes up. |
Beta Was this translation helpful? Give feedback.
-
@qexat I finally finished the migration and it was surprisingly easy! Took me only half an hour to do the job. Have a look and leave your comments: |
Beta Was this translation helpful? Give feedback.
-
Ansifmt However, I have started to use it for a more complex project, and while it works nicely for the most part, I am facing a few pain points:
For the second point, it used to be easy to do with string-based formatting - it was just about using Ideally, no further changes would need to be made on the formatting tree type as in introducing new variants, but it would be definitely useful to add some information (like indentation and which token to join the subtrees in the list on) to the To be honest though, I am not fully satisfied with the formatting language design. Or at least, it feels a bit bare-bones while still being a bit cumbersome and not very intuitive - it is only relatively easy to use for me as I am very familiar with the material, but I don't think it would be the same for someone that would try this part of Ansifmt for the first time. Seeing Sorry for the long text wall. I know this isn't about the part of Ansifmt that interests you the most, but I'd be delighted to hear your opinion on this. |
Beta Was this translation helpful? Give feedback.
-
Made a PR to opam for Ansifmt 0.3.0: ocaml/opam-repository#27487 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I started Ansifmt out of frustration with OCaml's pretty-printing capabilities, and I can't be satisfied with basic string rendering without some nice colored output. Specifically, I wanted to formatting term languages, which are inherently recursive structures, making it difficult to add ANSI escape sequences by string-patching. I happen to have some experience with ANSI escape sequences, especially the Select Graphics Rendition ones ; in fact, I am the author of the Python library Coquille. Thanks to that, I wrote without thinking much what I needed to handle ANSI stuff, and no dependencies involved :)
Originally, my mental model was to essentially do the opposite of parsing, that is transforming my term tree into a stream of tokens. This is the current
main
branch (as of January 30th). This worked fine, but I noticed that to handle parentheses and such, I tended to rewrite similar code over and over.Thus, I tried another approach (which corresponds to the
experimental-token-tree
branch). Instead of a stream of tokens, the structure is a tree, where the leafs are what was formerly the token list, and nodes are lists of leafs or other nodes. When rendering, nodes would be automatically parenthesized. While the idea sounded simple and good on paper, the result was more verbose code for the same amount of control over the output, and with a frustrating handling of parentheses.This leads us to the current design (found on the
experimental-token-term
branch). It is similar to the other experiment, but with an additionalParenthesized
node which alone makes, in my opinion, writing thetokenize
function more pleasing.Now that I have reached a state for tokenization that satisfies me, I think I want to focus on adding the missing ANSI escape sequences for now.
Pinging @chshersh as you requested :)
Beta Was this translation helpful? Give feedback.
All reactions