Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ANSI sequences #119

Open
pwntester opened this issue Jun 10, 2021 · 3 comments
Open

Support ANSI sequences #119

pwntester opened this issue Jun 10, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@pwntester
Copy link

Since ueberzug is not working on MacOS, I though about using iterm support for rendering images via ANSI sequences as explained here

I tried it on lookatme but does not work. Simple ANSI sequences such as \x1b[1;31mFOO don't work neither. I think it would be great to support ANSI sequences to introduce color and images

Thanks!

@pwntester pwntester added the enhancement New feature or request label Jun 10, 2021
@pwntester
Copy link
Author

I tried using the terminal as in:

```terminal8
echo "\x1b[1;31mFOO"
```

But got this error:

Error rendering slide 1: Focus Widget <LineBox selectable flow widget <BoxAdapter selectable flow widget <Terminal selectable box widget> height=8>> at position 7 within listbox calculated cursor coords (1, 2) but rendered cursor coords None!
Rerun with --debug to view the full traceback in logs
Aborted!

@bew
Copy link

bew commented Jun 11, 2021

Agreed, also I'd love to not put ansi stuff like this in the file, but have lookatme (a plugin?) do it for me, we may need to add some size constraints in some way, to ensure the image fits correctly..
NOTE: that this ansi sequence not only works with iterm2 but also with Wezterm, which is cross platform (windows, mac, linux), and would allow image display anywhere, even over ssh.

@d0c-s4vage
Copy link
Owner

Hmm, the last time I looked into this was to try to get imgcat (and similar tools) to display images correctly. Back then the recommended way was to translate the ANSI sequences into urwid text markup. All other suggestions had to do with printing the ANSI sequences in an embedded terminal, which urwid then would directly translate for you (not my favorite idea). This wouldn't work with iTerm though, because it needs to directly receive the ANSI sequences (https://iterm2.com/documentation-images.html)

HOWEVER it seems like there's a better way (urwid/urwid#177 (comment)) that uses a custom widget (https://github.com/kpj/pdftty/blob/master/pdftty/ansi_widget.py) to directly send the ANSI sequences to the terminal, which is what we would need to make use of iTerm's image rendering feature. Thank you @kpj for sharing this approach!

I think building on/adapting @kpj's ANSIWidget class inside an iterm-specific lookatme extension could be a good approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants