mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Remove on, off, globalOn
This commit is contained in:
+3
-3
@@ -33,15 +33,15 @@ function setPadding() {
|
||||
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") {
|
||||
e.preventDefault();
|
||||
term.findNext(actionElements.findNext.value);
|
||||
}
|
||||
});
|
||||
actionElements.findPrevious.addEventListener('keypress', function (e) {
|
||||
addDomListener(actionElements.findPrevious, 'keypress', function (e) {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
term.findPrevious(actionElements.findPrevious.value);
|
||||
|
||||
@@ -116,6 +116,11 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
||||
this._activeSelectionMode = SelectionMode.NORMAL;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
this._removeMouseDownListeners();
|
||||
}
|
||||
|
||||
private get _buffer(): IBuffer {
|
||||
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
|
||||
|
||||
// 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
|
||||
if (!this.x10Mouse) {
|
||||
const handler = (ev: MouseEvent) => {
|
||||
sendButton(ev);
|
||||
// TODO: Seems dangerous calling this on document?
|
||||
if (this.normalMouse) off(this._document, 'mousemove', sendMove);
|
||||
off(this._document, 'mouseup', handler);
|
||||
if (this.normalMouse) {
|
||||
this._document.removeEventListener('mousemove', sendMove);
|
||||
}
|
||||
this._document.removeEventListener('mouseup', handler);
|
||||
return this.cancel(ev);
|
||||
};
|
||||
// TODO: Seems dangerous calling this on document?
|
||||
on(this._document, 'mouseup', handler);
|
||||
this._document.addEventListener('mouseup', handler);
|
||||
}
|
||||
|
||||
return this.cancel(ev);
|
||||
@@ -1913,21 +1917,6 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
* 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 {
|
||||
return ev.keyCode === 16 || // Shift
|
||||
ev.keyCode === 17 || // Ctrl
|
||||
|
||||
Reference in New Issue
Block a user