From 5070a08b58bc0131a40b82d2fdae93c4de52ac8e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 30 May 2026 17:45:15 +0000 Subject: [PATCH] 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 --- addons/addon-image/src/Types.ts | 3 +- addons/addon-serialize/src/SerializeAddon.ts | 3 +- addons/addon-webgl/src/CellColorResolver.ts | 4 +- addons/addon-webgl/src/CharAtlasUtils.test.ts | 4 +- addons/addon-webgl/src/CharAtlasUtils.ts | 2 +- addons/addon-webgl/src/RectangleRenderer.ts | 2 +- addons/addon-webgl/src/TextureAtlas.ts | 4 +- addons/addon-webgl/src/Types.ts | 3 +- addons/addon-webgl/src/WebglRenderer.ts | 2 +- src/browser/ColorContrastCache.ts | 2 +- src/browser/CoreBrowserTerminal.ts | 6 +- src/browser/Linkifier.ts | 2 +- src/browser/OscLinkProvider.test.ts | 3 +- src/browser/OscLinkProvider.ts | 2 +- src/browser/Terminal.test.ts | 2 +- src/browser/TestUtils.test.ts | 8 +- src/browser/Types.ts | 7 +- src/browser/public/Terminal.ts | 2 +- src/browser/renderer/dom/DomRenderer.ts | 2 +- .../dom/DomRendererRowFactory.test.ts | 2 +- .../renderer/dom/DomRendererRowFactory.ts | 5 +- src/browser/renderer/dom/WidthCache.ts | 2 +- src/browser/renderer/shared/Types.ts | 2 +- .../services/CharacterJoinerService.test.ts | 2 +- .../services/CharacterJoinerService.ts | 2 +- src/browser/services/KeyboardService.ts | 2 +- src/browser/services/LinkProviderService.ts | 2 +- src/browser/services/MouseService.ts | 3 +- src/browser/services/SelectionService.test.ts | 2 +- src/browser/services/SelectionService.ts | 3 +- src/browser/services/Services.ts | 4 +- src/browser/services/ThemeService.ts | 5 +- src/browser/tsconfig.json | 3 + src/common/REARCHITECTURE.md | 6 +- src/common/{services => base}/Color.test.ts | 2 +- src/common/{services => base}/Color.ts | 3 +- src/common/base/ColorTypes.ts | 11 + src/common/buffer/AttributeData.ts | 3 +- src/common/buffer/CellTypes.ts | 4 +- src/common/input/WindowOptions.ts | 30 ++ src/common/public/BufferLineApiView.ts | 2 +- src/common/public/BufferNamespaceApi.ts | 2 +- src/common/public/ParserApi.ts | 2 +- src/common/public/UnicodeApi.ts | 2 +- src/common/services/BufferService.ts | 2 +- src/common/services/CharsetService.ts | 2 +- src/common/services/DecorationService.test.ts | 2 +- src/common/services/DecorationService.ts | 4 +- src/common/services/OptionsService.test.ts | 2 +- src/common/services/OptionsService.ts | 3 +- src/common/services/OscLinkService.ts | 3 +- src/common/services/Services.ts | 9 +- src/common/services/Types.ts | 289 +----------------- src/common/terminal/CoreTerminal.ts | 4 +- src/common/terminal/CoreTerminalTypes.ts | 31 ++ src/common/terminal/InputHandler.test.ts | 3 +- src/common/terminal/InputHandler.ts | 5 +- src/common/terminal/InputHandlerTypes.ts | 154 ++++++++++ src/common/terminal/TestUtils.test.ts | 5 +- src/headless/Terminal.ts | 3 +- src/headless/public/Terminal.ts | 2 +- test/playwright/TestUtils.ts | 4 +- 62 files changed, 345 insertions(+), 351 deletions(-) rename src/common/{services => base}/Color.test.ts (99%) rename src/common/{services => base}/Color.ts (99%) create mode 100644 src/common/base/ColorTypes.ts create mode 100644 src/common/input/WindowOptions.ts create mode 100644 src/common/terminal/CoreTerminalTypes.ts create mode 100644 src/common/terminal/InputHandlerTypes.ts diff --git a/addons/addon-image/src/Types.ts b/addons/addon-image/src/Types.ts index 8c0e94783..73b3e337f 100644 --- a/addons/addon-image/src/Types.ts +++ b/addons/addon-image/src/Types.ts @@ -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'; diff --git a/addons/addon-serialize/src/SerializeAddon.ts b/addons/addon-serialize/src/SerializeAddon.ts index 64ce9d0a8..109874690 100644 --- a/addons/addon-serialize/src/SerializeAddon.ts +++ b/addons/addon-serialize/src/SerializeAddon.ts @@ -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'; diff --git a/addons/addon-webgl/src/CellColorResolver.ts b/addons/addon-webgl/src/CellColorResolver.ts index dea062c10..1f51d55fe 100644 --- a/addons/addon-webgl/src/CellColorResolver.ts +++ b/addons/addon-webgl/src/CellColorResolver.ts @@ -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'; diff --git a/addons/addon-webgl/src/CharAtlasUtils.test.ts b/addons/addon-webgl/src/CharAtlasUtils.test.ts index b223b9b6f..dbce6dbc7 100644 --- a/addons/addon-webgl/src/CharAtlasUtils.test.ts +++ b/addons/addon-webgl/src/CharAtlasUtils.test.ts @@ -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 { const color: IColor = { css: '#ffffff', rgba: 0xffffffff }; diff --git a/addons/addon-webgl/src/CharAtlasUtils.ts b/addons/addon-webgl/src/CharAtlasUtils.ts index b0a6e5430..78f88b61e 100644 --- a/addons/addon-webgl/src/CharAtlasUtils.ts +++ b/addons/addon-webgl/src/CharAtlasUtils.ts @@ -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, colors: ReadonlyColorSet, devicePixelRatio: number, deviceMaxTextureSize: number, customGlyphs: boolean = true): ICharAtlasConfig { // null out some fields that don't matter diff --git a/addons/addon-webgl/src/RectangleRenderer.ts b/addons/addon-webgl/src/RectangleRenderer.ts index 64927e279..e7155a8cd 100644 --- a/addons/addon-webgl/src/RectangleRenderer.ts +++ b/addons/addon-webgl/src/RectangleRenderer.ts @@ -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'; diff --git a/addons/addon-webgl/src/TextureAtlas.ts b/addons/addon-webgl/src/TextureAtlas.ts index a185d4ff1..b2d786e8a 100644 --- a/addons/addon-webgl/src/TextureAtlas.ts +++ b/addons/addon-webgl/src/TextureAtlas.ts @@ -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'; diff --git a/addons/addon-webgl/src/Types.ts b/addons/addon-webgl/src/Types.ts index 946088644..d20410d50 100644 --- a/addons/addon-webgl/src/Types.ts +++ b/addons/addon-webgl/src/Types.ts @@ -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 { diff --git a/addons/addon-webgl/src/WebglRenderer.ts b/addons/addon-webgl/src/WebglRenderer.ts index 3ffcd2fb0..38816d094 100644 --- a/addons/addon-webgl/src/WebglRenderer.ts +++ b/addons/addon-webgl/src/WebglRenderer.ts @@ -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'; diff --git a/src/browser/ColorContrastCache.ts b/src/browser/ColorContrastCache.ts index 478577e58..22b1dc49f 100644 --- a/src/browser/ColorContrastCache.ts +++ b/src/browser/ColorContrastCache.ts @@ -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 { diff --git a/src/browser/CoreBrowserTerminal.ts b/src/browser/CoreBrowserTerminal.ts index 5520dc69d..baf574241 100644 --- a/src/browser/CoreBrowserTerminal.ts +++ b/src/browser/CoreBrowserTerminal.ts @@ -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'; diff --git a/src/browser/Linkifier.ts b/src/browser/Linkifier.ts index 94bd3d644..40262bdcc 100644 --- a/src/browser/Linkifier.ts +++ b/src/browser/Linkifier.ts @@ -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'; diff --git a/src/browser/OscLinkProvider.test.ts b/src/browser/OscLinkProvider.test.ts index d4deeddef..dfd7c7cd2 100644 --- a/src/browser/OscLinkProvider.test.ts +++ b/src/browser/OscLinkProvider.test.ts @@ -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; diff --git a/src/browser/OscLinkProvider.ts b/src/browser/OscLinkProvider.ts index 8e2ef3de4..02dcf7380 100644 --- a/src/browser/OscLinkProvider.ts +++ b/src/browser/OscLinkProvider.ts @@ -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 { diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 2a129a88a..6bcc200ac 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -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; diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 1617062dc..8427bbcef 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -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'; diff --git a/src/browser/Types.ts b/src/browser/Types.ts index 734699831..49eaac929 100644 --- a/src/browser/Types.ts +++ b/src/browser/Types.ts @@ -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'; /** diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 4aa67b765..6c48195a0 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -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'; diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index dee7a8547..7e9b8a689 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -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'; diff --git a/src/browser/renderer/dom/DomRendererRowFactory.test.ts b/src/browser/renderer/dom/DomRendererRowFactory.test.ts index 50628e10d..17e576b54 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.test.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.test.ts @@ -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'; diff --git a/src/browser/renderer/dom/DomRendererRowFactory.ts b/src/browser/renderer/dom/DomRendererRowFactory.ts index b35d80f7f..537830630 100644 --- a/src/browser/renderer/dom/DomRendererRowFactory.ts +++ b/src/browser/renderer/dom/DomRendererRowFactory.ts @@ -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'; diff --git a/src/browser/renderer/dom/WidthCache.ts b/src/browser/renderer/dom/WidthCache.ts index 52557976c..8d4c2e00e 100644 --- a/src/browser/renderer/dom/WidthCache.ts +++ b/src/browser/renderer/dom/WidthCache.ts @@ -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'; diff --git a/src/browser/renderer/shared/Types.ts b/src/browser/renderer/shared/Types.ts index ed4f908bd..dd7eb970e 100644 --- a/src/browser/renderer/shared/Types.ts +++ b/src/browser/renderer/shared/Types.ts @@ -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 { diff --git a/src/browser/services/CharacterJoinerService.test.ts b/src/browser/services/CharacterJoinerService.test.ts index 46e3f7b25..6d69a6cf4 100644 --- a/src/browser/services/CharacterJoinerService.test.ts +++ b/src/browser/services/CharacterJoinerService.test.ts @@ -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'; diff --git a/src/browser/services/CharacterJoinerService.ts b/src/browser/services/CharacterJoinerService.ts index 69b74526d..5b401a62c 100644 --- a/src/browser/services/CharacterJoinerService.ts +++ b/src/browser/services/CharacterJoinerService.ts @@ -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'; diff --git a/src/browser/services/KeyboardService.ts b/src/browser/services/KeyboardService.ts index 1782288ce..80f49059e 100644 --- a/src/browser/services/KeyboardService.ts +++ b/src/browser/services/KeyboardService.ts @@ -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; diff --git a/src/browser/services/LinkProviderService.ts b/src/browser/services/LinkProviderService.ts index 867a1747c..ca92ebdd4 100644 --- a/src/browser/services/LinkProviderService.ts +++ b/src/browser/services/LinkProviderService.ts @@ -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; diff --git a/src/browser/services/MouseService.ts b/src/browser/services/MouseService.ts index b2600197c..7b37bc080 100644 --- a/src/browser/services/MouseService.ts +++ b/src/browser/services/MouseService.ts @@ -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'; diff --git a/src/browser/services/SelectionService.test.ts b/src/browser/services/SelectionService.test.ts index 2d8e2ef29..236865f5b 100644 --- a/src/browser/services/SelectionService.test.ts +++ b/src/browser/services/SelectionService.test.ts @@ -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'; diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index ac92bc779..e16495bb3 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -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'; diff --git a/src/browser/services/Services.ts b/src/browser/services/Services.ts index 748a408f2..fb1724ef6 100644 --- a/src/browser/services/Services.ts +++ b/src/browser/services/Services.ts @@ -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('CharSizeService'); diff --git a/src/browser/services/ThemeService.ts b/src/browser/services/ThemeService.ts index acf17754e..ba08d0430 100644 --- a/src/browser/services/ThemeService.ts +++ b/src/browser/services/ThemeService.ts @@ -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 { diff --git a/src/browser/tsconfig.json b/src/browser/tsconfig.json index ff5bf6ad7..22b55efeb 100644 --- a/src/browser/tsconfig.json +++ b/src/browser/tsconfig.json @@ -19,6 +19,9 @@ "./**/*", "../../typings/xterm.d.ts" ], + "exclude": [ + "**/*.test.ts" + ], "references": [ { "path": "../common" } ] diff --git a/src/common/REARCHITECTURE.md b/src/common/REARCHITECTURE.md index b11b5a36e..1c008add4 100644 --- a/src/common/REARCHITECTURE.md +++ b/src/common/REARCHITECTURE.md @@ -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 diff --git a/src/common/services/Color.test.ts b/src/common/base/Color.test.ts similarity index 99% rename from src/common/services/Color.test.ts rename to src/common/base/Color.test.ts index fc285ff45..478128a63 100644 --- a/src/common/services/Color.test.ts +++ b/src/common/base/Color.test.ts @@ -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', () => { diff --git a/src/common/services/Color.ts b/src/common/base/Color.ts similarity index 99% rename from src/common/services/Color.ts rename to src/common/base/Color.ts index 5158da752..bd3d54ecb 100644 --- a/src/common/services/Color.ts +++ b/src/common/base/Color.ts @@ -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; diff --git a/src/common/base/ColorTypes.ts b/src/common/base/ColorTypes.ts new file mode 100644 index 000000000..7a32cfe22 --- /dev/null +++ b/src/common/base/ColorTypes.ts @@ -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]; diff --git a/src/common/buffer/AttributeData.ts b/src/common/buffer/AttributeData.ts index 8d94cc052..0f4b2ba96 100644 --- a/src/common/buffer/AttributeData.ts +++ b/src/common/buffer/AttributeData.ts @@ -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 { diff --git a/src/common/buffer/CellTypes.ts b/src/common/buffer/CellTypes.ts index c8a56b67b..223960d81 100644 --- a/src/common/buffer/CellTypes.ts +++ b/src/common/buffer/CellTypes.ts @@ -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; diff --git a/src/common/input/WindowOptions.ts b/src/common/input/WindowOptions.ts new file mode 100644 index 000000000..e84f5dfdb --- /dev/null +++ b/src/common/input/WindowOptions.ts @@ -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; +} diff --git a/src/common/public/BufferLineApiView.ts b/src/common/public/BufferLineApiView.ts index ecd5c3cf9..ac9de2eb0 100644 --- a/src/common/public/BufferLineApiView.ts +++ b/src/common/public/BufferLineApiView.ts @@ -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 { diff --git a/src/common/public/BufferNamespaceApi.ts b/src/common/public/BufferNamespaceApi.ts index 4bac17b08..806364aff 100644 --- a/src/common/public/BufferNamespaceApi.ts +++ b/src/common/public/BufferNamespaceApi.ts @@ -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'; diff --git a/src/common/public/ParserApi.ts b/src/common/public/ParserApi.ts index 8ad665c78..82fad9c24 100644 --- a/src/common/public/ParserApi.ts +++ b/src/common/public/ParserApi.ts @@ -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) { } diff --git a/src/common/public/UnicodeApi.ts b/src/common/public/UnicodeApi.ts index e2c6e523d..1ca570e6f 100644 --- a/src/common/public/UnicodeApi.ts +++ b/src/common/public/UnicodeApi.ts @@ -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 { diff --git a/src/common/services/BufferService.ts b/src/common/services/BufferService.ts index 862459002..9603ead6f 100644 --- a/src/common/services/BufferService.ts +++ b/src/common/services/BufferService.ts @@ -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'; diff --git a/src/common/services/CharsetService.ts b/src/common/services/CharsetService.ts index 5e987409e..9f65b8b3c 100644 --- a/src/common/services/CharsetService.ts +++ b/src/common/services/CharsetService.ts @@ -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; diff --git a/src/common/services/DecorationService.test.ts b/src/common/services/DecorationService.test.ts index 3ad0debca..4d1dd90af 100644 --- a/src/common/services/DecorationService.test.ts +++ b/src/common/services/DecorationService.test.ts @@ -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'; diff --git a/src/common/services/DecorationService.ts b/src/common/services/DecorationService.ts index a86eb5018..133900ff8 100644 --- a/src/common/services/DecorationService.ts +++ b/src/common/services/DecorationService.ts @@ -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'; diff --git a/src/common/services/OptionsService.test.ts b/src/common/services/OptionsService.test.ts index 6f5e7b4b0..fe79f4efb 100644 --- a/src/common/services/OptionsService.test.ts +++ b/src/common/services/OptionsService.test.ts @@ -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', () => { diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index c2dc22978..307e20fff 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -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'; diff --git a/src/common/services/OscLinkService.ts b/src/common/services/OscLinkService.ts index 11f8ec351..0e53b6101 100644 --- a/src/common/services/OscLinkService.ts +++ b/src/common/services/OscLinkService.ts @@ -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; diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 62473566d..7dcf4a728 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -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 { diff --git a/src/common/services/Types.ts b/src/common/services/Types.ts index 9d9b39019..1f8d3ed59 100644 --- a/src/common/services/Types.ts +++ b/src/common/services/Types.ts @@ -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; - registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; - registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; - registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; - registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; - registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise): 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 = Acc['length'] extends N - ? Acc[number] - : Enumerate; -type IntRange = Exclude, Enumerate>; - -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; - - parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise; - print(data: Uint32Array, start: number, end: number): void; - registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; - registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; - registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; - registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; - registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise): 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; -} diff --git a/src/common/terminal/CoreTerminal.ts b/src/common/terminal/CoreTerminal.ts index 40fdf337f..48f628e10 100644 --- a/src/common/terminal/CoreTerminal.ts +++ b/src/common/terminal/CoreTerminal.ts @@ -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'; diff --git a/src/common/terminal/CoreTerminalTypes.ts b/src/common/terminal/CoreTerminalTypes.ts new file mode 100644 index 000000000..3a6d6b4a8 --- /dev/null +++ b/src/common/terminal/CoreTerminalTypes.ts @@ -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; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; + registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; + registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise): IDisposable; +} + +export interface IScrollEvent { + position: number; +} + +export type XtermListener = (...args: any[]) => void; diff --git a/src/common/terminal/InputHandler.test.ts b/src/common/terminal/InputHandler.test.ts index 6e6de639c..ea752dd83 100644 --- a/src/common/terminal/InputHandler.test.ts +++ b/src/common/terminal/InputHandler.test.ts @@ -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'; diff --git a/src/common/terminal/InputHandler.ts b/src/common/terminal/InputHandler.ts index a739fdbf3..80c141fe8 100644 --- a/src/common/terminal/InputHandler.ts +++ b/src/common/terminal/InputHandler.ts @@ -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'; diff --git a/src/common/terminal/InputHandlerTypes.ts b/src/common/terminal/InputHandlerTypes.ts new file mode 100644 index 000000000..593f08ef0 --- /dev/null +++ b/src/common/terminal/InputHandlerTypes.ts @@ -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 = Acc['length'] extends N + ? Acc[number] + : Enumerate; +type IntRange = Exclude, Enumerate>; + +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; + + parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise; + print(data: Uint32Array, start: number, end: number): void; + registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise): IDisposable; + registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise): IDisposable; + registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise): IDisposable; + registerOscHandler(ident: number, callback: (data: string) => boolean | Promise): IDisposable; + registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise): 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; +} diff --git a/src/common/terminal/TestUtils.test.ts b/src/common/terminal/TestUtils.test.ts index c2c6c1321..198993d87 100644 --- a/src/common/terminal/TestUtils.test.ts +++ b/src/common/terminal/TestUtils.test.ts @@ -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'; diff --git a/src/headless/Terminal.ts b/src/headless/Terminal.ts index ba49af1cd..f0e873850 100644 --- a/src/headless/Terminal.ts +++ b/src/headless/Terminal.ts @@ -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 { diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index eecabb013..08616d952 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -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'; /** diff --git a/test/playwright/TestUtils.ts b/test/playwright/TestUtils.ts index eaa418db6..b2cdbb20c 100644 --- a/test/playwright/TestUtils.ts +++ b/test/playwright/TestUtils.ts @@ -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';