mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-31 05:32:58 +00:00
refactor(app): name the terminal key-event input shapes
Promote the inline multi-property parameter types added by this PR to named interfaces, per docs/coding-standards.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
a983ae0444
commit
70210f1071
@@ -73,12 +73,14 @@ function settleMountRefits(): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, 2_600));
|
||||
}
|
||||
|
||||
function createTerminalHost(input: {
|
||||
interface CreateTerminalHostInput {
|
||||
width: number;
|
||||
height: number;
|
||||
scrollback?: number;
|
||||
isMacLikePlatform?: boolean;
|
||||
}): MountedTerminal {
|
||||
}
|
||||
|
||||
function createTerminalHost(input: CreateTerminalHostInput): MountedTerminal {
|
||||
const root = document.createElement("div");
|
||||
root.style.width = `${input.width}px`;
|
||||
root.style.height = `${input.height}px`;
|
||||
@@ -178,7 +180,7 @@ function getBrowserTerminal(): BrowserTerminal {
|
||||
return terminal;
|
||||
}
|
||||
|
||||
function dispatchTerminalKey(input: {
|
||||
interface DispatchTerminalKeyInput {
|
||||
host: HTMLElement;
|
||||
key: string;
|
||||
keyCode?: number;
|
||||
@@ -186,7 +188,9 @@ function dispatchTerminalKey(input: {
|
||||
ctrlKey?: boolean;
|
||||
altKey?: boolean;
|
||||
metaKey?: boolean;
|
||||
}): boolean {
|
||||
}
|
||||
|
||||
function dispatchTerminalKey(input: DispatchTerminalKeyInput): boolean {
|
||||
const textarea = input.host.querySelector<HTMLTextAreaElement>("textarea");
|
||||
if (!textarea) {
|
||||
throw new Error("Expected xterm textarea to be mounted");
|
||||
|
||||
@@ -82,18 +82,18 @@ export function hasPendingTerminalModifiers(modifiers: PendingTerminalModifiers)
|
||||
return modifiers.ctrl || modifiers.shift || modifiers.alt;
|
||||
}
|
||||
|
||||
interface AppleHandheldDetectionInput {
|
||||
interface MacPlatformDetectionInput {
|
||||
userAgent: string | null | undefined;
|
||||
platform: string | null | undefined;
|
||||
}
|
||||
|
||||
interface AppleHandheldDetectionInput extends MacPlatformDetectionInput {
|
||||
maxTouchPoints: number | null | undefined;
|
||||
}
|
||||
|
||||
// Matches macOS and iPadOS (which reports a Mac user agent in WKWebView); both
|
||||
// follow the same cmd/option editing conventions on hardware keyboards.
|
||||
export function isMacLikePlatform(input: {
|
||||
userAgent: string | null | undefined;
|
||||
platform: string | null | undefined;
|
||||
}): boolean {
|
||||
export function isMacLikePlatform(input: MacPlatformDetectionInput): boolean {
|
||||
return /Macintosh|Mac OS/i.test(input.userAgent ?? "") || /Mac/i.test(input.platform ?? "");
|
||||
}
|
||||
|
||||
@@ -144,19 +144,23 @@ export function shouldInterceptDomTerminalKey(args: {
|
||||
return false;
|
||||
}
|
||||
|
||||
interface MacTerminalEditingShortcutInput {
|
||||
key: string;
|
||||
ctrlKey: boolean;
|
||||
shiftKey: boolean;
|
||||
altKey: boolean;
|
||||
metaKey: boolean;
|
||||
}
|
||||
|
||||
// macOS terminals translate these editing chords instead of forwarding raw modified
|
||||
// keys: Terminal.app and iTerm2 ("Natural Text Editing") send ^A/^E for cmd+arrows,
|
||||
// ESC b / ESC f for option+arrows, and ^U for cmd+backspace. xterm ignores meta+arrow
|
||||
// entirely, and 6.x dropped the 5.x macOS conversion of option+arrow to ESC b/f, so
|
||||
// without this the shell receives nothing or an `ESC[1;3C`-style sequence it can't
|
||||
// parse (which zsh renders as a stray "C"/"D" plus a bell).
|
||||
export function resolveMacTerminalEditingShortcut(args: {
|
||||
key: string;
|
||||
ctrlKey: boolean;
|
||||
shiftKey: boolean;
|
||||
altKey: boolean;
|
||||
metaKey: boolean;
|
||||
}): string | null {
|
||||
export function resolveMacTerminalEditingShortcut(
|
||||
args: MacTerminalEditingShortcutInput,
|
||||
): string | null {
|
||||
if (args.ctrlKey || args.shiftKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user