Colocate buffer types in buffer/Types.ts
The import/no-cycle refactor had moved IBuffer, IBufferSet, and related cell/line types into src/common/Types.ts, with buffer/Types.ts only re-exporting them. That inverted the natural module boundary and made buffer code depend on the top-level types hub. Define buffer-owned types in buffer/Types.ts instead: - CharData, IExtendedAttrs, IAttributeData, ICellData, IBufferLine - IMarker, IBuffer, IBufferSet, BufferIndex Restore UnderlineStyle to buffer/Constants.ts (used by IExtendedAttrs) and remove those definitions from Types.ts. buffer/Types.ts imports only what it needs from outside the buffer layer: ICircularList and ICharset from Types, IDisposable from Lifecycle, IEvent from Event, and UnderlineStyle from Constants. Types.ts does not import buffer/Types.ts, so the previous Types <-> buffer cycle stays broken. Update imports across common, browser, headless, addons, and tests to use common/buffer/Types for buffer types rather than common/Types. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IAttributeData, IColorRGB, IExtendedAttrs } from '../Types';
|
||||
import { IColorRGB } from '../Types';
|
||||
import { IAttributeData, IExtendedAttrs } from './Types';
|
||||
import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from './Constants';
|
||||
|
||||
export class AttributeData implements IAttributeData {
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import { CircularList, IInsertEvent } from '../CircularList';
|
||||
import { Disposable, toDisposable } from '../Lifecycle';
|
||||
import { IdleTaskQueue } from '../TaskQueue';
|
||||
import { IAttributeData, IBufferLine, ICellData, ICharset } from '../Types';
|
||||
import { ICharset } from '../Types';
|
||||
import { IAttributeData, IBuffer, IBufferLine, ICellData } from './Types';
|
||||
import { ExtendedAttrs } from './AttributeData';
|
||||
import { BufferLine, DEFAULT_ATTR_DATA } from './BufferLine';
|
||||
import { BufferLineStringCache } from './BufferLineStringCache';
|
||||
@@ -14,7 +15,6 @@ import { getWrappedLineTrimmedLength, reflowLargerApplyNewLayout, reflowLargerCr
|
||||
import { CellData } from './CellData';
|
||||
import { NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE, WHITESPACE_CELL_WIDTH } from './Constants';
|
||||
import { Marker } from './Marker';
|
||||
import { IBuffer } from './Types';
|
||||
import { DEFAULT_CHARSET } from '../data/Charsets';
|
||||
import { IBufferService, ILogService, IOptionsService } from '../services/Services';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR, Content,
|
||||
import { BufferLine } from './BufferLine';
|
||||
import { BufferLineStringCache } from './BufferLineStringCache';
|
||||
import { CellData } from './CellData';
|
||||
import { CharData, IBufferLine, ICellData } from '../Types';
|
||||
import { CharData, IBufferLine, ICellData } from './Types';
|
||||
import { assert } from 'chai';
|
||||
import { AttributeData } from './AttributeData';
|
||||
import { createCellData, NULL_CELL_DATA, extendedAttributes } from '../TestUtils.test';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { CharData, IAttributeData, IBufferLine, ICellData, IExtendedAttrs } from '../Types';
|
||||
import { CharData, IAttributeData, IBufferLine, ICellData, IExtendedAttrs } from './Types';
|
||||
import { AttributeData } from './AttributeData';
|
||||
import { CellData } from './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 './Constants';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { BufferLine } from './BufferLine';
|
||||
import { CircularList } from '../CircularList';
|
||||
import { IBufferLine, ICellData } from '../Types';
|
||||
import { IBufferLine, ICellData } from './Types';
|
||||
|
||||
export interface INewLayoutResult {
|
||||
layout: number[];
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
*/
|
||||
|
||||
import { Disposable, MutableDisposable } from '../Lifecycle';
|
||||
import { IAttributeData } from '../Types';
|
||||
import { Buffer } from './Buffer';
|
||||
import { IBuffer, IBufferSet } from './Types';
|
||||
import { IAttributeData, IBuffer, IBufferSet } from './Types';
|
||||
import { IBufferService, ILogService, IOptionsService } from '../services/Services';
|
||||
import { Emitter } from '../Event';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { CharData, ICellData, IExtendedAttrs } from '../Types';
|
||||
import { CharData, ICellData, IExtendedAttrs } from './Types';
|
||||
import { stringFromCodePoint } from '../input/TextDecoder';
|
||||
import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, Content } from './Constants';
|
||||
import { AttributeData, ExtendedAttrs } from './AttributeData';
|
||||
|
||||
@@ -147,4 +147,11 @@ export const enum ExtFlags {
|
||||
VARIANT_OFFSET = 0xE0000000
|
||||
}
|
||||
|
||||
export { UnderlineStyle } from '../Types';
|
||||
export const enum UnderlineStyle {
|
||||
NONE = 0,
|
||||
SINGLE = 1,
|
||||
DOUBLE = 2,
|
||||
CURLY = 3,
|
||||
DOTTED = 4,
|
||||
DASHED = 5
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IDisposable, IMarker } from '../Types';
|
||||
import { dispose, IDisposable } from '../Lifecycle';
|
||||
import { IMarker } from './Types';
|
||||
import { Emitter } from '../Event';
|
||||
import { dispose } from '../Lifecycle';
|
||||
|
||||
export class Marker implements IMarker {
|
||||
private static _nextId = 1;
|
||||
|
||||
+193
-1
@@ -3,7 +3,199 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
export type { IBuffer, IBufferSet } from '../Types';
|
||||
import type { IEvent } from '../Event';
|
||||
import type { ICircularList, ICharset } from '../Types';
|
||||
import type { IDisposable } from '../Lifecycle';
|
||||
import type { UnderlineStyle } from './Constants';
|
||||
|
||||
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
|
||||
export type BufferIndex = [number, number];
|
||||
|
||||
export type CharData = [attr: number, char: string, width: number, code: number];
|
||||
|
||||
export interface IExtendedAttrs {
|
||||
ext: number;
|
||||
underlineStyle: UnderlineStyle;
|
||||
underlineColor: number;
|
||||
underlineVariantOffset: number;
|
||||
urlId: number;
|
||||
clone(): IExtendedAttrs;
|
||||
isEmpty(): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that represents all attributes of a cell.
|
||||
*/
|
||||
export interface IAttributeData {
|
||||
/**
|
||||
* "fg" is a 32-bit unsigned integer that stores the foreground color of the cell in the 24 least
|
||||
* significant bits and additional flags in the remaining 8 bits.
|
||||
*/
|
||||
fg: number;
|
||||
/**
|
||||
* "bg" is a 32-bit unsigned integer that stores the background color of the cell in the 24 least
|
||||
* significant bits and additional flags in the remaining 8 bits.
|
||||
*/
|
||||
bg: number;
|
||||
/**
|
||||
* "extended", aka "ext", stores extended attributes beyond those available in fg and bg. This
|
||||
* data is optional on a cell and encodes less common data.
|
||||
*/
|
||||
extended: IExtendedAttrs;
|
||||
|
||||
clone(): IAttributeData;
|
||||
|
||||
// flags
|
||||
isInverse(): number;
|
||||
isBold(): number;
|
||||
isUnderline(): number;
|
||||
isBlink(): number;
|
||||
isInvisible(): number;
|
||||
isItalic(): number;
|
||||
isDim(): number;
|
||||
isStrikethrough(): number;
|
||||
isProtected(): number;
|
||||
isOverline(): number;
|
||||
|
||||
/**
|
||||
* The color mode of the foreground color which determines how to decode {@link getFgColor},
|
||||
* possible values include {@link Attributes.CM_DEFAULT}, {@link Attributes.CM_P16},
|
||||
* {@link Attributes.CM_P256} and {@link Attributes.CM_RGB}.
|
||||
*/
|
||||
getFgColorMode(): number;
|
||||
/**
|
||||
* The color mode of the background color which determines how to decode {@link getBgColor},
|
||||
* possible values include {@link Attributes.CM_DEFAULT}, {@link Attributes.CM_P16},
|
||||
* {@link Attributes.CM_P256} and {@link Attributes.CM_RGB}.
|
||||
*/
|
||||
getBgColorMode(): number;
|
||||
isFgRGB(): boolean;
|
||||
isBgRGB(): boolean;
|
||||
isFgPalette(): boolean;
|
||||
isBgPalette(): boolean;
|
||||
isFgDefault(): boolean;
|
||||
isBgDefault(): boolean;
|
||||
isAttributeDefault(): boolean;
|
||||
|
||||
/**
|
||||
* Gets an integer representation of the foreground color, how to decode the color depends on the
|
||||
* color mode {@link getFgColorMode}.
|
||||
*/
|
||||
getFgColor(): number;
|
||||
/**
|
||||
* Gets an integer representation of the background color, how to decode the color depends on the
|
||||
* color mode {@link getBgColorMode}.
|
||||
*/
|
||||
getBgColor(): number;
|
||||
|
||||
// extended attrs
|
||||
hasExtendedAttrs(): number;
|
||||
updateExtended(): void;
|
||||
getUnderlineColor(): number;
|
||||
getUnderlineColorMode(): number;
|
||||
isUnderlineColorRGB(): boolean;
|
||||
isUnderlineColorPalette(): boolean;
|
||||
isUnderlineColorDefault(): boolean;
|
||||
getUnderlineStyle(): number;
|
||||
getUnderlineVariantOffset(): number;
|
||||
}
|
||||
|
||||
/** Cell data */
|
||||
export interface ICellData extends IAttributeData {
|
||||
content: number;
|
||||
combinedData: string;
|
||||
isCombined(): number;
|
||||
getWidth(): number;
|
||||
getChars(): string;
|
||||
getCode(): number;
|
||||
setFromCharData(value: CharData): void;
|
||||
getAsCharData(): CharData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for a line in the terminal buffer.
|
||||
*/
|
||||
export interface IBufferLine {
|
||||
length: number;
|
||||
isWrapped: boolean;
|
||||
get(index: number): CharData;
|
||||
set(index: number, value: CharData): void;
|
||||
loadCell(index: number, cell: ICellData): ICellData;
|
||||
setCell(index: number, cell: ICellData): void;
|
||||
setCellFromCodepoint(index: number, codePoint: number, width: number, attrs: IAttributeData): void;
|
||||
addCodepointToCell(index: number, codePoint: number, width: number): void;
|
||||
insertCells(pos: number, n: number, ch: ICellData): void;
|
||||
deleteCells(pos: number, n: number, fill: ICellData): void;
|
||||
replaceCells(start: number, end: number, fill: ICellData, respectProtect?: boolean): void;
|
||||
resize(cols: number, fill: ICellData): boolean;
|
||||
cleanupMemory(): number;
|
||||
fill(fillCellData: ICellData, respectProtect?: boolean): void;
|
||||
copyFrom(line: IBufferLine): void;
|
||||
clone(): IBufferLine;
|
||||
getTrimmedLength(): number;
|
||||
getNoBgTrimmedLength(): number;
|
||||
translateToString(trimRight?: boolean, startCol?: number, endCol?: number, outColumns?: number[]): string;
|
||||
|
||||
/* direct access to cell attrs */
|
||||
getWidth(index: number): number;
|
||||
hasWidth(index: number): number;
|
||||
getFg(index: number): number;
|
||||
getBg(index: number): number;
|
||||
hasContent(index: number): number;
|
||||
getCodePoint(index: number): number;
|
||||
isCombined(index: number): number;
|
||||
getString(index: number): string;
|
||||
}
|
||||
|
||||
export interface IMarker extends IDisposable {
|
||||
readonly id: number;
|
||||
readonly isDisposed: boolean;
|
||||
readonly line: number;
|
||||
onDispose: IEvent<void>;
|
||||
}
|
||||
|
||||
export interface IBuffer {
|
||||
readonly lines: ICircularList<IBufferLine>;
|
||||
ydisp: number;
|
||||
ybase: number;
|
||||
y: number;
|
||||
x: number;
|
||||
tabs: any;
|
||||
scrollBottom: number;
|
||||
scrollTop: number;
|
||||
hasScrollback: boolean;
|
||||
savedY: number;
|
||||
savedX: number;
|
||||
savedCharset: ICharset | undefined;
|
||||
savedCharsets: (ICharset | undefined)[];
|
||||
savedGlevel: number;
|
||||
savedOriginMode: boolean;
|
||||
savedWraparoundMode: boolean;
|
||||
savedCurAttrData: IAttributeData;
|
||||
isCursorInViewport: boolean;
|
||||
markers: IMarker[];
|
||||
translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string;
|
||||
getWrappedRangeForLine(y: number): { first: number, last: number };
|
||||
nextStop(x?: number): number;
|
||||
prevStop(x?: number): number;
|
||||
getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine;
|
||||
getNullCell(attr?: IAttributeData): ICellData;
|
||||
getWhitespaceCell(attr?: IAttributeData): ICellData;
|
||||
addMarker(y: number): IMarker;
|
||||
clearMarkers(y: number): void;
|
||||
clearAllMarkers(): void;
|
||||
}
|
||||
|
||||
export interface IBufferSet extends IDisposable {
|
||||
alt: IBuffer;
|
||||
normal: IBuffer;
|
||||
active: IBuffer;
|
||||
|
||||
onBufferActivate: IEvent<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
|
||||
|
||||
activateNormalBuffer(): void;
|
||||
activateAltBuffer(fillAttr?: IAttributeData): void;
|
||||
reset(): void;
|
||||
resize(newCols: number, newRows: number): void;
|
||||
setupTabStops(i?: number): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user