Closed jerch closed 2 years ago
@Tyriar Yeah the CellMarker idea is somewhat related. But I am not sure, whether to go that path at all - in the image addon I cancelled that idea and went with a viewport scan, which turned out to be fast enough for that purpose. CellMarker would certainly speedup those tasks, but would penalize the buffer logic at other ends.
Somewhat obsolete, thus closing.
Is there any way to do this now? I am interested in attaching custom attributes to cells (actually, whole lines of input).
I see that there is a registerMarker
API, however:
It seems that markers cannot be reliably added due to async processing of input (https://github.com/xtermjs/xterm.js/issues/5214)
They don't offer a way to attach custom metadata/attributes
I would like to determine when a marked area is hovered with the mouse, and don't see a way to do that (OSC 8 links can be abused for this purpose, but the styling is not customizable)
It seems that markers cannot be reliably added due to async processing of input
@jtbandes see my response on https://github.com/xtermjs/xterm.js/issues/5214#issuecomment-2485981081
They don't offer a way to attach custom metadata/attributes
You can attach whatever data you want here, and modify the presentation of cells in a few ways (eg. hook into bg/fg rendering)
I would like to determine when a marked area is hovered with the mouse, and don't see a way to do that (OSC 8 links can be abused for this purpose, but the styling is not customizable)
If you want underline/italics/etc. this would be a new feature request to add to IDecorationOptions
which sounds reasonable. You could hack this in a less bad way than OSC 8 links by adding border-bottom
to the decoration.
Thanks for the tips and for your patience with my questions!
You can attach whatever data you want here
By "here", do you mean on the marker? I didn't see anything in the API or docs to indicate it is "safe"/expected to modify the IMarker
object, but perhaps that's what you are suggesting?
(eg. hook into bg/fg rendering)
Could you expand on this – I don't see where cell rendering can be customized in the public API other than setting the theme
options.
I didn't see anything in the API or docs to indicate it is "safe"/expected to modify the IMarker object, but perhaps that's what you are suggesting?
In the first place markers are just stable buffer line references into the terminal buffer. Their line
number will mutate by various actions on the ringbuffer (index gets updated) to keep the referenced line stable. Eventually it gets disposed (e.g. buffer line drops off the scrollbuffer at the top). They are not meant be customized itself.
What you can do with markers - attach custom functionality to a certain buffer line. This can be used to a great extend for your custom logic, e.g. do something, when the marked line is in the viewport. Important here - your custom logic is typically is outside of the terminal itself / fully managed by your code. Example: the image addon uses markers to track images still present in the scrollbuffer. When the marked line gets disposed / drops off the scrollbuffer the addon also disposes the linked image data to free the memory again.
By "here", do you mean on the marker? I didn't see anything in the API or docs to indicate it is "safe"/expected to modify the IMarker object, but perhaps that's what you are suggesting?
@jtbandes using the IMarker
object as a key in a Map
for example: Map<IMarker, MyExtraAttributes>
Could you expand on this – I don't see where cell rendering can be customized in the public API other than setting the theme options.
See backgroundColor
, foregroundColor
and layer
on IDecorationOptions
:
Coming from https://github.com/xtermjs/xterm.js/pull/2503. Also related https://github.com/xtermjs/xterm.js/pull/2904.
Extended attributes on cells offer a simply way of extending terminal buffer functionality for other purposes. Currently it is not possible to extend them in a flexible way to be used for custom data from addons.
TODO: Come up with an easy to interface to extend extended attributes from addons. Bonus goal - make this type safe even for runtime extensions (hard one with TS' static type system).