Move Color to base; slim services/Types; colocate ICoreTerminal

- Restore Color.ts under common/base/ (not services)
- Add base/ColorTypes (IColor, IColorRGB)
- Add terminal/CoreTerminalTypes (ICoreTerminal, IScrollEvent, XtermListener)
- Add terminal/InputHandlerTypes and input/WindowOptions for handler types
- services/Types.ts: service-only (modes, mouse, osc link, cursor styles)
- Update imports across src, addons, browser; re-export KeyboardResultType removed
- browser tsconfig: exclude unit tests from composite build

Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-05-30 17:45:15 +00:00
co-authored by Daniel Imms
parent 8f5c963982
commit 5070a08b58
62 changed files with 345 additions and 351 deletions
+2 -1
View File
@@ -9,7 +9,8 @@ import { IDisposable, IMarker, Terminal } from '@xterm/xterm';
import { Attributes, BgFlags, Content, ExtFlags, UnderlineStyle } from 'common/buffer/Constants';
import type { AttributeData } from 'common/buffer/AttributeData';
import type { IParams, IDcsHandler, IOscHandler, IApcHandler, IEscapeSequenceParser } from 'common/parser/Types';
import type { IBufferLine, IExtendedAttrs, IInputHandler } from 'common/services/Types';
import type { IBufferLine, IExtendedAttrs } from 'common/buffer/CellTypes';
import type { IInputHandler } from 'common/terminal/InputHandlerTypes';
import type { ITerminal, ReadonlyColorSet } from 'browser/Types';
import type { IRenderDimensions } from 'browser/renderer/shared/Types';
import type { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
+2 -1
View File
@@ -7,7 +7,8 @@
import type { IBuffer, IBufferCell, IBufferRange, ITerminalAddon, Terminal } from '@xterm/xterm';
import type { IHTMLSerializeOptions, SerializeAddon as ISerializeApi, ISerializeOptions, ISerializeRange } from '@xterm/addon-serialize';
import { IAttributeData, IColor } from 'common/services/Types';
import type { IAttributeData } from 'common/buffer/CellTypes';
import type { IColor } from 'common/base/ColorTypes';
import { DEFAULT_ANSI_COLORS } from 'browser/Types';
import { UnderlineStyle } from 'common/buffer/Constants';
+2 -2
View File
@@ -3,9 +3,9 @@ import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { ReadonlyColorSet } from 'browser/Types';
import { Attributes, BgFlags, ExtFlags, FgFlags, NULL_CELL_CODE, UnderlineStyle } from 'common/buffer/Constants';
import { IDecorationService, IOptionsService } from 'common/services/Services';
import { ICellData } from 'common/services/Types';
import type { ICellData } from 'common/buffer/CellTypes';
import { Terminal } from '@xterm/xterm';
import { rgba } from 'common/services/Color';
import { rgba } from 'common/base/Color';
import { treatGlyphAsBackgroundColor } from 'browser/renderer/shared/RendererUtils';
import { blockPatternCodepoints } from './customGlyphs/CustomGlyphDefinitions';
@@ -6,8 +6,8 @@
import { assert } from 'chai';
import { configEquals } from './CharAtlasUtils';
import { ICharAtlasConfig } from './Types';
import { NULL_COLOR } from 'common/services/Color';
import { IColor } from 'common/services/Types';
import { NULL_COLOR } from 'common/base/Color';
import type { IColor } from 'common/base/ColorTypes';
function createTestConfig(overrides: Partial<ICharAtlasConfig> = {}): ICharAtlasConfig {
const color: IColor = { css: '#ffffff', rgba: 0xffffffff };
+1 -1
View File
@@ -7,7 +7,7 @@ import { ICharAtlasConfig } from './Types';
import { Attributes } from 'common/buffer/Constants';
import { ITerminalOptions } from '@xterm/xterm';
import { IColorSet, ReadonlyColorSet } from 'browser/Types';
import { NULL_COLOR } from 'common/services/Color';
import { NULL_COLOR } from 'common/base/Color';
export function generateConfig(deviceCellWidth: number, deviceCellHeight: number, deviceCharWidth: number, deviceCharHeight: number, options: Required<ITerminalOptions>, colors: ReadonlyColorSet, devicePixelRatio: number, deviceMaxTextureSize: number, customGlyphs: boolean = true): ICharAtlasConfig {
// null out some fields that don't matter
+1 -1
View File
@@ -8,7 +8,7 @@ import { IThemeService } from 'browser/services/Services';
import { ReadonlyColorSet } from 'browser/Types';
import { Attributes, FgFlags } from 'common/buffer/Constants';
import { Disposable, toDisposable } from 'common/base/Lifecycle';
import { IColor } from 'common/services/Types';
import type { IColor } from 'common/base/ColorTypes';
import { Terminal } from '@xterm/xterm';
import { RenderModelConstants } from './RenderModel';
import { IRenderModel, IWebGL2RenderingContext, IWebGLVertexArrayObject } from './Types';
+2 -2
View File
@@ -8,10 +8,10 @@ import { DIM_OPACITY, TEXT_BASELINE } from './Constants';
import { tryDrawCustomGlyph } from './customGlyphs/CustomGlyphRasterizer';
import { computeNextVariantOffset, treatGlyphAsBackgroundColor, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from './Types';
import { NULL_COLOR, channels, color, rgba } from 'common/services/Color';
import { NULL_COLOR, channels, color, rgba } from 'common/base/Color';
import { FourKeyMap } from 'common/base/MultiKeyMap';
import { IdleTaskQueue } from 'common/base/TaskQueue';
import { IColor } from 'common/services/Types';
import type { IColor } from 'common/base/ColorTypes';
import { AttributeData } from 'common/buffer/AttributeData';
import { Attributes, DEFAULT_COLOR, DEFAULT_EXT, UnderlineStyle } from 'common/buffer/Constants';
import { ILogService, IUnicodeService } from 'common/services/Services';
+2 -1
View File
@@ -6,7 +6,8 @@
import { FontWeight } from '@xterm/xterm';
import { IColorSet } from 'browser/Types';
import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import { CursorInactiveStyle, CursorStyle } from 'common/services/Types';
import type { IEvent } from 'common/base/Event';
export interface IRenderModel {
+1 -1
View File
@@ -10,7 +10,7 @@ import { CursorBlinkStateManager } from './CursorBlinkStateManager';
import { observeDevicePixelDimensions } from './DevicePixelObserver';
import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/shared/Types';
import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { CharData, IBufferLine, ICellData } from 'common/services/Types';
import type { CharData, IBufferLine, ICellData } from 'common/buffer/CellTypes';
import { AttributeData } from 'common/buffer/AttributeData';
import { CellData } from 'common/buffer/CellData';
import { Attributes, Content, FgFlags, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { IColorContrastCache } from 'browser/Types';
import { IColor } from 'common/services/Types';
import type { IColor } from 'common/base/ColorTypes';
import { TwoKeyMap } from 'common/base/MultiKeyMap';
export class ColorContrastCache implements IColorContrastCache {
+4 -2
View File
@@ -43,10 +43,12 @@ import { SelectionService } from 'browser/services/SelectionService';
import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IKeyboardService, ILinkProviderService, IMouseCoordsService, IMouseService, IRenderService, ISelectionService, IThemeService } from 'browser/services/Services';
import { ThemeService } from 'browser/services/ThemeService';
import { KeyboardService } from 'browser/services/KeyboardService';
import { channels, color, rgb } from 'common/services/Color';
import { channels, color, rgb } from 'common/base/Color';
import { CoreTerminal } from 'common/terminal/CoreTerminal';
import * as Browser from 'common/base/Platform';
import { ColorRequestType, IColorEvent, ITerminalOptions, KeyboardResultType, SpecialColorIndex } from 'common/services/Types';
import type { ITerminalOptions } from 'common/services/Services';
import { ColorRequestType, IColorEvent, SpecialColorIndex } from 'common/terminal/InputHandlerTypes';
import { KeyboardResultType } from 'common/input/KeyboardTypes';
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { IBuffer } from 'common/buffer/Types';
import { C0, C1ESCAPED } from 'common/data/EscapeSequences';
+1 -1
View File
@@ -5,7 +5,7 @@
import { IBufferCellPosition, ILink, ILinkDecorations, ILinkWithState, ILinkifier2, ILinkifierEvent } from 'browser/Types';
import { Disposable, dispose, toDisposable } from 'common/base/Lifecycle';
import { IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import { IBufferService } from 'common/services/Services';
import { ILinkProviderService, IMouseCoordsService, IRenderService } from './services/Services';
import { Emitter } from 'common/base/Event';
+2 -1
View File
@@ -8,7 +8,8 @@ import { OscLinkProvider } from 'browser/OscLinkProvider';
import { ILink } from 'browser/Types';
import { createCellData, MockBufferService, MockOptionsService } from 'common/terminal/TestUtils.test';
import { IBufferService, IOscLinkService } from 'common/services/Services';
import { IBufferLine, IOscLinkData } from 'common/services/Types';
import type { IBufferLine } from 'common/buffer/CellTypes';
import { IOscLinkData } from 'common/services/Types';
class TestOscLinkService implements IOscLinkService {
public serviceBrand: any;
+1 -1
View File
@@ -6,7 +6,7 @@
import { IBufferRange, ILink } from 'browser/Types';
import { ILinkProvider } from 'browser/services/Services';
import { CellData } from 'common/buffer/CellData';
import { IBufferLine } from 'common/services/Types';
import type { IBufferLine } from 'common/buffer/CellTypes';
import { IBufferService, IOptionsService, IOscLinkService } from 'common/services/Services';
export class OscLinkProvider implements ILinkProvider {
+1 -1
View File
@@ -9,7 +9,7 @@ import { assert } from 'chai';
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { CellData } from 'common/buffer/CellData';
import { MockUnicodeService, createCellData } from 'common/terminal/TestUtils.test';
import { IMarker } from 'common/services/Types';
import type { IMarker } from 'common/buffer/CellTypes';
const INIT_COLS = 80;
const INIT_ROWS = 24;
+6 -2
View File
@@ -9,7 +9,11 @@ import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/rende
import { IColorSet, ITerminal, ILinkifier2, IBrowser, IViewport, ICompositionHelper, CharacterJoinerHandler, IBufferRange, ReadonlyColorSet, IBufferElementProvider } from 'browser/Types';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import type { ICircularList } from 'common/base/CircularList';
import { IBufferLine, ICellData, IAttributeData, XtermListener, ICharset, ITerminalOptions, ColorIndex } from 'common/services/Types';
import type { IBufferLine, ICellData, IAttributeData } from 'common/buffer/CellTypes';
import type { ICharset } from 'common/data/Charsets';
import type { ITerminalOptions } from 'common/services/Services';
import type { XtermListener } from 'common/terminal/CoreTerminalTypes';
import { ColorIndex } from 'common/terminal/InputHandlerTypes';
import { Buffer } from 'common/buffer/Buffer';
import * as Browser from 'common/base/Platform';
import { CoreBrowserTerminal } from 'browser/CoreBrowserTerminal';
@@ -17,7 +21,7 @@ import { IUnicodeService, IOptionsService, ICoreService, IMouseStateService } fr
import { IFunctionIdentifier, IParams } from 'common/parser/Types';
import { AttributeData } from 'common/buffer/AttributeData';
import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
import { css } from 'common/services/Color';
import { css } from 'common/base/Color';
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
import { Emitter, type IEvent } from 'common/base/Event';
+5 -2
View File
@@ -3,10 +3,13 @@
* @license MIT
*/
import { CharData, IColor, ICoreTerminal, ITerminalOptions } from 'common/services/Types';
import type { CharData } from 'common/buffer/CellTypes';
import type { IColor } from 'common/base/ColorTypes';
import type { ICoreTerminal } from 'common/terminal/CoreTerminalTypes';
import type { ITerminalOptions } from 'common/services/Services';
import { IBuffer } from 'common/buffer/Types';
import { IDisposable, IRenderDimensions as IRenderDimensionsApi, Terminal as ITerminalApi } from '@xterm/xterm';
import { channels, css } from 'common/services/Color';
import { channels, css } from 'common/base/Color';
import type { IEvent } from 'common/base/Event';
/**
+1 -1
View File
@@ -7,7 +7,7 @@ import * as Strings from 'browser/LocalizableStrings';
import { CoreBrowserTerminal as TerminalCore } from 'browser/CoreBrowserTerminal';
import { IBufferRange, ITerminal } from 'browser/Types';
import { Disposable } from 'common/base/Lifecycle';
import { ITerminalOptions } from 'common/services/Types';
import type { ITerminalOptions } from 'common/services/Services';
import { AddonManager } from 'common/public/AddonManager';
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
import { ParserApi } from 'common/public/ParserApi';
+1 -1
View File
@@ -12,7 +12,7 @@ import { TextBlinkStateManager } from 'browser/renderer/shared/TextBlinkStateMan
import { IRenderDimensions, IRenderer, IRequestRedrawEvent, ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { ICharSizeService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { ILinkifier2, ILinkifierEvent, ITerminal, ReadonlyColorSet } from 'browser/Types';
import { color } from 'common/services/Color';
import { color } from 'common/base/Color';
import { Disposable, toDisposable } from 'common/base/Lifecycle';
import { IBufferService, ICoreService, IInstantiationService, IOptionsService } from 'common/services/Services';
import { Emitter } from 'common/base/Event';
@@ -9,7 +9,7 @@ import { DomRendererRowFactory } from 'browser/renderer/dom/DomRendererRowFactor
import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, FgFlags, BgFlags, Attributes, UnderlineStyle } from 'common/buffer/Constants';
import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { BufferLineStringCache } from 'common/buffer/BufferLineStringCache';
import { IBufferLine } from 'common/services/Types';
import type { IBufferLine } from 'common/buffer/CellTypes';
import { CellData } from 'common/buffer/CellData';
import { MockCoreService, MockDecorationService, MockOptionsService, createCellData, NULL_CELL_DATA } from 'common/terminal/TestUtils.test';
import { MockCharacterJoinerService, MockCoreBrowserService, MockThemeService } from 'browser/TestUtils.test';
@@ -3,12 +3,13 @@
* @license MIT
*/
import { IBufferLine, ICellData, IColor } from 'common/services/Types';
import type { IBufferLine, ICellData } from 'common/buffer/CellTypes';
import type { IColor } from 'common/base/ColorTypes';
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/shared/Constants';
import { WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';
import { CellData } from 'common/buffer/CellData';
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
import { channels, color } from 'common/services/Color';
import { channels, color } from 'common/base/Color';
import { ICharacterJoinerService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { JoinedCellData } from 'browser/services/CharacterJoinerService';
import { treatGlyphAsBackgroundColor } from 'browser/renderer/shared/RendererUtils';
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import { FontWeight } from 'common/services/Services';
+1 -1
View File
@@ -5,7 +5,7 @@
import { Terminal } from '@xterm/xterm';
import { ITerminal } from 'browser/Types';
import { IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IEvent } from 'common/base/Event';
export interface IDimensions {
@@ -8,7 +8,7 @@ import { ICharacterJoinerService } from 'browser/services/Services';
import { CharacterJoinerService } from 'browser/services/CharacterJoinerService';
import { BufferLine } from 'common/buffer/BufferLine';
import { BufferLineStringCache } from 'common/buffer/BufferLineStringCache';
import { IBufferLine } from 'common/services/Types';
import type { IBufferLine } from 'common/buffer/CellTypes';
import { CellData } from 'common/buffer/CellData';
import { MockBufferService, createCellData } from 'common/terminal/TestUtils.test';
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IBufferLine, ICellData, CharData } from 'common/services/Types';
import type { CharData, IBufferLine, ICellData } from 'common/buffer/CellTypes';
import { ICharacterJoiner } from 'browser/Types';
import { AttributeData } from 'common/buffer/AttributeData';
import { WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants';
+1 -1
View File
@@ -9,7 +9,7 @@ import { KittyKeyboard, KittyKeyboardEventType, KittyKeyboardFlags } from 'commo
import { Win32InputMode } from 'common/input/Win32InputMode';
import { isMac } from 'common/base/Platform';
import { ICoreService, IOptionsService } from 'common/services/Services';
import { IKeyboardResult } from 'common/services/Types';
import type { IKeyboardResult } from 'common/input/KeyboardTypes';
export class KeyboardService implements IKeyboardService {
public serviceBrand: undefined;
+1 -1
View File
@@ -1,6 +1,6 @@
import { ILinkProvider, ILinkProviderService } from 'browser/services/Services';
import { Disposable, toDisposable } from 'common/base/Lifecycle';
import { IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
export class LinkProviderService extends Disposable implements ILinkProviderService {
declare public serviceBrand: undefined;
+2 -1
View File
@@ -5,7 +5,8 @@
import { addDisposableListener } from 'browser/Dom';
import { IBufferService, IMouseStateService, ICoreService, ILogService, IOptionsService } from 'common/services/Services';
import { CoreMouseAction, CoreMouseButton, CoreMouseEventType, ICoreMouseEvent, IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import { CoreMouseAction, CoreMouseButton, CoreMouseEventType, ICoreMouseEvent } from 'common/services/Types';
import { C0 } from 'common/data/EscapeSequences';
import { DisposableStore, MutableDisposable, toDisposable } from 'common/base/Lifecycle';
import { ICoreBrowserService, IMouseCoordsService, IMouseService, IMouseServiceTarget, IRenderService, ISelectionService } from './Services';
@@ -6,7 +6,7 @@
import { assert } from 'chai';
import { SelectionService, SelectionMode } from './SelectionService';
import { SelectionModel } from 'browser/selection/SelectionModel';
import { IBufferLine } from 'common/services/Types';
import type { IBufferLine } from 'common/buffer/CellTypes';
import { MockBufferService, MockOptionsService, MockCoreService, MockMouseStateService, createCellData } from 'common/terminal/TestUtils.test';
import { BufferLine } from 'common/buffer/BufferLine';
import { BufferLineStringCache } from 'common/buffer/BufferLineStringCache';
+2 -1
View File
@@ -11,7 +11,8 @@ import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from
import { ICoreBrowserService, IMouseCoordsService, IRenderService, ISelectionService } from 'browser/services/Services';
import { Disposable, MutableDisposable, toDisposable } from 'common/base/Lifecycle';
import * as Browser from 'common/base/Platform';
import { IBufferLine, ICellData, IDisposable } from 'common/services/Types';
import type { IBufferLine, ICellData } from 'common/buffer/CellTypes';
import type { IDisposable } from 'common/base/Lifecycle';
import { getRangeLength } from 'common/buffer/BufferRange';
import { CellData } from 'common/buffer/CellData';
import { IBuffer } from 'common/buffer/Types';
+3 -1
View File
@@ -7,7 +7,9 @@ import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
import { IColorSet, ILink, ReadonlyColorSet } from 'browser/Types';
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
import { createDecorator } from 'common/services/ServiceRegistry';
import { AllColorIndex, IDisposable, IKeyboardResult } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import { AllColorIndex } from 'common/terminal/InputHandlerTypes';
import type { IKeyboardResult } from 'common/input/KeyboardTypes';
import type { IEvent } from 'common/base/Event';
export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService');
+3 -2
View File
@@ -6,10 +6,11 @@
import { ColorContrastCache } from 'browser/ColorContrastCache';
import { IThemeService } from 'browser/services/Services';
import { DEFAULT_ANSI_COLORS, IColorContrastCache, IColorSet, ReadonlyColorSet } from 'browser/Types';
import { color, css, NULL_COLOR } from 'common/services/Color';
import { color, css, NULL_COLOR } from 'common/base/Color';
import { Disposable } from 'common/base/Lifecycle';
import { IOptionsService, ITheme } from 'common/services/Services';
import { AllColorIndex, IColor, SpecialColorIndex } from 'common/services/Types';
import type { IColor } from 'common/base/ColorTypes';
import { AllColorIndex, SpecialColorIndex } from 'common/terminal/InputHandlerTypes';
import { Emitter } from 'common/base/Event';
interface IRestoreColorSet {
+3
View File
@@ -19,6 +19,9 @@
"./**/*",
"../../typings/xterm.d.ts"
],
"exclude": [
"**/*.test.ts"
],
"references": [
{ "path": "../common" }
]
+3 -3
View File
@@ -42,14 +42,14 @@ flowchart BT
| Project | Role | Notable sources |
| --- | --- | --- |
| `common/base` | Core utilities (lifecycle, events, platform) | `Async`, `Event`, `Lifecycle`, `Platform`, `StringBuilder`, `Version`, `CircularList` |
| `common/base` | Core utilities (lifecycle, events, platform) | `Async`, `Event`, `Lifecycle`, `Platform`, `StringBuilder`, `Version`, `CircularList`, `Color`, `ColorTypes` |
| `common/encoding` | UTF conversion | `TextDecoder` (moved from `input/`) |
| `common/data` | Static terminal data | `Charsets`, `EscapeSequences` |
| `common/buffer` | Screen buffer | `Buffer`, `BufferLine`, … |
| `common/parser` | Escape sequence parser | `EscapeSequenceParser`, … |
| `common/input` | Keyboard / write path helpers | `Keyboard`, `WriteBuffer`, … |
| `common/services` | DI services and shared types | `Services`, `Types`, `Color`, … |
| `common/terminal` | Core terminal + input handler | `CoreTerminal`, `InputHandler`, `WindowsMode` |
| `common/services` | DI service implementations | `Services`, `Types` (modes, mouse, osc link), … |
| `common/terminal` | Core terminal + input handler | `CoreTerminal`, `CoreTerminalTypes`, `InputHandler`, `InputHandlerTypes`, `WindowsMode` |
| `common/public` | Public API adapters | `AddonManager`, buffer API views |
## TypeScript projects
@@ -4,7 +4,7 @@
*/
import { assert } from 'chai';
import { channels, color, css, rgb, rgba, toPaddedHex, contrastRatio } from 'common/services/Color';
import { channels, color, css, rgb, rgba, toPaddedHex, contrastRatio } from 'common/base/Color';
describe('Color', () => {
@@ -3,7 +3,8 @@
* @license MIT
*/
import { IColor, IColorRGB } from 'common/services/Types';
import type { IColor } from 'common/base/ColorTypes';
import type { IColorRGB } from 'common/base/ColorTypes';
let $r = 0;
let $g = 0;
+11
View File
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
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];
+2 -1
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { IAttributeData, IColorRGB, IExtendedAttrs } from 'common/buffer/CellTypes';
import type { IColorRGB } from 'common/base/ColorTypes';
import { IAttributeData, IExtendedAttrs } from 'common/buffer/CellTypes';
import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from 'common/buffer/Constants';
export class AttributeData implements IAttributeData {
+2 -2
View File
@@ -7,9 +7,9 @@ import type { UnderlineStyle } from 'common/buffer/Constants';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IEvent } from 'common/base/Event';
export type CharData = [attr: number, char: string, width: number, code: number];
export type { IColorRGB } from 'common/base/ColorTypes';
export type IColorRGB = [red: number, green: number, blue: number];
export type CharData = [attr: number, char: string, width: number, code: number];
export interface IExtendedAttrs {
ext: number;
+30
View File
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
/** CSI window manipulation options (see InputHandler). */
export interface IWindowOptions {
restoreWin?: boolean;
minimizeWin?: boolean;
setWinPosition?: boolean;
setWinSizePixels?: boolean;
raiseWin?: boolean;
lowerWin?: boolean;
refreshWin?: boolean;
setWinSizeChars?: boolean;
maximizeWin?: boolean;
fullscreenWin?: boolean;
getWinState?: boolean;
getWinPosition?: boolean;
getWinSizePixels?: boolean;
getScreenSizePixels?: boolean;
getCellSizePixels?: boolean;
getWinSizeChars?: boolean;
getScreenSizeChars?: boolean;
getIconTitle?: boolean;
getWinTitle?: boolean;
pushTitle?: boolean;
popTitle?: boolean;
setWinLines?: boolean;
}
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { CellData } from 'common/buffer/CellData';
import { IBufferLine, ICellData } from 'common/services/Types';
import type { IBufferLine, ICellData } from 'common/buffer/CellTypes';
import { IBufferCell as IBufferCellApi, IBufferLine as IBufferLineApi } from '@xterm/xterm';
export class BufferLineApiView implements IBufferLineApi {
+1 -1
View File
@@ -5,7 +5,7 @@
import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from '@xterm/xterm';
import { BufferApiView } from 'common/public/BufferApiView';
import { ICoreTerminal } from 'common/services/Types';
import type { ICoreTerminal } from 'common/terminal/CoreTerminalTypes';
import { Disposable } from 'common/base/Lifecycle';
import { Emitter } from 'common/base/Event';
+1 -1
View File
@@ -5,7 +5,7 @@
import { IParams } from 'common/parser/Types';
import { IDisposable, IFunctionIdentifier, IParser } from '@xterm/xterm';
import { ICoreTerminal } from 'common/services/Types';
import type { ICoreTerminal } from 'common/terminal/CoreTerminalTypes';
export class ParserApi implements IParser {
constructor(private _core: ICoreTerminal) { }
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { ICoreTerminal } from 'common/services/Types';
import type { ICoreTerminal } from 'common/terminal/CoreTerminalTypes';
import { IUnicodeHandling, IUnicodeVersionProvider } from '@xterm/xterm';
export class UnicodeApi implements IUnicodeHandling {
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { Disposable } from 'common/base/Lifecycle';
import { IAttributeData, IBufferLine } from 'common/services/Types';
import type { IAttributeData, IBufferLine } from 'common/buffer/CellTypes';
import { BufferSet } from 'common/buffer/BufferSet';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IBufferService, ILogService, IOptionsService, type IBufferResizeEvent } from 'common/services/Services';
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { ICharsetService } from 'common/services/Services';
import { ICharset } from 'common/services/Types';
import type { ICharset } from 'common/data/Charsets';
export class CharsetService implements ICharsetService {
public serviceBrand: any;
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { DecorationLineCache, DecorationService } from './DecorationService';
import { IMarker } from 'common/services/Types';
import type { IMarker } from 'common/buffer/CellTypes';
import { Disposable } from 'common/base/Lifecycle';
import { Emitter } from 'common/base/Event';
import { MockLogService, MockBufferService, MockOptionsService } from 'common/terminal/TestUtils.test';
+2 -2
View File
@@ -5,11 +5,11 @@
import type { ICircularList, IDeleteEvent, IInsertEvent } from 'common/base/CircularList';
import { MicrotaskTimer } from 'common/base/Async';
import { css } from 'common/services/Color';
import { css } from 'common/base/Color';
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'common/base/Lifecycle';
import type { IColor } from 'common/base/ColorTypes';
import { IBufferService, IDecorationService, IInternalDecoration, ILogService } from 'common/services/Services';
import { SortedList } from 'common/services/SortedList';
import { IColor } from 'common/services/Types';
import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
import { Emitter } from 'common/base/Event';
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { OptionsService, DEFAULT_OPTIONS } from 'common/services/OptionsService';
import { IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
describe('OptionsService', () => {
describe('constructor', () => {
+2 -1
View File
@@ -5,7 +5,8 @@
import { Disposable, toDisposable } from 'common/base/Lifecycle';
import { isMac } from 'common/base/Platform';
import { CursorStyle, IDisposable } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import { CursorStyle } from 'common/services/Types';
import { FontWeight, IOptionsService, ITerminalOptions } from 'common/services/Services';
import { Emitter } from 'common/base/Event';
+2 -1
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { IBufferService, IOscLinkService } from 'common/services/Services';
import { IMarker, IOscLinkData } from 'common/services/Types';
import type { IMarker } from 'common/buffer/CellTypes';
import { IOscLinkData } from 'common/services/Types';
export class OscLinkService implements IOscLinkService {
public serviceBrand: any;
+7 -2
View File
@@ -4,7 +4,12 @@
*/
import type { IDecoration, IDecorationOptions, ILinkHandler, ILogger, IWindowsPty, IOverviewRulerOptions } from '@xterm/xterm';
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, IAttributeData, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from 'common/services/Types';
import type { IAttributeData } from 'common/buffer/CellTypes';
import type { ICharset } from 'common/data/Charsets';
import type { IColor } from 'common/base/ColorTypes';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IWindowOptions } from 'common/input/WindowOptions';
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IKittyKeyboardState, IModes, IOscLinkData } from 'common/services/Types';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import type { IBufferResizeEvent, IBufferService as IBufferServiceApi } from 'common/buffer/BufferService';
import { createDecorator } from 'common/services/ServiceRegistry';
@@ -238,7 +243,7 @@ export interface ITerminalOptions {
vtExtensions?: IVtExtensions;
[key: string]: any;
termName: string;
termName?: string;
}
export interface ITheme {
+7 -282
View File
@@ -3,58 +3,12 @@
* @license MIT
*/
import type { IBufferSet } from 'common/buffer/Types';
import type { IParams } from 'common/parser/Types';
import type { IMouseStateService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
import { IFunctionIdentifier } from '@xterm/xterm';
import type { IDisposable } from 'common/base/Lifecycle';
import type { ITerminalOptions } from 'common/base/TerminalOptions';
import type { IColorRGB } from 'common/buffer/CellTypes';
import type { IEvent } from 'common/base/Event';
export type { IDisposable } from 'common/base/Lifecycle';
export type { ITerminalOptions } from 'common/base/TerminalOptions';
export type { CharData, IAttributeData, ICellData, IBufferLine, IExtendedAttrs, IMarker } from 'common/buffer/CellTypes';
export type { ICharset } from 'common/data/Charsets';
export type { IKeyboardEvent, IKeyboardResult } from 'common/input/KeyboardTypes';
export { KeyboardResultType } from 'common/input/KeyboardTypes';
export type { UnicodeCharProperties, UnicodeCharWidth, IUnicodeVersionProvider } from 'common/input/UnicodeTypes';
export interface ICoreTerminal {
mouseStateService: IMouseStateService;
coreService: ICoreService;
optionsService: IOptionsService;
unicodeService: IUnicodeService;
buffers: IBufferSet;
options: Required<ITerminalOptions>;
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
}
export type CursorStyle = 'block' | 'underline' | 'bar';
export type CursorInactiveStyle = 'outline' | 'block' | 'bar' | 'underline' | 'none';
export type XtermListener = (...args: any[]) => void;
export interface IScrollEvent {
position: number;
}
export interface IColor {
readonly css: string;
readonly rgba: number; // 32-bit int with rgba in each byte
}
export type { IColorRGB } from 'common/buffer/CellTypes';
/**
* 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.
* Tracks the current hyperlink for OscLinkService.
*/
export interface IOscLinkData {
id?: string;
@@ -81,38 +35,22 @@ export interface IDecPrivateModes {
}
/**
* Kitty keyboard protocol state.
* Maintains per-screen stacks of enhancement flags.
* Kitty keyboard protocol state (CoreService).
*/
export interface IKittyKeyboardState {
/** Current active enhancement flags (for current screen) */
flags: number;
/** Saved flags for main screen when alt is active */
mainFlags: number;
/** Saved flags for alternate screen when main is active */
altFlags: number;
/** Stack of flags for main screen */
mainStack: number[];
/** Stack of flags for alternate screen */
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,
@@ -124,250 +62,37 @@ export const enum CoreMouseButton {
}
export const enum CoreMouseAction {
UP = 0, // buttons, wheel
DOWN = 1, // buttons, wheel
LEFT = 2, // wheel only
RIGHT = 3, // wheel only
MOVE = 32 // buttons only
UP = 0,
DOWN = 1,
LEFT = 2,
RIGHT = 3,
MOVE = 32
}
export interface ICoreMouseEvent {
/** column (zero based). */
col: number;
/** row (zero based). */
row: number;
/** xy pixel positions. */
x: number;
y: number;
/**
* Button the action occured. 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
*/
export interface IWindowOptions {
restoreWin?: boolean;
minimizeWin?: boolean;
setWinPosition?: boolean;
setWinSizePixels?: boolean;
raiseWin?: boolean;
lowerWin?: boolean;
refreshWin?: boolean;
setWinSizeChars?: boolean;
maximizeWin?: boolean;
fullscreenWin?: boolean;
getWinState?: boolean;
getWinPosition?: boolean;
getWinSizePixels?: boolean;
getScreenSizePixels?: boolean;
getCellSizePixels?: boolean;
getWinSizeChars?: boolean;
getScreenSizeChars?: boolean;
getIconTitle?: boolean;
getWinTitle?: boolean;
pushTitle?: boolean;
popTitle?: boolean;
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.
*/
export interface IInputHandler {
onTitleChange: IEvent<string>;
parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise<boolean>;
print(data: Uint32Array, start: number, end: number): void;
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
/** C0 BEL */ bell(): boolean;
/** C0 LF */ lineFeed(): boolean;
/** C0 CR */ carriageReturn(): boolean;
/** C0 BS */ backspace(): boolean;
/** C0 HT */ tab(): boolean;
/** C0 SO */ shiftOut(): boolean;
/** C0 SI */ shiftIn(): boolean;
/** CSI @ */ insertChars(params: IParams): boolean;
/** CSI SP @ */ scrollLeft(params: IParams): boolean;
/** CSI A */ cursorUp(params: IParams): boolean;
/** CSI SP A */ scrollRight(params: IParams): boolean;
/** CSI B */ cursorDown(params: IParams): boolean;
/** CSI C */ cursorForward(params: IParams): boolean;
/** CSI D */ cursorBackward(params: IParams): boolean;
/** CSI E */ cursorNextLine(params: IParams): boolean;
/** CSI F */ cursorPrecedingLine(params: IParams): boolean;
/** CSI G */ cursorCharAbsolute(params: IParams): boolean;
/** CSI H */ cursorPosition(params: IParams): boolean;
/** CSI I */ cursorForwardTab(params: IParams): boolean;
/** CSI J */ eraseInDisplay(params: IParams): boolean;
/** CSI K */ eraseInLine(params: IParams): boolean;
/** CSI L */ insertLines(params: IParams): boolean;
/** CSI M */ deleteLines(params: IParams): boolean;
/** CSI P */ deleteChars(params: IParams): boolean;
/** CSI S */ scrollUp(params: IParams): boolean;
/** CSI T */ scrollDown(params: IParams, collect?: string): boolean;
/** CSI X */ eraseChars(params: IParams): boolean;
/** CSI Z */ cursorBackwardTab(params: IParams): boolean;
/** CSI ` */ charPosAbsolute(params: IParams): boolean;
/** CSI a */ hPositionRelative(params: IParams): boolean;
/** CSI b */ repeatPrecedingCharacter(params: IParams): boolean;
/** CSI c */ sendDeviceAttributesPrimary(params: IParams): boolean;
/** CSI > c */ sendDeviceAttributesSecondary(params: IParams): boolean;
/** CSI d */ linePosAbsolute(params: IParams): boolean;
/** CSI e */ vPositionRelative(params: IParams): boolean;
/** CSI f */ hVPosition(params: IParams): boolean;
/** CSI g */ tabClear(params: IParams): boolean;
/** CSI h */ setMode(params: IParams, collect?: string): boolean;
/** CSI l */ resetMode(params: IParams, collect?: string): boolean;
/** CSI m */ charAttributes(params: IParams): boolean;
/** CSI n */ deviceStatus(params: IParams, collect?: string): boolean;
/** CSI p */ softReset(params: IParams, collect?: string): boolean;
/** CSI q */ setCursorStyle(params: IParams, collect?: string): boolean;
/** CSI r */ setScrollRegion(params: IParams, collect?: string): boolean;
/** CSI s */ saveCursor(params: IParams): boolean;
/** CSI u */ restoreCursor(params: IParams): boolean;
/** CSI ' } */ insertColumns(params: IParams): boolean;
/** CSI ' ~ */ deleteColumns(params: IParams): boolean;
/** OSC 0 */
/** OSC 2 */ setTitle(data: string): boolean;
/** OSC 4 */ setOrReportIndexedColor(data: string): boolean;
/** OSC 10 */ setOrReportFgColor(data: string): boolean;
/** OSC 11 */ setOrReportBgColor(data: string): boolean;
/** OSC 12 */ setOrReportCursorColor(data: string): boolean;
/** OSC 104 */ restoreIndexedColor(data: string): boolean;
/** OSC 110 */ restoreFgColor(data: string): boolean;
/** OSC 111 */ restoreBgColor(data: string): boolean;
/** OSC 112 */ restoreCursorColor(data: string): boolean;
/** ESC E */ nextLine(): boolean;
/** ESC = */ keypadApplicationMode(): boolean;
/** ESC > */ keypadNumericMode(): boolean;
/** ESC % G */
/** ESC % @ */ selectDefaultCharset(): boolean;
/** ESC ( C */
/** ESC ) C */
/** ESC * C */
/** ESC + C */
/** ESC - C */
/** ESC . C */
/** ESC / C */ selectCharset(collectAndFlag: string): boolean;
/** ESC D */ index(): boolean;
/** ESC H */ tabSet(): boolean;
/** ESC M */ reverseIndex(): boolean;
/** ESC c */ fullReset(): boolean;
/** ESC n */
/** ESC o */
/** ESC | */
/** ESC } */
/** ESC ~ */ setgLevel(level: number): boolean;
/** ESC # 8 */ screenAlignmentPattern(): boolean;
}
export interface IParseStack {
paused: boolean;
cursorStartX: number;
cursorStartY: number;
decodedLength: number;
position: number;
}
+3 -1
View File
@@ -26,7 +26,9 @@ import { InstantiationService } from 'common/services/InstantiationService';
import { LogService } from 'common/services/LogService';
import { BufferService, BufferServiceConstants } from 'common/services/BufferService';
import { OptionsService } from 'common/services/OptionsService';
import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent } from 'common/services/Types';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IAttributeData } from 'common/buffer/CellTypes';
import type { ICoreTerminal, IScrollEvent } from 'common/terminal/CoreTerminalTypes';
import { CoreService } from 'common/services/CoreService';
import { MouseStateService } from 'common/services/MouseStateService';
import { UnicodeService } from 'common/services/UnicodeService';
+31
View File
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import type { IBufferSet } from 'common/buffer/Types';
import type { IParams } from 'common/parser/Types';
import type { IMouseStateService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
import { IFunctionIdentifier } from '@xterm/xterm';
import type { IDisposable } from 'common/base/Lifecycle';
import type { ITerminalOptions } from 'common/base/TerminalOptions';
export interface ICoreTerminal {
mouseStateService: IMouseStateService;
coreService: ICoreService;
optionsService: IOptionsService;
unicodeService: IUnicodeService;
buffers: IBufferSet;
options: Required<ITerminalOptions>;
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
}
export interface IScrollEvent {
position: number;
}
export type XtermListener = (...args: any[]) => void;
+2 -1
View File
@@ -5,7 +5,8 @@
import { assert } from 'chai';
import { InputHandler } from 'common/terminal/InputHandler';
import { IBufferLine, IAttributeData, IColorEvent, ColorRequestType, SpecialColorIndex } from 'common/services/Types';
import type { IBufferLine, IAttributeData } from 'common/buffer/CellTypes';
import { IColorEvent, ColorRequestType, SpecialColorIndex } from 'common/terminal/InputHandlerTypes';
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { CellData } from 'common/buffer/CellData';
import { Attributes, BgFlags, UnderlineStyle } from 'common/buffer/Constants';
+4 -1
View File
@@ -4,7 +4,10 @@
* @license MIT
*/
import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IColorEvent, IParseStack, ColorIndex, ColorRequestType, SpecialColorIndex } from 'common/services/Types';
import type { IAttributeData } from 'common/buffer/CellTypes';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IWindowOptions } from 'common/input/WindowOptions';
import { IInputHandler, IColorEvent, IParseStack, ColorIndex, ColorRequestType, SpecialColorIndex } from 'common/terminal/InputHandlerTypes';
import { C0, C1 } from 'common/data/EscapeSequences';
import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets';
import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';
+154
View File
@@ -0,0 +1,154 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import type { IColorRGB } from 'common/base/ColorTypes';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IEvent } from 'common/base/Event';
import type { IParams } from 'common/parser/Types';
import { IFunctionIdentifier } from '@xterm/xterm';
export type { IWindowOptions } from 'common/input/WindowOptions';
// 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.
*/
export interface IInputHandler {
onTitleChange: IEvent<string>;
parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise<boolean>;
print(data: Uint32Array, start: number, end: number): void;
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
/** C0 BEL */ bell(): boolean;
/** C0 LF */ lineFeed(): boolean;
/** C0 CR */ carriageReturn(): boolean;
/** C0 BS */ backspace(): boolean;
/** C0 HT */ tab(): boolean;
/** C0 SO */ shiftOut(): boolean;
/** C0 SI */ shiftIn(): boolean;
/** CSI @ */ insertChars(params: IParams): boolean;
/** CSI SP @ */ scrollLeft(params: IParams): boolean;
/** CSI A */ cursorUp(params: IParams): boolean;
/** CSI SP A */ scrollRight(params: IParams): boolean;
/** CSI B */ cursorDown(params: IParams): boolean;
/** CSI C */ cursorForward(params: IParams): boolean;
/** CSI D */ cursorBackward(params: IParams): boolean;
/** CSI E */ cursorNextLine(params: IParams): boolean;
/** CSI F */ cursorPrecedingLine(params: IParams): boolean;
/** CSI G */ cursorCharAbsolute(params: IParams): boolean;
/** CSI H */ cursorPosition(params: IParams): boolean;
/** CSI I */ cursorForwardTab(params: IParams): boolean;
/** CSI J */ eraseInDisplay(params: IParams): boolean;
/** CSI K */ eraseInLine(params: IParams): boolean;
/** CSI L */ insertLines(params: IParams): boolean;
/** CSI M */ deleteLines(params: IParams): boolean;
/** CSI P */ deleteChars(params: IParams): boolean;
/** CSI S */ scrollUp(params: IParams): boolean;
/** CSI T */ scrollDown(params: IParams, collect?: string): boolean;
/** CSI X */ eraseChars(params: IParams): boolean;
/** CSI Z */ cursorBackwardTab(params: IParams): boolean;
/** CSI ` */ charPosAbsolute(params: IParams): boolean;
/** CSI a */ hPositionRelative(params: IParams): boolean;
/** CSI b */ repeatPrecedingCharacter(params: IParams): boolean;
/** CSI c */ sendDeviceAttributesPrimary(params: IParams): boolean;
/** CSI > c */ sendDeviceAttributesSecondary(params: IParams): boolean;
/** CSI d */ linePosAbsolute(params: IParams): boolean;
/** CSI e */ vPositionRelative(params: IParams): boolean;
/** CSI f */ hVPosition(params: IParams): boolean;
/** CSI g */ tabClear(params: IParams): boolean;
/** CSI h */ setMode(params: IParams, collect?: string): boolean;
/** CSI l */ resetMode(params: IParams, collect?: string): boolean;
/** CSI m */ charAttributes(params: IParams): boolean;
/** CSI n */ deviceStatus(params: IParams, collect?: string): boolean;
/** CSI p */ softReset(params: IParams, collect?: string): boolean;
/** CSI q */ setCursorStyle(params: IParams, collect?: string): boolean;
/** CSI r */ setScrollRegion(params: IParams, collect?: string): boolean;
/** CSI s */ saveCursor(params: IParams): boolean;
/** CSI u */ restoreCursor(params: IParams): boolean;
/** CSI ' } */ insertColumns(params: IParams): boolean;
/** CSI ' ~ */ deleteColumns(params: IParams): boolean;
/** OSC 0 */
/** OSC 2 */ setTitle(data: string): boolean;
/** OSC 4 */ setOrReportIndexedColor(data: string): boolean;
/** OSC 10 */ setOrReportFgColor(data: string): boolean;
/** OSC 11 */ setOrReportBgColor(data: string): boolean;
/** OSC 12 */ setOrReportCursorColor(data: string): boolean;
/** OSC 104 */ restoreIndexedColor(data: string): boolean;
/** OSC 110 */ restoreFgColor(data: string): boolean;
/** OSC 111 */ restoreBgColor(data: string): boolean;
/** OSC 112 */ restoreCursorColor(data: string): boolean;
/** ESC E */ nextLine(): boolean;
/** ESC = */ keypadApplicationMode(): boolean;
/** ESC > */ keypadNumericMode(): boolean;
/** ESC % G */
/** ESC % @ */ selectDefaultCharset(): boolean;
/** ESC ( C */
/** ESC ) C */
/** ESC * C */
/** ESC + C */
/** ESC - C */
/** ESC . C */
/** ESC / C */ selectCharset(collectAndFlag: string): boolean;
/** ESC D */ index(): boolean;
/** ESC H */ tabSet(): boolean;
/** ESC M */ reverseIndex(): boolean;
/** ESC c */ fullReset(): boolean;
/** ESC n */
/** ESC o */
/** ESC | */
/** ESC } */
/** ESC ~ */ setgLevel(level: number): boolean;
/** ESC # 8 */ screenAlignmentPattern(): boolean;
}
export interface IParseStack {
paused: boolean;
cursorStartX: number;
cursorStartY: number;
decodedLength: number;
position: number;
}
+4 -1
View File
@@ -8,7 +8,10 @@ import { UnicodeService } from 'common/services/UnicodeService';
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
import { BufferSet } from 'common/buffer/BufferSet';
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData, IOscLinkData, IDisposable, IBufferLine, IExtendedAttrs } from 'common/services/Types';
import type { IAttributeData, IBufferLine, IExtendedAttrs } from 'common/buffer/CellTypes';
import type { ICharset } from 'common/data/Charsets';
import type { IDisposable } from 'common/base/Lifecycle';
import { CoreMouseEventType, ICoreMouseEvent, IDecPrivateModes, IKittyKeyboardState, IModes, IOscLinkData } from 'common/services/Types';
import { UnicodeV6 } from 'common/input/UnicodeV6';
import { IDecorationOptions, IDecoration } from '@xterm/xterm';
import { Emitter, type IEvent } from 'common/base/Event';
+2 -1
View File
@@ -24,7 +24,8 @@
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { IBuffer } from 'common/buffer/Types';
import { CoreTerminal } from 'common/terminal/CoreTerminal';
import { IMarker, ITerminalOptions } from 'common/services/Types';
import type { IMarker } from 'common/buffer/CellTypes';
import type { ITerminalOptions } from 'common/services/Services';
import { Emitter, EventUtils } from 'common/base/Event';
export class Terminal extends CoreTerminal {
+1 -1
View File
@@ -9,7 +9,7 @@ import { UnicodeApi } from 'common/public/UnicodeApi';
import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITerminalAddon, ITerminalInitOnlyOptions, IUnicodeHandling, Terminal as ITerminalApi } from '@xterm/headless';
import { Terminal as TerminalCore } from 'headless/Terminal';
import { AddonManager } from 'common/public/AddonManager';
import { ITerminalOptions } from 'common/services/Types';
import type { ITerminalOptions } from 'common/services/Services';
import { Disposable } from 'common/base/Lifecycle';
import type { IEvent } from 'common/base/Event';
/**
+3 -1
View File
@@ -7,7 +7,9 @@ import { Browser, JSHandle, Page } from '@playwright/test';
import { deepStrictEqual, strictEqual } from 'assert';
import type { IRenderDimensions as IRenderDimensionsInternal } from 'browser/renderer/shared/Types';
import type { IRenderService } from 'browser/services/Services';
import type { ICoreTerminal, IDisposable, IMarker } from 'common/services/Types';
import type { ICoreTerminal } from 'common/terminal/CoreTerminalTypes';
import type { IDisposable } from 'common/base/Lifecycle';
import type { IMarker } from 'common/buffer/CellTypes';
import * as playwright from '@playwright/test';
import { IBuffer, IBufferCell, IBufferLine, IBufferNamespace, IBufferRange, IDecoration, IDecorationOptions, IModes, IRenderDimensions, ITerminalInitOnlyOptions, ITerminalOptions, Terminal } from '@xterm/xterm';