Move primitive types from common/Types.ts to common/primitives/Types.ts

Extract low-level types (IParams, ParamsArray, IDisposable, color,
keyboard, mouse, charset, etc.) into primitives/Types.ts. Keep
runtime/integration types (ITerminalOptions, IInputHandler, terminal
modes) in common/Types.ts. Lifecycle re-exports IDisposable from
primitives/Types.ts.

Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-06-06 18:32:48 +00:00
co-authored by Daniel Imms
parent f6c1b21258
commit bd8510e3ab
55 changed files with 291 additions and 280 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
import type { IBuffer, IBufferCell, IBufferRange, ITerminalAddon, Terminal } from '@xterm/xterm';
import type { IHTMLSerializeOptions, SerializeAddon as ISerializeApi, ISerializeOptions, ISerializeRange } from '@xterm/addon-serialize';
import { IColor } from 'common/Types';
import { IColor } from 'common/primitives/Types';
import { IAttributeData } from 'common/primitives/buffer/Types';
import { DEFAULT_ANSI_COLORS } from 'browser/Types';
import { UnderlineStyle } from 'common/primitives/buffer/Constants';
@@ -7,7 +7,7 @@ import { assert } from 'chai';
import { configEquals } from './CharAtlasUtils';
import { ICharAtlasConfig } from './Types';
import { NULL_COLOR } from 'common/primitives/Color';
import { IColor } from 'common/Types';
import { IColor } from 'common/primitives/Types';
function createTestConfig(overrides: Partial<ICharAtlasConfig> = {}): ICharAtlasConfig {
const color: IColor = { css: '#ffffff', rgba: 0xffffffff };
+1 -1
View File
@@ -8,7 +8,7 @@ import { IThemeService } from 'browser/services/Services';
import { ReadonlyColorSet } from 'browser/Types';
import { Attributes, FgFlags } from 'common/primitives/buffer/Constants';
import { Disposable, toDisposable } from 'common/primitives/Lifecycle';
import { IColor } from 'common/Types';
import { IColor } from 'common/primitives/Types';
import { Terminal } from '@xterm/xterm';
import { RenderModelConstants } from './RenderModel';
import { IRenderModel, IWebGL2RenderingContext, IWebGLVertexArrayObject } from './Types';
+1 -1
View File
@@ -11,7 +11,7 @@ import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from
import { NULL_COLOR, channels, color, rgba } from 'common/primitives/Color';
import { FourKeyMap } from 'common/primitives/MultiKeyMap';
import { IdleTaskQueue } from 'common/primitives/TaskQueue';
import { IColor } from 'common/Types';
import { IColor } from 'common/primitives/Types';
import { AttributeData } from 'common/primitives/buffer/AttributeData';
import { Attributes, DEFAULT_COLOR, DEFAULT_EXT, UnderlineStyle } from 'common/primitives/buffer/Constants';
import { ILogService, IUnicodeService } from 'common/services/Services';
+1 -1
View File
@@ -6,7 +6,7 @@
import { FontWeight } from '@xterm/xterm';
import { IColorSet } from 'browser/Types';
import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/Types';
import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/primitives/Types';
import type { IEvent } from 'common/primitives/Event';
export interface IRenderModel {
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { IColorContrastCache } from './Types';
import { IColor } from '../common/Types';
import { IColor } from '../common/primitives/Types';
import { TwoKeyMap } from '../common/primitives/MultiKeyMap';
export class ColorContrastCache implements IColorContrastCache {
+2 -1
View File
@@ -46,7 +46,8 @@ import { KeyboardService } from './services/KeyboardService';
import { channels, color, rgb } from '../common/primitives/Color';
import { CoreTerminal } from '../common/CoreTerminal';
import * as Browser from '../common/primitives/Platform';
import { ColorRequestType, IColorEvent, ITerminalOptions, KeyboardResultType, SpecialColorIndex } from '../common/Types';
import { ColorRequestType, IColorEvent, KeyboardResultType, SpecialColorIndex } from '../common/primitives/Types';
import { ITerminalOptions } from '../common/Types';
import { DEFAULT_ATTR_DATA } from '../common/primitives/buffer/BufferLine';
import { IBuffer } from '../common/primitives/buffer/Types';
import { C0, C1ESCAPED } from '../common/primitives/data/EscapeSequences';
+1 -1
View File
@@ -5,7 +5,7 @@
import { IBufferCellPosition, ILink, ILinkDecorations, ILinkWithState, ILinkifier2, ILinkifierEvent } from './Types';
import { Disposable, dispose, toDisposable } from '../common/primitives/Lifecycle';
import { IDisposable } from '../common/Types';
import { IDisposable } from '../common/primitives/Types';
import { IBufferService } from '../common/services/Services';
import { ILinkProviderService, IMouseCoordsService, IRenderService } from './services/Services';
import { Emitter } from '../common/primitives/Event';
+1 -1
View File
@@ -8,7 +8,7 @@ import { OscLinkProvider } from './OscLinkProvider';
import { ILink } from './Types';
import { createCellData, MockBufferService, MockOptionsService } from '../common/TestUtils.test';
import { IBufferService, IOscLinkService } from '../common/services/Services';
import { IOscLinkData } from '../common/Types';
import { IOscLinkData } from '../common/primitives/Types';
import { IBufferLine } from '../common/primitives/buffer/Types';
class TestOscLinkService implements IOscLinkService {
+2 -1
View File
@@ -9,7 +9,8 @@ import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from './renderer/sh
import { IColorSet, ITerminal, ILinkifier2, IBrowser, IViewport, ICompositionHelper, CharacterJoinerHandler, IBufferRange, ReadonlyColorSet, IBufferElementProvider } from './Types';
import { IAttributeData, IBuffer, IBufferLine, IBufferSet, ICellData } from '../common/primitives/buffer/Types';
import { ICircularList } from '../common/primitives/CircularList';
import { XtermListener, ICharset, ITerminalOptions, ColorIndex } from '../common/Types';
import { XtermListener, ICharset, ColorIndex } from '../common/primitives/Types';
import { ITerminalOptions } from '../common/Types';
import { Buffer } from '../common/primitives/buffer/Buffer';
import * as Browser from '../common/primitives/Platform';
import { CoreBrowserTerminal } from './CoreBrowserTerminal';
+2 -1
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { IColor, ITerminalOptions } from '../common/Types';
import { IColor } from '../common/primitives/Types';
import { ITerminalOptions } from '../common/Types';
import { CharData, IBuffer } from '../common/primitives/buffer/Types';
import { ICoreTerminal } from '../common/CoreTerminal';
import { IDisposable, IRenderDimensions as IRenderDimensionsApi, Terminal as ITerminalApi } from '@xterm/xterm';
+1 -1
View File
@@ -7,7 +7,7 @@ import { ICoreBrowserService, IRenderService, IThemeService } from './services/S
import { ViewportConstants } from './shared/Constants';
import { Disposable, toDisposable } from '../common/primitives/Lifecycle';
import { IBufferService, ICoreService, IMouseStateService, IOptionsService } from '../common/services/Services';
import { CoreMouseEventType } from '../common/Types';
import { CoreMouseEventType } from '../common/primitives/Types';
import { scheduleAtNextAnimationFrame } from './Dom';
import { SmoothScrollableElement } from './scrollable/scrollableElement';
import type { IScrollableElementChangeOptions } from './scrollable/scrollableElementOptions';
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IColor } from '../../../common/Types';
import { IColor } from '../../../common/primitives/Types';
import { IBufferLine, ICellData } from '../../../common/primitives/buffer/Types';
import { INVERTED_DEFAULT_COLOR } from '../shared/Constants';
import { WHITESPACE_CELL_CHAR, Attributes } from '../../../common/primitives/buffer/Constants';
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { throwIfFalsy } from '../shared/RendererUtils';
import { IDisposable } from '../../../common/Types';
import { IDisposable } from '../../../common/primitives/Types';
import { FontWeight } from '../../../common/services/Services';
+1 -1
View File
@@ -5,7 +5,7 @@
import { Terminal } from '@xterm/xterm';
import { ITerminal } from '../../Types';
import { IDisposable } from '../../../common/Types';
import { IDisposable } from '../../../common/primitives/Types';
import type { IEvent } from '../../../common/primitives/Event';
export interface IDimensions {
+1 -1
View File
@@ -9,7 +9,7 @@ import { KittyKeyboard, KittyKeyboardEventType, KittyKeyboardFlags } from '../..
import { Win32InputMode } from '../../common/primitives/input/Win32InputMode';
import { isMac } from '../../common/primitives/Platform';
import { ICoreService, IOptionsService } from '../../common/services/Services';
import { IKeyboardResult } from '../../common/Types';
import { IKeyboardResult } from '../../common/primitives/Types';
export class KeyboardService implements IKeyboardService {
public serviceBrand: undefined;
+1 -1
View File
@@ -1,6 +1,6 @@
import { ILinkProvider, ILinkProviderService } from './Services';
import { Disposable, toDisposable } from '../../common/primitives/Lifecycle';
import { IDisposable } from '../../common/Types';
import { IDisposable } from '../../common/primitives/Types';
export class LinkProviderService extends Disposable implements ILinkProviderService {
declare public serviceBrand: undefined;
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { AltMouseCursorController, MouseEventCssClasses, MouseService } from './MouseService';
import { MouseStateService } from '../../common/services/MouseStateService';
import { CoreMouseAction, CoreMouseButton } from '../../common/Types';
import { CoreMouseAction, CoreMouseButton } from '../../common/primitives/Types';
import { IBufferService, ICoreService, ILogService, IOptionsService } from '../../common/services/Services';
import { OptionsService } from '../../common/services/OptionsService';
import { MockCoreBrowserService, MockRenderService, MockSelectionService } from '../TestUtils.test';
+1 -1
View File
@@ -5,7 +5,7 @@
import { addDisposableListener } from '../Dom';
import { IBufferService, IMouseStateService, ICoreService, ILogService, IOptionsService } from '../../common/services/Services';
import { CoreMouseAction, CoreMouseButton, CoreMouseEventType, ICoreMouseEvent, IDisposable } from '../../common/Types';
import { CoreMouseAction, CoreMouseButton, CoreMouseEventType, ICoreMouseEvent, IDisposable } from '../../common/primitives/Types';
import { C0 } from '../../common/primitives/data/EscapeSequences';
import { DisposableStore, MutableDisposable, toDisposable } from '../../common/primitives/Lifecycle';
import { ICoreBrowserService, IMouseCoordsService, IMouseService, IMouseServiceTarget, IRenderService, ISelectionService } from './Services';
+1 -1
View File
@@ -11,7 +11,7 @@ import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from
import { ICoreBrowserService, IMouseCoordsService, IRenderService, ISelectionService } from './Services';
import { Disposable, MutableDisposable, toDisposable } from '../../common/primitives/Lifecycle';
import * as Browser from '../../common/primitives/Platform';
import { IDisposable } from '../../common/Types';
import { IDisposable } from '../../common/primitives/Types';
import { IBuffer, IBufferLine, ICellData } from '../../common/primitives/buffer/Types';
import { getRangeLength } from '../../common/primitives/buffer/BufferRange';
import { CellData } from '../../common/primitives/buffer/CellData';
+1 -1
View File
@@ -7,7 +7,7 @@ import { IRenderDimensions, IRenderer } from '../renderer/shared/Types';
import { IColorSet, ILink, ReadonlyColorSet } from '../Types';
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from '../selection/Types';
import { createDecorator } from '../../common/services/ServiceRegistry';
import { AllColorIndex, IDisposable, IKeyboardResult } from '../../common/Types';
import { AllColorIndex, IDisposable, IKeyboardResult } from '../../common/primitives/Types';
import type { IEvent } from '../../common/primitives/Event';
export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService');
+1 -1
View File
@@ -9,7 +9,7 @@ import { DEFAULT_ANSI_COLORS, IColorContrastCache, IColorSet, ReadonlyColorSet }
import { color, css, NULL_COLOR } from '../../common/primitives/Color';
import { Disposable } from '../../common/primitives/Lifecycle';
import { IOptionsService, ITheme } from '../../common/services/Services';
import { AllColorIndex, IColor, SpecialColorIndex } from '../../common/Types';
import { AllColorIndex, IColor, SpecialColorIndex } from '../../common/primitives/Types';
import { Emitter } from '../../common/primitives/Event';
interface IRestoreColorSet {
+2 -1
View File
@@ -26,7 +26,8 @@ import { InstantiationService } from './services/InstantiationService';
import { LogService } from './services/LogService';
import { BufferService, BufferServiceConstants } from './services/BufferService';
import { OptionsService } from './services/OptionsService';
import { IDisposable, IScrollEvent, ITerminalOptions, IParams } from './Types';
import { IDisposable, IParams } from './primitives/Types';
import { IScrollEvent, ITerminalOptions } from './Types';
import { IAttributeData, IBufferSet } from './primitives/buffer/Types';
import { CoreService } from './services/CoreService';
import { MouseStateService } from './services/MouseStateService';
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { InputHandler } from './InputHandler';
import { IColorEvent, ColorRequestType, SpecialColorIndex } from './Types';
import { IColorEvent, ColorRequestType, SpecialColorIndex } from './primitives/Types';
import { IAttributeData, IBufferLine } from './primitives/buffer/Types';
import { DEFAULT_ATTR_DATA } from './primitives/buffer/BufferLine';
import { CellData } from './primitives/buffer/CellData';
+2 -1
View File
@@ -4,7 +4,8 @@
* @license MIT
*/
import { IInputHandler, IDisposable, IWindowOptions, IColorEvent, IParseStack, ColorIndex, ColorRequestType, SpecialColorIndex } from './Types';
import { IDisposable, IColorEvent, ColorIndex, ColorRequestType, SpecialColorIndex } from './primitives/Types';
import { IInputHandler, IWindowOptions, IParseStack } from './Types';
import { IAttributeData, IBuffer } from './primitives/buffer/Types';
import { C0, C1 } from './primitives/data/EscapeSequences';
import { CHARSETS, DEFAULT_CHARSET } from './primitives/data/Charsets';
+2 -1
View File
@@ -8,7 +8,8 @@ import { UnicodeService } from './services/UnicodeService';
import { DEFAULT_OPTIONS } from './services/OptionsService';
import { IAttributeData, IBuffer, IBufferLine, IBufferSet, IExtendedAttrs } from './primitives/buffer/Types';
import { BufferSet } from './primitives/buffer/BufferSet';
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IOscLinkData, IDisposable } from './Types';
import { ICoreMouseEvent, CoreMouseEventType, ICharset, IOscLinkData, IDisposable } from './primitives/Types';
import { IDecPrivateModes, IModes } from './Types';
import { UnicodeV6 } from './primitives/input/UnicodeV6';
import { IDecorationOptions, IDecoration } from '@xterm/xterm';
import { Emitter, type IEvent } from './primitives/Event';
+1 -225
View File
@@ -5,35 +5,7 @@
import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
import type { IEvent } from './primitives/Event';
/** sequence params serialized to js arrays */
export type ParamsArray = (number | number[])[];
/** Interface of Params storage class. */
export interface IParams {
/** from ctor */
maxLength: number;
maxSubParamsLength: number;
/** param values and its length */
params: Int32Array;
length: number;
/** methods */
clone(): IParams;
toArray(): ParamsArray;
reset(): void;
resetZdm(): void;
addParam(value: number): void;
addSubParam(value: number): void;
hasSubParams(idx: number): boolean;
getSubParams(idx: number): Int32Array | null;
getSubParamsAll(): {[idx: number]: Int32Array};
}
export interface IDisposable {
dispose(): void;
}
import type { CursorStyle, IColorEvent, ColorIndex, ColorRequestType, IDisposable, IParams, SpecialColorIndex } from './primitives/Types';
// TODO: The options that are not in the public API should be reviewed
export interface ITerminalOptions extends IPublicTerminalOptions {
@@ -42,66 +14,10 @@ export interface ITerminalOptions extends IPublicTerminalOptions {
termName?: string;
}
export type CursorStyle = 'block' | 'underline' | 'bar';
export type CursorInactiveStyle = 'outline' | 'block' | 'bar' | 'underline' | 'none';
export type XtermListener = (...args: any[]) => void;
/**
* A keyboard event interface which does not depend on the DOM, KeyboardEvent implicitly extends
* this event.
*/
export interface IKeyboardEvent {
altKey: boolean;
ctrlKey: boolean;
shiftKey: boolean;
metaKey: boolean;
/** @deprecated See KeyboardEvent.keyCode */
keyCode: number;
key: string;
type: string;
code: string;
}
export interface IScrollEvent {
position: number;
}
export const enum KeyboardResultType {
SEND_KEY,
SELECT_ALL,
PAGE_UP,
PAGE_DOWN
}
export interface IKeyboardResult {
type: KeyboardResultType;
cancel: boolean;
key: string | undefined;
}
export interface ICharset {
[key: string]: string | undefined;
}
export interface IColor {
readonly css: string;
readonly rgba: number; // 32-bit int with rgba in each byte
}
export type IColorRGB = [red: number, green: number, blue: number];
/**
* Tracks the current hyperlink. Since these are treated as extended attirbutes, these get passed on
* to the linkifier when anything is printed. Doing it this way ensures that even when the cursor
* moves around unexpectedly the link is tracked, as opposed to using a start position and
* finalizing it at the end.
*/
export interface IOscLinkData {
id?: string;
uri: string;
}
export interface IModes {
insertMode: boolean;
}
@@ -138,110 +54,6 @@ export interface IKittyKeyboardState {
altStack: number[];
}
export interface IRowRange {
start: number;
end: number;
}
/**
* Interface for mouse events in the core.
*/
export const enum CoreMouseButton {
LEFT = 0,
MIDDLE = 1,
RIGHT = 2,
NONE = 3,
WHEEL = 4,
// additional buttons 1..8
// untested!
AUX1 = 8,
AUX2 = 9,
AUX3 = 10,
AUX4 = 11,
AUX5 = 12,
AUX6 = 13,
AUX7 = 14,
AUX8 = 15
}
export const enum CoreMouseAction {
UP = 0, // buttons, wheel
DOWN = 1, // buttons, wheel
LEFT = 2, // wheel only
RIGHT = 3, // wheel only
MOVE = 32 // buttons only
}
export interface ICoreMouseEvent {
/** column (zero based). */
col: number;
/** row (zero based). */
row: number;
/** xy pixel positions. */
x: number;
y: number;
/**
* Button the action occurred. Due to restrictions of the tracking protocols
* it is not possible to report multiple buttons at once.
* Wheel is treated as a button.
* There are invalid combinations of buttons and actions possible
* (like move + wheel), those are silently ignored by the MouseStateService.
*/
button: CoreMouseButton;
action: CoreMouseAction;
/**
* Modifier states.
* Protocols will add/ignore those based on specific restrictions.
*/
ctrl?: boolean;
alt?: boolean;
shift?: boolean;
}
/**
* CoreMouseEventType
* To be reported to the browser component which events a mouse
* protocol wants to be catched and forwarded as an ICoreMouseEvent
* to MouseStateService.
*/
export const enum CoreMouseEventType {
NONE = 0,
/** any mousedown event */
DOWN = 1,
/** any mouseup event */
UP = 2,
/** any mousemove event while a button is held */
DRAG = 4,
/** any mousemove event without a button */
MOVE = 8,
/** any wheel event */
WHEEL = 16
}
/**
* Mouse protocol interface.
* A mouse protocol can be registered and activated at the MouseStateService.
* `events` should contain a list of needed events as a hint for the browser component
* to install/remove the appropriate event handlers.
* `restrict` applies further protocol specific restrictions like not allowed
* modifiers or filtering invalid event types.
*/
export interface ICoreMouseProtocol {
events: CoreMouseEventType;
restrict: (e: ICoreMouseEvent) => boolean;
}
/**
* CoreMouseEncoding
* The tracking encoding can be registered and activated at the MouseStateService.
* If a ICoreMouseEvent passes all procotol restrictions it will be encoded
* with the active encoding and sent out.
* Note: Returning an empty string will supress sending a mouse report,
* which can be used to skip creating falsey reports in limited encodings
* (DEFAULT only supports up to 223 1-based as coord value).
*/
export type CoreMouseEncoding = (event: ICoreMouseEvent) => string;
/**
* windowOptions
*/
@@ -270,42 +82,6 @@ export interface IWindowOptions {
setWinLines?: boolean;
}
// color events from common, used for OSC 4/10/11/12 and 104/110/111/112
export const enum ColorRequestType {
REPORT = 0,
SET = 1,
RESTORE = 2
}
// IntRange from https://stackoverflow.com/a/39495173
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc['length']]>;
type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
export type ColorIndex = IntRange<0, 256>; // number from 0 to 255
export type AllColorIndex = ColorIndex | SpecialColorIndex;
export const enum SpecialColorIndex {
FOREGROUND = 256,
BACKGROUND = 257,
CURSOR = 258
}
export interface IColorReportRequest {
type: ColorRequestType.REPORT;
index: AllColorIndex;
}
export interface IColorSetRequest {
type: ColorRequestType.SET;
index: AllColorIndex;
color: IColorRGB;
}
export interface IColorRestoreRequest {
type: ColorRequestType.RESTORE;
index?: AllColorIndex;
}
export type IColorEvent = (IColorReportRequest | IColorSetRequest | IColorRestoreRequest)[];
/**
* Calls the parser and handles actions generated by the parser.
*/
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IColor, IColorRGB } from '../Types';
import { IColor, IColorRGB } from './Types';
let $r = 0;
let $g = 0;
+3 -3
View File
@@ -6,9 +6,9 @@
* Simplified from VS Code's lifecycle.ts - no tracking/leak detection.
*/
export interface IDisposable {
dispose(): void;
}
import type { IDisposable } from './Types';
export type { IDisposable };
export function toDisposable(fn: () => void): IDisposable {
return { dispose: fn };
+228
View File
@@ -0,0 +1,228 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
/** sequence params serialized to js arrays */
export type ParamsArray = (number | number[])[];
/** Interface of Params storage class. */
export interface IParams {
/** from ctor */
maxLength: number;
maxSubParamsLength: number;
/** param values and its length */
params: Int32Array;
length: number;
/** methods */
clone(): IParams;
toArray(): ParamsArray;
reset(): void;
resetZdm(): void;
addParam(value: number): void;
addSubParam(value: number): void;
hasSubParams(idx: number): boolean;
getSubParams(idx: number): Int32Array | null;
getSubParamsAll(): {[idx: number]: Int32Array};
}
export interface IDisposable {
dispose(): void;
}
export type CursorStyle = 'block' | 'underline' | 'bar';
export type CursorInactiveStyle = 'outline' | 'block' | 'bar' | 'underline' | 'none';
export type XtermListener = (...args: any[]) => void;
/**
* A keyboard event interface which does not depend on the DOM, KeyboardEvent implicitly extends
* this event.
*/
export interface IKeyboardEvent {
altKey: boolean;
ctrlKey: boolean;
shiftKey: boolean;
metaKey: boolean;
/** @deprecated See KeyboardEvent.keyCode */
keyCode: number;
key: string;
type: string;
code: string;
}
export const enum KeyboardResultType {
SEND_KEY,
SELECT_ALL,
PAGE_UP,
PAGE_DOWN
}
export interface IKeyboardResult {
type: KeyboardResultType;
cancel: boolean;
key: string | undefined;
}
export interface ICharset {
[key: string]: string | undefined;
}
export interface IColor {
readonly css: string;
readonly rgba: number; // 32-bit int with rgba in each byte
}
export type IColorRGB = [red: number, green: number, blue: number];
/**
* Tracks the current hyperlink. Since these are treated as extended attirbutes, these get passed on
* to the linkifier when anything is printed. Doing it this way ensures that even when the cursor
* moves around unexpectedly the link is tracked, as opposed to using a start position and
* finalizing it at the end.
*/
export interface IOscLinkData {
id?: string;
uri: string;
}
export interface IRowRange {
start: number;
end: number;
}
/**
* Interface for mouse events in the core.
*/
export const enum CoreMouseButton {
LEFT = 0,
MIDDLE = 1,
RIGHT = 2,
NONE = 3,
WHEEL = 4,
// additional buttons 1..8
// untested!
AUX1 = 8,
AUX2 = 9,
AUX3 = 10,
AUX4 = 11,
AUX5 = 12,
AUX6 = 13,
AUX7 = 14,
AUX8 = 15
}
export const enum CoreMouseAction {
UP = 0, // buttons, wheel
DOWN = 1, // buttons, wheel
LEFT = 2, // wheel only
RIGHT = 3, // wheel only
MOVE = 32 // buttons only
}
export interface ICoreMouseEvent {
/** column (zero based). */
col: number;
/** row (zero based). */
row: number;
/** xy pixel positions. */
x: number;
y: number;
/**
* Button the action occurred. Due to restrictions of the tracking protocols
* it is not possible to report multiple buttons at once.
* Wheel is treated as a button.
* There are invalid combinations of buttons and actions possible
* (like move + wheel), those are silently ignored by the MouseStateService.
*/
button: CoreMouseButton;
action: CoreMouseAction;
/**
* Modifier states.
* Protocols will add/ignore those based on specific restrictions.
*/
ctrl?: boolean;
alt?: boolean;
shift?: boolean;
}
/**
* CoreMouseEventType
* To be reported to the browser component which events a mouse
* protocol wants to be catched and forwarded as an ICoreMouseEvent
* to MouseStateService.
*/
export const enum CoreMouseEventType {
NONE = 0,
/** any mousedown event */
DOWN = 1,
/** any mouseup event */
UP = 2,
/** any mousemove event while a button is held */
DRAG = 4,
/** any mousemove event without a button */
MOVE = 8,
/** any wheel event */
WHEEL = 16
}
/**
* Mouse protocol interface.
* A mouse protocol can be registered and activated at the MouseStateService.
* `events` should contain a list of needed events as a hint for the browser component
* to install/remove the appropriate event handlers.
* `restrict` applies further protocol specific restrictions like not allowed
* modifiers or filtering invalid event types.
*/
export interface ICoreMouseProtocol {
events: CoreMouseEventType;
restrict: (e: ICoreMouseEvent) => boolean;
}
/**
* CoreMouseEncoding
* The tracking encoding can be registered and activated at the MouseStateService.
* If a ICoreMouseEvent passes all procotol restrictions it will be encoded
* with the active encoding and sent out.
* Note: Returning an empty string will supress sending a mouse report,
* which can be used to skip creating falsey reports in limited encodings
* (DEFAULT only supports up to 223 1-based as coord value).
*/
export type CoreMouseEncoding = (event: ICoreMouseEvent) => string;
// color events from common, used for OSC 4/10/11/12 and 104/110/111/112
export const enum ColorRequestType {
REPORT = 0,
SET = 1,
RESTORE = 2
}
// IntRange from https://stackoverflow.com/a/39495173
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc['length']]>;
type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
export type ColorIndex = IntRange<0, 256>; // number from 0 to 255
export type AllColorIndex = ColorIndex | SpecialColorIndex;
export const enum SpecialColorIndex {
FOREGROUND = 256,
BACKGROUND = 257,
CURSOR = 258
}
export interface IColorReportRequest {
type: ColorRequestType.REPORT;
index: AllColorIndex;
}
export interface IColorSetRequest {
type: ColorRequestType.SET;
index: AllColorIndex;
color: IColorRGB;
}
export interface IColorRestoreRequest {
type: ColorRequestType.RESTORE;
index?: AllColorIndex;
}
export type IColorEvent = (IColorReportRequest | IColorSetRequest | IColorRestoreRequest)[];
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IColorRGB } from '../../Types';
import { IColorRGB } from '../Types';
import { IAttributeData, IExtendedAttrs } from './Types';
import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from './Constants';
+1 -1
View File
@@ -6,7 +6,7 @@
import { CircularList, IInsertEvent } from '../CircularList';
import { Disposable, toDisposable } from '../Lifecycle';
import { IdleTaskQueue } from '../TaskQueue';
import { 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';
+1 -1
View File
@@ -5,7 +5,7 @@
import type { IEvent } from '../Event';
import type { ICircularList } from '../CircularList';
import type { ICharset } from '../../Types';
import type { ICharset } from '../Types';
import type { IDisposable } from '../Lifecycle';
import type { UnderlineStyle } from './Constants';
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { ICharset } from '../../Types';
import { ICharset } from '../Types';
/**
* The character sets supported by the terminal. These enable several languages
+1 -1
View File
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { evaluateKeyboardEvent } from './Keyboard';
import { IKeyboardResult, IKeyboardEvent } from '../../Types';
import { IKeyboardResult, IKeyboardEvent } from '../Types';
/**
* A helper function for testing which allows passing in a partial event and defaults will be filled
+1 -1
View File
@@ -4,7 +4,7 @@
* @license MIT
*/
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from '../../Types';
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from '../Types';
import { C0 } from '../data/EscapeSequences';
// reg + shift key mappings for digits and special chars
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { KittyKeyboard, KittyKeyboardEventType, KittyKeyboardFlags } from './KittyKeyboard';
import { IKeyboardEvent } from '../../Types';
import { IKeyboardEvent } from '../Types';
function createEvent(partialEvent: Partial<IKeyboardEvent> = {}): IKeyboardEvent {
return {
+1 -1
View File
@@ -6,7 +6,7 @@
* @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
*/
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from '../../Types';
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from '../Types';
import { C0 } from '../data/EscapeSequences';
/**
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { Win32InputMode, Win32ControlKeyState } from './Win32InputMode';
import { IKeyboardEvent, KeyboardResultType } from '../../Types';
import { IKeyboardEvent, KeyboardResultType } from '../Types';
type EventOpts = Partial<IKeyboardEvent>;
const ev = (opts: EventOpts): IKeyboardEvent => ({
@@ -14,7 +14,7 @@
* Rc: Repeat count (usually 1)
*/
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from '../../Types';
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from '../Types';
import { C0 } from '../data/EscapeSequences';
/**
+1 -1
View File
@@ -6,7 +6,7 @@
import { IApcHandler, IHandlerCollection, ApcFallbackHandlerType, IApcParser, ISubParserStackState } from './Types';
import { ParserConstants } from './Constants';
import { utf32ToString } from '../input/TextDecoder';
import { IDisposable } from '../../Types';
import { IDisposable } from '../Types';
import { LimitedStringBuilder } from '../StringBuilder';
const EMPTY_HANDLERS: IApcHandler[] = [];
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IDisposable } from '../../Types';
import { IDisposable } from '../Types';
import { IDcsHandler, IParams, IHandlerCollection, IDcsParser, DcsFallbackHandlerType, ISubParserStackState } from './Types';
import { utf32ToString } from '../input/TextDecoder';
import { Params } from './Params';
@@ -10,7 +10,7 @@ import { StringToUtf32, stringFromCodePoint, utf32ToString } from '../input/Text
import { ParserState } from './Constants';
import { Params } from './Params';
import { OscHandler } from './OscParser';
import { IDisposable } from '../../Types';
import { IDisposable } from '../Types';
import { DcsHandler } from './DcsParser';
import { ApcHandler } from './ApcParser';
@@ -6,7 +6,7 @@
import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType, IParserStackState, ParserStackType, ResumableHandlersType, IApcHandler, IApcParser, ApcFallbackHandlerType } from './Types';
import { ParserState, ParserAction } from './Constants';
import { Disposable, toDisposable } from '../Lifecycle';
import { IDisposable } from '../../Types';
import { IDisposable } from '../Types';
import { Params } from './Params';
import { OscParser } from './OscParser';
import { DcsParser } from './DcsParser';
+1 -1
View File
@@ -6,7 +6,7 @@
import { IOscHandler, IHandlerCollection, OscFallbackHandlerType, IOscParser, ISubParserStackState } from './Types';
import { OscState, ParserConstants } from './Constants';
import { utf32ToString } from '../input/TextDecoder';
import { IDisposable } from '../../Types';
import { IDisposable } from '../Types';
import { LimitedStringBuilder } from '../StringBuilder';
const EMPTY_HANDLERS: IOscHandler[] = [];
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IDisposable, IParams, ParamsArray } from '../../Types';
import { IDisposable, IParams, ParamsArray } from '../Types';
import { ParserState } from './Constants';
export type { IParams, ParamsArray };
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { ICharsetService } from './Services';
import { ICharset } from '../Types';
import { ICharset } from '../primitives/Types';
export class CharsetService implements ICharsetService {
public serviceBrand: any;
+1 -1
View File
@@ -9,7 +9,7 @@ import { css } from '../primitives/Color';
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from '../primitives/Lifecycle';
import { IBufferService, IDecorationService, IInternalDecoration, ILogService } from './Services';
import { SortedList } from '../primitives/SortedList';
import { IColor } from '../Types';
import { IColor } from '../primitives/Types';
import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
import { Emitter } from '../primitives/Event';
@@ -4,7 +4,7 @@
*/
import { MouseStateService } from './MouseStateService';
import { assert } from 'chai';
import { ICoreMouseEvent, CoreMouseEventType } from '../Types';
import { ICoreMouseEvent, CoreMouseEventType } from '../primitives/Types';
function toBytes(s: string | undefined): number[] {
if (!s) {
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IMouseStateService } from './Services';
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from '../Types';
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from '../primitives/Types';
import { Disposable } from '../primitives/Lifecycle';
import { Emitter } from '../primitives/Event';
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { OptionsService, DEFAULT_OPTIONS } from './OptionsService';
import { IDisposable } from '../Types';
import { IDisposable } from '../primitives/Types';
describe('OptionsService', () => {
describe('constructor', () => {
+1 -1
View File
@@ -5,7 +5,7 @@
import { Disposable, toDisposable } from '../primitives/Lifecycle';
import { isMac } from '../primitives/Platform';
import { CursorStyle, IDisposable } from '../Types';
import { CursorStyle, IDisposable } from '../primitives/Types';
import { FontWeight, IOptionsService, ITerminalOptions } from './Services';
import { Emitter } from '../primitives/Event';
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IBufferService, IOscLinkService } from './Services';
import { IOscLinkData } from '../Types';
import { IOscLinkData } from '../primitives/Types';
import { IMarker } from '../primitives/buffer/Types';
export class OscLinkService implements IOscLinkService {
+2 -1
View File
@@ -4,7 +4,8 @@
*/
import type { IDecoration, IDecorationOptions, ILinkHandler, ILogger, IWindowsPty, IOverviewRulerOptions } from '@xterm/xterm';
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from '../Types';
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDisposable, IOscLinkData } from '../primitives/Types';
import { IDecPrivateModes, IKittyKeyboardState, IModes, IWindowOptions } from '../Types';
import { IAttributeData, IBuffer, IBufferSet } from '../primitives/buffer/Types';
import { createDecorator, IServiceIdentifier } from './ServiceRegistry';
import type { Emitter, IEvent } from '../primitives/Event';
+1 -1
View File
@@ -7,7 +7,7 @@ import { Browser, JSHandle, Page } from '@playwright/test';
import { deepStrictEqual, strictEqual } from 'assert';
import type { IRenderDimensions as IRenderDimensionsInternal } from '../../src/browser/renderer/shared/Types';
import type { IRenderService } from '../../src/browser/services/Services';
import type { IDisposable } from '../../src/common/Types';
import type { IDisposable } from '../../src/common/primitives/Types';
import type { IMarker } from '../../src/common/primitives/buffer/Types';
import type { ICoreTerminal } from '../../src/common/CoreTerminal';
import * as playwright from '@playwright/test';