Remove on, off, globalOn
This commit is contained in:
+3
-3
@@ -33,15 +33,15 @@ function setPadding() {
|
|||||||
term.fit();
|
term.fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
paddingElement.addEventListener('change', setPadding);
|
addDomListener(paddingElement, 'change', setPadding);
|
||||||
|
|
||||||
actionElements.findNext.addEventListener('keypress', function (e) {
|
addDomListener(actionElements.findNext, 'keypress', function (e) {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
term.findNext(actionElements.findNext.value);
|
term.findNext(actionElements.findNext.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
actionElements.findPrevious.addEventListener('keypress', function (e) {
|
addDomListener(actionElements.findPrevious, 'keypress', function (e) {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
term.findPrevious(actionElements.findPrevious.value);
|
term.findPrevious(actionElements.findPrevious.value);
|
||||||
|
|||||||
@@ -116,6 +116,11 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
this._activeSelectionMode = SelectionMode.NORMAL;
|
this._activeSelectionMode = SelectionMode.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public dispose(): void {
|
||||||
|
super.dispose();
|
||||||
|
this._removeMouseDownListeners();
|
||||||
|
}
|
||||||
|
|
||||||
private get _buffer(): IBuffer {
|
private get _buffer(): IBuffer {
|
||||||
return this._terminal.buffers.active;
|
return this._terminal.buffers.active;
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-19
@@ -1004,19 +1004,23 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
// be kept aroud if Terminal.dispose is fired when the mouse is down
|
// be kept aroud if Terminal.dispose is fired when the mouse is down
|
||||||
|
|
||||||
// bind events
|
// bind events
|
||||||
if (this.normalMouse) on(this._document, 'mousemove', sendMove);
|
if (this.normalMouse) {
|
||||||
|
this._document.addEventListener('mousemove', sendMove);
|
||||||
|
}
|
||||||
|
|
||||||
// x10 compatibility mode can't send button releases
|
// x10 compatibility mode can't send button releases
|
||||||
if (!this.x10Mouse) {
|
if (!this.x10Mouse) {
|
||||||
const handler = (ev: MouseEvent) => {
|
const handler = (ev: MouseEvent) => {
|
||||||
sendButton(ev);
|
sendButton(ev);
|
||||||
// TODO: Seems dangerous calling this on document?
|
// TODO: Seems dangerous calling this on document?
|
||||||
if (this.normalMouse) off(this._document, 'mousemove', sendMove);
|
if (this.normalMouse) {
|
||||||
off(this._document, 'mouseup', handler);
|
this._document.removeEventListener('mousemove', sendMove);
|
||||||
|
}
|
||||||
|
this._document.removeEventListener('mouseup', handler);
|
||||||
return this.cancel(ev);
|
return this.cancel(ev);
|
||||||
};
|
};
|
||||||
// TODO: Seems dangerous calling this on document?
|
// TODO: Seems dangerous calling this on document?
|
||||||
on(this._document, 'mouseup', handler);
|
this._document.addEventListener('mouseup', handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.cancel(ev);
|
return this.cancel(ev);
|
||||||
@@ -1913,21 +1917,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
|||||||
* Helpers
|
* Helpers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function globalOn(el: any, type: string, handler: (event: Event) => any, capture?: boolean, passive?: boolean): void {
|
|
||||||
if (!Array.isArray(el)) {
|
|
||||||
el = [el];
|
|
||||||
}
|
|
||||||
el.forEach((element: HTMLElement) => {
|
|
||||||
element.addEventListener(type, handler, { capture: capture || false, passive: passive || false });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// TODO: Remove once everything is typed
|
|
||||||
const on = globalOn;
|
|
||||||
|
|
||||||
function off(el: any, type: string, handler: (event: Event) => any, capture: boolean = false): void {
|
|
||||||
el.removeEventListener(type, handler, capture);
|
|
||||||
}
|
|
||||||
|
|
||||||
function wasMondifierKeyOnlyEvent(ev: KeyboardEvent): boolean {
|
function wasMondifierKeyOnlyEvent(ev: KeyboardEvent): boolean {
|
||||||
return ev.keyCode === 16 || // Shift
|
return ev.keyCode === 16 || // Shift
|
||||||
ev.keyCode === 17 || // Ctrl
|
ev.keyCode === 17 || // Ctrl
|
||||||
|
|||||||
Reference in New Issue
Block a user