Skip to content

Commit 5018a07

Browse files
authored
Merge pull request #5260 from Tyriar/5241
Blend cursor with background to support alpha in webgl
2 parents e826f6b + b74ec26 commit 5018a07

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

demo/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if ('WebAssembly' in window) {
1616
ImageAddon = imageAddon.ImageAddon;
1717
}
1818

19-
import { Terminal, ITerminalOptions, type IDisposable } from '@xterm/xterm';
19+
import { Terminal, ITerminalOptions, type IDisposable, type ITheme } from '@xterm/xterm';
2020
import { AttachAddon } from '@xterm/addon-attach';
2121
import { ClipboardAddon } from '@xterm/addon-clipboard';
2222
import { FitAddon } from '@xterm/addon-fit';
@@ -131,7 +131,7 @@ const xtermjsTheme = {
131131
brightCyan: '#72F0FF',
132132
white: '#F8F8F8',
133133
brightWhite: '#FFFFFF'
134-
};
134+
} satisfies ITheme;
135135
function setPadding(): void {
136136
term.element.style.padding = parseInt(paddingElement.value, 10).toString() + 'px';
137137
addons.fit.instance.fit();

src/browser/services/ThemeService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class ThemeService extends Disposable implements IThemeService {
8282
const colors = this._colors;
8383
colors.foreground = parseColor(theme.foreground, DEFAULT_FOREGROUND);
8484
colors.background = parseColor(theme.background, DEFAULT_BACKGROUND);
85-
colors.cursor = parseColor(theme.cursor, DEFAULT_CURSOR);
85+
colors.cursor = color.blend(colors.background, parseColor(theme.cursor, DEFAULT_CURSOR));
8686
colors.cursorAccent = parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT);
8787
colors.selectionBackgroundTransparent = parseColor(theme.selectionBackground, DEFAULT_SELECTION);
8888
colors.selectionBackgroundOpaque = color.blend(colors.background, colors.selectionBackgroundTransparent);

test/playwright/SharedRendererTests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,14 @@ export function injectSharedRendererTests(ctx: ISharedRendererTestContext): void
12481248
await ctx.value.proxy.scrollLines(-2);
12491249
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [0, 0, 0, 255]);
12501250
});
1251+
test('#5241 cursor with alpha should blend color with background color', async () => {
1252+
const theme: ITheme = {
1253+
cursor: '#FF000080'
1254+
};
1255+
await ctx.value.page.evaluate(`window.term.options.theme = ${JSON.stringify(theme)};`);
1256+
await ctx.value.proxy.focus();
1257+
await pollFor(ctx.value.page, () => getCellColor(ctx.value, 1, 1), [128, 0, 0, 255]);
1258+
});
12511259
});
12521260
}
12531261

0 commit comments

Comments
 (0)