@xterm/xterm 6.1.0-beta.227 → 6.1.0-beta.229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +6 -6
- package/lib/xterm.mjs.map +3 -3
- package/package.json +2 -2
- package/src/browser/OscLinkProvider.ts +79 -13
- package/src/common/Version.ts +1 -1
- package/src/common/public/BufferNamespaceApi.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/xterm",
|
|
3
3
|
"description": "Full xterm terminal, in your browser",
|
|
4
|
-
"version": "6.1.0-beta.
|
|
4
|
+
"version": "6.1.0-beta.229",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"ws": "^8.2.3",
|
|
112
112
|
"xterm-benchmark": "^0.3.1"
|
|
113
113
|
},
|
|
114
|
-
"commit": "
|
|
114
|
+
"commit": "1064e4f783a6998f49b255e7d2c480be539ac5b3"
|
|
115
115
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { IBufferRange, ILink } from 'browser/Types';
|
|
7
7
|
import { ILinkProvider } from 'browser/services/Services';
|
|
8
8
|
import { CellData } from 'common/buffer/CellData';
|
|
9
|
+
import { IBufferLine } from 'common/Types';
|
|
9
10
|
import { IBufferService, IOptionsService, IOscLinkService } from 'common/services/Services';
|
|
10
11
|
|
|
11
12
|
export class OscLinkProvider implements ILinkProvider {
|
|
@@ -57,19 +58,8 @@ export class OscLinkProvider implements ILinkProvider {
|
|
|
57
58
|
if (finishLink || (currentStart !== -1 && x === lineLength - 1)) {
|
|
58
59
|
const text = this._oscLinkService.getLinkData(currentLinkId)?.uri;
|
|
59
60
|
if (text) {
|
|
60
|
-
|
|
61
|
-
const range
|
|
62
|
-
start: {
|
|
63
|
-
x: currentStart + 1,
|
|
64
|
-
y
|
|
65
|
-
},
|
|
66
|
-
end: {
|
|
67
|
-
// Offset end x if it's a link that ends on the last cell in the line
|
|
68
|
-
x: x + (!finishLink && x === lineLength - 1 ? 1 : 0),
|
|
69
|
-
y
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
61
|
+
const endX = x + (!finishLink && x === lineLength - 1 ? 1 : 0);
|
|
62
|
+
const range = this._getRangeWithLineWrap(y, currentStart, endX, currentLinkId);
|
|
73
63
|
let ignoreLink = false;
|
|
74
64
|
if (!linkHandler?.allowNonHttpProtocols) {
|
|
75
65
|
try {
|
|
@@ -111,6 +101,82 @@ export class OscLinkProvider implements ILinkProvider {
|
|
|
111
101
|
// id
|
|
112
102
|
callback(result);
|
|
113
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Expand a single-line OSC 8 range to a contiguous wrapped range for the same link id.
|
|
107
|
+
*/
|
|
108
|
+
private _getRangeWithLineWrap(y: number, startX: number, endX: number, linkId: number): IBufferRange {
|
|
109
|
+
let startY = y;
|
|
110
|
+
let finalStartX = startX;
|
|
111
|
+
let endY = y;
|
|
112
|
+
let finalEndX = endX;
|
|
113
|
+
|
|
114
|
+
// Expand upward only when this segment starts at column 0 and the current line is wrapped.
|
|
115
|
+
while (finalStartX === 0) {
|
|
116
|
+
const currentLine = this._bufferService.buffer.lines.get(startY - 1);
|
|
117
|
+
if (!currentLine?.isWrapped) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
const previousLine = this._bufferService.buffer.lines.get(startY - 2);
|
|
121
|
+
if (!previousLine) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
const previousLineLength = previousLine.getTrimmedLength();
|
|
125
|
+
if (previousLineLength === 0 || !this._hasUrlId(previousLine, previousLineLength - 1, linkId)) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
let previousStartX = previousLineLength - 1;
|
|
129
|
+
while (previousStartX > 0 && this._hasUrlId(previousLine, previousStartX - 1, linkId)) {
|
|
130
|
+
previousStartX--;
|
|
131
|
+
}
|
|
132
|
+
startY--;
|
|
133
|
+
finalStartX = previousStartX;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Expand downward only when this segment reaches trimmed EOL and the next line is wrapped.
|
|
137
|
+
while (true) {
|
|
138
|
+
const currentLine = this._bufferService.buffer.lines.get(endY - 1);
|
|
139
|
+
if (!currentLine) {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
const currentLineLength = currentLine.getTrimmedLength();
|
|
143
|
+
if (finalEndX !== currentLineLength) {
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
const nextLine = this._bufferService.buffer.lines.get(endY);
|
|
147
|
+
if (!nextLine?.isWrapped) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
const nextLineLength = nextLine.getTrimmedLength();
|
|
151
|
+
if (nextLineLength === 0 || !this._hasUrlId(nextLine, 0, linkId)) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
let nextEndX = 1;
|
|
155
|
+
while (nextEndX < nextLineLength && this._hasUrlId(nextLine, nextEndX, linkId)) {
|
|
156
|
+
nextEndX++;
|
|
157
|
+
}
|
|
158
|
+
endY++;
|
|
159
|
+
finalEndX = nextEndX;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// IBufferRange uses 1-based coordinates.
|
|
163
|
+
return {
|
|
164
|
+
start: {
|
|
165
|
+
x: finalStartX + 1,
|
|
166
|
+
y: startY
|
|
167
|
+
},
|
|
168
|
+
end: {
|
|
169
|
+
x: finalEndX,
|
|
170
|
+
y: endY
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private _hasUrlId(line: IBufferLine, x: number, linkId: number): boolean {
|
|
176
|
+
const cell = this._workCell;
|
|
177
|
+
line.loadCell(x, cell);
|
|
178
|
+
return !!cell.hasExtendedAttrs() && cell.extended.urlId === linkId;
|
|
179
|
+
}
|
|
114
180
|
}
|
|
115
181
|
|
|
116
182
|
function defaultActivate(e: MouseEvent, uri: string): void {
|
package/src/common/Version.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class BufferNamespaceApi extends Disposable implements IBufferNamespaceAp
|
|
|
20
20
|
super();
|
|
21
21
|
this._normal = new BufferApiView(this._core.buffers.normal, 'normal');
|
|
22
22
|
this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate');
|
|
23
|
-
this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active));
|
|
23
|
+
this._register(this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active)));
|
|
24
24
|
}
|
|
25
25
|
public get active(): IBufferApi {
|
|
26
26
|
if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; }
|