Add cursorInactiveStyle option

This commit is contained in:
tisilent
2023-08-10 16:11:04 +08:00
parent 4f41070b45
commit 482dad3036
10 changed files with 115 additions and 46 deletions
@@ -150,7 +150,14 @@ export class CursorRenderLayer extends BaseRenderLayer {
this._ctx.save();
this._ctx.fillStyle = this._themeService.colors.cursor.css;
const cursorStyle = this._optionsService.rawOptions.cursorStyle;
this._renderBlurCursor(cursorX, viewportRelativeCursorY, this._cell);
if (this._optionsService.rawOptions.cursorInactiveStyle === 'outline') {
this._renderBlurCursor(cursorX, viewportRelativeCursorY, this._cell);
} else if (this._optionsService.rawOptions.cursorInactiveStyle === 'line') {
this._cursorRenderers['bar'](cursorX, viewportRelativeCursorY, this._cell);
} else if (this._optionsService.rawOptions.cursorInactiveStyle === 'underline') {
this._cursorRenderers['underline'](cursorX, viewportRelativeCursorY, this._cell);
} else {
}
this._ctx.restore();
this._state.x = cursorX;
this._state.y = viewportRelativeCursorY;
+14 -1
View File
@@ -461,7 +461,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
y: this._terminal.buffer.active.cursorY,
width: cell.getWidth(),
style: this._coreBrowserService.isFocused ?
(terminal.options.cursorStyle || 'block') : 'blur',
(terminal.options.cursorStyle || 'block') : this._getInactiveCursorStyle(terminal.options.cursorInactiveStyle),
cursorWidth: terminal.options.cursorWidth,
dpr: this._devicePixelRatio
};
@@ -600,6 +600,19 @@ export class WebglRenderer extends Disposable implements IRenderer {
const cursorY = this._terminal.buffer.active.cursorY;
this._onRequestRedraw.fire({ start: cursorY, end: cursorY });
}
private _getInactiveCursorStyle(cursorInactiveStyle: 'outline' | 'line' | 'underline' | 'none'): string {
if (cursorInactiveStyle === 'outline') {
return 'blur';
}
if (cursorInactiveStyle === 'line') {
return 'bar';
}
if (cursorInactiveStyle === 'underline'){
return 'underline';
}
return 'block';
}
}
// TODO: Share impl with core