mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.19k stars 29 forks source link

feat: handle colored output #296

Closed DrunkenToast closed 1 month ago

DrunkenToast commented 2 months ago

Fix #272

Don't write a lot of Rust, so all feedback obviously welcome!

image

Colored output works, however with the caveat of chunking not working. I am not sure how to approach chunking as it would be likely that I cut through ANSI escapes codes. Keeping track of positions for where to slice seems messy.

Another expected issue is that the reset code clears out the codeblock format colors, not sure if we wanna resolve that too. I was thinking that the rendering could intercept clear codes and apply the chosen colors but I think that is out of scope for this PR.

DrunkenToast commented 2 months ago

Created a naive POC which already works really well and is promising. I don't think it's very performant however, it's also a bit of an ugly trick with ansi codes right now, it would be better to only keep the resulting style. Wrapping: image image Color reset: image

mfontanini commented 2 months ago

This is great! Sorry I haven't had time to look into this, I found a bunch of bugs and have been prioritizing that. The only thing I'll add is the logic for splitting text and fit it into the screen is there already but you need to turn text into WeightedTextBlock and render it via BlockLineText::Weighted instead of BlockLineText::Preformatted but that may create other issues.

mfontanini commented 1 month ago

Hey @DrunkenToast, I just wanted to know I started looking into this. I had to change a few internal things to make this work as expected, but I have a somewhat working version based on yours that parses lines only once after reading them rather than every time they're rendered. Thanks for setting the base for this change!

DrunkenToast commented 1 month ago

Hey @DrunkenToast, I just wanted to know I started looking into this. I had to change a few internal things to make this work as expected, but I have a somewhat working version based on yours that parses lines only once after reading them rather than every time they're rendered. Thanks for setting the base for this change!

Awesome! Thanks for the hard work ❤️

DrunkenToast commented 1 month ago

closed in favor of #316