@sanohiro/casty 0.5.3 → 0.5.4
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/bin/casty +1 -0
- package/bin/casty.js +11 -10
- package/lib/input.js +18 -4
- package/lib/kitty.js +2 -2
- package/package.json +1 -1
package/bin/casty
CHANGED
|
@@ -200,5 +200,6 @@ fi
|
|
|
200
200
|
# When called from casty.js, CASTY_ENSURE_CHROME is set — just return
|
|
201
201
|
# When called directly (./bin/casty), launch the app
|
|
202
202
|
if [ -z "$CASTY_ENSURE_CHROME" ]; then
|
|
203
|
+
export CASTY_ENSURE_CHROME=1
|
|
203
204
|
exec node "$CASTY_DIR/bin/casty.js" "$@"
|
|
204
205
|
fi
|
package/bin/casty.js
CHANGED
|
@@ -5,16 +5,17 @@ import { execFileSync } from 'node:child_process';
|
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { dirname, join } from 'node:path';
|
|
7
7
|
|
|
8
|
-
// Ensure Chrome is installed (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
// Ensure Chrome is installed (skip if launched from bin/casty shell script)
|
|
9
|
+
if (!process.env.CASTY_ENSURE_CHROME) {
|
|
10
|
+
const __bin = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
try {
|
|
12
|
+
execFileSync('bash', [join(__bin, 'casty')], {
|
|
13
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
14
|
+
env: { ...process.env, CASTY_ENSURE_CHROME: '1' },
|
|
15
|
+
});
|
|
16
|
+
} catch (err) {
|
|
17
|
+
if (err.status) process.exit(err.status);
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
import { startBrowser, setupPage, startScreencast, stopScreencast } from '../lib/browser.js';
|
package/lib/input.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { toKeyName } from './keys.js';
|
|
5
5
|
import { UrlBar } from './urlbar.js';
|
|
6
6
|
import { HintMode } from './hints.js';
|
|
7
|
+
import { loadConfig } from './config.js';
|
|
7
8
|
|
|
8
9
|
// SGR 1006 mouse button codes
|
|
9
10
|
const MOUSE_BTN_LEFT = 0;
|
|
@@ -19,16 +20,29 @@ const CLIPBOARD_TIMEOUT = 1000; // ms
|
|
|
19
20
|
// Status message display duration
|
|
20
21
|
const STATUS_DISPLAY_MS = 2000;
|
|
21
22
|
|
|
23
|
+
// Detect mouse tracking mode:
|
|
24
|
+
// 1002 = button-event tracking (reports motion only while button held)
|
|
25
|
+
// 1003 = any-event tracking (reports all motion — needed for hover on Ghostty)
|
|
26
|
+
// Default: 1002 (compatible). Ghostty auto-upgrades to 1003.
|
|
27
|
+
// Override via config.json: "mouseMode": 1002 or 1003
|
|
28
|
+
function detectMouseMode() {
|
|
29
|
+
const config = loadConfig();
|
|
30
|
+
if (config.mouseMode) return config.mouseMode;
|
|
31
|
+
const termProg = (process.env.TERM_PROGRAM || '').toLowerCase();
|
|
32
|
+
if (termProg === 'ghostty') return 1003;
|
|
33
|
+
return 1002;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const MOUSE_MODE = detectMouseMode();
|
|
37
|
+
|
|
22
38
|
// Enable mouse events (SGR 1006 format)
|
|
23
|
-
// Mode 1003: any-event tracking (reports motion even without button press)
|
|
24
|
-
// This ensures Chrome always knows cursor position for proper hover/click handling
|
|
25
39
|
export function enableMouse() {
|
|
26
|
-
process.stdout.write(
|
|
40
|
+
process.stdout.write(`\x1b[?1000;${MOUSE_MODE};1006h`);
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
// Disable mouse events
|
|
30
44
|
export function disableMouse() {
|
|
31
|
-
process.stdout.write(
|
|
45
|
+
process.stdout.write(`\x1b[?1000;${MOUSE_MODE};1006l`);
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
// Convert terminal cell coordinates to pixel coordinates
|
package/lib/kitty.js
CHANGED
|
@@ -37,10 +37,10 @@ function detectTransport() {
|
|
|
37
37
|
if (setting === 'file') return 'file';
|
|
38
38
|
if (setting === 'inline') return 'inline';
|
|
39
39
|
|
|
40
|
-
// auto:
|
|
40
|
+
// auto: file transfer (t=f) for terminals that support it
|
|
41
41
|
const termProg = process.env.TERM_PROGRAM || '';
|
|
42
42
|
if (/bcon/i.test(termProg)) return 'file';
|
|
43
|
-
|
|
43
|
+
if (/kitty/i.test(termProg)) return 'file';
|
|
44
44
|
return 'inline';
|
|
45
45
|
}
|
|
46
46
|
|