remove BufferCellApiView
This commit is contained in:
@@ -320,13 +320,13 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Adjust the searchIndex to normalize emoji into single chars
|
// Adjust the searchIndex to normalize emoji into single chars
|
||||||
const char = cell.char;
|
const char = cell.getChars();
|
||||||
if (char.length > 1) {
|
if (char.length > 1) {
|
||||||
resultIndex -= char.length - 1;
|
resultIndex -= char.length - 1;
|
||||||
}
|
}
|
||||||
// Adjust the searchIndex for empty characters following wide unicode
|
// Adjust the searchIndex for empty characters following wide unicode
|
||||||
// chars (eg. CJK)
|
// chars (eg. CJK)
|
||||||
const charWidth = cell.width;
|
const charWidth = cell.getWidth();
|
||||||
if (charWidth === 0) {
|
if (charWidth === 0) {
|
||||||
resultIndex++;
|
resultIndex++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ describe('SerializeAddon', () => {
|
|||||||
const rows = 32;
|
const rows = 32;
|
||||||
const cols = 10;
|
const cols = 10;
|
||||||
const lines = newArray<string>(
|
const lines = newArray<string>(
|
||||||
(index: number) => digitsString(cols, index, `\x1b[38;5;${index}m`),
|
(index: number) => digitsString(cols, index, `\x1b[38;5;${16 + index}m`),
|
||||||
rows
|
rows
|
||||||
);
|
);
|
||||||
await writeSync(page, lines.join('\\r\\n'));
|
await writeSync(page, lines.join('\\r\\n'));
|
||||||
@@ -256,7 +256,7 @@ describe('SerializeAddon', () => {
|
|||||||
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('serialize tabs correctly', async () => {
|
it('serialize tabs correctly', async () => {
|
||||||
const lines = [
|
const lines = [
|
||||||
'a\tb',
|
'a\tb',
|
||||||
'aa\tc',
|
'aa\tc',
|
||||||
@@ -311,9 +311,9 @@ const NORMAL = '0';
|
|||||||
const FG_P16_RED = '31';
|
const FG_P16_RED = '31';
|
||||||
const FG_P16_GREEN = '32';
|
const FG_P16_GREEN = '32';
|
||||||
const FG_P16_YELLOW = '33';
|
const FG_P16_YELLOW = '33';
|
||||||
const FG_P256_RED = '38;5;1';
|
const FG_P256_RED = '38;5;196';
|
||||||
const FG_P256_GREEN = '38;5;2';
|
const FG_P256_GREEN = '38;5;46';
|
||||||
const FG_P256_YELLOW = '38;5;3';
|
const FG_P256_YELLOW = '38;5;226';
|
||||||
const FG_RGB_RED = '38;2;255;0;0';
|
const FG_RGB_RED = '38;2;255;0;0';
|
||||||
const FG_RGB_GREEN = '38;2;0;255;0';
|
const FG_RGB_GREEN = '38;2;0;255;0';
|
||||||
const FG_RGB_YELLOW = '38;2;255;255;0';
|
const FG_RGB_YELLOW = '38;2;255;255;0';
|
||||||
@@ -323,9 +323,9 @@ const FG_RESET = '39';
|
|||||||
const BG_P16_RED = '41';
|
const BG_P16_RED = '41';
|
||||||
const BG_P16_GREEN = '42';
|
const BG_P16_GREEN = '42';
|
||||||
const BG_P16_YELLOW = '43';
|
const BG_P16_YELLOW = '43';
|
||||||
const BG_P256_RED = '48;5;1';
|
const BG_P256_RED = '48;5;196';
|
||||||
const BG_P256_GREEN = '48;5;2';
|
const BG_P256_GREEN = '48;5;46';
|
||||||
const BG_P256_YELLOW = '48;5;3';
|
const BG_P256_YELLOW = '48;5;226';
|
||||||
const BG_RGB_RED = '48;2;255;0;0';
|
const BG_RGB_RED = '48;2;255;0;0';
|
||||||
const BG_RGB_GREEN = '48;2;0;255;0';
|
const BG_RGB_GREEN = '48;2;0;255;0';
|
||||||
const BG_RGB_YELLOW = '48;2;255;255;0';
|
const BG_RGB_YELLOW = '48;2;255;255;0';
|
||||||
|
|||||||
@@ -104,15 +104,19 @@ class StringSerializeHandler extends BaseSerializeHandler {
|
|||||||
if (fgChanged) {
|
if (fgChanged) {
|
||||||
const color = cell.getFgColor();
|
const color = cell.getFgColor();
|
||||||
if (cell.isFgRGB()) { sgrSeq.push(38, 2, (color >>> 16) & 0xFF, (color >>> 8) & 0xFF, color & 0xFF); }
|
if (cell.isFgRGB()) { sgrSeq.push(38, 2, (color >>> 16) & 0xFF, (color >>> 8) & 0xFF, color & 0xFF); }
|
||||||
else if (cell.isFgPalette256()) { sgrSeq.push(38, 5, color); }
|
else if (cell.isFgPalette()) {
|
||||||
else if (cell.isFgPalette16()) { sgrSeq.push(color & 8 ? 90 + (color & 7) : 30 + (color & 7)); }
|
if (color >= 16) { sgrSeq.push(38, 5, color); }
|
||||||
|
else { sgrSeq.push(color & 8 ? 90 + (color & 7) : 30 + (color & 7)); }
|
||||||
|
}
|
||||||
else { sgrSeq.push(39); }
|
else { sgrSeq.push(39); }
|
||||||
}
|
}
|
||||||
if (bgChanged) {
|
if (bgChanged) {
|
||||||
const color = cell.getBgColor();
|
const color = cell.getBgColor();
|
||||||
if (cell.isBgRGB()) { sgrSeq.push(48, 2, (color >>> 16) & 0xFF, (color >>> 8) & 0xFF, color & 0xFF); }
|
if (cell.isBgRGB()) { sgrSeq.push(48, 2, (color >>> 16) & 0xFF, (color >>> 8) & 0xFF, color & 0xFF); }
|
||||||
else if (cell.isBgPalette256()) { sgrSeq.push(48, 5, color); }
|
else if (cell.isBgPalette()) {
|
||||||
else if (cell.isBgPalette16()) { sgrSeq.push(color & 8 ? 100 + (color & 7) : 40 + (color & 7)); }
|
if (color >= 16) { sgrSeq.push(48, 5, color); }
|
||||||
|
else { sgrSeq.push(color & 8 ? 100 + (color & 7) : 40 + (color & 7)); }
|
||||||
|
}
|
||||||
else { sgrSeq.push(49); }
|
else { sgrSeq.push(49); }
|
||||||
}
|
}
|
||||||
if (flagsChanged) {
|
if (flagsChanged) {
|
||||||
@@ -133,14 +137,14 @@ class StringSerializeHandler extends BaseSerializeHandler {
|
|||||||
|
|
||||||
// Count number of null cells encountered after the last non-null cell and move the cursor
|
// Count number of null cells encountered after the last non-null cell and move the cursor
|
||||||
// if a non-null cell is found (eg. \t or cursor move)
|
// if a non-null cell is found (eg. \t or cursor move)
|
||||||
if (cell.char === '') {
|
if (cell.getChars() === '') {
|
||||||
this._nullCellCount++;
|
this._nullCellCount++;
|
||||||
} else if (this._nullCellCount > 0) {
|
} else if (this._nullCellCount > 0) {
|
||||||
this._currentRow += `\x1b[${this._nullCellCount}C`;
|
this._currentRow += `\x1b[${this._nullCellCount}C`;
|
||||||
this._nullCellCount = 0;
|
this._nullCellCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._currentRow += cell.char;
|
this._currentRow += cell.getChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _serializeString(): string {
|
protected _serializeString(): string {
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ export class GlyphRenderer {
|
|||||||
if (!line) {
|
if (!line) {
|
||||||
line = terminal.buffer.getLine(row);
|
line = terminal.buffer.getLine(row);
|
||||||
}
|
}
|
||||||
const chars = line!.getCell(x)!.char;
|
const chars = line!.getCell(x)!.getChars();
|
||||||
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RENDER_MODEL_FG_OFFSET], chars);
|
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RENDER_MODEL_FG_OFFSET], chars);
|
||||||
} else {
|
} else {
|
||||||
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RENDER_MODEL_FG_OFFSET]);
|
this._updateCell(this._vertices.selectionAttributes, x, y, model.cells[offset], bg, model.cells[offset + RENDER_MODEL_FG_OFFSET]);
|
||||||
|
|||||||
Vendored
+1
@@ -93,6 +93,7 @@ export interface IAttributeData {
|
|||||||
isBgPalette(): boolean;
|
isBgPalette(): boolean;
|
||||||
isFgDefault(): boolean;
|
isFgDefault(): boolean;
|
||||||
isBgDefault(): boolean;
|
isBgDefault(): boolean;
|
||||||
|
isAttributeDefault(): boolean;
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
getFgColor(): number;
|
getFgColor(): number;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export class AttributeData implements IAttributeData {
|
|||||||
public isBgPalette(): boolean { return (this.bg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.bg & Attributes.CM_MASK) === Attributes.CM_P256; }
|
public isBgPalette(): boolean { return (this.bg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.bg & Attributes.CM_MASK) === Attributes.CM_P256; }
|
||||||
public isFgDefault(): boolean { return (this.fg & Attributes.CM_MASK) === 0; }
|
public isFgDefault(): boolean { return (this.fg & Attributes.CM_MASK) === 0; }
|
||||||
public isBgDefault(): boolean { return (this.bg & Attributes.CM_MASK) === 0; }
|
public isBgDefault(): boolean { return (this.bg & Attributes.CM_MASK) === 0; }
|
||||||
|
public isAttributeDefault(): boolean { return this.fg === 0 && this.bg === 0; }
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
public getFgColor(): number {
|
public getFgColor(): number {
|
||||||
|
|||||||
@@ -116,12 +116,7 @@ export const enum FgFlags {
|
|||||||
BOLD = 0x8000000,
|
BOLD = 0x8000000,
|
||||||
UNDERLINE = 0x10000000,
|
UNDERLINE = 0x10000000,
|
||||||
BLINK = 0x20000000,
|
BLINK = 0x20000000,
|
||||||
INVISIBLE = 0x40000000,
|
INVISIBLE = 0x40000000
|
||||||
|
|
||||||
/**
|
|
||||||
* bit 27..31 (32th bit unused)
|
|
||||||
*/
|
|
||||||
FM_MASK = 0x7C000000
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum BgFlags {
|
export const enum BgFlags {
|
||||||
@@ -129,10 +124,5 @@ export const enum BgFlags {
|
|||||||
* bit 27..32 (upper 4 unused)
|
* bit 27..32 (upper 4 unused)
|
||||||
*/
|
*/
|
||||||
ITALIC = 0x4000000,
|
ITALIC = 0x4000000,
|
||||||
DIM = 0x8000000,
|
DIM = 0x8000000
|
||||||
|
|
||||||
/**
|
|
||||||
* bit 27..32 (upper 4 unused)
|
|
||||||
*/
|
|
||||||
FM_MASK = 0xFC000000
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-43
@@ -5,9 +5,8 @@
|
|||||||
|
|
||||||
import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier } from 'xterm';
|
import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier } from 'xterm';
|
||||||
import { ITerminal } from '../Types';
|
import { ITerminal } from '../Types';
|
||||||
import { IBufferLine } from 'common/Types';
|
import { IBufferLine, ICellData } from 'common/Types';
|
||||||
import { IBuffer } from 'common/buffer/Types';
|
import { IBuffer } from 'common/buffer/Types';
|
||||||
import { Attributes } from 'common/buffer/Constants';
|
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { Terminal as TerminalCore } from '../Terminal';
|
import { Terminal as TerminalCore } from '../Terminal';
|
||||||
import * as Strings from '../browser/LocalizableStrings';
|
import * as Strings from '../browser/LocalizableStrings';
|
||||||
@@ -203,7 +202,7 @@ class BufferApiView implements IBufferApi {
|
|||||||
}
|
}
|
||||||
return new BufferLineApiView(line);
|
return new BufferLineApiView(line);
|
||||||
}
|
}
|
||||||
public getNullCell(): IBufferCellApi { return new BufferCellApiView(new CellData()); }
|
public getNullCell(): IBufferCellApi { return new CellData(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class BufferLineApiView implements IBufferLineApi {
|
class BufferLineApiView implements IBufferLineApi {
|
||||||
@@ -211,59 +210,22 @@ class BufferLineApiView implements IBufferLineApi {
|
|||||||
|
|
||||||
public get isWrapped(): boolean { return this._line.isWrapped; }
|
public get isWrapped(): boolean { return this._line.isWrapped; }
|
||||||
public get length(): number { return this._line.length; }
|
public get length(): number { return this._line.length; }
|
||||||
public getCell(x: number, cell?: BufferCellApiView): IBufferCellApi | undefined {
|
public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined {
|
||||||
if (x < 0 || x >= this._line.length) {
|
if (x < 0 || x >= this._line.length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell) {
|
if (cell) {
|
||||||
this._line.loadCell(x, cell.cell);
|
this._line.loadCell(x, <ICellData>cell);
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
return new BufferCellApiView(this._line.loadCell(x, new CellData()));
|
return this._line.loadCell(x, new CellData());
|
||||||
}
|
}
|
||||||
public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string {
|
public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string {
|
||||||
return this._line.translateToString(trimRight, startColumn, endColumn);
|
return this._line.translateToString(trimRight, startColumn, endColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BufferCellApiView implements IBufferCellApi {
|
|
||||||
constructor(public cell: CellData) {}
|
|
||||||
|
|
||||||
public get char(): string { return this.cell.getChars(); }
|
|
||||||
public get width(): number { return this.cell.getWidth(); }
|
|
||||||
|
|
||||||
public getWidth(): number { return this.cell.getWidth(); }
|
|
||||||
public getChars(): string { return this.cell.getChars(); }
|
|
||||||
public getCode(): number { return this.cell.getCode(); }
|
|
||||||
|
|
||||||
public isInverse(): number { return this.cell.isInverse(); }
|
|
||||||
public isBold(): number { return this.cell.isBold(); }
|
|
||||||
public isUnderline(): number { return this.cell.isUnderline(); }
|
|
||||||
public isBlink(): number { return this.cell.isBlink(); }
|
|
||||||
public isInvisible(): number { return this.cell.isInvisible(); }
|
|
||||||
public isItalic(): number { return this.cell.isItalic(); }
|
|
||||||
public isDim(): number { return this.cell.isDim(); }
|
|
||||||
|
|
||||||
public getFgColorMode(): number { return this.cell.getFgColorMode(); }
|
|
||||||
public getBgColorMode(): number { return this.cell.getBgColorMode(); }
|
|
||||||
public isFgRGB(): boolean { return this.cell.isFgRGB(); }
|
|
||||||
public isBgRGB(): boolean { return this.cell.isBgRGB(); }
|
|
||||||
public isFgPalette(): boolean { return this.cell.isFgPalette(); }
|
|
||||||
public isBgPalette(): boolean { return this.cell.isBgPalette(); }
|
|
||||||
public isFgPalette16(): boolean { return this.cell.getFgColorMode() === Attributes.CM_P16; }
|
|
||||||
public isBgPalette16(): boolean { return this.cell.getBgColorMode() === Attributes.CM_P16; }
|
|
||||||
public isFgPalette256(): boolean { return this.cell.getFgColorMode() === Attributes.CM_P256; }
|
|
||||||
public isBgPalette256(): boolean { return this.cell.getBgColorMode() === Attributes.CM_P256; }
|
|
||||||
|
|
||||||
public isAttributeDefault(): boolean { return this.cell.fg === 0 && this.cell.bg === 0; }
|
|
||||||
public isFgDefault(): boolean { return this.cell.isFgDefault(); }
|
|
||||||
public isBgDefault(): boolean { return this.cell.isBgDefault(); }
|
|
||||||
|
|
||||||
public getFgColor(): number { return this.cell.getFgColor(); }
|
|
||||||
public getBgColor(): number { return this.cell.getBgColor(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class ParserApi implements IParser {
|
class ParserApi implements IParser {
|
||||||
constructor(private _core: ITerminal) {}
|
constructor(private _core: ITerminal) {}
|
||||||
|
|
||||||
|
|||||||
Vendored
-18
@@ -1007,20 +1007,6 @@ declare module 'xterm' {
|
|||||||
* Represents a single cell in the terminal's buffer.
|
* Represents a single cell in the terminal's buffer.
|
||||||
*/
|
*/
|
||||||
interface IBufferCell {
|
interface IBufferCell {
|
||||||
/**
|
|
||||||
* The character within the cell.
|
|
||||||
*/
|
|
||||||
readonly char: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The width of the character. Some examples:
|
|
||||||
*
|
|
||||||
* - This is `1` for most cells.
|
|
||||||
* - This is `2` for wide character like CJK glyphs.
|
|
||||||
* - This is `0` for cells immediately following cells with a width of `2`.
|
|
||||||
*/
|
|
||||||
readonly width: number;
|
|
||||||
|
|
||||||
getWidth(): number;
|
getWidth(): number;
|
||||||
getChars(): string;
|
getChars(): string;
|
||||||
getCode(): number;
|
getCode(): number;
|
||||||
@@ -1042,10 +1028,6 @@ declare module 'xterm' {
|
|||||||
isBgRGB(): boolean;
|
isBgRGB(): boolean;
|
||||||
isFgPalette(): boolean;
|
isFgPalette(): boolean;
|
||||||
isBgPalette(): boolean;
|
isBgPalette(): boolean;
|
||||||
isFgPalette16(): boolean;
|
|
||||||
isBgPalette16(): boolean;
|
|
||||||
isFgPalette256(): boolean;
|
|
||||||
isBgPalette256(): boolean;
|
|
||||||
isAttributeDefault(): boolean;
|
isAttributeDefault(): boolean;
|
||||||
isFgDefault(): boolean;
|
isFgDefault(): boolean;
|
||||||
isBgDefault(): boolean;
|
isBgDefault(): boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user