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: process colored output from execution output #316

Closed mfontanini closed 1 month ago

mfontanini commented 1 month ago

This processes execution output's ansi escape codes and turns them into WeightedTexBlock. This can then be rendered so that we:

This needs more testing, I just tested a couple of commands and it works fine but I didn't thoroughly test yet.

This is based on the initial work done on #296.

cc @DrunkenToast @calebdw I would appreciate if you could give this PR a test. It's only handling a very tiny subset of escape codes so I wouldn't be surprised if something failed. At least I tried basic things like ls --color=always and piping stuff to lolcat and they both seem to work fine to me.

calebdw commented 1 month ago

@mfontanini,

It looks pretty good to me as far as most use-cases go! I did notice it has trouble wrapping but looks like that's related to #289

image

DrunkenToast commented 1 month ago

@mfontanini,

It looks pretty good to me as far as most use-cases go! I did notice it has trouble wrapping but looks like that's related to #289

image

This might actually be a bit problematic for some people. Codeblocks you can manually chunk up, but output of said codeblock is not as easy. The advantage of the previous method was that it was chunked up beforehand with context of the maximum width.

mfontanini commented 1 month ago

Nice, thanks for testing it! Will fix both issues.

Codeblocks you can manually chunk up, but output of said codeblock is not as easy.

Don't worry, I won't merge until this is fixed. This should not look this way. Btw the changes that I'm adding here will allow simplifying a bunch of things + I think will allow fixing the other issue you created re: splitting long code snippet lines.

mfontanini commented 1 month ago

Alright, both issues are fixed:

image image

calebdw commented 1 month ago

That was fast!

mfontanini commented 1 month ago

Merging, if anything comes out I can re-visit. There's lots of escape codes missing here so it's possible the output of some tools won't look right.