mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
pass in startLine, endLine, startCol
This commit is contained in:
@@ -149,17 +149,19 @@ describe('SerializeAddon', () => {
|
||||
});
|
||||
|
||||
it('serializes rows within a provided range', async () => {
|
||||
await writeP(terminal, 'hello\r\nworld');
|
||||
await writeP(terminal, 'prompt>hello\r\nworld');
|
||||
|
||||
const output = serializeAddon.serializeAsHTML({
|
||||
range: {
|
||||
start: 0,
|
||||
end: 0
|
||||
startLine: 0,
|
||||
endLine: 0,
|
||||
startCol: 7
|
||||
}
|
||||
});
|
||||
const rowMatches = output.match(/<div><span>.*?<\/span><\/div>/g) || [];
|
||||
assert.equal(rowMatches.length, 1, output);
|
||||
assert.ok(rowMatches[0]?.includes('hello'));
|
||||
assert.ok(!output.includes('prompt>'));
|
||||
assert.ok(!output.includes('world'));
|
||||
});
|
||||
|
||||
|
||||
@@ -453,8 +453,8 @@ export class SerializeAddon implements ITerminalAddon , ISerializeApi {
|
||||
const range = options.range;
|
||||
if (range) {
|
||||
return handler.serialize({
|
||||
start: { x: 0, y: typeof range.start === 'number' ? range.start : range.start.line },
|
||||
end: { x: terminal.cols, y: typeof range.end === 'number' ? range.end : range.end.line }
|
||||
start: { x: range.startCol, y: typeof range.startLine === 'number' ? range.startLine : range.startLine },
|
||||
end: { x: terminal.cols, y: typeof range.endLine === 'number' ? range.endLine : range.endLine }
|
||||
});
|
||||
}
|
||||
if (!onlySelection) {
|
||||
|
||||
+8
-2
@@ -92,9 +92,15 @@ declare module '@xterm/addon-serialize' {
|
||||
includeGlobalBackground: boolean;
|
||||
|
||||
/**
|
||||
* The row range to serialize. This is prioritized over {@link onlySelection}.
|
||||
* The range to serialize. This is prioritized over {@link onlySelection}.
|
||||
*/
|
||||
range?: ISerializeRange;
|
||||
range?: ISerializeBufferRange;
|
||||
}
|
||||
|
||||
export interface ISerializeBufferRange {
|
||||
startLine: number;
|
||||
endLine: number;
|
||||
startCol: number;
|
||||
}
|
||||
|
||||
export interface ISerializeRange {
|
||||
|
||||
Reference in New Issue
Block a user