Rename CoreMouseService to MouseStateService

Part of #5756
This commit is contained in:
Daniel Imms
2026-03-11 10:31:57 +09:00
parent b66128b239
commit 2331abe6bd
15 changed files with 93 additions and 93 deletions
@@ -2,7 +2,7 @@
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { CoreMouseService } from 'common/services/CoreMouseService';
import { MouseStateService } from 'common/services/MouseStateService';
import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test';
import { assert } from 'chai';
import { ICoreMouseEvent, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
@@ -23,22 +23,22 @@ function toBytes(s: string | undefined): number[] {
return res;
}
describe('CoreMouseService', () => {
describe('MouseStateService', () => {
it('init', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
assert.equal(cms.activeEncoding, 'DEFAULT');
assert.equal(cms.activeProtocol, 'NONE');
});
it('default protocols - NONE, X10, VT200, DRAG, ANY', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
assert.deepEqual(Object.keys((cms as any)._protocols), ['NONE', 'X10', 'VT200', 'DRAG', 'ANY']);
});
it('default encodings - DEFAULT, SGR', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
assert.deepEqual(Object.keys((cms as any)._encodings), ['DEFAULT', 'SGR', 'SGR_PIXELS']);
});
it('protocol/encoding setter, reset', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
cms.activeEncoding = 'SGR';
cms.activeProtocol = 'ANY';
assert.equal(cms.activeEncoding, 'SGR');
@@ -50,19 +50,19 @@ describe('CoreMouseService', () => {
assert.throws(() => { cms.activeProtocol = 'xyz'; }, 'unknown protocol "xyz"');
});
it('addEncoding', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
cms.addEncoding('XYZ', (e: ICoreMouseEvent) => '');
cms.activeEncoding = 'XYZ';
assert.equal(cms.activeEncoding, 'XYZ');
});
it('addProtocol', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
cms.addProtocol('XYZ', { events: CoreMouseEventType.NONE, restrict: (e: ICoreMouseEvent) => false });
cms.activeProtocol = 'XYZ';
assert.equal(cms.activeProtocol, 'XYZ');
});
it('onProtocolChange', () => {
const cms = new CoreMouseService(bufferService, coreService, optionsService);
const cms = new MouseStateService(bufferService, coreService, optionsService);
const wantedEvents: CoreMouseEventType[] = [];
cms.onProtocolChange(events => wantedEvents.push(events));
cms.activeProtocol = 'NONE';
@@ -74,10 +74,10 @@ describe('CoreMouseService', () => {
]);
});
describe('triggerMouseEvent', () => {
let cms: CoreMouseService;
let cms: MouseStateService;
let reports: string[];
beforeEach(() => {
cms = new CoreMouseService(bufferService, coreService, optionsService);
cms = new MouseStateService(bufferService, coreService, optionsService);
reports = [];
coreService.triggerDataEvent = (data: string, userInput?: boolean) => reports.push(data);
coreService.triggerBinaryEvent = (data: string) => reports.push(data);
@@ -2,7 +2,7 @@
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IBufferService, ICoreService, ICoreMouseService, IOptionsService } from 'common/services/Services';
import { IBufferService, ICoreService, IMouseStateService, IOptionsService } from 'common/services/Services';
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
import { Disposable } from 'common/Lifecycle';
import { Emitter } from 'common/Event';
@@ -151,7 +151,7 @@ const DEFAULT_ENCODINGS: { [key: string]: CoreMouseEncoding } = {
};
/**
* CoreMouseService
* MouseStateService
*
* Provides mouse tracking reports with different protocols and encodings.
* - protocols: NONE (default), X10, VT200, DRAG, ANY
@@ -166,7 +166,7 @@ const DEFAULT_ENCODINGS: { [key: string]: CoreMouseEncoding } = {
* a tracking report to the backend based on protocol and encoding limitations.
* To send a mouse event call `triggerMouseEvent`.
*/
export class CoreMouseService extends Disposable implements ICoreMouseService {
export class MouseStateService extends Disposable implements IMouseStateService {
public serviceBrand: any;
private _protocols: { [name: string]: ICoreMouseProtocol } = {};
+2 -2
View File
@@ -33,8 +33,8 @@ export interface IBufferResizeEvent {
rowsChanged: boolean;
}
export const ICoreMouseService = createDecorator<ICoreMouseService>('CoreMouseService');
export interface ICoreMouseService {
export const IMouseStateService = createDecorator<IMouseStateService>('MouseStateService');
export interface IMouseStateService {
serviceBrand: undefined;
activeProtocol: string;