Merge branch 'master' into di-enhancement
This commit is contained in:
@@ -202,38 +202,38 @@ describe('InputHandler', () => {
|
||||
describe('setCursorStyle', () => {
|
||||
it('should call Terminal.setOption with correct params', () => {
|
||||
inputHandler.setCursorStyle(Params.fromArray([0]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'block');
|
||||
assert.equal(optionsService.options['cursorBlink'], true);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, undefined);
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, undefined);
|
||||
|
||||
optionsService.options = clone(DEFAULT_OPTIONS);
|
||||
inputHandler.setCursorStyle(Params.fromArray([1]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'block');
|
||||
assert.equal(optionsService.options['cursorBlink'], true);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, 'block');
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, true);
|
||||
|
||||
optionsService.options = clone(DEFAULT_OPTIONS);
|
||||
inputHandler.setCursorStyle(Params.fromArray([2]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'block');
|
||||
assert.equal(optionsService.options['cursorBlink'], false);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, 'block');
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, false);
|
||||
|
||||
optionsService.options = clone(DEFAULT_OPTIONS);
|
||||
inputHandler.setCursorStyle(Params.fromArray([3]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'underline');
|
||||
assert.equal(optionsService.options['cursorBlink'], true);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, 'underline');
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, true);
|
||||
|
||||
optionsService.options = clone(DEFAULT_OPTIONS);
|
||||
inputHandler.setCursorStyle(Params.fromArray([4]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'underline');
|
||||
assert.equal(optionsService.options['cursorBlink'], false);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, 'underline');
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, false);
|
||||
|
||||
optionsService.options = clone(DEFAULT_OPTIONS);
|
||||
inputHandler.setCursorStyle(Params.fromArray([5]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'bar');
|
||||
assert.equal(optionsService.options['cursorBlink'], true);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, 'bar');
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, true);
|
||||
|
||||
optionsService.options = clone(DEFAULT_OPTIONS);
|
||||
inputHandler.setCursorStyle(Params.fromArray([6]));
|
||||
assert.equal(optionsService.options['cursorStyle'], 'bar');
|
||||
assert.equal(optionsService.options['cursorBlink'], false);
|
||||
assert.equal(coreService.decPrivateModes.cursorStyle, 'bar');
|
||||
assert.equal(coreService.decPrivateModes.cursorBlink, false);
|
||||
});
|
||||
});
|
||||
describe('setMode', () => {
|
||||
|
||||
+29
-23
@@ -2714,7 +2714,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
|
||||
/**
|
||||
* CSI Ps SP q Set cursor style (DECSCUSR, VT520).
|
||||
* Ps = 0 -> blinking block.
|
||||
* Ps = 0 -> reset to option.
|
||||
* Ps = 1 -> blinking block (default).
|
||||
* Ps = 2 -> steady block.
|
||||
* Ps = 3 -> blinking underline.
|
||||
@@ -2724,31 +2724,37 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*
|
||||
* @vt: #Y CSI DECSCUSR "Set Cursor Style" "CSI Ps SP q" "Set cursor style."
|
||||
* Supported cursor styles:
|
||||
* - empty, 0 or 1: steady block
|
||||
* - 2: blink block
|
||||
* - 3: steady underline
|
||||
* - 4: blink underline
|
||||
* - 5: steady bar
|
||||
* - 6: blink bar
|
||||
* - 0: reset to option
|
||||
* - empty, 1: blinking block
|
||||
* - 2: steady block
|
||||
* - 3: blinking underline
|
||||
* - 4: steady underline
|
||||
* - 5: blinking bar
|
||||
* - 6: steady bar
|
||||
*/
|
||||
public setCursorStyle(params: IParams): boolean {
|
||||
const param = params.params[0] || 1;
|
||||
switch (param) {
|
||||
case 1:
|
||||
case 2:
|
||||
this._optionsService.options.cursorStyle = 'block';
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
this._optionsService.options.cursorStyle = 'underline';
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
this._optionsService.options.cursorStyle = 'bar';
|
||||
break;
|
||||
const param = params.length === 0 ? 1 : params.params[0];
|
||||
if (param === 0) {
|
||||
this._coreService.decPrivateModes.cursorStyle = undefined;
|
||||
this._coreService.decPrivateModes.cursorBlink = undefined;
|
||||
} else {
|
||||
switch (param) {
|
||||
case 1:
|
||||
case 2:
|
||||
this._coreService.decPrivateModes.cursorStyle = 'block';
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
this._coreService.decPrivateModes.cursorStyle = 'underline';
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
this._coreService.decPrivateModes.cursorStyle = 'bar';
|
||||
break;
|
||||
}
|
||||
const isBlinking = param % 2 === 1;
|
||||
this._coreService.decPrivateModes.cursorBlink = isBlinking;
|
||||
}
|
||||
const isBlinking = param % 2 === 1;
|
||||
this._optionsService.options.cursorBlink = isBlinking;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ export class MockCoreService implements ICoreService {
|
||||
applicationCursorKeys: false,
|
||||
applicationKeypad: false,
|
||||
bracketedPasteMode: false,
|
||||
cursorBlink: undefined,
|
||||
cursorStyle: undefined,
|
||||
origin: false,
|
||||
reverseWraparound: false,
|
||||
sendFocus: false,
|
||||
|
||||
@@ -268,6 +268,8 @@ export interface IDecPrivateModes {
|
||||
applicationCursorKeys: boolean;
|
||||
applicationKeypad: boolean;
|
||||
bracketedPasteMode: boolean;
|
||||
cursorBlink: boolean | undefined;
|
||||
cursorStyle: CursorStyle | undefined;
|
||||
origin: boolean;
|
||||
reverseWraparound: boolean;
|
||||
sendFocus: boolean;
|
||||
|
||||
@@ -315,7 +315,8 @@ export class Buffer implements IBuffer {
|
||||
}
|
||||
|
||||
private _reflowLarger(newCols: number, newRows: number): void {
|
||||
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA));
|
||||
const reflowCursorLine = this._optionsService.rawOptions.reflowCursorLine;
|
||||
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA), reflowCursorLine);
|
||||
if (toRemove.length > 0) {
|
||||
const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);
|
||||
reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
|
||||
@@ -347,6 +348,7 @@ export class Buffer implements IBuffer {
|
||||
}
|
||||
|
||||
private _reflowSmaller(newCols: number, newRows: number): void {
|
||||
const reflowCursorLine = this._optionsService.rawOptions.reflowCursorLine;
|
||||
const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
|
||||
// Gather all BufferLines that need to be inserted into the Buffer here so that they can be
|
||||
// batched up and only committed once
|
||||
@@ -367,11 +369,13 @@ export class Buffer implements IBuffer {
|
||||
wrappedLines.unshift(nextLine);
|
||||
}
|
||||
|
||||
// If these lines contain the cursor don't touch them, the program will handle fixing up
|
||||
// wrapped lines with the cursor
|
||||
const absoluteY = this.ybase + this.y;
|
||||
if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
|
||||
continue;
|
||||
if (!reflowCursorLine) {
|
||||
// If these lines contain the cursor don't touch them, the program will handle fixing up
|
||||
// wrapped lines with the cursor
|
||||
const absoluteY = this.ybase + this.y;
|
||||
if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
|
||||
|
||||
@@ -20,8 +20,9 @@ export interface INewLayoutResult {
|
||||
* @param newCols The columns after resize.
|
||||
* @param bufferAbsoluteY The absolute y position of the cursor (baseY + cursorY).
|
||||
* @param nullCell The cell data to use when filling in empty cells.
|
||||
* @param reflowCursorLine Whether to reflow the line containing the cursor.
|
||||
*/
|
||||
export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData): number[] {
|
||||
export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData, reflowCursorLine: boolean): number[] {
|
||||
// Gather all BufferLines that need to be removed from the Buffer here so that they can be
|
||||
// batched up and only committed once
|
||||
const toRemove: number[] = [];
|
||||
@@ -41,11 +42,13 @@ export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, o
|
||||
nextLine = lines.get(++i) as BufferLine;
|
||||
}
|
||||
|
||||
// If these lines contain the cursor don't touch them, the program will handle fixing up wrapped
|
||||
// lines with the cursor
|
||||
if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
|
||||
y += wrappedLines.length - 1;
|
||||
continue;
|
||||
if (!reflowCursorLine) {
|
||||
// If these lines contain the cursor don't touch them, the program will handle fixing up
|
||||
// wrapped lines with the cursor
|
||||
if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
|
||||
y += wrappedLines.length - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy buffer data to new locations
|
||||
|
||||
@@ -17,6 +17,8 @@ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
||||
applicationCursorKeys: false,
|
||||
applicationKeypad: false,
|
||||
bracketedPasteMode: false,
|
||||
cursorBlink: undefined,
|
||||
cursorStyle: undefined,
|
||||
origin: false,
|
||||
reverseWraparound: false,
|
||||
sendFocus: false,
|
||||
|
||||
@@ -44,6 +44,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
||||
allowTransparency: false,
|
||||
tabStopWidth: 8,
|
||||
theme: {},
|
||||
reflowCursorLine: false,
|
||||
rescaleOverlappingGlyphs: false,
|
||||
rightClickSelectsWord: isMac,
|
||||
windowOptions: {},
|
||||
|
||||
@@ -238,6 +238,7 @@ export interface ITerminalOptions {
|
||||
macOptionIsMeta?: boolean;
|
||||
macOptionClickForcesSelection?: boolean;
|
||||
minimumContrastRatio?: number;
|
||||
reflowCursorLine?: boolean;
|
||||
rescaleOverlappingGlyphs?: boolean;
|
||||
rightClickSelectsWord?: boolean;
|
||||
rows?: number;
|
||||
|
||||
Reference in New Issue
Block a user