mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Add block to cursorInactiveStyle,
change line to bar
This commit is contained in:
@@ -58,7 +58,8 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
this._cursorRenderers = {
|
||||
'bar': this._renderBarCursor.bind(this),
|
||||
'block': this._renderBlockCursor.bind(this),
|
||||
'underline': this._renderUnderlineCursor.bind(this)
|
||||
'underline': this._renderUnderlineCursor.bind(this),
|
||||
'outline': this._renderOutlineCursor.bind(this)
|
||||
};
|
||||
this.register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
this._handleOptionsChanged();
|
||||
@@ -150,13 +151,9 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
this._ctx.save();
|
||||
this._ctx.fillStyle = this._themeService.colors.cursor.css;
|
||||
const cursorStyle = this._optionsService.rawOptions.cursorStyle;
|
||||
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 {
|
||||
const cursorInactiveStyle = this._optionsService.rawOptions.cursorInactiveStyle;
|
||||
if (cursorInactiveStyle && cursorInactiveStyle !== 'none') {
|
||||
this._cursorRenderers[cursorInactiveStyle](cursorX, viewportRelativeCursorY, this._cell);
|
||||
}
|
||||
this._ctx.restore();
|
||||
this._state.x = cursorX;
|
||||
@@ -238,7 +235,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
|
||||
this._ctx.restore();
|
||||
}
|
||||
|
||||
private _renderBlurCursor(x: number, y: number, cell: ICellData): void {
|
||||
private _renderOutlineCursor(x: number, y: number, cell: ICellData): void {
|
||||
this._ctx.save();
|
||||
this._ctx.strokeStyle = this._themeService.colors.cursor.css;
|
||||
this._strokeRectAtCell(x, y, cell.getWidth(), 1);
|
||||
|
||||
@@ -455,21 +455,24 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
|
||||
// Override colors for cursor cell
|
||||
if (isCursorVisible && row === cursorY) {
|
||||
const inactiveCursorStyle = this._getInactiveCursorStyle(terminal.options.cursorInactiveStyle);
|
||||
if (x === cursorX) {
|
||||
this._model.cursor = {
|
||||
x: cursorX,
|
||||
y: this._terminal.buffer.active.cursorY,
|
||||
width: cell.getWidth(),
|
||||
style: this._coreBrowserService.isFocused ?
|
||||
(terminal.options.cursorStyle || 'block') : this._getInactiveCursorStyle(terminal.options.cursorInactiveStyle),
|
||||
(terminal.options.cursorStyle || 'block') : inactiveCursorStyle,
|
||||
cursorWidth: terminal.options.cursorWidth,
|
||||
dpr: this._devicePixelRatio
|
||||
};
|
||||
lastCursorX = cursorX + cell.getWidth() - 1;
|
||||
}
|
||||
if (x >= cursorX && x <= lastCursorX &&
|
||||
this._coreBrowserService.isFocused &&
|
||||
(terminal.options.cursorStyle || 'block') === 'block') {
|
||||
((this._coreBrowserService.isFocused &&
|
||||
(terminal.options.cursorStyle || 'block') === 'block') ||
|
||||
(this._coreBrowserService.isFocused === false &&
|
||||
inactiveCursorStyle === 'block'))) {
|
||||
this._cellColorResolver.result.fg =
|
||||
Attributes.CM_RGB | (this._themeService.colors.cursorAccent.rgba >> 8 & Attributes.RGB_MASK);
|
||||
this._cellColorResolver.result.bg =
|
||||
@@ -601,17 +604,20 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
this._onRequestRedraw.fire({ start: cursorY, end: cursorY });
|
||||
}
|
||||
|
||||
private _getInactiveCursorStyle(cursorInactiveStyle: 'outline' | 'line' | 'underline' | 'none'): string {
|
||||
private _getInactiveCursorStyle(cursorInactiveStyle: 'outline' | 'block' | 'bar' | 'underline' | 'none'): string {
|
||||
if (cursorInactiveStyle === 'outline') {
|
||||
return 'blur';
|
||||
}
|
||||
if (cursorInactiveStyle === 'line') {
|
||||
if (cursorInactiveStyle === 'block') {
|
||||
return 'block';
|
||||
}
|
||||
if (cursorInactiveStyle === 'bar') {
|
||||
return 'bar';
|
||||
}
|
||||
if (cursorInactiveStyle === 'underline'){
|
||||
if (cursorInactiveStyle === 'underline') {
|
||||
return 'underline';
|
||||
}
|
||||
return 'block';
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user