Merge branch 'master' into patch-1

This commit is contained in:
octoclonius
2024-02-04 15:55:14 -05:00
committed by GitHub
11 changed files with 56 additions and 12 deletions
+3
View File
@@ -72,6 +72,9 @@ export class MockTerminal implements ITerminal {
public focus(): void { public focus(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public input(data: string, wasUserInput: boolean = true): void {
throw new Error('Method not implemented.');
}
public resize(columns: number, rows: number): void { public resize(columns: number, rows: number): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
+3
View File
@@ -138,6 +138,9 @@ export class Terminal extends Disposable implements ITerminalApi {
public focus(): void { public focus(): void {
this._core.focus(); this._core.focus();
} }
public input(data: string, wasUserInput: boolean = true): void {
this._core.input(data, wasUserInput);
}
public resize(columns: number, rows: number): void { public resize(columns: number, rows: number): void {
this._verifyIntegers(columns, rows); this._verifyIntegers(columns, rows);
this._core.resize(columns, rows); this._core.resize(columns, rows);
@@ -92,7 +92,7 @@ export class CellColorResolver {
$bg = this._themeService.colors.ansi[this.result.fg & Attributes.PCOLOR_MASK].rgba; $bg = this._themeService.colors.ansi[this.result.fg & Attributes.PCOLOR_MASK].rgba;
break; break;
case Attributes.CM_RGB: case Attributes.CM_RGB:
$bg = (this.result.fg & Attributes.RGB_MASK) << 8 | 0xFF; $bg = ((this.result.fg & Attributes.RGB_MASK) << 8) | 0xFF;
break; break;
case Attributes.CM_DEFAULT: case Attributes.CM_DEFAULT:
default: default:
@@ -105,7 +105,7 @@ export class CellColorResolver {
$bg = this._themeService.colors.ansi[this.result.bg & Attributes.PCOLOR_MASK].rgba; $bg = this._themeService.colors.ansi[this.result.bg & Attributes.PCOLOR_MASK].rgba;
break; break;
case Attributes.CM_RGB: case Attributes.CM_RGB:
$bg = this.result.bg & Attributes.RGB_MASK << 8 | 0xFF; $bg = ((this.result.bg & Attributes.RGB_MASK) << 8) | 0xFF;
break; break;
// No need to consider default bg color here as it's not possible // No need to consider default bg color here as it's not possible
} }
@@ -143,7 +143,7 @@ export class CellColorResolver {
$fg = this._themeService.colors.ansi[this.result.bg & Attributes.PCOLOR_MASK].rgba; $fg = this._themeService.colors.ansi[this.result.bg & Attributes.PCOLOR_MASK].rgba;
break; break;
case Attributes.CM_RGB: case Attributes.CM_RGB:
$fg = this.result.bg & Attributes.RGB_MASK << 8 | 0xFF; $fg = ((this.result.bg & Attributes.RGB_MASK) << 8) | 0xFF;
break; break;
// No need to consider default bg color here as it's not possible // No need to consider default bg color here as it's not possible
} }
@@ -154,7 +154,7 @@ export class CellColorResolver {
$fg = this._themeService.colors.ansi[this.result.fg & Attributes.PCOLOR_MASK].rgba; $fg = this._themeService.colors.ansi[this.result.fg & Attributes.PCOLOR_MASK].rgba;
break; break;
case Attributes.CM_RGB: case Attributes.CM_RGB:
$fg = (this.result.fg & Attributes.RGB_MASK) << 8 | 0xFF; $fg = ((this.result.fg & Attributes.RGB_MASK) << 8) | 0xFF;
break; break;
case Attributes.CM_DEFAULT: case Attributes.CM_DEFAULT:
default: default:
+1 -1
View File
@@ -247,7 +247,7 @@ export class RenderService extends Disposable implements IRenderService {
return; return;
} }
if (this._isPaused) { if (this._isPaused) {
this._pausedResizeTask.set(() => this._renderer.value!.handleResize(cols, rows)); this._pausedResizeTask.set(() => this._renderer.value?.handleResize(cols, rows));
} else { } else {
this._renderer.value.handleResize(cols, rows); this._renderer.value.handleResize(cols, rows);
} }
+4
View File
@@ -168,6 +168,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
this._writeBuffer.writeSync(data, maxSubsequentCalls); this._writeBuffer.writeSync(data, maxSubsequentCalls);
} }
public input(data: string, wasUserInput: boolean = true): void {
this.coreService.triggerDataEvent(data, wasUserInput);
}
public resize(x: number, y: number): void { public resize(x: number, y: number): void {
if (isNaN(x) || isNaN(y)) { if (isNaN(x) || isNaN(y)) {
return; return;
+4
View File
@@ -81,6 +81,10 @@ export class Terminal extends CoreTerminal {
this._onBell.fire(); this._onBell.fire();
} }
public input(data: string, wasUserInput: boolean = true): void {
this.coreService.triggerDataEvent(data, wasUserInput);
}
/** /**
* Resizes the terminal. * Resizes the terminal.
* *
+3
View File
@@ -134,6 +134,9 @@ export class Terminal extends Disposable implements ITerminalApi {
this._publicOptions[propName] = options[propName]; this._publicOptions[propName] = options[propName];
} }
} }
public input(data: string, wasUserInput: boolean = true): void {
this._core.input(data, wasUserInput);
}
public resize(columns: number, rows: number): void { public resize(columns: number, rows: number): void {
this._verifyIntegers(columns, rows); this._verifyIntegers(columns, rows);
this._core.resize(columns, rows); this._core.resize(columns, rows);
+9 -7
View File
@@ -6,7 +6,7 @@
import { IImage32, decodePng } from '@lunapaint/png-codec'; import { IImage32, decodePng } from '@lunapaint/png-codec';
import { LocatorScreenshotOptions, test } from '@playwright/test'; import { LocatorScreenshotOptions, test } from '@playwright/test';
import { ITheme } from '@xterm/xterm'; import { ITheme } from '@xterm/xterm';
import { ITestContext, MaybeAsync, openTerminal, pollFor, pollForApproximate } from './TestUtils'; import { ITestContext, MaybeAsync, openTerminal, pollFor, pollForApproximate, timeout } from './TestUtils';
export interface ISharedRendererTestContext { export interface ISharedRendererTestContext {
value: ITestContext; value: ITestContext;
@@ -989,13 +989,15 @@ export function injectSharedRendererTests(ctx: ISharedRendererTestContext): void
}; };
await ctx.value.page.evaluate(`window.term.options.theme = ${JSON.stringify(theme)};`); await ctx.value.page.evaluate(`window.term.options.theme = ${JSON.stringify(theme)};`);
await ctx.value.proxy.focus(); await ctx.value.proxy.focus();
await ctx.value.proxy.writeln('\x1b[41m red bg'); await ctx.value.proxy.writeln('\x1b[41m red bg\x1b[0m');
await ctx.value.proxy.writeln('\x1b[7m inverse'); await ctx.value.proxy.writeln('\x1b[7m inverse\x1b[0m');
await ctx.value.proxy.writeln('\x1b[31;7m red fg inverse'); await ctx.value.proxy.writeln('\x1b[31;7m red fg inverse\x1b[0m');
await ctx.value.proxy.writeln('\x1b[48:2:0:204:0:0m red truecolor bg\x1b[0m');
await ctx.value.proxy.selectAll(); await ctx.value.proxy.selectAll();
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [230,128,128,255]); await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [230, 128, 128, 255]);
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 2), [255,255,255,255]); await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 2), [255, 255, 255, 255]);
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 3), [230,128,128,255]); await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 3), [230, 128, 128, 255]);
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 4), [230, 128, 128, 255]);
}); });
test('powerline decorative symbols', async () => { test('powerline decorative symbols', async () => {
const theme: ITheme = { const theme: ITheme = {
+1
View File
@@ -216,6 +216,7 @@ export class TerminalProxy implements ITerminalProxyCustomMethods, PlaywrightApi
return new Promise(r => term.writeln(typeof data === 'string' ? data : new Uint8Array(data), r)); return new Promise(r => term.writeln(typeof data === 'string' ? data : new Uint8Array(data), r));
}, [await this.getHandle(), typeof data === 'string' ? data : Array.from(data)] as const); }, [await this.getHandle(), typeof data === 'string' ? data : Array.from(data)] as const);
} }
public async input(data: string, wasUserInput: boolean = true): Promise<void> { return this.evaluate(([term]) => term.input(data, wasUserInput)); }
public async resize(cols: number, rows: number): Promise<void> { return this._page.evaluate(([term, cols, rows]) => term.resize(cols, rows), [await this.getHandle(), cols, rows] as const); } public async resize(cols: number, rows: number): Promise<void> { return this._page.evaluate(([term, cols, rows]) => term.resize(cols, rows), [await this.getHandle(), cols, rows] as const); }
public async registerMarker(y?: number | undefined): Promise<IMarker> { return this._page.evaluate(([term, y]) => term.registerMarker(y), [await this.getHandle(), y] as const); } public async registerMarker(y?: number | undefined): Promise<IMarker> { return this._page.evaluate(([term, y]) => term.registerMarker(y), [await this.getHandle(), y] as const); }
public async registerDecoration(decorationOptions: IDecorationOptions): Promise<IDecoration | undefined> { return this._page.evaluate(([term, decorationOptions]) => term.registerDecoration(decorationOptions), [await this.getHandle(), decorationOptions] as const); } public async registerDecoration(decorationOptions: IDecorationOptions): Promise<IDecoration | undefined> { return this._page.evaluate(([term, decorationOptions]) => term.registerDecoration(decorationOptions), [await this.getHandle(), decorationOptions] as const); }
+12
View File
@@ -718,6 +718,18 @@ declare module '@xterm/headless' {
*/ */
onTitleChange: IEvent<string>; onTitleChange: IEvent<string>;
/**
* Input data to application side. The data is treated the same way input
* typed into the terminal would (ie. the {@link onData} event will fire).
* @param data The data to forward to the application.
* @param wasUserInput Whether the input is genuine user input. This is true
* by default and triggers additionalbehavior like focus or selection
* clearing. Set this to false if the data sent should not be treated like
* user input would, for example passing an escape sequence to the
* application.
*/
input(data: string, wasUserInput?: boolean): void;
/** /**
* Resizes the terminal. It's best practice to debounce calls to resize, * Resizes the terminal. It's best practice to debounce calls to resize,
* this will help ensure that the pty can respond to the resize event * this will help ensure that the pty can respond to the resize event
+12
View File
@@ -963,6 +963,18 @@ declare module '@xterm/xterm' {
*/ */
focus(): void; focus(): void;
/**
* Input data to application side. The data is treated the same way input
* typed into the terminal would (ie. the {@link onData} event will fire).
* @param data The data to forward to the application.
* @param wasUserInput Whether the input is genuine user input. This is true
* by default and triggers additionalbehavior like focus or selection
* clearing. Set this to false if the data sent should not be treated like
* user input would, for example passing an escape sequence to the
* application.
*/
input(data: string, wasUserInput?: boolean): void;
/** /**
* Resizes the terminal. It's best practice to debounce calls to resize, * Resizes the terminal. It's best practice to debounce calls to resize,
* this will help ensure that the pty can respond to the resize event * this will help ensure that the pty can respond to the resize event