Move custom mouse event handler into MouseStateService

Don't need to keep it in CoreBrowserTerminal
This commit is contained in:
Daniel Imms
2026-03-11 10:36:35 +09:00
parent 2331abe6bd
commit d63445be94
7 changed files with 25 additions and 18 deletions
+2
View File
@@ -82,6 +82,8 @@ export class MockMouseStateService implements IMouseStateService {
public consumeWheelEvent(ev: WheelEvent, cellHeight: number, dpr: number): number {
return 1;
}
public setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void { }
public allowCustomWheelEvent(ev: WheelEvent): boolean { return true; }
}
export class MockCharsetService implements ICharsetService {
+9
View File
@@ -175,6 +175,7 @@ export class MouseStateService extends Disposable implements IMouseStateService
private _activeEncoding: string = '';
private _lastEvent: ICoreMouseEvent | null = null;
private _wheelPartialScroll: number = 0;
private _customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined;
private readonly _onProtocolChange = this._register(new Emitter<CoreMouseEventType>());
public readonly onProtocolChange = this._onProtocolChange.event;
@@ -268,6 +269,14 @@ export class MouseStateService extends Disposable implements IMouseStateService
return amount;
}
public setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void {
this._customWheelEventHandler = customWheelEventHandler;
}
public allowCustomWheelEvent(ev: WheelEvent): boolean {
return this._customWheelEventHandler ? this._customWheelEventHandler(ev) !== false : true;
}
private _applyScrollModifier(amount: number, ev: WheelEvent): number {
// Multiply the scroll speed when the modifier key is pressed
if (ev.altKey || ev.ctrlKey || ev.shiftKey) {
+10
View File
@@ -70,6 +70,16 @@ export interface IMouseStateService {
* Process wheel event taking partial scroll into account.
*/
consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number;
/**
* Sets a custom wheel event handler that can veto wheel processing.
*/
setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void;
/**
* Checks whether a wheel event should be processed.
*/
allowCustomWheelEvent(ev: WheelEvent): boolean;
}
export const ICoreService = createDecorator<ICoreService>('CoreService');