Move over to vs disposables
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import * as Strings from 'browser/LocalizableStrings';
|
||||
import { ITerminal, IRenderDebouncer } from 'browser/Types';
|
||||
import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
||||
import { IBuffer } from 'common/buffer/Types';
|
||||
import { IInstantiationService } from 'common/services/Services';
|
||||
@@ -82,7 +82,7 @@ export class AccessibilityManager extends Disposable {
|
||||
this._liveRegion.classList.add('live-region');
|
||||
this._liveRegion.setAttribute('aria-live', 'assertive');
|
||||
this._accessibilityContainer.appendChild(this._liveRegion);
|
||||
this._liveRegionDebouncer = this.register(new TimeBasedDebouncer(this._renderRows.bind(this)));
|
||||
this._liveRegionDebouncer = this._register(new TimeBasedDebouncer(this._renderRows.bind(this)));
|
||||
|
||||
if (!this._terminal.element) {
|
||||
throw new Error('Cannot enable accessibility before Terminal.open');
|
||||
@@ -105,22 +105,22 @@ export class AccessibilityManager extends Disposable {
|
||||
this._terminal.element.insertAdjacentElement('afterbegin', this._accessibilityContainer);
|
||||
}
|
||||
|
||||
this.register(this._terminal.onResize(e => this._handleResize(e.rows)));
|
||||
this.register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));
|
||||
this.register(this._terminal.onScroll(() => this._refreshRows()));
|
||||
this._register(this._terminal.onResize(e => this._handleResize(e.rows)));
|
||||
this._register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));
|
||||
this._register(this._terminal.onScroll(() => this._refreshRows()));
|
||||
// Line feed is an issue as the prompt won't be read out after a command is run
|
||||
this.register(this._terminal.onA11yChar(char => this._handleChar(char)));
|
||||
this.register(this._terminal.onLineFeed(() => this._handleChar('\n')));
|
||||
this.register(this._terminal.onA11yTab(spaceCount => this._handleTab(spaceCount)));
|
||||
this.register(this._terminal.onKey(e => this._handleKey(e.key)));
|
||||
this.register(this._terminal.onBlur(() => this._clearLiveRegion()));
|
||||
this.register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions()));
|
||||
this.register(addDisposableListener(doc, 'selectionchange', () => this._handleSelectionChange()));
|
||||
this.register(this._coreBrowserService.onDprChange(() => this._refreshRowsDimensions()));
|
||||
this._register(this._terminal.onA11yChar(char => this._handleChar(char)));
|
||||
this._register(this._terminal.onLineFeed(() => this._handleChar('\n')));
|
||||
this._register(this._terminal.onA11yTab(spaceCount => this._handleTab(spaceCount)));
|
||||
this._register(this._terminal.onKey(e => this._handleKey(e.key)));
|
||||
this._register(this._terminal.onBlur(() => this._clearLiveRegion()));
|
||||
this._register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions()));
|
||||
this._register(addDisposableListener(doc, 'selectionchange', () => this._handleSelectionChange()));
|
||||
this._register(this._coreBrowserService.onDprChange(() => this._refreshRowsDimensions()));
|
||||
|
||||
this._refreshRowsDimensions();
|
||||
this._refreshRows();
|
||||
this.register(toDisposable(() => {
|
||||
this._register(toDisposable(() => {
|
||||
if (DEBUG) {
|
||||
this._debugRootContainer!.remove();
|
||||
} else {
|
||||
|
||||
@@ -43,7 +43,6 @@ import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, ILinkPr
|
||||
import { ThemeService } from 'browser/services/ThemeService';
|
||||
import { channels, color } from 'common/Color';
|
||||
import { CoreTerminal } from 'common/CoreTerminal';
|
||||
import { toDisposable } from 'common/Lifecycle';
|
||||
import * as Browser from 'common/Platform';
|
||||
import { ColorRequestType, CoreMouseAction, CoreMouseButton, CoreMouseEventType, IColorEvent, ITerminalOptions, KeyboardResultType, SpecialColorIndex } from 'common/Types';
|
||||
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||
@@ -58,7 +57,7 @@ import { AccessibilityManager } from './AccessibilityManager';
|
||||
import { Linkifier } from './Linkifier';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { addDisposableListener } from 'vs/base/browser/dom';
|
||||
import { MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
public textarea: HTMLTextAreaElement | undefined;
|
||||
@@ -120,30 +119,30 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
private _unprocessedDeadKey: boolean = false;
|
||||
|
||||
private _compositionHelper: ICompositionHelper | undefined;
|
||||
private _accessibilityManager: MutableDisposable<AccessibilityManager> = this.register(new MutableDisposable());
|
||||
private _accessibilityManager: MutableDisposable<AccessibilityManager> = this._register(new MutableDisposable());
|
||||
|
||||
private readonly _onCursorMove = this.register(new Emitter<void>());
|
||||
private readonly _onCursorMove = this._register(new Emitter<void>());
|
||||
public readonly onCursorMove = this._onCursorMove.event;
|
||||
private readonly _onKey = this.register(new Emitter<{ key: string, domEvent: KeyboardEvent }>());
|
||||
private readonly _onKey = this._register(new Emitter<{ key: string, domEvent: KeyboardEvent }>());
|
||||
public readonly onKey = this._onKey.event;
|
||||
private readonly _onRender = this.register(new Emitter<{ start: number, end: number }>());
|
||||
private readonly _onRender = this._register(new Emitter<{ start: number, end: number }>());
|
||||
public readonly onRender = this._onRender.event;
|
||||
private readonly _onSelectionChange = this.register(new Emitter<void>());
|
||||
private readonly _onSelectionChange = this._register(new Emitter<void>());
|
||||
public readonly onSelectionChange = this._onSelectionChange.event;
|
||||
private readonly _onTitleChange = this.register(new Emitter<string>());
|
||||
private readonly _onTitleChange = this._register(new Emitter<string>());
|
||||
public readonly onTitleChange = this._onTitleChange.event;
|
||||
private readonly _onBell = this.register(new Emitter<void>());
|
||||
private readonly _onBell = this._register(new Emitter<void>());
|
||||
public readonly onBell = this._onBell.event;
|
||||
|
||||
private _onFocus = this.register(new Emitter<void>());
|
||||
private _onFocus = this._register(new Emitter<void>());
|
||||
public get onFocus(): Event<void> { return this._onFocus.event; }
|
||||
private _onBlur = this.register(new Emitter<void>());
|
||||
private _onBlur = this._register(new Emitter<void>());
|
||||
public get onBlur(): Event<void> { return this._onBlur.event; }
|
||||
private _onA11yCharEmitter = this.register(new Emitter<string>());
|
||||
private _onA11yCharEmitter = this._register(new Emitter<string>());
|
||||
public get onA11yChar(): Event<string> { return this._onA11yCharEmitter.event; }
|
||||
private _onA11yTabEmitter = this.register(new Emitter<number>());
|
||||
private _onA11yTabEmitter = this._register(new Emitter<number>());
|
||||
public get onA11yTab(): Event<number> { return this._onA11yTabEmitter.event; }
|
||||
private _onWillOpen = this.register(new Emitter<HTMLElement>());
|
||||
private _onWillOpen = this._register(new Emitter<HTMLElement>());
|
||||
public get onWillOpen(): Event<HTMLElement> { return this._onWillOpen.event; }
|
||||
|
||||
constructor(
|
||||
@@ -160,21 +159,21 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(OscLinkProvider));
|
||||
|
||||
// Setup InputHandler listeners
|
||||
this.register(this._inputHandler.onRequestBell(() => this._onBell.fire()));
|
||||
this.register(this._inputHandler.onRequestRefreshRows((e) => this.refresh(e?.start ?? 0, e?.end ?? (this.rows - 1))));
|
||||
this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus()));
|
||||
this.register(this._inputHandler.onRequestReset(() => this.reset()));
|
||||
this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type)));
|
||||
this.register(this._inputHandler.onColor((event) => this._handleColorEvent(event)));
|
||||
this.register(Event.forward(this._inputHandler.onCursorMove, this._onCursorMove));
|
||||
this.register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
|
||||
this.register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
|
||||
this.register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
|
||||
this._register(this._inputHandler.onRequestBell(() => this._onBell.fire()));
|
||||
this._register(this._inputHandler.onRequestRefreshRows((e) => this.refresh(e?.start ?? 0, e?.end ?? (this.rows - 1))));
|
||||
this._register(this._inputHandler.onRequestSendFocus(() => this._reportFocus()));
|
||||
this._register(this._inputHandler.onRequestReset(() => this.reset()));
|
||||
this._register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type)));
|
||||
this._register(this._inputHandler.onColor((event) => this._handleColorEvent(event)));
|
||||
this._register(Event.forward(this._inputHandler.onCursorMove, this._onCursorMove));
|
||||
this._register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
|
||||
this._register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
|
||||
this._register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
|
||||
|
||||
// Setup listeners
|
||||
this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows)));
|
||||
this._register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows)));
|
||||
|
||||
this.register(toDisposable(() => {
|
||||
this._register(toDisposable(() => {
|
||||
this._customKeyEventHandler = undefined;
|
||||
this.element?.parentNode?.removeChild(this.element);
|
||||
}));
|
||||
@@ -331,7 +330,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
this._bindKeys();
|
||||
|
||||
// Bind clipboard functionality
|
||||
this.register(addDisposableListener(this.element!, 'copy', (event: ClipboardEvent) => {
|
||||
this._register(addDisposableListener(this.element!, 'copy', (event: ClipboardEvent) => {
|
||||
// If mouse events are active it means the selection manager is disabled and
|
||||
// copy should be handled by the host program.
|
||||
if (!this.hasSelection()) {
|
||||
@@ -340,19 +339,19 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
copyHandler(event, this._selectionService!);
|
||||
}));
|
||||
const pasteHandlerWrapper = (event: ClipboardEvent): void => handlePasteEvent(event, this.textarea!, this.coreService, this.optionsService);
|
||||
this.register(addDisposableListener(this.textarea!, 'paste', pasteHandlerWrapper));
|
||||
this.register(addDisposableListener(this.element!, 'paste', pasteHandlerWrapper));
|
||||
this._register(addDisposableListener(this.textarea!, 'paste', pasteHandlerWrapper));
|
||||
this._register(addDisposableListener(this.element!, 'paste', pasteHandlerWrapper));
|
||||
|
||||
// Handle right click context menus
|
||||
if (Browser.isFirefox) {
|
||||
// Firefox doesn't appear to fire the contextmenu event on right click
|
||||
this.register(addDisposableListener(this.element!, 'mousedown', (event: MouseEvent) => {
|
||||
this._register(addDisposableListener(this.element!, 'mousedown', (event: MouseEvent) => {
|
||||
if (event.button === 2) {
|
||||
rightClickHandler(event, this.textarea!, this.screenElement!, this._selectionService!, this.options.rightClickSelectsWord);
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
this.register(addDisposableListener(this.element!, 'contextmenu', (event: MouseEvent) => {
|
||||
this._register(addDisposableListener(this.element!, 'contextmenu', (event: MouseEvent) => {
|
||||
rightClickHandler(event, this.textarea!, this.screenElement!, this._selectionService!, this.options.rightClickSelectsWord);
|
||||
}));
|
||||
}
|
||||
@@ -363,7 +362,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
if (Browser.isLinux) {
|
||||
// Use auxclick event over mousedown the latter doesn't seem to work. Note
|
||||
// that the regular click event doesn't fire for the middle mouse button.
|
||||
this.register(addDisposableListener(this.element!, 'auxclick', (event: MouseEvent) => {
|
||||
this._register(addDisposableListener(this.element!, 'auxclick', (event: MouseEvent) => {
|
||||
if (event.button === 1) {
|
||||
moveTextAreaUnderMouseCursor(event, this.textarea!, this.screenElement!);
|
||||
}
|
||||
@@ -375,14 +374,14 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
* Apply key handling to the terminal
|
||||
*/
|
||||
private _bindKeys(): void {
|
||||
this.register(addDisposableListener(this.textarea!, 'keyup', (ev: KeyboardEvent) => this._keyUp(ev), true));
|
||||
this.register(addDisposableListener(this.textarea!, 'keydown', (ev: KeyboardEvent) => this._keyDown(ev), true));
|
||||
this.register(addDisposableListener(this.textarea!, 'keypress', (ev: KeyboardEvent) => this._keyPress(ev), true));
|
||||
this.register(addDisposableListener(this.textarea!, 'compositionstart', () => this._compositionHelper!.compositionstart()));
|
||||
this.register(addDisposableListener(this.textarea!, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper!.compositionupdate(e)));
|
||||
this.register(addDisposableListener(this.textarea!, 'compositionend', () => this._compositionHelper!.compositionend()));
|
||||
this.register(addDisposableListener(this.textarea!, 'input', (ev: InputEvent) => this._inputEvent(ev), true));
|
||||
this.register(this.onRender(() => this._compositionHelper!.updateCompositionElements()));
|
||||
this._register(addDisposableListener(this.textarea!, 'keyup', (ev: KeyboardEvent) => this._keyUp(ev), true));
|
||||
this._register(addDisposableListener(this.textarea!, 'keydown', (ev: KeyboardEvent) => this._keyDown(ev), true));
|
||||
this._register(addDisposableListener(this.textarea!, 'keypress', (ev: KeyboardEvent) => this._keyPress(ev), true));
|
||||
this._register(addDisposableListener(this.textarea!, 'compositionstart', () => this._compositionHelper!.compositionstart()));
|
||||
this._register(addDisposableListener(this.textarea!, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper!.compositionupdate(e)));
|
||||
this._register(addDisposableListener(this.textarea!, 'compositionend', () => this._compositionHelper!.compositionend()));
|
||||
this._register(addDisposableListener(this.textarea!, 'input', (ev: InputEvent) => this._inputEvent(ev), true));
|
||||
this._register(this.onRender(() => this._compositionHelper!.updateCompositionElements()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,7 +428,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
|
||||
this.screenElement = this._document.createElement('div');
|
||||
this.screenElement.classList.add('xterm-screen');
|
||||
this.register(addDisposableListener(this.screenElement, 'mousemove', (ev: MouseEvent) => this.updateCursorStyle(ev)));
|
||||
this._register(addDisposableListener(this.screenElement, 'mousemove', (ev: MouseEvent) => this.updateCursorStyle(ev)));
|
||||
// Create the container that will hold helpers like the textarea for
|
||||
// capturing DOM Events. Then produce the helpers.
|
||||
this._helperContainer = this._document.createElement('div');
|
||||
@@ -452,7 +451,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
|
||||
// Register the core browser service before the generic textarea handlers are registered so it
|
||||
// handles them first. Otherwise the renderers may use the wrong focus state.
|
||||
this._coreBrowserService = this.register(this._instantiationService.createInstance(CoreBrowserService,
|
||||
this._coreBrowserService = this._register(this._instantiationService.createInstance(CoreBrowserService,
|
||||
this.textarea,
|
||||
parent.ownerDocument.defaultView ?? window,
|
||||
// Force unsafe null in node.js environment for tests
|
||||
@@ -460,8 +459,8 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
));
|
||||
this._instantiationService.setService(ICoreBrowserService, this._coreBrowserService);
|
||||
|
||||
this.register(addDisposableListener(this.textarea, 'focus', (ev: FocusEvent) => this._handleTextAreaFocus(ev)));
|
||||
this.register(addDisposableListener(this.textarea, 'blur', () => this._handleTextAreaBlur()));
|
||||
this._register(addDisposableListener(this.textarea, 'focus', (ev: FocusEvent) => this._handleTextAreaFocus(ev)));
|
||||
this._register(addDisposableListener(this.textarea, 'blur', () => this._handleTextAreaBlur()));
|
||||
this._helperContainer.appendChild(this.textarea);
|
||||
|
||||
this._charSizeService = this._instantiationService.createInstance(CharSizeService, this._document, this._helperContainer);
|
||||
@@ -473,9 +472,9 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
this._characterJoinerService = this._instantiationService.createInstance(CharacterJoinerService);
|
||||
this._instantiationService.setService(ICharacterJoinerService, this._characterJoinerService);
|
||||
|
||||
this._renderService = this.register(this._instantiationService.createInstance(RenderService, this.rows, this.screenElement));
|
||||
this._renderService = this._register(this._instantiationService.createInstance(RenderService, this.rows, this.screenElement));
|
||||
this._instantiationService.setService(IRenderService, this._renderService);
|
||||
this.register(this._renderService.onRenderedViewportChange(e => this._onRender.fire(e)));
|
||||
this._register(this._renderService.onRenderedViewportChange(e => this._onRender.fire(e)));
|
||||
this.onResize(e => this._renderService!.resize(e.cols, e.rows));
|
||||
|
||||
this._compositionView = this._document.createElement('div');
|
||||
@@ -486,7 +485,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
this._mouseService = this._instantiationService.createInstance(MouseService);
|
||||
this._instantiationService.setService(IMouseService, this._mouseService);
|
||||
|
||||
this.linkifier = this.register(this._instantiationService.createInstance(Linkifier, this.screenElement));
|
||||
this.linkifier = this._register(this._instantiationService.createInstance(Linkifier, this.screenElement));
|
||||
|
||||
// Performance: Add viewport and helper elements from the fragment
|
||||
this.element.appendChild(fragment);
|
||||
@@ -499,30 +498,30 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
this._renderService.setRenderer(this._createRenderer());
|
||||
}
|
||||
|
||||
this.register(this.onCursorMove(() => {
|
||||
this._register(this.onCursorMove(() => {
|
||||
this._renderService!.handleCursorMove();
|
||||
this._syncTextArea();
|
||||
}));
|
||||
this.register(this.onResize(() => this._renderService!.handleResize(this.cols, this.rows)));
|
||||
this.register(this.onBlur(() => this._renderService!.handleBlur()));
|
||||
this.register(this.onFocus(() => this._renderService!.handleFocus()));
|
||||
this._register(this.onResize(() => this._renderService!.handleResize(this.cols, this.rows)));
|
||||
this._register(this.onBlur(() => this._renderService!.handleBlur()));
|
||||
this._register(this.onFocus(() => this._renderService!.handleFocus()));
|
||||
|
||||
this._viewport = this.register(this._instantiationService.createInstance(Viewport, this.element, this.screenElement));
|
||||
this.register(this._viewport.onRequestScrollLines(e => {
|
||||
this._viewport = this._register(this._instantiationService.createInstance(Viewport, this.element, this.screenElement));
|
||||
this._register(this._viewport.onRequestScrollLines(e => {
|
||||
super.scrollLines(e, false);
|
||||
this.refresh(0, this.rows - 1);
|
||||
}));
|
||||
|
||||
this._selectionService = this.register(this._instantiationService.createInstance(SelectionService,
|
||||
this._selectionService = this._register(this._instantiationService.createInstance(SelectionService,
|
||||
this.element,
|
||||
this.screenElement,
|
||||
this.linkifier
|
||||
));
|
||||
this._instantiationService.setService(ISelectionService, this._selectionService);
|
||||
this.register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent)));
|
||||
this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
|
||||
this.register(this._selectionService.onRequestRedraw(e => this._renderService!.handleSelectionChanged(e.start, e.end, e.columnSelectMode)));
|
||||
this.register(this._selectionService.onLinuxMouseSelection(text => {
|
||||
this._register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent)));
|
||||
this._register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
|
||||
this._register(this._selectionService.onRequestRedraw(e => this._renderService!.handleSelectionChanged(e.start, e.end, e.columnSelectMode)));
|
||||
this._register(this._selectionService.onLinuxMouseSelection(text => {
|
||||
// If there's a new selection, put it into the textarea, focus and select it
|
||||
// in order to register it as a selection on the OS. This event is fired
|
||||
// only on Linux to enable middle click to paste selection.
|
||||
@@ -530,10 +529,10 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
this.textarea!.focus();
|
||||
this.textarea!.select();
|
||||
}));
|
||||
this.register(this._onScroll.event(() => this._selectionService!.refresh()));
|
||||
this._register(this._onScroll.event(() => this._selectionService!.refresh()));
|
||||
|
||||
this.register(this._instantiationService.createInstance(BufferDecorationRenderer, this.screenElement));
|
||||
this.register(addDisposableListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.handleMouseDown(e)));
|
||||
this._register(this._instantiationService.createInstance(BufferDecorationRenderer, this.screenElement));
|
||||
this._register(addDisposableListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.handleMouseDown(e)));
|
||||
|
||||
// apply mouse event classes set by escape codes before terminal was attached
|
||||
if (this.coreMouseService.areMouseEventsActive) {
|
||||
@@ -548,14 +547,14 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
// ensure the correct order of the dprchange event
|
||||
this._accessibilityManager.value = this._instantiationService.createInstance(AccessibilityManager, this);
|
||||
}
|
||||
this.register(this.optionsService.onSpecificOptionChange('screenReaderMode', e => this._handleScreenReaderModeOptionChange(e)));
|
||||
this._register(this.optionsService.onSpecificOptionChange('screenReaderMode', e => this._handleScreenReaderModeOptionChange(e)));
|
||||
|
||||
if (this.options.overviewRulerWidth) {
|
||||
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
|
||||
this._overviewRulerRenderer = this._register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
|
||||
}
|
||||
this.optionsService.onSpecificOptionChange('overviewRulerWidth', value => {
|
||||
if (!this._overviewRulerRenderer && value && this._viewportElement && this.screenElement) {
|
||||
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
|
||||
this._overviewRulerRenderer = this._register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
|
||||
}
|
||||
});
|
||||
// Measure the character size
|
||||
@@ -708,7 +707,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
}
|
||||
}
|
||||
};
|
||||
this.register(this.coreMouseService.onProtocolChange(events => {
|
||||
this._register(this.coreMouseService.onProtocolChange(events => {
|
||||
// apply global changes on events
|
||||
if (events) {
|
||||
if (this.optionsService.rawOptions.logLevel === 'debug') {
|
||||
@@ -760,7 +759,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
/**
|
||||
* "Always on" event listeners.
|
||||
*/
|
||||
this.register(addDisposableListener(el, 'mousedown', (ev: MouseEvent) => {
|
||||
this._register(addDisposableListener(el, 'mousedown', (ev: MouseEvent) => {
|
||||
ev.preventDefault();
|
||||
this.focus();
|
||||
|
||||
@@ -787,7 +786,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
return this.cancel(ev);
|
||||
}));
|
||||
|
||||
this.register(addDisposableListener(el, 'wheel', (ev: WheelEvent) => {
|
||||
this._register(addDisposableListener(el, 'wheel', (ev: WheelEvent) => {
|
||||
// do nothing, if app side handles wheel itself
|
||||
if (requestedEvents.wheel) return;
|
||||
|
||||
|
||||
+13
-11
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { IBufferCellPosition, ILink, ILinkDecorations, ILinkWithState, ILinkifier2, ILinkifierEvent } from 'browser/Types';
|
||||
import { Disposable, disposeArray, getDisposeArrayDisposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable } from 'common/Types';
|
||||
import { IBufferService } from 'common/services/Services';
|
||||
import { ILinkProviderService, IMouseService, IRenderService } from './services/Services';
|
||||
@@ -23,9 +23,9 @@ export class Linkifier extends Disposable implements ILinkifier2 {
|
||||
private _activeProviderReplies: Map<Number, ILinkWithState[] | undefined> | undefined;
|
||||
private _activeLine: number = -1;
|
||||
|
||||
private readonly _onShowLinkUnderline = this.register(new Emitter<ILinkifierEvent>());
|
||||
private readonly _onShowLinkUnderline = this._register(new Emitter<ILinkifierEvent>());
|
||||
public readonly onShowLinkUnderline = this._onShowLinkUnderline.event;
|
||||
private readonly _onHideLinkUnderline = this.register(new Emitter<ILinkifierEvent>());
|
||||
private readonly _onHideLinkUnderline = this._register(new Emitter<ILinkifierEvent>());
|
||||
public readonly onHideLinkUnderline = this._onHideLinkUnderline.event;
|
||||
|
||||
constructor(
|
||||
@@ -36,24 +36,25 @@ export class Linkifier extends Disposable implements ILinkifier2 {
|
||||
@ILinkProviderService private readonly _linkProviderService: ILinkProviderService
|
||||
) {
|
||||
super();
|
||||
this.register(getDisposeArrayDisposable(this._linkCacheDisposables));
|
||||
this.register(toDisposable(() => {
|
||||
this._register(toDisposable(() => {
|
||||
dispose(this._linkCacheDisposables);
|
||||
this._linkCacheDisposables.length = 0;
|
||||
this._lastMouseEvent = undefined;
|
||||
// Clear out link providers as they could easily cause an embedder memory leak
|
||||
this._activeProviderReplies?.clear();
|
||||
}));
|
||||
// Listen to resize to catch the case where it's resized and the cursor is out of the viewport.
|
||||
this.register(this._bufferService.onResize(() => {
|
||||
this._register(this._bufferService.onResize(() => {
|
||||
this._clearCurrentLink();
|
||||
this._wasResized = true;
|
||||
}));
|
||||
this.register(addDisposableListener(this._element, 'mouseleave', () => {
|
||||
this._register(addDisposableListener(this._element, 'mouseleave', () => {
|
||||
this._isMouseOut = true;
|
||||
this._clearCurrentLink();
|
||||
}));
|
||||
this.register(addDisposableListener(this._element, 'mousemove', this._handleMouseMove.bind(this)));
|
||||
this.register(addDisposableListener(this._element, 'mousedown', this._handleMouseDown.bind(this)));
|
||||
this.register(addDisposableListener(this._element, 'mouseup', this._handleMouseUp.bind(this)));
|
||||
this._register(addDisposableListener(this._element, 'mousemove', this._handleMouseMove.bind(this)));
|
||||
this._register(addDisposableListener(this._element, 'mousedown', this._handleMouseDown.bind(this)));
|
||||
this._register(addDisposableListener(this._element, 'mouseup', this._handleMouseUp.bind(this)));
|
||||
}
|
||||
|
||||
private _handleMouseMove(event: MouseEvent): void {
|
||||
@@ -240,7 +241,8 @@ export class Linkifier extends Disposable implements ILinkifier2 {
|
||||
if (!startRow || !endRow || (this._currentLink.link.range.start.y >= startRow && this._currentLink.link.range.end.y <= endRow)) {
|
||||
this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent);
|
||||
this._currentLink = undefined;
|
||||
disposeArray(this._linkCacheDisposables);
|
||||
dispose(this._linkCacheDisposables);
|
||||
this._linkCacheDisposables.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -5,7 +5,7 @@
|
||||
|
||||
import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
||||
import { ViewportConstants } from 'browser/shared/Constants';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IBufferService, ICoreMouseService, IOptionsService } from 'common/services/Services';
|
||||
import { CoreMouseEventType } from 'common/Types';
|
||||
import { scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
|
||||
@@ -16,7 +16,7 @@ import { Scrollable, ScrollbarVisibility, type ScrollEvent } from 'vs/base/commo
|
||||
|
||||
export class Viewport extends Disposable {
|
||||
|
||||
protected _onRequestScrollLines = this.register(new Emitter<number>());
|
||||
protected _onRequestScrollLines = this._register(new Emitter<number>());
|
||||
public readonly onRequestScrollLines = this._onRequestScrollLines.event;
|
||||
|
||||
private _scrollableElement: SmoothScrollableElement;
|
||||
@@ -40,46 +40,46 @@ export class Viewport extends Disposable {
|
||||
) {
|
||||
super();
|
||||
|
||||
const scrollable = this.register(new Scrollable({
|
||||
const scrollable = this._register(new Scrollable({
|
||||
forceIntegerValues: false,
|
||||
smoothScrollDuration: this._optionsService.rawOptions.smoothScrollDuration,
|
||||
// This is used over `IRenderService.addRefreshCallback` since it can be canceled
|
||||
scheduleAtNextAnimationFrame: cb => scheduleAtNextAnimationFrame(coreBrowserService.window, cb)
|
||||
}));
|
||||
this.register(this._optionsService.onSpecificOptionChange('smoothScrollDuration', () => {
|
||||
this._register(this._optionsService.onSpecificOptionChange('smoothScrollDuration', () => {
|
||||
scrollable.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration);
|
||||
}));
|
||||
|
||||
this._scrollableElement = this.register(new SmoothScrollableElement(screenElement, {
|
||||
this._scrollableElement = this._register(new SmoothScrollableElement(screenElement, {
|
||||
vertical: ScrollbarVisibility.Auto,
|
||||
horizontal: ScrollbarVisibility.Hidden,
|
||||
useShadows: false,
|
||||
mouseWheelSmoothScroll: true,
|
||||
...this._getChangeOptions()
|
||||
}, scrollable));
|
||||
this.register(this._optionsService.onMultipleOptionChange([
|
||||
this._register(this._optionsService.onMultipleOptionChange([
|
||||
'scrollSensitivity',
|
||||
'fastScrollSensitivity',
|
||||
'overviewRulerWidth'
|
||||
], () => this._scrollableElement.updateOptions(this._getChangeOptions())));
|
||||
// Don't handle mouse wheel if wheel events are supported by the current mouse prototcol
|
||||
this.register(coreMouseService.onProtocolChange(type => {
|
||||
this._register(coreMouseService.onProtocolChange(type => {
|
||||
this._scrollableElement.updateOptions({
|
||||
handleMouseWheel: !(type & CoreMouseEventType.WHEEL)
|
||||
});
|
||||
}));
|
||||
|
||||
this._scrollableElement.setScrollDimensions({ height: 0, scrollHeight: 0 });
|
||||
this.register(Event.runAndSubscribe(themeService.onChangeColors, () => {
|
||||
this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
|
||||
this._scrollableElement.getDomNode().style.backgroundColor = themeService.colors.background.css;
|
||||
}));
|
||||
element.appendChild(this._scrollableElement.getDomNode());
|
||||
this.register(toDisposable(() => this._scrollableElement.getDomNode().remove()));
|
||||
this._register(toDisposable(() => this._scrollableElement.getDomNode().remove()));
|
||||
|
||||
this._styleElement = coreBrowserService.window.document.createElement('style');
|
||||
screenElement.appendChild(this._styleElement);
|
||||
this.register(toDisposable(() => this._styleElement.remove()));
|
||||
this.register(Event.runAndSubscribe(themeService.onChangeColors, () => {
|
||||
this._register(toDisposable(() => this._styleElement.remove()));
|
||||
this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
|
||||
this._styleElement.textContent = [
|
||||
`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,
|
||||
` background: ${themeService.colors.scrollbarSliderBackground.css};`,
|
||||
@@ -93,10 +93,10 @@ export class Viewport extends Disposable {
|
||||
].join('\n');
|
||||
}));
|
||||
|
||||
this.register(this._bufferService.onResize(() => this._queueSync()));
|
||||
this.register(this._bufferService.onScroll(() => this._sync()));
|
||||
this._register(this._bufferService.onResize(() => this._queueSync()));
|
||||
this._register(this._bufferService.onScroll(() => this._sync()));
|
||||
|
||||
this.register(this._scrollableElement.onScroll(e => this._handleScroll(e)));
|
||||
this._register(this._scrollableElement.onScroll(e => this._handleScroll(e)));
|
||||
}
|
||||
|
||||
public scrollLines(disp: number): void {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IBufferService, IDecorationService, IInternalDecoration } from 'common/services/Services';
|
||||
|
||||
export class BufferDecorationRenderer extends Disposable {
|
||||
@@ -28,18 +28,18 @@ export class BufferDecorationRenderer extends Disposable {
|
||||
this._container.classList.add('xterm-decoration-container');
|
||||
this._screenElement.appendChild(this._container);
|
||||
|
||||
this.register(this._renderService.onRenderedViewportChange(() => this._doRefreshDecorations()));
|
||||
this.register(this._renderService.onDimensionsChange(() => {
|
||||
this._register(this._renderService.onRenderedViewportChange(() => this._doRefreshDecorations()));
|
||||
this._register(this._renderService.onDimensionsChange(() => {
|
||||
this._dimensionsChanged = true;
|
||||
this._queueRefresh();
|
||||
}));
|
||||
this.register(this._coreBrowserService.onDprChange(() => this._queueRefresh()));
|
||||
this.register(this._bufferService.buffers.onBufferActivate(() => {
|
||||
this._register(this._coreBrowserService.onDprChange(() => this._queueRefresh()));
|
||||
this._register(this._bufferService.buffers.onBufferActivate(() => {
|
||||
this._altBufferIsActive = this._bufferService.buffer === this._bufferService.buffers.alt;
|
||||
}));
|
||||
this.register(this._decorationService.onDecorationRegistered(() => this._queueRefresh()));
|
||||
this.register(this._decorationService.onDecorationRemoved(decoration => this._removeDecoration(decoration)));
|
||||
this.register(toDisposable(() => {
|
||||
this._register(this._decorationService.onDecorationRegistered(() => this._queueRefresh()));
|
||||
this._register(this._decorationService.onDecorationRemoved(decoration => this._removeDecoration(decoration)));
|
||||
this._register(toDisposable(() => {
|
||||
this._container.remove();
|
||||
this._decorationElements.clear();
|
||||
}));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { ColorZoneStore, IColorZone, IColorZoneStore } from 'browser/decorations/ColorZoneStore';
|
||||
import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||
|
||||
const enum Constants {
|
||||
@@ -63,7 +63,7 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
this._canvas.classList.add('xterm-decoration-overview-ruler');
|
||||
this._refreshCanvasDimensions();
|
||||
this._viewportElement.parentElement?.insertBefore(this._canvas, this._viewportElement);
|
||||
this.register(toDisposable(() => this._canvas?.remove()));
|
||||
this._register(toDisposable(() => this._canvas?.remove()));
|
||||
|
||||
const ctx = this._canvas.getContext('2d');
|
||||
if (!ctx) {
|
||||
@@ -72,14 +72,14 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
this._ctx = ctx;
|
||||
}
|
||||
|
||||
this.register(this._decorationService.onDecorationRegistered(() => this._queueRefresh(undefined, true)));
|
||||
this.register(this._decorationService.onDecorationRemoved(() => this._queueRefresh(undefined, true)));
|
||||
this._register(this._decorationService.onDecorationRegistered(() => this._queueRefresh(undefined, true)));
|
||||
this._register(this._decorationService.onDecorationRemoved(() => this._queueRefresh(undefined, true)));
|
||||
|
||||
this.register(this._renderService.onRenderedViewportChange(() => this._queueRefresh()));
|
||||
this.register(this._bufferService.buffers.onBufferActivate(() => {
|
||||
this._register(this._renderService.onRenderedViewportChange(() => this._queueRefresh()));
|
||||
this._register(this._bufferService.buffers.onBufferActivate(() => {
|
||||
this._canvas!.style.display = this._bufferService.buffer === this._bufferService.buffers.alt ? 'none' : 'block';
|
||||
}));
|
||||
this.register(this._bufferService.onScroll(() => {
|
||||
this._register(this._bufferService.onScroll(() => {
|
||||
if (this._lastKnownBufferLength !== this._bufferService.buffers.normal.lines.length) {
|
||||
this._refreshDrawHeightConstants();
|
||||
this._refreshColorZonePadding();
|
||||
@@ -87,16 +87,16 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
}));
|
||||
|
||||
// Container height changed
|
||||
this.register(this._renderService.onRender((): void => {
|
||||
this._register(this._renderService.onRender((): void => {
|
||||
if (!this._containerHeight || this._containerHeight !== this._screenElement.clientHeight) {
|
||||
this._queueRefresh(true);
|
||||
this._containerHeight = this._screenElement.clientHeight;
|
||||
}
|
||||
}));
|
||||
|
||||
this.register(this._coreBrowserService.onDprChange(() => this._queueRefresh(true)));
|
||||
this.register(this._optionsService.onSpecificOptionChange('overviewRulerWidth', () => this._queueRefresh(true)));
|
||||
this.register(this._themeService.onChangeColors(() => this._queueRefresh()));
|
||||
this._register(this._coreBrowserService.onDprChange(() => this._queueRefresh(true)));
|
||||
this._register(this._optionsService.onSpecificOptionChange('overviewRulerWidth', () => this._queueRefresh(true)));
|
||||
this._register(this._themeService.onChangeColors(() => this._queueRefresh()));
|
||||
this._queueRefresh(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as Strings from 'browser/LocalizableStrings';
|
||||
import { CoreBrowserTerminal as TerminalCore } from 'browser/CoreBrowserTerminal';
|
||||
import { IBufferRange, ITerminal } from 'browser/Types';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ITerminalOptions } from 'common/Types';
|
||||
import { AddonManager } from 'common/public/AddonManager';
|
||||
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
|
||||
@@ -32,8 +32,8 @@ export class Terminal extends Disposable implements ITerminalApi {
|
||||
constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions) {
|
||||
super();
|
||||
|
||||
this._core = this.register(new TerminalCore(options));
|
||||
this._addonManager = this.register(new AddonManager());
|
||||
this._core = this._register(new TerminalCore(options));
|
||||
this._addonManager = this._register(new AddonManager());
|
||||
|
||||
this._publicOptions = { ... this._core.options };
|
||||
const getter = (propName: string): any => {
|
||||
@@ -97,7 +97,7 @@ export class Terminal extends Disposable implements ITerminalApi {
|
||||
public get cols(): number { return this._core.cols; }
|
||||
public get buffer(): IBufferNamespaceApi {
|
||||
if (!this._buffer) {
|
||||
this._buffer = this.register(new BufferNamespaceApi(this._core));
|
||||
this._buffer = this._register(new BufferNamespaceApi(this._core));
|
||||
}
|
||||
return this._buffer;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { IRenderDimensions, IRenderer, IRequestRedrawEvent, ISelectionRenderMode
|
||||
import { ICharSizeService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
||||
import { ILinkifier2, ILinkifierEvent, ITerminal, ReadonlyColorSet } from 'browser/Types';
|
||||
import { color } from 'common/Color';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IBufferService, IInstantiationService, IOptionsService } from 'common/services/Services';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
@@ -45,7 +45,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
||||
|
||||
public dimensions: IRenderDimensions;
|
||||
|
||||
public readonly onRequestRedraw = this.register(new Emitter<IRequestRedrawEvent>()).event;
|
||||
public readonly onRequestRedraw = this._register(new Emitter<IRequestRedrawEvent>()).event;
|
||||
|
||||
constructor(
|
||||
private readonly _terminal: ITerminal,
|
||||
@@ -74,9 +74,9 @@ export class DomRenderer extends Disposable implements IRenderer {
|
||||
|
||||
this.dimensions = createRenderDimensions();
|
||||
this._updateDimensions();
|
||||
this.register(this._optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
this._register(this._optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
|
||||
this.register(this._themeService.onChangeColors(e => this._injectCss(e)));
|
||||
this._register(this._themeService.onChangeColors(e => this._injectCss(e)));
|
||||
this._injectCss(this._themeService.colors);
|
||||
|
||||
this._rowFactory = instantiationService.createInstance(DomRendererRowFactory, document);
|
||||
@@ -85,10 +85,10 @@ export class DomRenderer extends Disposable implements IRenderer {
|
||||
this._screenElement.appendChild(this._rowContainer);
|
||||
this._screenElement.appendChild(this._selectionContainer);
|
||||
|
||||
this.register(this._linkifier2.onShowLinkUnderline(e => this._handleLinkHover(e)));
|
||||
this.register(this._linkifier2.onHideLinkUnderline(e => this._handleLinkLeave(e)));
|
||||
this._register(this._linkifier2.onShowLinkUnderline(e => this._handleLinkHover(e)));
|
||||
this._register(this._linkifier2.onHideLinkUnderline(e => this._handleLinkLeave(e)));
|
||||
|
||||
this.register(toDisposable(() => {
|
||||
this._register(toDisposable(() => {
|
||||
this._element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);
|
||||
|
||||
// Outside influences such as React unmounts may manipulate the DOM before our disposal.
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { toDisposable } from 'common/Lifecycle';
|
||||
import { IDisposable } from 'common/Types';
|
||||
import { toDisposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export function observeDevicePixelDimensions(element: HTMLElement, parentWindow: Window & typeof globalThis, callback: (deviceWidth: number, deviceHeight: number) => void): IDisposable {
|
||||
// Observe any resizes to the element and extract the actual pixel size of the element if the
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { IOptionsService } from 'common/services/Services';
|
||||
import { ICharSizeService } from 'browser/services/Services';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
export class CharSizeService extends Disposable implements ICharSizeService {
|
||||
@@ -17,7 +17,7 @@ export class CharSizeService extends Disposable implements ICharSizeService {
|
||||
|
||||
public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }
|
||||
|
||||
private readonly _onCharSizeChange = this.register(new Emitter<void>());
|
||||
private readonly _onCharSizeChange = this._register(new Emitter<void>());
|
||||
public readonly onCharSizeChange = this._onCharSizeChange.event;
|
||||
|
||||
constructor(
|
||||
@@ -27,11 +27,11 @@ export class CharSizeService extends Disposable implements ICharSizeService {
|
||||
) {
|
||||
super();
|
||||
try {
|
||||
this._measureStrategy = this.register(new TextMetricsMeasureStrategy(this._optionsService));
|
||||
this._measureStrategy = this._register(new TextMetricsMeasureStrategy(this._optionsService));
|
||||
} catch {
|
||||
this._measureStrategy = this.register(new DomMeasureStrategy(document, parentElement, this._optionsService));
|
||||
this._measureStrategy = this._register(new DomMeasureStrategy(document, parentElement, this._optionsService));
|
||||
}
|
||||
this.register(this._optionsService.onMultipleOptionChange(['fontFamily', 'fontSize'], () => this.measure()));
|
||||
this._register(this._optionsService.onMultipleOptionChange(['fontFamily', 'fontSize'], () => this.measure()));
|
||||
}
|
||||
|
||||
public measure(): void {
|
||||
|
||||
@@ -3,22 +3,21 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { ICoreBrowserService } from './Services';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { addDisposableListener } from 'vs/base/browser/dom';
|
||||
import { MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class CoreBrowserService extends Disposable implements ICoreBrowserService {
|
||||
public serviceBrand: undefined;
|
||||
|
||||
private _isFocused = false;
|
||||
private _cachedIsFocused: boolean | undefined = undefined;
|
||||
private _screenDprMonitor = this.register(new ScreenDprMonitor(this._window));
|
||||
private _screenDprMonitor = this._register(new ScreenDprMonitor(this._window));
|
||||
|
||||
private readonly _onDprChange = this.register(new Emitter<number>());
|
||||
private readonly _onDprChange = this._register(new Emitter<number>());
|
||||
public readonly onDprChange = this._onDprChange.event;
|
||||
private readonly _onWindowChange = this.register(new Emitter<Window & typeof globalThis>());
|
||||
private readonly _onWindowChange = this._register(new Emitter<Window & typeof globalThis>());
|
||||
public readonly onWindowChange = this._onWindowChange.event;
|
||||
|
||||
constructor(
|
||||
@@ -29,11 +28,11 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
|
||||
super();
|
||||
|
||||
// Monitor device pixel ratio
|
||||
this.register(this.onWindowChange(w => this._screenDprMonitor.setWindow(w)));
|
||||
this.register(Event.forward(this._screenDprMonitor.onDprChange, this._onDprChange));
|
||||
this._register(this.onWindowChange(w => this._screenDprMonitor.setWindow(w)));
|
||||
this._register(Event.forward(this._screenDprMonitor.onDprChange, this._onDprChange));
|
||||
|
||||
this.register(addDisposableListener(this._textarea, 'focus', () => this._isFocused = true));
|
||||
this.register(addDisposableListener(this._textarea, 'blur', () => this._isFocused = false));
|
||||
this._register(addDisposableListener(this._textarea, 'focus', () => this._isFocused = true));
|
||||
this._register(addDisposableListener(this._textarea, 'blur', () => this._isFocused = false));
|
||||
}
|
||||
|
||||
public get window(): Window & typeof globalThis {
|
||||
@@ -66,7 +65,7 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
|
||||
* window.devicePixelRatio value changes. This is done not with polling but with
|
||||
* the use of window.matchMedia to watch media queries. When the event fires,
|
||||
* the listener will be reattached using a different media query to ensure that
|
||||
* any further changes will register.
|
||||
* any further changes will _register.
|
||||
*
|
||||
* The listener should fire on both window zoom changes and switching to a
|
||||
* monitor with a different DPI.
|
||||
@@ -75,9 +74,9 @@ class ScreenDprMonitor extends Disposable {
|
||||
private _currentDevicePixelRatio: number;
|
||||
private _outerListener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | undefined;
|
||||
private _resolutionMediaMatchList: MediaQueryList | undefined;
|
||||
private _windowResizeListener = this.register(new MutableDisposable());
|
||||
private _windowResizeListener = this._register(new MutableDisposable());
|
||||
|
||||
private readonly _onDprChange = this.register(new Emitter<number>());
|
||||
private readonly _onDprChange = this._register(new Emitter<number>());
|
||||
public readonly onDprChange = this._onDprChange.event;
|
||||
|
||||
constructor(private _parentWindow: Window) {
|
||||
@@ -92,7 +91,7 @@ class ScreenDprMonitor extends Disposable {
|
||||
this._setWindowResizeListener();
|
||||
|
||||
// Setup additional disposables
|
||||
this.register(toDisposable(() => this.clearListener()));
|
||||
this._register(toDisposable(() => this.clearListener()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ILinkProvider, ILinkProviderService } from 'browser/services/Services';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable } from 'common/Types';
|
||||
|
||||
export class LinkProviderService extends Disposable implements ILinkProviderService {
|
||||
@@ -9,7 +9,7 @@ export class LinkProviderService extends Disposable implements ILinkProviderServ
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.register(toDisposable(() => this.linkProviders.length = 0));
|
||||
this._register(toDisposable(() => this.linkProviders.length = 0));
|
||||
}
|
||||
|
||||
public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { RenderDebouncer } from 'browser/RenderDebouncer';
|
||||
import { IRenderDebouncerWithCallback } from 'browser/Types';
|
||||
import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
|
||||
import { ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DebouncedIdleTask } from 'common/TaskQueue';
|
||||
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
@@ -22,10 +22,10 @@ interface ISelectionState {
|
||||
export class RenderService extends Disposable implements IRenderService {
|
||||
public serviceBrand: undefined;
|
||||
|
||||
private _renderer: MutableDisposable<IRenderer> = this.register(new MutableDisposable());
|
||||
private _renderer: MutableDisposable<IRenderer> = this._register(new MutableDisposable());
|
||||
private _renderDebouncer: IRenderDebouncerWithCallback;
|
||||
private _pausedResizeTask = new DebouncedIdleTask();
|
||||
private _observerDisposable = this.register(new MutableDisposable());
|
||||
private _observerDisposable = this._register(new MutableDisposable());
|
||||
|
||||
private _isPaused: boolean = false;
|
||||
private _needsFullRefresh: boolean = false;
|
||||
@@ -39,13 +39,13 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
columnSelectMode: false
|
||||
};
|
||||
|
||||
private readonly _onDimensionsChange = this.register(new Emitter<IRenderDimensions>());
|
||||
private readonly _onDimensionsChange = this._register(new Emitter<IRenderDimensions>());
|
||||
public readonly onDimensionsChange = this._onDimensionsChange.event;
|
||||
private readonly _onRenderedViewportChange = this.register(new Emitter<{ start: number, end: number }>());
|
||||
private readonly _onRenderedViewportChange = this._register(new Emitter<{ start: number, end: number }>());
|
||||
public readonly onRenderedViewportChange = this._onRenderedViewportChange.event;
|
||||
private readonly _onRender = this.register(new Emitter<{ start: number, end: number }>());
|
||||
private readonly _onRender = this._register(new Emitter<{ start: number, end: number }>());
|
||||
public readonly onRender = this._onRender.event;
|
||||
private readonly _onRefreshRequest = this.register(new Emitter<{ start: number, end: number }>());
|
||||
private readonly _onRefreshRequest = this._register(new Emitter<{ start: number, end: number }>());
|
||||
public readonly onRefreshRequest = this._onRefreshRequest.event;
|
||||
|
||||
public get dimensions(): IRenderDimensions { return this._renderer.value!.dimensions; }
|
||||
@@ -63,23 +63,23 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
super();
|
||||
|
||||
this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end), coreBrowserService);
|
||||
this.register(this._renderDebouncer);
|
||||
this._register(this._renderDebouncer);
|
||||
|
||||
this.register(coreBrowserService.onDprChange(() => this.handleDevicePixelRatioChange()));
|
||||
this._register(coreBrowserService.onDprChange(() => this.handleDevicePixelRatioChange()));
|
||||
|
||||
this.register(bufferService.onResize(() => this._fullRefresh()));
|
||||
this.register(bufferService.buffers.onBufferActivate(() => this._renderer.value?.clear()));
|
||||
this.register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
this.register(this._charSizeService.onCharSizeChange(() => this.handleCharSizeChanged()));
|
||||
this._register(bufferService.onResize(() => this._fullRefresh()));
|
||||
this._register(bufferService.buffers.onBufferActivate(() => this._renderer.value?.clear()));
|
||||
this._register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
this._register(this._charSizeService.onCharSizeChange(() => this.handleCharSizeChanged()));
|
||||
|
||||
// Do a full refresh whenever any decoration is added or removed. This may not actually result
|
||||
// in changes but since decorations should be used sparingly or added/removed all in the same
|
||||
// frame this should have minimal performance impact.
|
||||
this.register(decorationService.onDecorationRegistered(() => this._fullRefresh()));
|
||||
this.register(decorationService.onDecorationRemoved(() => this._fullRefresh()));
|
||||
this._register(decorationService.onDecorationRegistered(() => this._fullRefresh()));
|
||||
this._register(decorationService.onDecorationRemoved(() => this._fullRefresh()));
|
||||
|
||||
// Clear the renderer when the a change that could affect glyphs occurs
|
||||
this.register(optionsService.onMultipleOptionChange([
|
||||
this._register(optionsService.onMultipleOptionChange([
|
||||
'customGlyphs',
|
||||
'drawBoldTextInBrightColors',
|
||||
'letterSpacing',
|
||||
@@ -97,15 +97,15 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
}));
|
||||
|
||||
// Refresh the cursor line when the cursor changes
|
||||
this.register(optionsService.onMultipleOptionChange([
|
||||
this._register(optionsService.onMultipleOptionChange([
|
||||
'cursorBlink',
|
||||
'cursorStyle'
|
||||
], () => this.refreshRows(bufferService.buffer.y, bufferService.buffer.y, true)));
|
||||
|
||||
this.register(themeService.onChangeColors(() => this._fullRefresh()));
|
||||
this._register(themeService.onChangeColors(() => this._fullRefresh()));
|
||||
|
||||
this._registerIntersectionObserver(coreBrowserService.window, screenElement);
|
||||
this.register(coreBrowserService.onWindowChange((w) => this._registerIntersectionObserver(w, screenElement)));
|
||||
this._register(coreBrowserService.onWindowChange((w) => this._registerIntersectionObserver(w, screenElement)));
|
||||
}
|
||||
|
||||
private _registerIntersectionObserver(w: Window & typeof globalThis, screenElement: HTMLElement): void {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { moveToCellSequence } from 'browser/input/MoveToCell';
|
||||
import { SelectionModel } from 'browser/selection/SelectionModel';
|
||||
import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
|
||||
import { ICoreBrowserService, IMouseService, IRenderService, ISelectionService } from 'browser/services/Services';
|
||||
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as Browser from 'common/Platform';
|
||||
import { IBufferLine, IDisposable } from 'common/Types';
|
||||
import { getRangeLength } from 'common/buffer/BufferRange';
|
||||
@@ -111,13 +111,13 @@ export class SelectionService extends Disposable implements ISelectionService {
|
||||
private _oldSelectionStart: [number, number] | undefined = undefined;
|
||||
private _oldSelectionEnd: [number, number] | undefined = undefined;
|
||||
|
||||
private readonly _onLinuxMouseSelection = this.register(new Emitter<string>());
|
||||
private readonly _onLinuxMouseSelection = this._register(new Emitter<string>());
|
||||
public readonly onLinuxMouseSelection = this._onLinuxMouseSelection.event;
|
||||
private readonly _onRedrawRequest = this.register(new Emitter<ISelectionRedrawRequestEvent>());
|
||||
private readonly _onRedrawRequest = this._register(new Emitter<ISelectionRedrawRequestEvent>());
|
||||
public readonly onRequestRedraw = this._onRedrawRequest.event;
|
||||
private readonly _onSelectionChange = this.register(new Emitter<void>());
|
||||
private readonly _onSelectionChange = this._register(new Emitter<void>());
|
||||
public readonly onSelectionChange = this._onSelectionChange.event;
|
||||
private readonly _onRequestScrollLines = this.register(new Emitter<ISelectionRequestScrollLinesEvent>());
|
||||
private readonly _onRequestScrollLines = this._register(new Emitter<ISelectionRequestScrollLinesEvent>());
|
||||
public readonly onRequestScrollLines = this._onRequestScrollLines.event;
|
||||
|
||||
constructor(
|
||||
@@ -142,14 +142,14 @@ export class SelectionService extends Disposable implements ISelectionService {
|
||||
}
|
||||
});
|
||||
this._trimListener = this._bufferService.buffer.lines.onTrim(amount => this._handleTrim(amount));
|
||||
this.register(this._bufferService.buffers.onBufferActivate(e => this._handleBufferActivate(e)));
|
||||
this._register(this._bufferService.buffers.onBufferActivate(e => this._handleBufferActivate(e)));
|
||||
|
||||
this.enable();
|
||||
|
||||
this._model = new SelectionModel(this._bufferService);
|
||||
this._activeSelectionMode = SelectionMode.NORMAL;
|
||||
|
||||
this.register(toDisposable(() => {
|
||||
this._register(toDisposable(() => {
|
||||
this._removeMouseDownListeners();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ 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/Color';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IOptionsService, ITheme } from 'common/services/Services';
|
||||
import { AllColorIndex, IColor, SpecialColorIndex } from 'common/Types';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
@@ -40,7 +40,7 @@ export class ThemeService extends Disposable implements IThemeService {
|
||||
|
||||
public get colors(): ReadonlyColorSet { return this._colors; }
|
||||
|
||||
private readonly _onChangeColors = this.register(new Emitter<ReadonlyColorSet>());
|
||||
private readonly _onChangeColors = this._register(new Emitter<ReadonlyColorSet>());
|
||||
public readonly onChangeColors = this._onChangeColors.event;
|
||||
|
||||
constructor(
|
||||
@@ -69,8 +69,8 @@ export class ThemeService extends Disposable implements IThemeService {
|
||||
this._updateRestoreColors();
|
||||
this._setTheme(this._optionsService.rawOptions.theme);
|
||||
|
||||
this.register(this._optionsService.onSpecificOptionChange('minimumContrastRatio', () => this._contrastCache.clear()));
|
||||
this.register(this._optionsService.onSpecificOptionChange('theme', () => this._setTheme(this._optionsService.rawOptions.theme)));
|
||||
this._register(this._optionsService.onSpecificOptionChange('minimumContrastRatio', () => this._contrastCache.clear()));
|
||||
this._register(this._optionsService.onSpecificOptionChange('theme', () => this._setTheme(this._optionsService.rawOptions.theme)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user