mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 15:41:17 +00:00
* fix(#3408): automated AI fix * fix: address Codex review on PR #3409 * fix: address Codex review on PR #3409 * fix: address Codex review on PR #3409 * fix: address Codex review on PR #3409 * fix: address Codex review on PR #3409 * fix: address Codex review on PR #3409 * fix: address Codex review on PR #3409 * fix: preserve physical releases for Command-period interrupts * fix: allow Command-period with selected terminal text * style: keep Command-period additions ASCII-only * test: validate Command-period fixture without renderer errors * fix: support logical period across macOS keyboard layouts --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
type InterruptShortcutEvent = Pick<KeyboardEvent, "altKey" | "code" | "ctrlKey" | "key" | "metaKey" | "shiftKey">;
|
|
|
|
/**
|
|
* macOS Terminal convention: Command-Period interrupts the running
|
|
* command, equivalent to Ctrl+C. Netcatty does not bind Command-Period elsewhere, so on
|
|
* macOS it is forwarded as a SIGINT interrupt (#3408).
|
|
*/
|
|
export function isMacCommandPeriodInterruptChord(
|
|
event: InterruptShortcutEvent,
|
|
): boolean {
|
|
if (!event.metaKey || event.ctrlKey || event.altKey) return false;
|
|
// Shift can produce the logical period (for example on AZERTY).
|
|
// Only the physical-key fallback requires an unshifted event.
|
|
if (/^[\x20-\x7e]$/.test(event.key)) return event.key === ".";
|
|
return !event.shiftKey && event.code === "Period";
|
|
}
|
|
|
|
export function shouldUseUrgentTerminalInterrupt(
|
|
event: InterruptShortcutEvent,
|
|
options: { hasSelection: boolean },
|
|
): boolean {
|
|
if (options.hasSelection) return false;
|
|
if (!event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return false;
|
|
if (/^[\x20-\x7e]$/.test(event.key)) return event.key.toLowerCase() === "c";
|
|
return event.code === "KeyC" || event.key.toLowerCase() === "c";
|
|
}
|