-
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
hyperlinks addon #2904
hyperlinks addon #2904
Conversation
* Copyright (c) 2019 The xterm.js authors. All rights reserved. | ||
* @license MIT | ||
* | ||
* UnicodeVersionProvider for V11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Victim of c&p 😄
/** | ||
* TODO: | ||
* Need the following changes in xterm.js: | ||
* - allow LinkProvider callback to contain multiple ranges (currently sloppy hacked into Linkifier2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be working on #2848 soon which will change the API to return all links for the current line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well for the purpose of this addon all it needs are multiple buffer ranges for an URL to still recognize http://example.com
as one link anchor text here:
╔═ file1 ════╗
║ ╔═ file2 ═══╗
║http://exa║Lorem ipsum║
║le.com ║ dolor sit ║
║ ║amet, conse║
╚══════════║ctetur adip║
╚═══════════╝
* TODO: | ||
* Need the following changes in xterm.js: | ||
* - allow LinkProvider callback to contain multiple ranges (currently sloppy hacked into Linkifier2) | ||
* - make extended attributes contributable by outer code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about an ICellMarker
API instead? Or tweaking the current one to optionally track a cell in a wrapped line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some more design work, yes I think this can be turned into something like cell markers (that stick to a cell, thus would move with it).
[...this._urlMap.keys()] | ||
.filter(key => key < this._lowestId) | ||
.forEach(key => this._urlMap.delete(key)); | ||
[...this._idMap.entries()] | ||
.filter(([unused, value]) => value < this._lowestId) | ||
.forEach(([key, unused]) => this._idMap.delete(key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably know but [...arr].filter()
is probably a little slow to put into a parser hook?
Would LRUMap
be useful here? We could pull into the addon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, well it gets only executed once in a while (with default limits every 1000 urls). For some reason this declarative way was the only one I could find with proper type inference. Every loop attempt (which tend to be faster in general) was countered with type issues by TS lol.
LRUMap:
I think a linked list is not needed here, since the identifiers are just auto increasing integers (always to be cut from left side). Gonna rework that to a loop with early exit condition.
activate: this._urlMap.get(urlId)!.schemeHandler.opener, | ||
hover: (event: MouseEvent, text: string) => { | ||
console.log('tooltip to show:', text); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activate
, hover
and leave
need to be settable when creating the addon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As talked about earlier, this prolly will end up with the LinkProvider being exposed on addon API level for individual customization.
Playing around with this addon and a custom The |
That gif 🤯 |
@jerch link providers have been working great in vscode, 👍 for removing experimental from it |
This is far off, thus closing it. |
Early WIP.