-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
CellMarker #2919
Comments
The conditional marking during writing is too much of a burden, thus I gonna remove the condition (
In the end the same cells will be marked as with the conditional write marking in the first place. The methods |
Can you expand on the API proposal to show where export class Terminal {
addMarker(x: number, y: number): ICellMarker | undefined;
}
export interface ICellMarker extends IDisposable {
readonly id: number;
readonly isDisposed: boolean;
readonly position: IBufferCellPosition;
} I guess with an Then allowing embedders to store data in their own way, eg: interface IHyperlink {
link: string;
startPosition: ICellMarker
}
const hyperlinks: IHyperlink[] = [];
// ...
hyperlinks.push({
link: url,
startPosition: term.addMarker(x, y)
}); Essentially a pretty simple thing like the current |
@Tyriar Well the API idea is still early and needs refinement to be usable/useful. I started from the line marker interface to shape this (basically what your interfaces look like). Several problems popped up early with a direct transition of line markers into cell level. Esp. they are very wasteful on the buffer, if they can only represent a single cell, thus the idea to expand it to cell ranges. It is still possible to get the same behavior as your interface: // your interface
const marker = addMarker(x, y);
// compared to the range based interface
const marker = new CellMarker(CellMarkerType.CONTENT);
marker.markCells({start: {x, y}, end: {x: x+1, y}}); Here a cell marker has a life of its own, and the proper creation / lifecycling is not yet clear from above. I have not shaped that part yet, but maybe some kind of a marker manager living on export class Terminal {
// Create a cell marker of attribute or content type.
createCellMarker(type: 'attribute' | 'content'): ICellMarker;
}
// + interface definitions from above Next problem I stumbled over are position updates - if the marker itself should always know its correct position in the buffer, any buffer action will suffer bad due to the need to update all markers' positions. Sadly I see no speedy way to get auto-updated positions on the marker working. Thus I turned the problem upside-down - if you need to get a hold of cell marker positions you have to actively request the positions from the buffer with Btw the same is true for an
Yes, once I got this working the extended attributes could be replace with this. And prolly be used by addons later on as well. But I am not yet there, lol. |
Don't we only need to change it when it scrolls off the scrollback or on resize?
Is the intent here that any change in content or attribute invalidate the marker?
I was thinking they would only get disposed when they leave scrollback just like markers today which already fire an event, it's just not included in the API: xterm.js/src/common/buffer/Marker.ts Line 34 in 92fdf0c
|
If perf here is a concern, another idea that I've been thinking about for a while is that we could avoid the marker line shift all together (within scrollback at least) if we just marked each line with an index, starting at 0. So if your scrollback is 1000 and 2000 lines have gone by, the buffer lines would have ids 1000-1999. We could then remove this all together when that line leaves the viewport (as it's the only mutable part of the buffer): xterm.js/src/common/buffer/Buffer.ts Lines 585 to 607 in 92fdf0c
delete/insert within the viewport could get complicated but still seems doable, slightly slower for the handful of lines in the viewport for no cost in the many lines of scrollback would be a win. |
Well we have tons of "cell moving" sequences, they would have to update the positions. and yes, resize will suffer really bad as it has to go through all buffer cells and re-eval marker positions.
Yepp:
The attribute type is basically there to replace extended attrs later on (to not clutter the buffer with tons of optional additional types, that all have to be eval'ed during buffer manipulations). The content type is there for pretty much the same reason, but with another domain in mind: as I currently abuse the extended attrs in the hyperlink-addon it has a really nasty drawback - calling But as I said above, this is still not thought out in depth, prolly missing several things. Yet it already covers almost all cell marking needs I have from the hyperlink addon, the image addon and even the underline extension.
You mean like an always incrementing line index? I guess this would simplifly several position awkwardities throughout the whole codebase, prolly a good idea. Would only need special care during resize, and once we hit the max number (around 2³¹-1 I guess), and line inserts/removal. |
Turned out, its not acutally needed for what I has in mind, thus closing. |
With PR #2751
AttributeData
got extended by "extended attributes". While it is quickly hardcoded there for the special needs to hold underline style and colors with small buffer footprint in mind, this approach is very limited in its static nature. If we can get this working in a more dynamic fashion, we can solve a long missing feature in xterm.js - cell markers.Proposal
Early idea of a CellMarker API (for internal usage first):
Basic idea of this marker interface is:
onDispose
etc. (TBD)Additionally a cell marker might follow these cell marker types:
This is basically a rewrite of the extended attributes in a more general and reusable fashion. The API idea is still convoluted, will see if this can be made simpler.
Why even care for cell markers?
We have several loose ends, where cell markers will help:
The last point might be the most important - currently we have no way to attach some custom functionality on individual cell level. For example - with cell markers it will be pretty easy to hook up some custom overlay when hovering over a cell (in conjunction with the new
LinkProvider
).Up for discussion.
FYI: @Tyriar, @mofux
The text was updated successfully, but these errors were encountered: