Move CircularList to base and colocate ICircularList

Define ICircularList, IInsertEvent, and IDeleteEvent in common/base/CircularList
instead of common/services/Types. Removes the Types ↔ CircularList cycle and
keeps services from depending on Types for base-layer types.

Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-05-30 17:26:10 +00:00
co-authored by Daniel Imms
parent 3f39edb025
commit 6ff26d2c7e
10 changed files with 36 additions and 36 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IMouseS
import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/shared/Types';
import { IColorSet, ITerminal, ILinkifier2, IBrowser, IViewport, ICompositionHelper, CharacterJoinerHandler, IBufferRange, ReadonlyColorSet, IBufferElementProvider } from 'browser/Types';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener, ICharset, ITerminalOptions, ColorIndex } from 'common/services/Types';
import type { ICircularList } from 'common/base/CircularList';
import { IBufferLine, ICellData, IAttributeData, XtermListener, ICharset, ITerminalOptions, ColorIndex } from 'common/services/Types';
import { Buffer } from 'common/buffer/Buffer';
import * as Browser from 'common/base/Platform';
import { CoreBrowserTerminal } from 'browser/CoreBrowserTerminal';
+2 -2
View File
@@ -42,13 +42,13 @@ flowchart BT
| Project | Role | Notable sources |
| --- | --- | --- |
| `common/base` | Core utilities (lifecycle, events, platform) | `Async`, `Event`, `Lifecycle`, `Platform`, `StringBuilder`, `Version` |
| `common/base` | Core utilities (lifecycle, events, platform) | `Async`, `Event`, `Lifecycle`, `Platform`, `StringBuilder`, `Version`, `CircularList` |
| `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`, `CircularList`, … |
| `common/services` | DI services and shared types | `Services`, `Types`, `Color`, … |
| `common/terminal` | Core terminal + input handler | `CoreTerminal`, `InputHandler`, `WindowsMode` |
| `common/public` | Public API adapters | `AddonManager`, buffer API views |
@@ -4,7 +4,7 @@
*/
import { assert } from 'chai';
import { CircularList } from 'common/services/CircularList';
import { CircularList } from 'common/base/CircularList';
describe('CircularList', () => {
describe('push', () => {
@@ -3,9 +3,8 @@
* @license MIT
*/
import { ICircularList } from 'common/services/Types';
import { Disposable } from 'common/base/Lifecycle';
import { Emitter } from 'common/base/Event';
import { Emitter, type IEvent } from 'common/base/Event';
export interface IInsertEvent {
index: number;
@@ -17,6 +16,28 @@ export interface IDeleteEvent {
amount: number;
}
export interface ICircularList<T> {
length: number;
maxLength: number;
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
recycle(): T;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
/**
* Represents a circular list; a list with a maximum size that wraps around when push is called,
* overriding values at the start of the list.
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { Buffer } from 'common/buffer/Buffer';
import { CircularList } from 'common/services/CircularList';
import { CircularList } from 'common/base/CircularList';
import { MockOptionsService, MockBufferService, MockLogService, createCellData } from 'common/terminal/TestUtils.test';
import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { BufferLineStringCache } from 'common/buffer/BufferLineStringCache';
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { CircularList, IInsertEvent } from 'common/services/CircularList';
import { CircularList, IInsertEvent } from 'common/base/CircularList';
import { Disposable, toDisposable } from 'common/base/Lifecycle';
import { IdleTaskQueue } from 'common/services/TaskQueue';
import { IAttributeData, IBufferLine, ICellData, ICharset } from 'common/services/Types';
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { BufferLine } from 'common/buffer/BufferLine';
import { CircularList } from 'common/services/CircularList';
import { CircularList } from 'common/base/CircularList';
import { IBufferLine, ICellData } from 'common/services/Types';
export interface INewLayoutResult {
+2 -1
View File
@@ -3,7 +3,8 @@
* @license MIT
*/
import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/services/Types';
import type { ICircularList } from 'common/base/CircularList';
import { IAttributeData, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/services/Types';
import type { IEvent } from 'common/base/Event';
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
+2 -2
View File
@@ -3,13 +3,13 @@
* @license MIT
*/
import type { IDeleteEvent, IInsertEvent } from 'common/services/CircularList';
import type { ICircularList, IDeleteEvent, IInsertEvent } from 'common/base/CircularList';
import { MicrotaskTimer } from 'common/base/Async';
import { css } from 'common/services/Color';
import { Disposable, DisposableStore, MutableDisposable, toDisposable } from 'common/base/Lifecycle';
import { IBufferService, IDecorationService, IInternalDecoration, ILogService } from 'common/services/Services';
import { SortedList } from 'common/services/SortedList';
import { IColor, ICircularList } from 'common/services/Types';
import { IColor } from 'common/services/Types';
import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
import { Emitter } from 'common/base/Event';
+1 -24
View File
@@ -3,13 +3,12 @@
* @license MIT
*/
import type { IDeleteEvent, IInsertEvent } from 'common/services/CircularList';
import type { UnderlineStyle } from 'common/buffer/Constants';
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, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
import type { Emitter, IEvent } from 'common/base/Event';
import type { IEvent } from 'common/base/Event';
export type { ICharset } from 'common/data/Charsets';
@@ -64,28 +63,6 @@ export interface IScrollEvent {
position: number;
}
export interface ICircularList<T> {
length: number;
maxLength: number;
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
recycle(): T;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
export const enum KeyboardResultType {
SEND_KEY,
SELECT_ALL,