Merge remote-tracking branch 'upstream/master' into pr/JasonXJ/4742

This commit is contained in:
Daniel Imms
2023-11-03 08:47:05 -07:00
285 changed files with 1097 additions and 621 deletions
+15
View File
@@ -126,6 +126,9 @@ export class AttributeData implements IAttributeData {
? (this.bg & BgFlags.HAS_EXTENDED ? this.extended.underlineStyle : UnderlineStyle.SINGLE)
: UnderlineStyle.NONE;
}
public getUnderlineVariantOffset(): number {
return this.extended.underlineVariantOffset;
}
}
@@ -174,6 +177,18 @@ export class ExtendedAttrs implements IExtendedAttrs {
this._urlId = value;
}
public get underlineVariantOffset(): number {
const val = (this._ext & ExtFlags.VARIANT_OFFSET) >> 29;
if (val < 0) {
return val ^ 0xFFFFFFF8;
}
return val;
}
public set underlineVariantOffset(value: number) {
this._ext &= ~ExtFlags.VARIANT_OFFSET;
this._ext |= (value << 29) & ExtFlags.VARIANT_OFFSET;
}
constructor(
ext: number = 0,
urlId: number = 0
+12
View File
@@ -119,6 +119,18 @@ describe('AttributeData', () => {
attrs.fg &= ~FgFlags.UNDERLINE;
assert.equal(attrs.getUnderlineStyle(), UnderlineStyle.NONE);
});
it('getUnderlineVariantOffset', () => {
const attrs = new AttributeData();
// defaults to no offset
assert.equal(attrs.getUnderlineVariantOffset(), 0);
// should return 0 - 7
for (let i = 0; i < 8; ++i) {
attrs.extended.underlineVariantOffset = i;
assert.equal(attrs.getUnderlineVariantOffset(), i);
}
});
});
});
+17 -17
View File
@@ -4,7 +4,7 @@
*/
import { CharData, IAttributeData, IBufferLine, ICellData, IExtendedAttrs } from 'common/Types';
import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData';
import { AttributeData } from 'common/buffer/AttributeData';
import { CellData } from 'common/buffer/CellData';
import { Attributes, BgFlags, CHAR_DATA_ATTR_INDEX, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, Content, NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR } from 'common/buffer/Constants';
import { stringFromCodePoint } from 'common/input/TextDecoder';
@@ -212,13 +212,13 @@ export class BufferLine implements IBufferLine {
* Since the input handler see the incoming chars as UTF32 codepoints,
* it gets an optimized access method.
*/
public setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number, eAttrs: IExtendedAttrs): void {
if (bg & BgFlags.HAS_EXTENDED) {
this._extendedAttrs[index] = eAttrs;
public setCellFromCodepoint(index: number, codePoint: number, width: number, attrs: IAttributeData): void {
if (attrs.bg & BgFlags.HAS_EXTENDED) {
this._extendedAttrs[index] = attrs.extended;
}
this._data[index * CELL_SIZE + Cell.CONTENT] = codePoint | (width << Content.WIDTH_SHIFT);
this._data[index * CELL_SIZE + Cell.FG] = fg;
this._data[index * CELL_SIZE + Cell.BG] = bg;
this._data[index * CELL_SIZE + Cell.FG] = attrs.fg;
this._data[index * CELL_SIZE + Cell.BG] = attrs.bg;
}
/**
@@ -253,12 +253,12 @@ export class BufferLine implements IBufferLine {
this._data[index * CELL_SIZE + Cell.CONTENT] = content;
}
public insertCells(pos: number, n: number, fillCellData: ICellData, eraseAttr?: IAttributeData): void {
public insertCells(pos: number, n: number, fillCellData: ICellData): void {
pos %= this.length;
// handle fullwidth at pos: reset cell one to the left if pos is second cell of a wide char
if (pos && this.getWidth(pos - 1) === 2) {
this.setCellFromCodePoint(pos - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(pos - 1, 0, 1, fillCellData);
}
if (n < this.length - pos) {
@@ -277,11 +277,11 @@ export class BufferLine implements IBufferLine {
// handle fullwidth at line end: reset last cell if it is first cell of a wide char
if (this.getWidth(this.length - 1) === 2) {
this.setCellFromCodePoint(this.length - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(this.length - 1, 0, 1, fillCellData);
}
}
public deleteCells(pos: number, n: number, fillCellData: ICellData, eraseAttr?: IAttributeData): void {
public deleteCells(pos: number, n: number, fillCellData: ICellData): void {
pos %= this.length;
if (n < this.length - pos) {
const cell = new CellData();
@@ -301,21 +301,21 @@ export class BufferLine implements IBufferLine {
// - reset pos-1 if wide char
// - reset pos if width==0 (previous second cell of a wide char)
if (pos && this.getWidth(pos - 1) === 2) {
this.setCellFromCodePoint(pos - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(pos - 1, 0, 1, fillCellData);
}
if (this.getWidth(pos) === 0 && !this.hasContent(pos)) {
this.setCellFromCodePoint(pos, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(pos, 0, 1, fillCellData);
}
}
public replaceCells(start: number, end: number, fillCellData: ICellData, eraseAttr?: IAttributeData, respectProtect: boolean = false): void {
public replaceCells(start: number, end: number, fillCellData: ICellData, respectProtect: boolean = false): void {
// full branching on respectProtect==true, hopefully getting fast JIT for standard case
if (respectProtect) {
if (start && this.getWidth(start - 1) === 2 && !this.isProtected(start - 1)) {
this.setCellFromCodePoint(start - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(start - 1, 0, 1, fillCellData);
}
if (end < this.length && this.getWidth(end - 1) === 2 && !this.isProtected(end)) {
this.setCellFromCodePoint(end, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(end, 0, 1, fillCellData);
}
while (start < end && start < this.length) {
if (!this.isProtected(start)) {
@@ -328,11 +328,11 @@ export class BufferLine implements IBufferLine {
// handle fullwidth at start: reset cell one to the left if start is second cell of a wide char
if (start && this.getWidth(start - 1) === 2) {
this.setCellFromCodePoint(start - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(start - 1, 0, 1, fillCellData);
}
// handle fullwidth at last cell + 1: reset to empty cell if it is second part of a wide char
if (end < this.length && this.getWidth(end - 1) === 2) {
this.setCellFromCodePoint(end, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
this.setCellFromCodepoint(end, 0, 1, fillCellData);
}
while (start < end && start < this.length) {
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { getRangeLength } from 'common/buffer/BufferRange';
import { IBufferRange } from 'xterm';
import { IBufferRange } from '@xterm/xterm';
describe('BufferRange', () => {
describe('getRangeLength', () => {
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IBufferRange } from 'xterm';
import { IBufferRange } from '@xterm/xterm';
export function getRangeLength(range: IBufferRange, bufferCols: number): number {
if (range.start.y > range.end.y) {
+10 -2
View File
@@ -134,9 +134,17 @@ export const enum BgFlags {
export const enum ExtFlags {
/**
* bit 27..32 (upper 3 unused)
* bit 27..29
*/
UNDERLINE_STYLE = 0x1C000000
UNDERLINE_STYLE = 0x1C000000,
/**
* bit 30..32
*
* An optional variant for the glyph, this can be used for example to offset underlines by a
* number of pixels to create a perfect pattern.
*/
VARIANT_OFFSET = 0xE0000000
}
export const enum UnderlineStyle {