From 2e3f9e709495d5599ebf1d43b8a7914befe36968 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 27 Feb 2018 08:37:16 -0800 Subject: [PATCH] Multi-line links prototype Part of #24 --- src/Linkifier.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index a9617952..700b05f4 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -204,7 +204,19 @@ export class Linkifier extends EventEmitter implements ILinkifier { if (absoluteRowIndex >= this._terminal.buffer.lines.length) { return; } - const text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false); + if ((this._terminal.buffer.lines.get(absoluteRowIndex)).isWrapped) { + // TODO: Make sure if a wrapped line is requested to be linkified it gets backtracked to ensure the link is filled + return; + } + + let text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false); + + // Check if the line is wrapped + if (absoluteRowIndex + 1 < this._terminal.buffer.lines.length && (this._terminal.buffer.lines.get(absoluteRowIndex + 1)).isWrapped) { + // TODO: Do this for lines that wrap over more than 2 lines + text += this._terminal.buffer.translateBufferLineToString(absoluteRowIndex + 1, false); + } + for (let i = 0; i < this._linkMatchers.length; i++) { this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]); } @@ -265,6 +277,7 @@ export class Linkifier extends EventEmitter implements ILinkifier { * @param matcher The link matcher for the link. */ private _addLink(x: number, y: number, uri: string, matcher: ILinkMatcher): void { + // TODO: Make MouseZone's work over multiple lines this._mouseZoneManager.add(new MouseZone( x + 1, x + 1 + uri.length,