pi-cc-extensions 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/claude-code-style.ts +34 -39
- package/package.json +1 -1
|
@@ -321,7 +321,7 @@ let toolMouseTui: any = null;
|
|
|
321
321
|
let toolMouseUi: any = null;
|
|
322
322
|
let toolMouseInputUnsubscribe: (() => void) | null = null;
|
|
323
323
|
let toolMouseInputPatchTui: any = null;
|
|
324
|
-
let
|
|
324
|
+
let toolMouseInputPatchOriginalHandle: ((...args: any[]) => any) | null = null;
|
|
325
325
|
let toolMouseInputPatchWrapper: ((...args: any[]) => any) | null = null;
|
|
326
326
|
|
|
327
327
|
function parseSgrMousePackets(data: string): SgrMousePacket[] | null {
|
|
@@ -445,56 +445,51 @@ function toggleToolAtMouseClick(tui: any, packet: SgrMousePacket): boolean {
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
448
|
+
* pi-zentui consumes left-button presses for text selection. Intercept only a
|
|
449
|
+
* tool-row click at the TUI input boundary, before extension listeners run.
|
|
450
|
+
* Keyboard, wheel, drag, release, and non-tool clicks continue through Pi's
|
|
451
|
+
* original dispatcher, preserving pi-zentui's scroll-to-bottom behavior.
|
|
452
452
|
*/
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
if (!(listeners instanceof Set) || !listeners.has(handleToolMouseInput)) return;
|
|
456
|
-
|
|
457
|
-
const ordered = Array.from(listeners);
|
|
458
|
-
if (ordered[0] === handleToolMouseInput) return;
|
|
459
|
-
listeners.clear();
|
|
460
|
-
listeners.add(handleToolMouseInput);
|
|
461
|
-
for (const listener of ordered) {
|
|
462
|
-
if (listener !== handleToolMouseInput) listeners.add(listener);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
function patchToolMouseInputPriority(tui: any): void {
|
|
467
|
-
if (toolMouseInputPatchTui === tui) {
|
|
468
|
-
prioritizeToolMouseInput(tui);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
453
|
+
function patchToolMouseInputCapture(tui: any): void {
|
|
454
|
+
if (toolMouseInputPatchTui === tui) return;
|
|
471
455
|
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
if (typeof
|
|
456
|
+
restoreToolMouseInputCapture();
|
|
457
|
+
const originalHandle = tui?.handleInput;
|
|
458
|
+
if (typeof originalHandle !== "function") return;
|
|
475
459
|
|
|
476
460
|
const wrapper = function (this: any, ...args: any[]): any {
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
461
|
+
const data = args[0];
|
|
462
|
+
if (typeof data === "string") {
|
|
463
|
+
const packets = parseSgrMousePackets(data);
|
|
464
|
+
if (packets) {
|
|
465
|
+
for (const packet of packets) {
|
|
466
|
+
if (isSgrLeftPress(packet) && toggleToolAtMouseClick(this, packet)) return;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return Reflect.apply(originalHandle, this, args);
|
|
480
471
|
};
|
|
481
|
-
|
|
472
|
+
|
|
473
|
+
try {
|
|
474
|
+
tui.handleInput = wrapper;
|
|
475
|
+
} catch {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
482
478
|
toolMouseInputPatchTui = tui;
|
|
483
|
-
|
|
479
|
+
toolMouseInputPatchOriginalHandle = originalHandle;
|
|
484
480
|
toolMouseInputPatchWrapper = wrapper;
|
|
485
|
-
prioritizeToolMouseInput(tui);
|
|
486
481
|
}
|
|
487
482
|
|
|
488
|
-
function
|
|
483
|
+
function restoreToolMouseInputCapture(): void {
|
|
489
484
|
if (
|
|
490
485
|
toolMouseInputPatchTui
|
|
491
|
-
&&
|
|
492
|
-
&& toolMouseInputPatchTui.
|
|
486
|
+
&& toolMouseInputPatchOriginalHandle
|
|
487
|
+
&& toolMouseInputPatchTui.handleInput === toolMouseInputPatchWrapper
|
|
493
488
|
) {
|
|
494
|
-
toolMouseInputPatchTui.
|
|
489
|
+
toolMouseInputPatchTui.handleInput = toolMouseInputPatchOriginalHandle;
|
|
495
490
|
}
|
|
496
491
|
toolMouseInputPatchTui = null;
|
|
497
|
-
|
|
492
|
+
toolMouseInputPatchOriginalHandle = null;
|
|
498
493
|
toolMouseInputPatchWrapper = null;
|
|
499
494
|
}
|
|
500
495
|
|
|
@@ -528,7 +523,7 @@ function teardownToolMouseInteraction(): void {
|
|
|
528
523
|
} catch {
|
|
529
524
|
// The UI context may already have been reset during /reload.
|
|
530
525
|
}
|
|
531
|
-
|
|
526
|
+
restoreToolMouseInputCapture();
|
|
532
527
|
toolMouseTui = null;
|
|
533
528
|
toolMouseUi = null;
|
|
534
529
|
}
|
|
@@ -541,7 +536,7 @@ function installToolMouseInteraction(ctx: any): void {
|
|
|
541
536
|
toolMouseUi = ctx.ui;
|
|
542
537
|
ctx.ui.setWidget(TOOL_MOUSE_WIDGET_KEY, (tui: any) => {
|
|
543
538
|
toolMouseTui = tui;
|
|
544
|
-
|
|
539
|
+
patchToolMouseInputCapture(tui);
|
|
545
540
|
tui?.terminal?.write?.(TOOL_MOUSE_ENABLE);
|
|
546
541
|
// Keep the widget visually empty so Pi's default input bar/layout remains.
|
|
547
542
|
return { render: () => [], invalidate() {} };
|