url -> text
This commit is contained in:
@@ -30,8 +30,8 @@ export class LinkComputer {
|
|||||||
let stringIndex = -1;
|
let stringIndex = -1;
|
||||||
|
|
||||||
while ((match = rex.exec(line)) !== null) {
|
while ((match = rex.exec(line)) !== null) {
|
||||||
const url = match[1];
|
const text = match[1];
|
||||||
if (!url) {
|
if (!text) {
|
||||||
// something matched but does not comply with the given matchIndex
|
// something matched but does not comply with the given matchIndex
|
||||||
// since this is most likely a bug the regex itself we simply do nothing here
|
// since this is most likely a bug the regex itself we simply do nothing here
|
||||||
console.log('match found without corresponding matchIndex');
|
console.log('match found without corresponding matchIndex');
|
||||||
@@ -42,14 +42,14 @@ export class LinkComputer {
|
|||||||
// therefore we cannot use match.index directly, instead we search the position
|
// therefore we cannot use match.index directly, instead we search the position
|
||||||
// of the match group in text again
|
// of the match group in text again
|
||||||
// also correct regex and string search offsets for the next loop run
|
// also correct regex and string search offsets for the next loop run
|
||||||
stringIndex = line.indexOf(url, stringIndex + 1);
|
stringIndex = line.indexOf(text, stringIndex + 1);
|
||||||
rex.lastIndex = stringIndex + url.length;
|
rex.lastIndex = stringIndex + text.length;
|
||||||
if (stringIndex < 0) {
|
if (stringIndex < 0) {
|
||||||
// invalid stringIndex (should not have happened)
|
// invalid stringIndex (should not have happened)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let endX = stringIndex + url.length + 1;
|
let endX = stringIndex + text.length + 1;
|
||||||
let endY = startLineIndex + 1;
|
let endY = startLineIndex + 1;
|
||||||
|
|
||||||
while (endX > terminal.cols) {
|
while (endX > terminal.cols) {
|
||||||
@@ -68,7 +68,7 @@ export class LinkComputer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return { range, url, handle };
|
return { range, text, handle };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -685,8 +685,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
} else {
|
} else {
|
||||||
// according to MDN buttons only reports up to button 5 (AUX2)
|
// according to MDN buttons only reports up to button 5 (AUX2)
|
||||||
but = ev.buttons & 1 ? CoreMouseButton.LEFT :
|
but = ev.buttons & 1 ? CoreMouseButton.LEFT :
|
||||||
ev.buttons & 4 ? CoreMouseButton.MIDDLE :
|
ev.buttons & 4 ? CoreMouseButton.MIDDLE :
|
||||||
ev.buttons & 2 ? CoreMouseButton.RIGHT :
|
ev.buttons & 2 ? CoreMouseButton.RIGHT :
|
||||||
CoreMouseButton.NONE; // fallback to NONE
|
CoreMouseButton.NONE; // fallback to NONE
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export class Linkifier2 implements ILinkifier2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._linkAtPosition(this._currentLink, position)) {
|
if (this._linkAtPosition(this._currentLink, position)) {
|
||||||
this._currentLink.handle(event, this._currentLink.url);
|
this._currentLink.handle(event, this._currentLink.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ export class Linkifier2 implements ILinkifier2 {
|
|||||||
element.classList.add('xterm-cursor-pointer');
|
element.classList.add('xterm-cursor-pointer');
|
||||||
|
|
||||||
if (link.showTooltip) {
|
if (link.showTooltip) {
|
||||||
link.showTooltip(event, link.url);
|
link.showTooltip(event, link.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ export class Linkifier2 implements ILinkifier2 {
|
|||||||
element.classList.remove('xterm-cursor-pointer');
|
element.classList.remove('xterm-cursor-pointer');
|
||||||
|
|
||||||
if (link.hideTooltip) {
|
if (link.hideTooltip) {
|
||||||
link.hideTooltip(event, link.url);
|
link.hideTooltip(event, link.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+4
-4
@@ -171,10 +171,10 @@ interface ILinkProvider {
|
|||||||
|
|
||||||
interface ILink {
|
interface ILink {
|
||||||
range: IBufferRange;
|
range: IBufferRange;
|
||||||
url: string;
|
text: string;
|
||||||
showTooltip?(event: MouseEvent, link: string): void;
|
showTooltip?(event: MouseEvent, text: string): void;
|
||||||
hideTooltip?(event: MouseEvent, link: string): void;
|
hideTooltip?(event: MouseEvent, text: string): void;
|
||||||
handle(event: MouseEvent, link: string): void;
|
handle(event: MouseEvent, text: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IBufferRange {
|
interface IBufferRange {
|
||||||
|
|||||||
Vendored
+8
-8
@@ -1104,30 +1104,30 @@ declare module 'xterm' {
|
|||||||
range: IBufferRange;
|
range: IBufferRange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url of the link.
|
* The text of the link.
|
||||||
*/
|
*/
|
||||||
url: string;
|
text: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the link's tooltip is ready to show.
|
* Called when the link's tooltip is ready to show.
|
||||||
* @param event The mouse event triggering the callback.
|
* @param event The mouse event triggering the callback.
|
||||||
* @param link
|
* @param text The text of the link.
|
||||||
*/
|
*/
|
||||||
showTooltip?(event: MouseEvent, link: string): void;
|
showTooltip?(event: MouseEvent, teext: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the link's tooltip is ready to hide.
|
* Called when the link's tooltip is ready to hide.
|
||||||
* @param event The mouse event triggering the callback.
|
* @param event The mouse event triggering the callback.
|
||||||
* @param link
|
* @param text The text of the link.
|
||||||
*/
|
*/
|
||||||
hideTooltip?(event: MouseEvent, link: string): void;
|
hideTooltip?(event: MouseEvent, text: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls when the link is activated.
|
* Calls when the link is activated.
|
||||||
* @param event The mouse event triggering the callback.
|
* @param event The mouse event triggering the callback.
|
||||||
* @param link
|
* @param text The text of the link.
|
||||||
*/
|
*/
|
||||||
handle(event: MouseEvent, link: string): void;
|
handle(event: MouseEvent, text: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user