Skip to content

Commit b579649

Browse files
committed
Revert to cursor options after DECSCUSR 0
Fixes #3293
1 parent fb2e96e commit b579649

7 files changed

Lines changed: 43 additions & 30 deletions

File tree

addons/addon-webgl/src/WebglRenderer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
354354
}
355355

356356
private _updateCursorBlink(): void {
357-
if (this._terminal.options.cursorBlink) {
357+
if (this._coreService.decPrivateModes.cursorBlink ?? this._terminal.options.cursorBlink) {
358358
this._cursorBlinkStateManager.value = new CursorBlinkStateManager(() => {
359359
this._requestRedrawCursor();
360360
}, this._coreBrowserService);
@@ -387,6 +387,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
387387
let j: number;
388388
start = clamp(start, terminal.rows - 1, 0);
389389
end = clamp(end, terminal.rows - 1, 0);
390+
const cursorStyle = this._coreService.decPrivateModes.cursorStyle ?? terminal.options.cursorStyle ?? 'block';
390391

391392
const cursorY = this._terminal.buffer.active.baseY + this._terminal.buffer.active.cursorY;
392393
const viewportRelativeCursorY = cursorY - terminal.buffer.ydisp;
@@ -450,18 +451,18 @@ export class WebglRenderer extends Disposable implements IRenderer {
450451
x: cursorX,
451452
y: viewportRelativeCursorY,
452453
width: cell.getWidth(),
453-
style: this._coreBrowserService.isFocused ?
454-
(terminal.options.cursorStyle || 'block') : terminal.options.cursorInactiveStyle,
454+
style: this._coreBrowserService.isFocused ? cursorStyle : terminal.options.cursorInactiveStyle,
455455
cursorWidth: terminal.options.cursorWidth,
456456
dpr: this._devicePixelRatio
457457
};
458458
lastCursorX = cursorX + cell.getWidth() - 1;
459459
}
460460
if (x >= cursorX && x <= lastCursorX &&
461461
((this._coreBrowserService.isFocused &&
462-
(terminal.options.cursorStyle || 'block') === 'block') ||
462+
cursorStyle === 'block') ||
463463
(this._coreBrowserService.isFocused === false &&
464-
terminal.options.cursorInactiveStyle === 'block'))) {
464+
terminal.options.cursorInactiveStyle === 'block'))
465+
) {
465466
this._cellColorResolver.result.fg =
466467
Attributes.CM_RGB | (this._themeService.colors.cursorAccent.rgba >> 8 & Attributes.RGB_MASK);
467468
this._cellColorResolver.result.bg =

demo/client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,10 +1269,7 @@ function addVtButtons(): void {
12691269
const writeCsiSplit = writeCsi.split('|');
12701270
const prefix = writeCsiSplit.length === 2 ? writeCsiSplit[0] : '';
12711271
const suffix = writeCsiSplit[writeCsiSplit.length - 1];
1272-
element.addEventListener(`click`, () => {
1273-
debugger;
1274-
term.write(csi(`${prefix}${inputs.map(e => e.value).join(';')}${suffix}`));
1275-
});
1272+
element.addEventListener(`click`, () => term.write(csi(`${prefix}${inputs.map(e => e.value).join(';')}${suffix}`)));
12761273

12771274
const desc = document.createElement('span');
12781275
desc.textContent = description;

src/browser/renderer/dom/DomRenderer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ICharSizeService, ICoreBrowserService, IThemeService } from 'browser/se
1313
import { ILinkifier2, ILinkifierEvent, ITerminal, ReadonlyColorSet } from 'browser/Types';
1414
import { color } from 'common/Color';
1515
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
16-
import { IBufferService, IInstantiationService, IOptionsService } from 'common/services/Services';
16+
import { IBufferService, ICoreService, IInstantiationService, IOptionsService } from 'common/services/Services';
1717
import { Emitter } from 'vs/base/common/event';
1818

1919

@@ -59,6 +59,7 @@ export class DomRenderer extends Disposable implements IRenderer {
5959
@ICharSizeService private readonly _charSizeService: ICharSizeService,
6060
@IOptionsService private readonly _optionsService: IOptionsService,
6161
@IBufferService private readonly _bufferService: IBufferService,
62+
@ICoreService private readonly _coreService: ICoreService,
6263
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService,
6364
@IThemeService private readonly _themeService: IThemeService
6465
) {
@@ -437,8 +438,8 @@ export class DomRenderer extends Disposable implements IRenderer {
437438
const buffer = this._bufferService.buffer;
438439
const cursorAbsoluteY = buffer.ybase + buffer.y;
439440
const cursorX = Math.min(buffer.x, this._bufferService.cols - 1);
440-
const cursorBlink = this._optionsService.rawOptions.cursorBlink;
441-
const cursorStyle = this._optionsService.rawOptions.cursorStyle;
441+
const cursorBlink = this._coreService.decPrivateModes.cursorBlink ?? this._optionsService.rawOptions.cursorBlink;
442+
const cursorStyle = this._coreService.decPrivateModes.cursorStyle ?? this._optionsService.rawOptions.cursorStyle;
442443
const cursorInactiveStyle = this._optionsService.rawOptions.cursorInactiveStyle;
443444

444445
for (let y = start; y <= end; y++) {

src/common/InputHandler.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,7 @@ export class InputHandler extends Disposable implements IInputHandler {
27142714

27152715
/**
27162716
* CSI Ps SP q Set cursor style (DECSCUSR, VT520).
2717-
* Ps = 0 -> blinking block.
2717+
* Ps = 0 -> reset to option.
27182718
* Ps = 1 -> blinking block (default).
27192719
* Ps = 2 -> steady block.
27202720
* Ps = 3 -> blinking underline.
@@ -2724,31 +2724,39 @@ export class InputHandler extends Disposable implements IInputHandler {
27242724
*
27252725
* @vt: #Y CSI DECSCUSR "Set Cursor Style" "CSI Ps SP q" "Set cursor style."
27262726
* Supported cursor styles:
2727-
* - empty, 0 or 1: steady block
2727+
* - empty, 0: reset to option
2728+
* - 1: steady block
27282729
* - 2: blink block
27292730
* - 3: steady underline
27302731
* - 4: blink underline
27312732
* - 5: steady bar
27322733
* - 6: blink bar
27332734
*/
27342735
public setCursorStyle(params: IParams): boolean {
2735-
const param = params.params[0] || 1;
2736-
switch (param) {
2737-
case 1:
2738-
case 2:
2739-
this._optionsService.options.cursorStyle = 'block';
2740-
break;
2741-
case 3:
2742-
case 4:
2743-
this._optionsService.options.cursorStyle = 'underline';
2744-
break;
2745-
case 5:
2746-
case 6:
2747-
this._optionsService.options.cursorStyle = 'bar';
2748-
break;
2736+
const param = params.params[0] ?? 1;
2737+
if (param === 0) {
2738+
this._coreService.decPrivateModes.cursorStyle = undefined;
2739+
this._coreService.decPrivateModes.cursorBlink = undefined;
2740+
} else {
2741+
switch (param) {
2742+
case 0:
2743+
break;
2744+
case 1:
2745+
case 2:
2746+
this._coreService.decPrivateModes.cursorStyle = 'block';
2747+
break;
2748+
case 3:
2749+
case 4:
2750+
this._coreService.decPrivateModes.cursorStyle = 'underline';
2751+
break;
2752+
case 5:
2753+
case 6:
2754+
this._coreService.decPrivateModes.cursorStyle = 'bar';
2755+
break;
2756+
}
2757+
const isBlinking = param % 2 === 1;
2758+
this._coreService.decPrivateModes.cursorBlink = isBlinking;
27492759
}
2750-
const isBlinking = param % 2 === 1;
2751-
this._optionsService.options.cursorBlink = isBlinking;
27522760
return true;
27532761
}
27542762

src/common/TestUtils.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export class MockCoreService implements ICoreService {
8989
applicationCursorKeys: false,
9090
applicationKeypad: false,
9191
bracketedPasteMode: false,
92+
cursorBlink: undefined,
93+
cursorStyle: undefined,
9294
origin: false,
9395
reverseWraparound: false,
9496
sendFocus: false,

src/common/Types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ export interface IDecPrivateModes {
268268
applicationCursorKeys: boolean;
269269
applicationKeypad: boolean;
270270
bracketedPasteMode: boolean;
271+
cursorBlink: boolean | undefined;
272+
cursorStyle: CursorStyle | undefined;
271273
origin: boolean;
272274
reverseWraparound: boolean;
273275
sendFocus: boolean;

src/common/services/CoreService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
1717
applicationCursorKeys: false,
1818
applicationKeypad: false,
1919
bracketedPasteMode: false,
20+
cursorBlink: undefined,
21+
cursorStyle: undefined,
2022
origin: false,
2123
reverseWraparound: false,
2224
sendFocus: false,

0 commit comments

Comments
 (0)