MCPcopy
hub / github.com/codeaashu/claude-code / bindMouse

Method bindMouse

src/server/web/public/terminal.js:581–634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

579 return this._instantiationService.createInstance(_.DomRenderer, this, this._document, this.element, this.screenElement, this._viewportElement, this._helperContainer, this.linkifier);
580 }
581 bindMouse() {
582 const e3 = this, t3 = this.element;
583 function i3(t4) {
584 const i4 = e3._mouseService.getMouseReportCoords(t4, e3.screenElement);
585 if (!i4) return false;
586 let s4, r2;
587 switch (t4.overrideType || t4.type) {
588 case "mousemove":
589 r2 = 32, void 0 === t4.buttons ? (s4 = 3, void 0 !== t4.button && (s4 = t4.button < 3 ? t4.button : 3)) : s4 = 1 & t4.buttons ? 0 : 4 & t4.buttons ? 1 : 2 & t4.buttons ? 2 : 3;
590 break;
591 case "mouseup":
592 r2 = 0, s4 = t4.button < 3 ? t4.button : 3;
593 break;
594 case "mousedown":
595 r2 = 1, s4 = t4.button < 3 ? t4.button : 3;
596 break;
597 case "wheel":
598 if (e3._customWheelEventHandler && false === e3._customWheelEventHandler(t4)) return false;
599 if (0 === e3.viewport.getLinesScrolled(t4)) return false;
600 r2 = t4.deltaY < 0 ? 0 : 1, s4 = 4;
601 break;
602 default:
603 return false;
604 }
605 return !(void 0 === r2 || void 0 === s4 || s4 > 4) && e3.coreMouseService.triggerMouseEvent({ col: i4.col, row: i4.row, x: i4.x, y: i4.y, button: s4, action: r2, ctrl: t4.ctrlKey, alt: t4.altKey, shift: t4.shiftKey });
606 }
607 const s3 = { mouseup: null, wheel: null, mousedrag: null, mousemove: null }, n2 = { mouseup: (e4) => (i3(e4), e4.buttons || (this._document.removeEventListener("mouseup", s3.mouseup), s3.mousedrag && this._document.removeEventListener("mousemove", s3.mousedrag)), this.cancel(e4)), wheel: (e4) => (i3(e4), this.cancel(e4, true)), mousedrag: (e4) => {
608 e4.buttons && i3(e4);
609 }, mousemove: (e4) => {
610 e4.buttons || i3(e4);
611 } };
612 this.register(this.coreMouseService.onProtocolChange(((e4) => {
613 e4 ? ("debug" === this.optionsService.rawOptions.logLevel && this._logService.debug("Binding to mouse events:", this.coreMouseService.explainEvents(e4)), this.element.classList.add("enable-mouse-events"), this._selectionService.disable()) : (this._logService.debug("Unbinding from mouse events."), this.element.classList.remove("enable-mouse-events"), this._selectionService.enable()), 8 & e4 ? s3.mousemove || (t3.addEventListener("mousemove", n2.mousemove), s3.mousemove = n2.mousemove) : (t3.removeEventListener("mousemove", s3.mousemove), s3.mousemove = null), 16 & e4 ? s3.wheel || (t3.addEventListener("wheel", n2.wheel, { passive: false }), s3.wheel = n2.wheel) : (t3.removeEventListener("wheel", s3.wheel), s3.wheel = null), 2 & e4 ? s3.mouseup || (s3.mouseup = n2.mouseup) : (this._document.removeEventListener("mouseup", s3.mouseup), s3.mouseup = null), 4 & e4 ? s3.mousedrag || (s3.mousedrag = n2.mousedrag) : (this._document.removeEventListener("mousemove", s3.mousedrag), s3.mousedrag = null);
614 }))), this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol, this.register((0, r.addDisposableDomListener)(t3, "mousedown", ((e4) => {
615 if (e4.preventDefault(), this.focus(), this.coreMouseService.areMouseEventsActive && !this._selectionService.shouldForceSelection(e4)) return i3(e4), s3.mouseup && this._document.addEventListener("mouseup", s3.mouseup), s3.mousedrag && this._document.addEventListener("mousemove", s3.mousedrag), this.cancel(e4);
616 }))), this.register((0, r.addDisposableDomListener)(t3, "wheel", ((e4) => {
617 if (!s3.wheel) {
618 if (this._customWheelEventHandler && false === this._customWheelEventHandler(e4)) return false;
619 if (!this.buffer.hasScrollback) {
620 const t4 = this.viewport.getLinesScrolled(e4);
621 if (0 === t4) return;
622 const i4 = D.C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? "O" : "[") + (e4.deltaY < 0 ? "A" : "B");
623 let s4 = "";
624 for (let e5 = 0; e5 < Math.abs(t4); e5++) s4 += i4;
625 return this.coreService.triggerDataEvent(s4, true), this.cancel(e4, true);
626 }
627 return this.viewport.handleWheel(e4) ? this.cancel(e4) : void 0;
628 }
629 }), { passive: false })), this.register((0, r.addDisposableDomListener)(t3, "touchstart", ((e4) => {
630 if (!this.coreMouseService.areMouseEventsActive) return this.viewport.handleTouchStart(e4), this.cancel(e4);
631 }), { passive: true })), this.register((0, r.addDisposableDomListener)(t3, "touchmove", ((e4) => {
632 if (!this.coreMouseService.areMouseEventsActive) return this.viewport.handleTouchMove(e4) ? void 0 : this.cancel(e4);
633 }), { passive: false }));
634 }
635 refresh(e3, t3) {
636 var _a;
637 (_a = this._renderService) == null ? void 0 : _a.refreshRows(e3, t3);

Callers 1

openMethod · 0.95

Calls 15

cancelMethod · 0.95
focusMethod · 0.95
i3Function · 0.85
explainEventsMethod · 0.80
preventDefaultMethod · 0.80
shouldForceSelectionMethod · 0.80
getLinesScrolledMethod · 0.80
triggerDataEventMethod · 0.80
handleWheelMethod · 0.80
handleTouchStartMethod · 0.80
handleTouchMoveMethod · 0.80
registerMethod · 0.45

Tested by

no test coverage detected