-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Inline images #1466
base: master
Are you sure you want to change the base?
Inline images #1466
Conversation
First tests with libchafa for displaying pictures inline. We choose to use ASCII art for now. Reason is that the regular method uses color escape codes and ncurses will just print those codes and not use the colors. Regards #1301
chafa has a test branch with added functionality for us: Need to build this chafa version and see whether this helps progressing on this task. |
i'm pretty sure using |
|
I merged the wip/cell-access branch into master some time ago. I don't expect it to change very much between now and release, so it should be safe to start using. I'm also planning Kitty and iTerm2 support, but I'm not sure how you'd get ncurses to cooperate... |
@binex-dsk a little similar to the QR code task. Do you think that would be something for you? ;) |
I could possibly do basic block art in the same vain as the QR code. Not sure if colorful images would be my forte, but I'll look into it. Also: are shell color codes agnostic to operating systems/shell standards? Also, I'm currently on a band trip without access to a computer. I'll see if I want to tackle this after next Sunday/Monday. |
In this PR I tried to use the library "chafa" actually it should do most of the work. We just need set the correct settings (what it will return) and then print this properly in the window. Like
I'm not entirely sure. But I don't think so.
Enjoy! |
I recommend reading the ncurses example @jubalh mentioned before. I've tried to comment it liberally, but if anything is unclear I'll gladly answer questions and review code. As an aside, I think it's possible to support Kitty and sixel graphics in ncurses too, but you'd have to print raw character codes, so it probably wouldn't work inline (ncurses repaints would likely mess it up). But e.g. vifm uses a frame in a fixed location, and that seems to work (using |
Okay, I see. In that case I'll mess around with the settings and see what I can do. What is it you're looking for that this PR does not yet do (other than deciding on what to do for displaying them, of course) And should I test this on the cell-access thing mentioned? Or on master? EDIT: cell-access is old and merged, so I'll test this on master. And also I won't have a huge amount of time again (Robotics, summer classes, sports, etc...) but depending on what's needed I'm confident I'll be able to get it done quickly. |
If your package manager has Chafa 1.8.0 or later, the cell access API will be there, so you can build against the devel package instead of master. In case it saves time. |
If no one else takes this up within a few weeks I'll go ahead and do it... right now I've got a boatload of stuff to do: summer classes, driving practice, and soccer. I might experiment with the ncurses examples at some point though :) |
Having inline images rendered via Chafa would really be awesome! I have only scratched the surface here, but this also requires integration with OMEMO in case of |
@binex-dsk how are your driving classes? Do you have time for this feature now maybe? |
Finished them up. I have my driver's test this week and soccer (should) end this week as well, so I will begin work for real (like, actually for real this time I swear) next week. |
That's great news! |
Quick update, I have been doing some basic libchafa testing (on its own, not with profanity) and although I haven't made that much progress, I AM getting there. I would be farther but, I had to go to urgent care, which (unfortunately) is more important than programming... |
Thanks for the update! |
I've been messing with this for a while and so far I've not been able to figure out several things. Here's the point I've reached: I have yet to figure out:
You can also notice that the pixels don't look right. It's a QR code so it should be all squares. Commit is here: https://github.com/binex-dsk/profanity/commit/8e5aa52c72fbb99b8ca4b50b8a7278521ad56b83 |
Looked into the ncurses example a bit more and I'm confused. @hpjansson Would you mind explaining the Also, how would we go about actual Kitty support? It seems like it would be really hard to make it work with kitty, though I don't know the internals of the Kitty protocol so maybe I'm missing something. |
Sure! It iterates over the ChafaCanvas character cells, row by row and column by column. For each cell, it:
The ncurses functions Note that you need to link with the correct build of ncurses (e.g. ending in
I think this would be impossible, or at least not worth the effort, to support in an ncurses program unless there's a non-scrolling preview rectangle where you can just bypass ncurses and overwrite the contents using your own escape codes. I think |
Aha, that's why the function didn't end up working after I plugged it in! An interesting thing I'll need to look into is getting it to work with the standard I'm unfamiliar with the internal workings of the profanity window thingy so I have no clue if it'll properly scroll if printed with I suppose I'll look into all of this, perhaps more, tomorrow. Depends how much free time I've got. Which might not be a lot, because God knows if I'll end up needing to go to the ER again.
This is what I suspected. I have an idea on how that could work, but it would be clunky, awkward, perhaps user-unfriendly, and not to mention a HUGE pain to program. Thanks for the assistance @hpjansson; this makes a lot more sense now! |
After a test using Also, if ncursesw isn't found we probably have to do basic ASCII/block art |
@jubalh perhaps you could help with the wchar printing? I have no idea how to implement this, as I'm not familiar with the internal print functions. |
@binex-dsk ok I will try to look at it! :) |
@jubalh how has the wchar printing progress coming? Perfectly okay if you haven't done anything yet |
@binex-dsk sorry I haven't yet. I'm having some health issues. I will try to look at it when all is okay again :) |
Just from a quick look, it looks like I'd store the original raster image (after decoding from the network) in the buffer entry, and call Chafa every time it needs to redraw. That lets you deal with window resizes etc. gracefully after the message is received. |
Also -- @jubalh, take care and get well soon! |
Lmao same Hope you get well! :) |
PR for #1301
So far this is just a test. Displaying an image
~/test.png
when Profanitys "about" is printed.So far in ASCII art.
libchafa can also return colourful images using escape codes. But not sure how to use them inside ncurses yet.
I assume later we want a setting that either displays all images (URLs which we assume to be images based on ending) or we want it only explicitly with somethine like
/image
//imagepreview
//inlineimage
where one can tab through the latest URLs with image endings.