-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Prototype of iTerm2 like image display #1577
Conversation
@mme cool! I have some high level questions before I jump in:
Here are some notes on how iterm places the image: #614 (comment) @jerch you'll be interested in the change to https://github.com/xtermjs/xterm.js/pull/1577/files#diff-c59b761ad01bc77f0c593de25ec4d847R21 https://github.com/xtermjs/xterm.js/pull/1577/files#diff-c59b761ad01bc77f0c593de25ec4d847R15 I think this is going the opposite direction for memory of the overall buffer to what we want (an extra pointer for every character). |
Managed to get it working on Linux by commenting out the support if blocks in First bug spotted when changing font family: Not sure there's an easy way to fix this with the way that it currently works, what if instead of each cell having a reference to an |
Yupp thats a really cool feature addon, also Im kinda surprised it worked this straight forward. Still I have 2 issues with the current impl:
|
@jerch Good point, @mme to give you more context on this, we're moving towards this architecture: #1507 (comment)
@jerch Well the inlineImages: { [markerId: number]: SomeImage }; |
@Tyriar @jerch thanks for your in depth comments! @Tyriar regarding your initial questions:
Regarding the bug when changing the font size and @jerch remarks about the memory usage of the additional slot in buffer: I agree that having the image directly in buffer is not an ideal solution. Slicing the image is probably also not flexible enough. The reason I chose this initial approach is that I want to support clearing up the memory used by the image once it is not visible on the screen. In our specific use case we are developing a deep learning toolkit and want to display an animated chart while training a model, by moving the cursor up, overwriting the previous chart. When we keep the image outside of the buffer, what would be the best way of determining if the image has been completely overwritten by either text or other images, so it can be thrown away? I see that Reading the image through a delegate of some kind should be no problem. I have read through your plans for the new architecture which seems clear, but I think I need some guidance on where to put this abstraction. One issue which made implementing this a little more difficult was that loading an Image is not synchronous on Chrome and Firefox, even when the image src is a data url. That's why we need to read the image size manually to determine the area covered by the image, since I think OSC handlers are expected to be finished once the handler function returns. We then put placeholders which are replaced once the image has loaded. Is there a way to tell InputHandler to somehow pause processing until the asynchronous onload event is fired and we get the image parsed by the browser? |
Eww, thats kinda impossible since down the road from |
@jerch I see. This not a big deal since the current implementation deals with this already. |
Thanks for the effort on this but I don't think we'll be moving forward with this any time soon. I'd say we should hold off on supporting this until we get more of the current stories finished up, have a good plan on how to handle varying height rows and we're sure we want to commit to supporting this (is it a security issue for apps being able to add tracking images?). |
I’d say no, since they could just make a tracking request using normal HTTP APIs. |
This is a prototype of adding iTerm2 like image display capabilities to xterm.js, as requested in several tickets:
#614
vercel/hyper#101
microsoft/vscode#44436
Images can also be clicked to be opened in full size in a new window.
It works by slicing the image into patches of
scaledCellWidth
/scaledCellHeight
size and adding the resultingImageData
object directly to theBuffer
object. When a cell in the buffer is overwritten, the previousImageData
is thrown away and the memory is freed - e.g. this is useful when showing animated charts by overwriting the previous image.We are developing an app that would greatly benefit from a cross platform terminal with image display, so I would be quite happy if this feature could make it to xterm.js in one way or another.
Please let me know if I can be of further help to have this feature land in xterm.js!