mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 23:50:45 +00:00
Adds customizable global keyboard shortcut support
Implements a flexible system for configuring and persisting keyboard shortcuts across the app, enabling users to select hotkey schemes (Mac/PC), edit, disable, or reset shortcuts, and apply them globally and in terminal contexts. Improves accessibility and workflow by allowing tailored key bindings, storing preferences in local storage, and integrating shortcut management into settings UI. Refines styling for active UI elements, spinners, and borders for better theme consistency.
This commit is contained in:
1 parent
b272ae799c
commit
151cd4bfab
14 files changed
+1096
-78
No files matched your search
@@ -1,8 +1,9 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useIsVaultActive } from './application/state/activeTabStore';
|
||||
import { activeTabStore, useIsVaultActive } from './application/state/activeTabStore';
|
||||
import { useSessionState } from './application/state/useSessionState';
|
||||
import { useSettingsState } from './application/state/useSettingsState';
|
||||
import { useVaultState } from './application/state/useVaultState';
|
||||
import { matchesKeyBinding } from './domain/models';
|
||||
import ProtocolSelectDialog from './components/ProtocolSelectDialog';
|
||||
import { QuickSwitcher } from './components/QuickSwitcher';
|
||||
import SettingsDialog from './components/SettingsDialog';
|
||||
@@ -57,6 +58,12 @@ function App() {
|
||||
setTerminalFontSize,
|
||||
terminalSettings,
|
||||
updateTerminalSetting,
|
||||
hotkeyScheme,
|
||||
setHotkeyScheme,
|
||||
keyBindings,
|
||||
updateKeyBinding,
|
||||
resetKeyBinding,
|
||||
resetAllKeyBindings,
|
||||
} = useSettingsState();
|
||||
|
||||
const {
|
||||
@@ -111,6 +118,153 @@ function App() {
|
||||
// isMacClient is used for window controls styling
|
||||
const isMacClient = typeof navigator !== 'undefined' && /Mac|Macintosh/.test(navigator.userAgent);
|
||||
|
||||
// Global hotkey handler
|
||||
useEffect(() => {
|
||||
if (hotkeyScheme === 'disabled') return;
|
||||
|
||||
const isMac = hotkeyScheme === 'mac';
|
||||
|
||||
const handleGlobalKeyDown = (e: KeyboardEvent) => {
|
||||
// Don't handle if we're in an input or textarea (except for Escape)
|
||||
// Note: xterm terminal handles its own key interception via attachCustomKeyEventHandler
|
||||
const target = e.target as HTMLElement;
|
||||
const isFormElement = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
||||
|
||||
if (isFormElement && e.key !== 'Escape') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check each key binding
|
||||
for (const binding of keyBindings) {
|
||||
const keyStr = isMac ? binding.mac : binding.pc;
|
||||
if (matchesKeyBinding(e, keyStr, isMac)) {
|
||||
// Terminal-specific actions should be handled by the terminal
|
||||
// Don't handle them at app level
|
||||
const terminalActions = ['copy', 'paste', 'selectAll', 'clearBuffer', 'searchTerminal'];
|
||||
if (terminalActions.includes(binding.action)) {
|
||||
return; // Let terminal handle it
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Execute the action
|
||||
switch (binding.action) {
|
||||
case 'switchToTab': {
|
||||
// Get the number key pressed (1-9)
|
||||
const num = parseInt(e.key, 10);
|
||||
if (num >= 1 && num <= 9) {
|
||||
// Build complete tab list: vault + sessions/workspaces
|
||||
const allTabs = ['vault', ...orderedTabs];
|
||||
if (num <= allTabs.length) {
|
||||
setActiveTabId(allTabs[num - 1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'nextTab': {
|
||||
// Build complete tab list: vault + sessions/workspaces
|
||||
const allTabs = ['vault', ...orderedTabs];
|
||||
const currentId = activeTabStore.getActiveTabId();
|
||||
const currentIdx = allTabs.indexOf(currentId);
|
||||
if (currentIdx !== -1 && allTabs.length > 0) {
|
||||
const nextIdx = (currentIdx + 1) % allTabs.length;
|
||||
setActiveTabId(allTabs[nextIdx]);
|
||||
} else if (allTabs.length > 0) {
|
||||
setActiveTabId(allTabs[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'prevTab': {
|
||||
// Build complete tab list: vault + sessions/workspaces
|
||||
const allTabs = ['vault', ...orderedTabs];
|
||||
const currentId = activeTabStore.getActiveTabId();
|
||||
const currentIdx = allTabs.indexOf(currentId);
|
||||
if (currentIdx !== -1 && allTabs.length > 0) {
|
||||
const prevIdx = (currentIdx - 1 + allTabs.length) % allTabs.length;
|
||||
setActiveTabId(allTabs[prevIdx]);
|
||||
} else if (allTabs.length > 0) {
|
||||
setActiveTabId(allTabs[allTabs.length - 1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'closeTab': {
|
||||
const currentId = activeTabStore.getActiveTabId();
|
||||
if (currentId !== 'vault' && currentId !== 'sftp') {
|
||||
// Find if it's a session or workspace
|
||||
const session = sessions.find(s => s.id === currentId);
|
||||
if (session) {
|
||||
closeSession(currentId);
|
||||
} else {
|
||||
const workspace = workspaces.find(w => w.id === currentId);
|
||||
if (workspace) {
|
||||
closeWorkspace(currentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'newTab':
|
||||
case 'openLocal':
|
||||
createLocalTerminal();
|
||||
break;
|
||||
case 'openHosts':
|
||||
setActiveTabId('vault');
|
||||
break;
|
||||
case 'openSftp':
|
||||
setActiveTabId('sftp');
|
||||
break;
|
||||
case 'quickSwitch':
|
||||
case 'commandPalette':
|
||||
setIsQuickSwitcherOpen(true);
|
||||
break;
|
||||
case 'portForwarding':
|
||||
// Navigate to vault and could open port forwarding section
|
||||
setActiveTabId('vault');
|
||||
break;
|
||||
case 'snippets':
|
||||
// Navigate to vault
|
||||
setActiveTabId('vault');
|
||||
break;
|
||||
case 'broadcast':
|
||||
// TODO: Implement broadcast mode toggle
|
||||
console.log('[Hotkey] Broadcast mode toggle requested');
|
||||
break;
|
||||
case 'sidePanel':
|
||||
// TODO: Implement side panel toggle
|
||||
console.log('[Hotkey] Side panel toggle requested');
|
||||
break;
|
||||
case 'splitHorizontal':
|
||||
// TODO: Implement horizontal split
|
||||
console.log('[Hotkey] Split horizontal requested');
|
||||
break;
|
||||
case 'splitVertical':
|
||||
// TODO: Implement vertical split
|
||||
console.log('[Hotkey] Split vertical requested');
|
||||
break;
|
||||
case 'moveFocus': {
|
||||
// Move focus between split panes
|
||||
const direction = e.key === 'ArrowUp' ? 'up'
|
||||
: e.key === 'ArrowDown' ? 'down'
|
||||
: e.key === 'ArrowLeft' ? 'left'
|
||||
: e.key === 'ArrowRight' ? 'right'
|
||||
: null;
|
||||
if (direction) {
|
||||
console.log(`[Hotkey] Move focus ${direction}`);
|
||||
// TODO: Implement focus movement in workspace
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleGlobalKeyDown, true);
|
||||
return () => window.removeEventListener('keydown', handleGlobalKeyDown, true);
|
||||
}, [hotkeyScheme, keyBindings, orderedTabs, sessions, workspaces, setActiveTabId, closeSession, closeWorkspace, createLocalTerminal]);
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && isQuickSwitcherOpen) {
|
||||
@@ -256,6 +410,8 @@ function App() {
|
||||
draggingSessionId={draggingSessionId}
|
||||
terminalTheme={currentTerminalTheme}
|
||||
fontSize={terminalFontSize}
|
||||
hotkeyScheme={hotkeyScheme}
|
||||
keyBindings={keyBindings}
|
||||
onCloseSession={closeSession}
|
||||
onUpdateSessionStatus={updateSessionStatus}
|
||||
onUpdateHostDistro={updateHostDistro}
|
||||
@@ -347,6 +503,12 @@ function App() {
|
||||
onTerminalFontSizeChange={setTerminalFontSize}
|
||||
terminalSettings={terminalSettings}
|
||||
onTerminalSettingsChange={updateTerminalSetting}
|
||||
hotkeyScheme={hotkeyScheme}
|
||||
onHotkeySchemeChange={setHotkeyScheme}
|
||||
keyBindings={keyBindings}
|
||||
onUpdateKeyBinding={updateKeyBinding}
|
||||
onResetKeyBinding={resetKeyBinding}
|
||||
onResetAllKeyBindings={resetAllKeyBindings}
|
||||
/>
|
||||
|
||||
{/* Protocol Select Dialog for QuickSwitcher */}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import { KeyBinding, matchesKeyBinding } from '../../domain/models';
|
||||
import { activeTabStore } from './activeTabStore';
|
||||
|
||||
export interface HotkeyActions {
|
||||
// Tab management
|
||||
switchToTab: (tabIndex: number) => void;
|
||||
nextTab: () => void;
|
||||
prevTab: () => void;
|
||||
closeTab: () => void;
|
||||
newTab: () => void;
|
||||
|
||||
// Navigation
|
||||
openHosts: () => void;
|
||||
openSftp: () => void;
|
||||
quickSwitch: () => void;
|
||||
commandPalette: () => void;
|
||||
portForwarding: () => void;
|
||||
snippets: () => void;
|
||||
|
||||
// Terminal actions (handled per-terminal)
|
||||
copy: () => void;
|
||||
paste: () => void;
|
||||
selectAll: () => void;
|
||||
clearBuffer: () => void;
|
||||
searchTerminal: () => void;
|
||||
|
||||
// Workspace/split actions
|
||||
splitHorizontal: () => void;
|
||||
splitVertical: () => void;
|
||||
moveFocus: (direction: 'up' | 'down' | 'left' | 'right') => void;
|
||||
|
||||
// App features
|
||||
broadcast: () => void;
|
||||
sidePanel: () => void;
|
||||
openLocal: () => void;
|
||||
}
|
||||
|
||||
// Check if keyboard event matches our app-level shortcuts
|
||||
// Returns the matched binding action or null
|
||||
export const checkAppShortcut = (
|
||||
e: KeyboardEvent,
|
||||
keyBindings: KeyBinding[],
|
||||
isMac: boolean
|
||||
): { action: string; binding: KeyBinding } | null => {
|
||||
for (const binding of keyBindings) {
|
||||
const keyStr = isMac ? binding.mac : binding.pc;
|
||||
if (matchesKeyBinding(e, keyStr, isMac)) {
|
||||
return { action: binding.action, binding };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// Get list of key bindings that should be handled at app level (not by terminal)
|
||||
export const getAppLevelActions = (): Set<string> => {
|
||||
return new Set([
|
||||
'switchToTab',
|
||||
'nextTab',
|
||||
'prevTab',
|
||||
'closeTab',
|
||||
'newTab',
|
||||
'openHosts',
|
||||
'openSftp',
|
||||
'quickSwitch',
|
||||
'commandPalette',
|
||||
'portForwarding',
|
||||
'snippets',
|
||||
'splitHorizontal',
|
||||
'splitVertical',
|
||||
'moveFocus',
|
||||
'broadcast',
|
||||
'sidePanel',
|
||||
'openLocal',
|
||||
]);
|
||||
};
|
||||
|
||||
// Terminal-level actions that xterm should not intercept
|
||||
export const getTerminalPassthroughActions = (): Set<string> => {
|
||||
return new Set([
|
||||
'copy',
|
||||
'paste',
|
||||
'selectAll',
|
||||
'clearBuffer',
|
||||
'searchTerminal',
|
||||
]);
|
||||
};
|
||||
|
||||
interface UseGlobalHotkeysOptions {
|
||||
hotkeyScheme: 'disabled' | 'mac' | 'pc';
|
||||
keyBindings: KeyBinding[];
|
||||
actions: Partial<HotkeyActions>;
|
||||
orderedTabs: string[];
|
||||
sessions: { id: string }[];
|
||||
workspaces: { id: string }[];
|
||||
isSettingsOpen?: boolean;
|
||||
}
|
||||
|
||||
export const useGlobalHotkeys = ({
|
||||
hotkeyScheme,
|
||||
keyBindings,
|
||||
actions,
|
||||
orderedTabs,
|
||||
sessions,
|
||||
workspaces,
|
||||
isSettingsOpen = false,
|
||||
}: UseGlobalHotkeysOptions) => {
|
||||
const actionsRef = useRef(actions);
|
||||
actionsRef.current = actions;
|
||||
|
||||
const orderedTabsRef = useRef(orderedTabs);
|
||||
orderedTabsRef.current = orderedTabs;
|
||||
|
||||
const sessionsRef = useRef(sessions);
|
||||
sessionsRef.current = sessions;
|
||||
|
||||
const workspacesRef = useRef(workspaces);
|
||||
workspacesRef.current = workspaces;
|
||||
|
||||
const handleGlobalKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (hotkeyScheme === 'disabled') return;
|
||||
if (isSettingsOpen) return; // Don't handle hotkeys when settings is open
|
||||
|
||||
const isMac = hotkeyScheme === 'mac';
|
||||
const appLevelActions = getAppLevelActions();
|
||||
|
||||
// Check if this is an app-level shortcut
|
||||
const matched = checkAppShortcut(e, keyBindings, isMac);
|
||||
if (!matched) return;
|
||||
|
||||
const { action, binding: _binding } = matched;
|
||||
|
||||
// Only handle app-level actions here
|
||||
// Terminal-level actions are handled by the terminal itself
|
||||
if (!appLevelActions.has(action)) return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const currentActions = actionsRef.current;
|
||||
const tabs = orderedTabsRef.current;
|
||||
|
||||
switch (action) {
|
||||
case 'switchToTab': {
|
||||
const num = parseInt(e.key, 10);
|
||||
if (num >= 1 && num <= 9) {
|
||||
currentActions.switchToTab?.(num);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'nextTab':
|
||||
currentActions.nextTab?.();
|
||||
break;
|
||||
case 'prevTab':
|
||||
currentActions.prevTab?.();
|
||||
break;
|
||||
case 'closeTab':
|
||||
currentActions.closeTab?.();
|
||||
break;
|
||||
case 'newTab':
|
||||
currentActions.newTab?.();
|
||||
break;
|
||||
case 'openHosts':
|
||||
currentActions.openHosts?.();
|
||||
break;
|
||||
case 'openSftp':
|
||||
currentActions.openSftp?.();
|
||||
break;
|
||||
case 'openLocal':
|
||||
currentActions.openLocal?.();
|
||||
break;
|
||||
case 'quickSwitch':
|
||||
currentActions.quickSwitch?.();
|
||||
break;
|
||||
case 'commandPalette':
|
||||
currentActions.commandPalette?.();
|
||||
break;
|
||||
case 'portForwarding':
|
||||
currentActions.portForwarding?.();
|
||||
break;
|
||||
case 'snippets':
|
||||
currentActions.snippets?.();
|
||||
break;
|
||||
case 'splitHorizontal':
|
||||
currentActions.splitHorizontal?.();
|
||||
break;
|
||||
case 'splitVertical':
|
||||
currentActions.splitVertical?.();
|
||||
break;
|
||||
case 'moveFocus': {
|
||||
// Determine direction from arrow key
|
||||
const key = e.key;
|
||||
if (key === 'ArrowUp') currentActions.moveFocus?.('up');
|
||||
else if (key === 'ArrowDown') currentActions.moveFocus?.('down');
|
||||
else if (key === 'ArrowLeft') currentActions.moveFocus?.('left');
|
||||
else if (key === 'ArrowRight') currentActions.moveFocus?.('right');
|
||||
break;
|
||||
}
|
||||
case 'broadcast':
|
||||
currentActions.broadcast?.();
|
||||
break;
|
||||
case 'sidePanel':
|
||||
currentActions.sidePanel?.();
|
||||
break;
|
||||
}
|
||||
}, [hotkeyScheme, keyBindings, isSettingsOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
// Use capture phase to intercept before xterm
|
||||
window.addEventListener('keydown', handleGlobalKeyDown, true);
|
||||
return () => window.removeEventListener('keydown', handleGlobalKeyDown, true);
|
||||
}, [handleGlobalKeyDown]);
|
||||
};
|
||||
|
||||
// Helper to create key event handler for xterm's attachCustomKeyEventHandler
|
||||
// Returns false to let xterm handle the key, true to prevent xterm from handling
|
||||
export const createXtermKeyHandler = (
|
||||
keyBindings: KeyBinding[],
|
||||
isMac: boolean,
|
||||
onTerminalAction?: (action: string, e: KeyboardEvent) => void
|
||||
) => {
|
||||
const appLevelActions = getAppLevelActions();
|
||||
const terminalActions = getTerminalPassthroughActions();
|
||||
|
||||
return (e: KeyboardEvent): boolean => {
|
||||
const matched = checkAppShortcut(e, keyBindings, isMac);
|
||||
if (!matched) return true; // Let xterm handle it
|
||||
|
||||
const { action } = matched;
|
||||
|
||||
// App-level actions: prevent xterm from handling, let global handler take over
|
||||
if (appLevelActions.has(action)) {
|
||||
return false; // Don't let xterm handle, will bubble to global handler
|
||||
}
|
||||
|
||||
// Terminal-level actions: handle here and prevent default
|
||||
if (terminalActions.has(action)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
onTerminalAction?.(action, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // Let xterm handle other keys
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback,useEffect,useMemo,useState } from 'react';
|
||||
import { SyncConfig, TerminalSettings, DEFAULT_TERMINAL_SETTINGS } from '../../domain/models';
|
||||
import { SyncConfig, TerminalSettings, DEFAULT_TERMINAL_SETTINGS, HotkeyScheme, CustomKeyBindings, DEFAULT_KEY_BINDINGS, KeyBinding } from '../../domain/models';
|
||||
import {
|
||||
STORAGE_KEY_COLOR,
|
||||
STORAGE_KEY_SYNC,
|
||||
@@ -8,6 +8,8 @@ STORAGE_KEY_THEME,
|
||||
STORAGE_KEY_TERM_FONT_FAMILY,
|
||||
STORAGE_KEY_TERM_FONT_SIZE,
|
||||
STORAGE_KEY_TERM_SETTINGS,
|
||||
STORAGE_KEY_HOTKEY_SCHEME,
|
||||
STORAGE_KEY_CUSTOM_KEY_BINDINGS,
|
||||
} from '../../infrastructure/config/storageKeys';
|
||||
import { TERMINAL_THEMES } from '../../infrastructure/config/terminalThemes';
|
||||
import { TERMINAL_FONTS, DEFAULT_FONT_SIZE } from '../../infrastructure/config/fonts';
|
||||
@@ -17,6 +19,7 @@ const DEFAULT_COLOR = '221.2 83.2% 53.3%';
|
||||
const DEFAULT_THEME: 'light' | 'dark' = 'light';
|
||||
const DEFAULT_TERMINAL_THEME = 'netcatty-dark';
|
||||
const DEFAULT_FONT_FAMILY = 'menlo';
|
||||
const DEFAULT_HOTKEY_SCHEME: HotkeyScheme = 'mac';
|
||||
|
||||
const applyThemeTokens = (theme: 'light' | 'dark', primaryColor: string) => {
|
||||
const root = window.document.documentElement;
|
||||
@@ -46,6 +49,10 @@ export const useSettingsState = () => {
|
||||
const stored = localStorageAdapter.read<TerminalSettings>(STORAGE_KEY_TERM_SETTINGS);
|
||||
return stored ? { ...DEFAULT_TERMINAL_SETTINGS, ...stored } : DEFAULT_TERMINAL_SETTINGS;
|
||||
});
|
||||
const [hotkeyScheme, setHotkeyScheme] = useState<HotkeyScheme>(() => (localStorageAdapter.readString(STORAGE_KEY_HOTKEY_SCHEME) as HotkeyScheme) || DEFAULT_HOTKEY_SCHEME);
|
||||
const [customKeyBindings, setCustomKeyBindings] = useState<CustomKeyBindings>(() =>
|
||||
localStorageAdapter.read<CustomKeyBindings>(STORAGE_KEY_CUSTOM_KEY_BINDINGS) || {}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
applyThemeTokens(theme, primaryColor);
|
||||
@@ -69,6 +76,61 @@ export const useSettingsState = () => {
|
||||
localStorageAdapter.write(STORAGE_KEY_TERM_SETTINGS, terminalSettings);
|
||||
}, [terminalSettings]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorageAdapter.writeString(STORAGE_KEY_HOTKEY_SCHEME, hotkeyScheme);
|
||||
}, [hotkeyScheme]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorageAdapter.write(STORAGE_KEY_CUSTOM_KEY_BINDINGS, customKeyBindings);
|
||||
}, [customKeyBindings]);
|
||||
|
||||
// Get merged key bindings (defaults + custom overrides)
|
||||
const keyBindings = useMemo((): KeyBinding[] => {
|
||||
return DEFAULT_KEY_BINDINGS.map(binding => {
|
||||
const custom = customKeyBindings[binding.id];
|
||||
if (!custom) return binding;
|
||||
return {
|
||||
...binding,
|
||||
mac: custom.mac ?? binding.mac,
|
||||
pc: custom.pc ?? binding.pc,
|
||||
};
|
||||
});
|
||||
}, [customKeyBindings]);
|
||||
|
||||
// Update a single key binding
|
||||
const updateKeyBinding = useCallback((bindingId: string, scheme: 'mac' | 'pc', newKey: string) => {
|
||||
setCustomKeyBindings(prev => ({
|
||||
...prev,
|
||||
[bindingId]: {
|
||||
...prev[bindingId],
|
||||
[scheme]: newKey,
|
||||
},
|
||||
}));
|
||||
}, []);
|
||||
|
||||
// Reset a key binding to default
|
||||
const resetKeyBinding = useCallback((bindingId: string, scheme?: 'mac' | 'pc') => {
|
||||
setCustomKeyBindings(prev => {
|
||||
const next = { ...prev };
|
||||
if (scheme) {
|
||||
if (next[bindingId]) {
|
||||
delete next[bindingId][scheme];
|
||||
if (Object.keys(next[bindingId]).length === 0) {
|
||||
delete next[bindingId];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
delete next[bindingId];
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
// Reset all key bindings to defaults
|
||||
const resetAllKeyBindings = useCallback(() => {
|
||||
setCustomKeyBindings({});
|
||||
}, []);
|
||||
|
||||
const updateSyncConfig = useCallback((config: SyncConfig | null) => {
|
||||
setSyncConfig(config);
|
||||
localStorageAdapter.write(STORAGE_KEY_SYNC, config);
|
||||
@@ -109,5 +171,12 @@ export const useSettingsState = () => {
|
||||
terminalSettings,
|
||||
setTerminalSettings,
|
||||
updateTerminalSetting,
|
||||
hotkeyScheme,
|
||||
setHotkeyScheme,
|
||||
keyBindings,
|
||||
customKeyBindings,
|
||||
updateKeyBinding,
|
||||
resetKeyBinding,
|
||||
resetAllKeyBindings,
|
||||
};
|
||||
};
|
||||
+367
-65
@@ -3,15 +3,18 @@ import {
|
||||
Cloud,
|
||||
Download,
|
||||
Github,
|
||||
Keyboard,
|
||||
Loader2,
|
||||
Moon,
|
||||
Palette,
|
||||
RotateCcw,
|
||||
Sun,
|
||||
TerminalSquare,
|
||||
Upload,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import React, { useState } from "react";
|
||||
import { Host, SSHKey, Snippet, TerminalSettings, CursorShape, RightClickBehavior, LinkModifier, DEFAULT_TERMINAL_SETTINGS } from "../domain/models";
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Host, SSHKey, Snippet, TerminalSettings, CursorShape, RightClickBehavior, LinkModifier, DEFAULT_TERMINAL_SETTINGS, HotkeyScheme, KeyBinding, keyEventToString } from "../domain/models";
|
||||
import { TERMINAL_THEMES } from "../infrastructure/config/terminalThemes";
|
||||
import { TERMINAL_FONTS, MIN_FONT_SIZE, MAX_FONT_SIZE } from "../infrastructure/config/fonts";
|
||||
import {
|
||||
@@ -53,6 +56,12 @@ interface SettingsDialogProps {
|
||||
onTerminalFontSizeChange?: (size: number) => void;
|
||||
terminalSettings?: TerminalSettings;
|
||||
onTerminalSettingsChange?: <K extends keyof TerminalSettings>(key: K, value: TerminalSettings[K]) => void;
|
||||
hotkeyScheme?: HotkeyScheme;
|
||||
onHotkeySchemeChange?: (scheme: HotkeyScheme) => void;
|
||||
keyBindings?: KeyBinding[];
|
||||
onUpdateKeyBinding?: (bindingId: string, scheme: 'mac' | 'pc', newKey: string) => void;
|
||||
onResetKeyBinding?: (bindingId: string, scheme?: 'mac' | 'pc') => void;
|
||||
onResetAllKeyBindings?: () => void;
|
||||
}
|
||||
|
||||
const COLORS = [
|
||||
@@ -138,8 +147,8 @@ function Select<T extends string | number>({ value, options, onChange, className
|
||||
<select
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
const val = typeof value === 'number'
|
||||
? parseInt(e.target.value) as T
|
||||
const val = typeof value === 'number'
|
||||
? parseInt(e.target.value) as T
|
||||
: e.target.value as T;
|
||||
onChange(val);
|
||||
}}
|
||||
@@ -166,6 +175,41 @@ const SectionHeader: React.FC<{ title: string }> = ({ title }) => (
|
||||
// Divider component
|
||||
const Divider: React.FC = () => <div className="h-px bg-border my-2" />;
|
||||
|
||||
// Tab title mapping
|
||||
const TAB_TITLES: Record<string, string> = {
|
||||
appearance: "Appearance",
|
||||
terminal: "Terminal",
|
||||
shortcuts: "Shortcuts",
|
||||
sync: "Sync & Cloud",
|
||||
data: "Data",
|
||||
};
|
||||
|
||||
// Settings Tab Content wrapper with fixed header
|
||||
interface SettingsTabContentProps {
|
||||
value: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const SettingsTabContent: React.FC<SettingsTabContentProps> = ({
|
||||
value,
|
||||
children,
|
||||
className,
|
||||
}) => (
|
||||
<TabsContent value={value} className="mt-0 border-0 h-full flex flex-col data-[state=inactive]:hidden">
|
||||
{/* Fixed Header */}
|
||||
<div className="shrink-0 h-14 px-6 flex items-center justify-between border-b border-border/60 bg-background">
|
||||
<h2 className="text-lg font-semibold">{TAB_TITLES[value] || value}</h2>
|
||||
</div>
|
||||
{/* Scrollable Content */}
|
||||
<ScrollArea className="flex-1">
|
||||
<div className={cn("p-6", className)}>
|
||||
{children}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</TabsContent>
|
||||
);
|
||||
|
||||
const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
@@ -185,8 +229,17 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
onTerminalFontSizeChange,
|
||||
terminalSettings = DEFAULT_TERMINAL_SETTINGS,
|
||||
onTerminalSettingsChange,
|
||||
hotkeyScheme = "mac",
|
||||
onHotkeySchemeChange,
|
||||
keyBindings = [],
|
||||
onUpdateKeyBinding,
|
||||
onResetKeyBinding,
|
||||
onResetAllKeyBindings,
|
||||
}) => {
|
||||
const [importText, setImportText] = useState("");
|
||||
const [editingBindingId, setEditingBindingId] = useState<string | null>(null);
|
||||
const [recordedKey, setRecordedKey] = useState<string>("");
|
||||
const keyRecordRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// Sync State
|
||||
const [githubToken, setGithubToken] = useState(syncConfig?.githubToken || "");
|
||||
@@ -196,6 +249,85 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
"idle",
|
||||
);
|
||||
|
||||
const isMac = hotkeyScheme === 'mac';
|
||||
|
||||
// Handle key recording for shortcut editing
|
||||
const handleKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (!editingBindingId) return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const keyStr = keyEventToString(e, isMac);
|
||||
|
||||
// If it's just modifier keys, keep waiting
|
||||
if (['Meta', 'Control', 'Alt', 'Shift'].includes(e.key)) {
|
||||
setRecordedKey(keyStr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Complete key combination recorded
|
||||
setRecordedKey(keyStr);
|
||||
}, [editingBindingId, isMac]);
|
||||
|
||||
const handleKeyUp = useCallback((e: KeyboardEvent) => {
|
||||
if (!editingBindingId || !recordedKey) return;
|
||||
|
||||
// If we have a complete key combo (not just modifiers), save it
|
||||
if (!['Meta', 'Control', 'Alt', 'Shift'].includes(e.key)) {
|
||||
// Recorded key is complete, will be saved on blur or confirm
|
||||
}
|
||||
}, [editingBindingId, recordedKey]);
|
||||
|
||||
// Start editing a binding
|
||||
const startEditing = useCallback((bindingId: string) => {
|
||||
setEditingBindingId(bindingId);
|
||||
setRecordedKey('');
|
||||
// Focus will trigger key listening
|
||||
setTimeout(() => {
|
||||
keyRecordRef.current?.focus();
|
||||
}, 0);
|
||||
}, []);
|
||||
|
||||
// Save the recorded key
|
||||
const saveRecordedKey = useCallback(() => {
|
||||
if (editingBindingId && recordedKey && onUpdateKeyBinding) {
|
||||
const scheme = hotkeyScheme === 'mac' ? 'mac' : 'pc';
|
||||
onUpdateKeyBinding(editingBindingId, scheme, recordedKey);
|
||||
}
|
||||
setEditingBindingId(null);
|
||||
setRecordedKey('');
|
||||
}, [editingBindingId, recordedKey, hotkeyScheme, onUpdateKeyBinding]);
|
||||
|
||||
// Cancel editing
|
||||
const cancelEditing = useCallback(() => {
|
||||
setEditingBindingId(null);
|
||||
setRecordedKey('');
|
||||
}, []);
|
||||
|
||||
// Disable this binding
|
||||
const disableBinding = useCallback((bindingId?: string) => {
|
||||
const targetId = bindingId || editingBindingId;
|
||||
if (targetId && onUpdateKeyBinding) {
|
||||
const scheme = hotkeyScheme === 'mac' ? 'mac' : 'pc';
|
||||
onUpdateKeyBinding(targetId, scheme, 'Disabled');
|
||||
}
|
||||
setEditingBindingId(null);
|
||||
setRecordedKey('');
|
||||
}, [editingBindingId, hotkeyScheme, onUpdateKeyBinding]);
|
||||
|
||||
// Listen for keydown when editing
|
||||
useEffect(() => {
|
||||
if (editingBindingId) {
|
||||
window.addEventListener('keydown', handleKeyDown, true);
|
||||
window.addEventListener('keyup', handleKeyUp, true);
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown, true);
|
||||
window.removeEventListener('keyup', handleKeyUp, true);
|
||||
};
|
||||
}
|
||||
}, [editingBindingId, handleKeyDown, handleKeyUp]);
|
||||
|
||||
const handleManualExport = () => {
|
||||
const dataStr =
|
||||
"data:text/json;charset=utf-8," +
|
||||
@@ -289,8 +421,6 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
|
||||
const getHslStyle = (hsl: string) => ({ backgroundColor: `hsl(${hsl})` });
|
||||
|
||||
const currentTerminalTheme = TERMINAL_THEMES.find(t => t.id === terminalThemeId) || TERMINAL_THEMES[0];
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="max-w-4xl p-0 h-[700px] gap-0 overflow-hidden flex flex-row">
|
||||
@@ -321,6 +451,12 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
>
|
||||
<TerminalSquare size={16} /> Terminal
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="shortcuts"
|
||||
className="w-full justify-start gap-3 px-3 py-2 data-[state=active]:bg-background"
|
||||
>
|
||||
<Keyboard size={16} /> Shortcuts
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="sync"
|
||||
className="w-full justify-start gap-3 px-3 py-2 data-[state=active]:bg-background"
|
||||
@@ -337,10 +473,9 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
</div>
|
||||
|
||||
{/* Content Area */}
|
||||
<ScrollArea className="flex-1 h-full">
|
||||
<div className="p-6">
|
||||
<div className="flex-1 h-full flex flex-col min-h-0">
|
||||
{/* Appearance Tab */}
|
||||
<TabsContent value="appearance" className="mt-0 border-0">
|
||||
<SettingsTabContent value="appearance">
|
||||
<SectionHeader title="UI Theme" />
|
||||
<div className="grid grid-cols-2 gap-4 max-w-sm">
|
||||
<ThemeCard
|
||||
@@ -381,43 +516,21 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
</SettingsTabContent>
|
||||
|
||||
{/* Terminal Tab - Redesigned */}
|
||||
<TabsContent value="terminal" className="mt-0 border-0">
|
||||
<SettingsTabContent value="terminal">
|
||||
{/* Color Scheme Section */}
|
||||
<SectionHeader title="Color Scheme" />
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-3 p-3 rounded-lg border bg-card">
|
||||
{/* Mini Terminal Preview */}
|
||||
<div
|
||||
className="w-20 h-14 rounded border flex flex-col p-1.5 gap-0.5 shrink-0 shadow-sm"
|
||||
style={{
|
||||
backgroundColor: currentTerminalTheme.colors.background,
|
||||
borderColor: currentTerminalTheme.colors.selection,
|
||||
}}
|
||||
>
|
||||
<div className="flex gap-1">
|
||||
<div className="w-4 h-1 rounded-full" style={{ backgroundColor: currentTerminalTheme.colors.green }} />
|
||||
<div className="w-6 h-1 rounded-full" style={{ backgroundColor: currentTerminalTheme.colors.foreground, opacity: 0.5 }} />
|
||||
</div>
|
||||
<div className="flex gap-1">
|
||||
<div className="w-3 h-1 rounded-full" style={{ backgroundColor: currentTerminalTheme.colors.blue }} />
|
||||
<div className="w-5 h-1 rounded-full" style={{ backgroundColor: currentTerminalTheme.colors.cyan }} />
|
||||
</div>
|
||||
<div className="w-2 h-2 mt-auto rounded-sm" style={{ backgroundColor: currentTerminalTheme.colors.cursor }} />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<div className="font-medium">{currentTerminalTheme.name}</div>
|
||||
<div className="text-xs text-muted-foreground capitalize">{currentTerminalTheme.type} Theme</div>
|
||||
</div>
|
||||
<Select
|
||||
value={terminalThemeId}
|
||||
options={TERMINAL_THEMES.map(t => ({ value: t.id, label: t.name }))}
|
||||
onChange={onTerminalThemeChange}
|
||||
className="w-48"
|
||||
<SectionHeader title="Terminal Theme" />
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
{TERMINAL_THEMES.map((t) => (
|
||||
<TerminalThemeCard
|
||||
key={t.id}
|
||||
theme={t}
|
||||
active={terminalThemeId === t.id}
|
||||
onClick={() => onTerminalThemeChange(t.id)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Font Section */}
|
||||
@@ -450,7 +563,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
</div>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Enable font ligatures"
|
||||
description="Display programming ligatures like => and !="
|
||||
>
|
||||
@@ -478,7 +591,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Line padding"
|
||||
description="Additional space between lines"
|
||||
>
|
||||
@@ -492,7 +605,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Fallback font"
|
||||
description="Secondary font for missing characters"
|
||||
>
|
||||
@@ -542,7 +655,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
{/* Rendering Section */}
|
||||
<SectionHeader title="Rendering" />
|
||||
<div className="space-y-0 divide-y divide-border rounded-lg border bg-card px-4">
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Scrollback"
|
||||
description="Number of lines kept in buffer"
|
||||
>
|
||||
@@ -557,7 +670,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Draw bold text in bright colors"
|
||||
>
|
||||
<Toggle
|
||||
@@ -566,7 +679,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Minimum contrast ratio"
|
||||
description="Adjust for accessibility (1-21)"
|
||||
>
|
||||
@@ -584,7 +697,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
{/* Keyboard Section */}
|
||||
<SectionHeader title="Keyboard" />
|
||||
<div className="space-y-0 divide-y divide-border rounded-lg border bg-card px-4">
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Use ⌥ as the Meta key"
|
||||
description="Lets the shell handle Meta key instead of OS"
|
||||
>
|
||||
@@ -594,7 +707,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Scroll on input"
|
||||
description="Scrolls the terminal to bottom on user input"
|
||||
>
|
||||
@@ -628,7 +741,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Word separators"
|
||||
description="Double-click selection stops at these characters"
|
||||
>
|
||||
@@ -640,7 +753,7 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
<SettingRow
|
||||
<SettingRow
|
||||
label="Require a key to click links"
|
||||
description="Links are only clickable while holding this key"
|
||||
>
|
||||
@@ -659,13 +772,144 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
</div>
|
||||
|
||||
<div className="h-6" /> {/* Bottom padding */}
|
||||
</TabsContent>
|
||||
</SettingsTabContent>
|
||||
|
||||
{/* Shortcuts Tab */}
|
||||
<SettingsTabContent value="shortcuts">
|
||||
{/* Hotkey Scheme Selector */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<Select
|
||||
value={hotkeyScheme}
|
||||
options={[
|
||||
{ value: 'disabled' as HotkeyScheme, label: 'Disabled' },
|
||||
{ value: 'mac' as HotkeyScheme, label: 'Mac hotkeys' },
|
||||
{ value: 'pc' as HotkeyScheme, label: 'PC hotkeys' },
|
||||
]}
|
||||
onChange={(v) => onHotkeySchemeChange?.(v)}
|
||||
className="w-44"
|
||||
/>
|
||||
{hotkeyScheme !== 'disabled' && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={onResetAllKeyBindings}
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<RotateCcw size={14} className="mr-1.5" />
|
||||
Reset All
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{hotkeyScheme !== 'disabled' && (
|
||||
<>
|
||||
{/* Shortcuts Table Header */}
|
||||
<div className="grid grid-cols-[180px_1fr] gap-4 pb-2 border-b border-border mb-2">
|
||||
<div className="text-sm font-semibold text-foreground">Shortcut</div>
|
||||
<div className="text-sm font-semibold text-foreground">Action</div>
|
||||
</div>
|
||||
|
||||
{/* Shortcuts List */}
|
||||
<div className="space-y-0">
|
||||
{keyBindings.map((binding) => {
|
||||
const shortcut = hotkeyScheme === 'mac' ? binding.mac : binding.pc;
|
||||
const isDisabled = shortcut === 'Disabled';
|
||||
const isEditing = editingBindingId === binding.id;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={binding.id}
|
||||
className={cn(
|
||||
"grid grid-cols-[180px_1fr] gap-4 py-2.5 border-b border-border/50 last:border-0 group",
|
||||
isEditing && "bg-primary/5"
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
{isEditing ? (
|
||||
<div className="flex items-center gap-2 w-full">
|
||||
<div
|
||||
ref={keyRecordRef}
|
||||
tabIndex={0}
|
||||
className="flex-1 h-8 px-2 rounded border-2 border-primary bg-background flex items-center justify-center text-sm font-medium animate-pulse focus:outline-none"
|
||||
>
|
||||
{recordedKey || 'Press keys...'}
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={saveRecordedKey}
|
||||
disabled={!recordedKey}
|
||||
>
|
||||
<Check size={14} className="text-green-500" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={cancelEditing}
|
||||
>
|
||||
<X size={14} className="text-muted-foreground" />
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className="cursor-pointer hover:opacity-80 flex items-center gap-2"
|
||||
onClick={() => startEditing(binding.id)}
|
||||
>
|
||||
{isDisabled ? (
|
||||
<span className="text-sm text-muted-foreground italic">Disabled</span>
|
||||
) : (
|
||||
<KeyCombo keys={shortcut} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{binding.label}
|
||||
</span>
|
||||
{!isEditing && (
|
||||
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-2 text-xs text-muted-foreground"
|
||||
onClick={() => disableBinding(binding.id)}
|
||||
disabled={isDisabled}
|
||||
>
|
||||
Disable
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-6 w-6"
|
||||
onClick={() => onResetKeyBinding?.(binding.id, hotkeyScheme === 'mac' ? 'mac' : 'pc')}
|
||||
title="Reset to default"
|
||||
>
|
||||
<RotateCcw size={12} />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{hotkeyScheme === 'disabled' && (
|
||||
<div className="flex flex-col items-center justify-center py-16 text-muted-foreground">
|
||||
<Keyboard size={48} className="mb-4 opacity-40" />
|
||||
<p className="text-sm">Keyboard shortcuts are disabled</p>
|
||||
<p className="text-xs mt-1">Select a hotkey scheme above to enable</p>
|
||||
</div>
|
||||
)}
|
||||
</SettingsTabContent>
|
||||
|
||||
{/* Sync Tab */}
|
||||
<TabsContent
|
||||
value="sync"
|
||||
className="space-y-6 max-w-lg mt-0 border-0"
|
||||
>
|
||||
<SettingsTabContent value="sync" className="space-y-6 max-w-lg">
|
||||
<div className="bg-blue-500/10 border border-blue-500/20 rounded-lg p-4 text-sm text-blue-500 flex gap-3">
|
||||
<Github className="shrink-0 mt-0.5" size={18} />
|
||||
<div>
|
||||
@@ -747,13 +991,10 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</TabsContent>
|
||||
</SettingsTabContent>
|
||||
|
||||
{/* Data Tab */}
|
||||
<TabsContent
|
||||
value="data"
|
||||
className="space-y-6 max-w-lg mt-0 border-0"
|
||||
>
|
||||
<SettingsTabContent value="data" className="space-y-6 max-w-lg">
|
||||
<div className="p-5 border rounded-lg bg-card hover:bg-muted/20 transition-colors">
|
||||
<h4 className="font-medium mb-2 flex items-center gap-2">
|
||||
<Download size={16} /> Export Data
|
||||
@@ -793,9 +1034,8 @@ const SettingsDialog: React.FC<SettingsDialogProps> = ({
|
||||
Import JSON
|
||||
</Button>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</SettingsTabContent>
|
||||
</div>
|
||||
</Tabs>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
@@ -828,4 +1068,66 @@ const ThemeCard = ({ active, onClick, icon, label }: ThemeCardProps) => (
|
||||
</div>
|
||||
);
|
||||
|
||||
// Terminal theme card with preview
|
||||
interface TerminalThemeCardProps {
|
||||
theme: typeof TERMINAL_THEMES[0];
|
||||
active: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
const TerminalThemeCard: React.FC<TerminalThemeCardProps> = ({ theme, active, onClick }) => (
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
"cursor-pointer rounded-lg border-2 p-2 flex items-center gap-3 transition-all duration-200",
|
||||
active
|
||||
? "border-primary bg-primary/5 ring-1 ring-primary/20"
|
||||
: "border-border hover:border-primary/50",
|
||||
)}
|
||||
>
|
||||
{/* Terminal Preview */}
|
||||
<div
|
||||
className="w-16 h-11 rounded flex flex-col p-1.5 gap-0.5 shrink-0"
|
||||
style={{ backgroundColor: theme.colors.background }}
|
||||
>
|
||||
<div className="flex gap-0.5">
|
||||
<div className="w-3 h-0.5 rounded-full" style={{ backgroundColor: theme.colors.green }} />
|
||||
<div className="w-4 h-0.5 rounded-full" style={{ backgroundColor: theme.colors.foreground, opacity: 0.5 }} />
|
||||
</div>
|
||||
<div className="flex gap-0.5">
|
||||
<div className="w-2 h-0.5 rounded-full" style={{ backgroundColor: theme.colors.blue }} />
|
||||
<div className="w-3 h-0.5 rounded-full" style={{ backgroundColor: theme.colors.cyan }} />
|
||||
</div>
|
||||
<div className="flex gap-0.5 mt-auto">
|
||||
<div className="w-2 h-0.5 rounded-full" style={{ backgroundColor: theme.colors.yellow }} />
|
||||
<div className="w-4 h-0.5 rounded-full" style={{ backgroundColor: theme.colors.magenta }} />
|
||||
</div>
|
||||
<div className="w-1.5 h-1.5 rounded-sm" style={{ backgroundColor: theme.colors.cursor }} />
|
||||
</div>
|
||||
{/* Theme Info */}
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-sm font-medium truncate">{theme.name}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// Key combo display component
|
||||
const KeyCombo: React.FC<{ keys: string }> = ({ keys }) => {
|
||||
// Parse key combo like "⌘ + Shift + ]" or "Ctrl + Alt + arrows"
|
||||
const parts = keys.split(/\s*\+\s*/);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
{parts.map((part, i) => (
|
||||
<React.Fragment key={i}>
|
||||
{i > 0 && <span className="text-muted-foreground text-xs mx-0.5">+</span>}
|
||||
<kbd className="inline-flex items-center justify-center min-w-[24px] h-6 px-1.5 text-xs font-medium bg-muted border border-border rounded">
|
||||
{part.trim()}
|
||||
</kbd>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsDialog;
|
||||
@@ -13,7 +13,9 @@ import {
|
||||
Snippet,
|
||||
TerminalSession,
|
||||
TerminalTheme,
|
||||
KeyBinding,
|
||||
} from "../types";
|
||||
import { checkAppShortcut, getAppLevelActions, getTerminalPassthroughActions } from "../application/state/useGlobalHotkeys";
|
||||
import KnownHostConfirmDialog, { HostKeyInfo } from "./KnownHostConfirmDialog";
|
||||
import SFTPModal from "./SFTPModal";
|
||||
import { Button } from "./ui/button";
|
||||
@@ -43,6 +45,9 @@ interface TerminalProps {
|
||||
terminalTheme: TerminalTheme;
|
||||
sessionId: string;
|
||||
startupCommand?: string; // Command to run after connection (for snippet runner)
|
||||
// Hotkey configuration
|
||||
hotkeyScheme?: 'disabled' | 'mac' | 'pc';
|
||||
keyBindings?: KeyBinding[];
|
||||
onStatusChange?: (
|
||||
sessionId: string,
|
||||
status: TerminalSession["status"],
|
||||
@@ -77,6 +82,8 @@ const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
terminalTheme,
|
||||
sessionId,
|
||||
startupCommand,
|
||||
hotkeyScheme = 'disabled',
|
||||
keyBindings = [],
|
||||
onStatusChange,
|
||||
onSessionExit,
|
||||
onOsDetected,
|
||||
@@ -372,6 +379,68 @@ const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
|
||||
logRenderer();
|
||||
|
||||
// Attach custom key event handler to intercept app-level shortcuts
|
||||
// This allows keyboard shortcuts to work even when terminal is focused
|
||||
if (hotkeyScheme !== 'disabled' && keyBindings.length > 0) {
|
||||
const isMac = hotkeyScheme === 'mac';
|
||||
const appLevelActions = getAppLevelActions();
|
||||
const terminalActions = getTerminalPassthroughActions();
|
||||
|
||||
term.attachCustomKeyEventHandler((e: KeyboardEvent) => {
|
||||
// Check if this matches any of our shortcuts
|
||||
const matched = checkAppShortcut(e, keyBindings, isMac);
|
||||
if (!matched) return true; // Let xterm handle it
|
||||
|
||||
const { action } = matched;
|
||||
|
||||
// App-level actions: return false to prevent xterm from handling
|
||||
// The event will bubble up to our global handler
|
||||
if (appLevelActions.has(action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Terminal-level actions: handle here
|
||||
if (terminalActions.has(action)) {
|
||||
e.preventDefault();
|
||||
switch (action) {
|
||||
case 'copy': {
|
||||
const selection = term.getSelection();
|
||||
if (selection) {
|
||||
navigator.clipboard.writeText(selection);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'paste': {
|
||||
navigator.clipboard.readText().then((text) => {
|
||||
const id = sessionRef.current;
|
||||
if (id && window.netcatty?.writeToSession) {
|
||||
window.netcatty.writeToSession(id, text);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'selectAll': {
|
||||
term.selectAll();
|
||||
break;
|
||||
}
|
||||
case 'clearBuffer': {
|
||||
term.clear();
|
||||
break;
|
||||
}
|
||||
case 'searchTerminal': {
|
||||
// TODO: Open search UI - for now just log
|
||||
console.log('[Terminal] Search requested');
|
||||
// Could trigger a search UI component here
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // Let xterm handle other keys
|
||||
});
|
||||
}
|
||||
|
||||
fitAddon.fit();
|
||||
term.focus();
|
||||
} catch (openErr) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Circle, LayoutGrid, Server } from 'lucide-react';
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useActiveTabId } from '../application/state/activeTabStore';
|
||||
import { collectSessionIds } from '../domain/workspace';
|
||||
import { KeyBinding } from '../domain/models';
|
||||
import { cn } from '../lib/utils';
|
||||
import { Host, KnownHost, SSHKey, Snippet, TerminalSession, TerminalTheme, Workspace, WorkspaceNode } from '../types';
|
||||
import { DistroAvatar } from './DistroAvatar';
|
||||
@@ -37,6 +38,8 @@ interface TerminalLayerProps {
|
||||
draggingSessionId: string | null;
|
||||
terminalTheme: TerminalTheme;
|
||||
fontSize?: number;
|
||||
hotkeyScheme?: 'disabled' | 'mac' | 'pc';
|
||||
keyBindings?: KeyBinding[];
|
||||
onCloseSession: (sessionId: string, e?: React.MouseEvent) => void;
|
||||
onUpdateSessionStatus: (sessionId: string, status: TerminalSession['status']) => void;
|
||||
onUpdateHostDistro: (hostId: string, distro: string) => void;
|
||||
@@ -61,6 +64,8 @@ const TerminalLayerInner: React.FC<TerminalLayerProps> = ({
|
||||
draggingSessionId,
|
||||
terminalTheme,
|
||||
fontSize = 14,
|
||||
hotkeyScheme = 'disabled',
|
||||
keyBindings = [],
|
||||
onCloseSession,
|
||||
onUpdateSessionStatus,
|
||||
onUpdateHostDistro,
|
||||
@@ -557,6 +562,8 @@ const TerminalLayerInner: React.FC<TerminalLayerProps> = ({
|
||||
terminalTheme={terminalTheme}
|
||||
sessionId={session.id}
|
||||
startupCommand={session.startupCommand}
|
||||
hotkeyScheme={hotkeyScheme}
|
||||
keyBindings={keyBindings}
|
||||
onCloseSession={handleCloseSession}
|
||||
onStatusChange={handleStatusChange}
|
||||
onSessionExit={handleSessionExit}
|
||||
|
||||
@@ -34,7 +34,7 @@ const sessionStatusDot = (status: TerminalSession['status']) => {
|
||||
: status === 'connecting'
|
||||
? "bg-amber-400"
|
||||
: "bg-rose-500";
|
||||
return <span className={cn("inline-block h-2 w-2 rounded-full shadow-[0_0_0_2px_rgba(0,0,0,0.35)]", tone)} />;
|
||||
return <span className={cn("inline-block h-2 w-2 rounded-full ring-2 ring-background/60", tone)} />;
|
||||
};
|
||||
|
||||
// Custom window controls for Windows/Linux (frameless window)
|
||||
|
||||
@@ -518,7 +518,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
|
||||
className={cn(
|
||||
"w-full justify-start gap-3 h-10",
|
||||
currentSection === "hosts" &&
|
||||
"bg-black/5 dark:bg-white/10 text-foreground hover:bg-black/10 dark:hover:bg-white/15 dark:border-white/10",
|
||||
"bg-foreground/5 text-foreground hover:bg-foreground/10 border-border/40",
|
||||
)}
|
||||
onClick={() => {
|
||||
setCurrentSection("hosts");
|
||||
@@ -532,7 +532,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
|
||||
className={cn(
|
||||
"w-full justify-start gap-3 h-10",
|
||||
currentSection === "keys" &&
|
||||
"bg-black/5 dark:bg-white/10 text-foreground hover:bg-black/10 dark:hover:bg-white/15 dark:border-white/10",
|
||||
"bg-foreground/5 text-foreground hover:bg-foreground/10 border-border/40",
|
||||
)}
|
||||
onClick={() => {
|
||||
setCurrentSection("keys");
|
||||
@@ -545,7 +545,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
|
||||
className={cn(
|
||||
"w-full justify-start gap-3 h-10",
|
||||
currentSection === "port" &&
|
||||
"bg-black/5 dark:bg-white/10 text-foreground hover:bg-black/10 dark:hover:bg-white/15 dark:border-white/10",
|
||||
"bg-foreground/5 text-foreground hover:bg-foreground/10 border-border/40",
|
||||
)}
|
||||
onClick={() => setCurrentSection("port")}
|
||||
>
|
||||
@@ -556,7 +556,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
|
||||
className={cn(
|
||||
"w-full justify-start gap-3 h-10",
|
||||
currentSection === "snippets" &&
|
||||
"bg-black/5 dark:bg-white/10 text-foreground hover:bg-black/10 dark:hover:bg-white/15 dark:border-white/10",
|
||||
"bg-foreground/5 text-foreground hover:bg-foreground/10 border-border/40",
|
||||
)}
|
||||
onClick={() => {
|
||||
setCurrentSection("snippets");
|
||||
@@ -569,7 +569,7 @@ const VaultViewInner: React.FC<VaultViewProps> = ({
|
||||
className={cn(
|
||||
"w-full justify-start gap-3 h-10",
|
||||
currentSection === "knownhosts" &&
|
||||
"bg-black/5 dark:bg-white/10 text-foreground hover:bg-black/10 dark:hover:bg-white/15 dark:border-white/10",
|
||||
"bg-foreground/5 text-foreground hover:bg-foreground/10 border-border/40",
|
||||
)}
|
||||
onClick={() => setCurrentSection("knownhosts")}
|
||||
>
|
||||
|
||||
@@ -82,7 +82,7 @@ export const GenerateBiometricPanel: React.FC<GenerateBiometricPanelProps> = ({
|
||||
disabled={isGenerating || !draftKey.label?.trim()}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<div className="h-4 w-4 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
||||
<div className="h-4 w-4 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin" />
|
||||
) : (
|
||||
'Generate'
|
||||
)}
|
||||
|
||||
@@ -65,7 +65,7 @@ export const GenerateFido2Panel: React.FC<GenerateFido2PanelProps> = ({
|
||||
disabled={isGenerating || !draftKey.label?.trim()}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<div className="h-4 w-4 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
||||
<div className="h-4 w-4 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin" />
|
||||
) : (
|
||||
<>
|
||||
<Shield size={14} className="mr-2" />
|
||||
|
||||
@@ -127,7 +127,7 @@ export const GenerateStandardPanel: React.FC<GenerateStandardPanelProps> = ({
|
||||
disabled={isGenerating || !draftKey.label?.trim()}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<div className="h-4 w-4 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
||||
<div className="h-4 w-4 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin" />
|
||||
) : (
|
||||
'Generate & save'
|
||||
)}
|
||||
|
||||
@@ -139,6 +139,157 @@ export interface SyncConfig {
|
||||
lastSync?: number;
|
||||
}
|
||||
|
||||
// Keyboard Shortcuts / Hotkeys
|
||||
export type HotkeyScheme = 'disabled' | 'mac' | 'pc';
|
||||
|
||||
export interface KeyBinding {
|
||||
id: string;
|
||||
action: string;
|
||||
label: string;
|
||||
mac: string; // e.g., '⌘+1', '⌘+⌥+arrows'
|
||||
pc: string; // e.g., 'Ctrl+1', 'Ctrl+Alt+arrows'
|
||||
category: 'tabs' | 'terminal' | 'navigation' | 'app';
|
||||
}
|
||||
|
||||
// User's custom key bindings - only stores overrides from defaults
|
||||
export type CustomKeyBindings = Record<string, { mac?: string; pc?: string }>;
|
||||
|
||||
// Parse a key string like "⌘ + Shift + K" or "Ctrl + Alt + T" into normalized form
|
||||
export const parseKeyCombo = (keyStr: string): { modifiers: string[]; key: string } | null => {
|
||||
if (!keyStr || keyStr === 'Disabled') return null;
|
||||
const parts = keyStr.split('+').map(p => p.trim());
|
||||
const key = parts.pop() || '';
|
||||
return { modifiers: parts, key };
|
||||
};
|
||||
|
||||
// Convert keyboard event to a key string
|
||||
export const keyEventToString = (e: KeyboardEvent, isMac: boolean): string => {
|
||||
const parts: string[] = [];
|
||||
|
||||
if (isMac) {
|
||||
if (e.metaKey) parts.push('⌘');
|
||||
if (e.ctrlKey) parts.push('⌃');
|
||||
if (e.altKey) parts.push('⌥');
|
||||
if (e.shiftKey) parts.push('Shift');
|
||||
} else {
|
||||
if (e.ctrlKey) parts.push('Ctrl');
|
||||
if (e.altKey) parts.push('Alt');
|
||||
if (e.shiftKey) parts.push('Shift');
|
||||
if (e.metaKey) parts.push('Win');
|
||||
}
|
||||
|
||||
// Get the key name
|
||||
let keyName = e.key;
|
||||
// Normalize special keys
|
||||
if (keyName === ' ') keyName = 'Space';
|
||||
else if (keyName === 'ArrowUp') keyName = '↑';
|
||||
else if (keyName === 'ArrowDown') keyName = '↓';
|
||||
else if (keyName === 'ArrowLeft') keyName = '←';
|
||||
else if (keyName === 'ArrowRight') keyName = '→';
|
||||
else if (keyName === 'Escape') keyName = 'Esc';
|
||||
else if (keyName === 'Backspace') keyName = '⌫';
|
||||
else if (keyName === 'Delete') keyName = 'Del';
|
||||
else if (keyName === 'Enter') keyName = '↵';
|
||||
else if (keyName === 'Tab') keyName = '⇥';
|
||||
else if (keyName.length === 1) keyName = keyName.toUpperCase();
|
||||
|
||||
// Don't include modifier keys themselves
|
||||
if (['Meta', 'Control', 'Alt', 'Shift'].includes(e.key)) {
|
||||
return parts.join(' + ');
|
||||
}
|
||||
|
||||
parts.push(keyName);
|
||||
return parts.join(' + ');
|
||||
};
|
||||
|
||||
// Check if a keyboard event matches a key binding string
|
||||
export const matchesKeyBinding = (e: KeyboardEvent, keyStr: string, isMac: boolean): boolean => {
|
||||
if (!keyStr || keyStr === 'Disabled') return false;
|
||||
|
||||
// Handle range patterns like "[1...9]"
|
||||
if (keyStr.includes('[1...9]')) {
|
||||
const basePattern = keyStr.replace('[1...9]', '');
|
||||
const key = e.key;
|
||||
if (!/^[1-9]$/.test(key)) return false;
|
||||
// Check modifiers match the base pattern
|
||||
const testStr = basePattern + key;
|
||||
return matchesKeyBinding(e, testStr.trim(), isMac);
|
||||
}
|
||||
|
||||
const parsed = parseKeyCombo(keyStr);
|
||||
if (!parsed) return false;
|
||||
|
||||
const { modifiers, key } = parsed;
|
||||
|
||||
// Check modifiers
|
||||
if (isMac) {
|
||||
const needMeta = modifiers.includes('⌘');
|
||||
const needCtrl = modifiers.includes('⌃');
|
||||
const needAlt = modifiers.includes('⌥');
|
||||
const needShift = modifiers.includes('Shift');
|
||||
|
||||
if (e.metaKey !== needMeta) return false;
|
||||
if (e.ctrlKey !== needCtrl) return false;
|
||||
if (e.altKey !== needAlt) return false;
|
||||
if (e.shiftKey !== needShift) return false;
|
||||
} else {
|
||||
const needCtrl = modifiers.includes('Ctrl');
|
||||
const needAlt = modifiers.includes('Alt');
|
||||
const needShift = modifiers.includes('Shift');
|
||||
const needMeta = modifiers.includes('Win');
|
||||
|
||||
if (e.ctrlKey !== needCtrl) return false;
|
||||
if (e.altKey !== needAlt) return false;
|
||||
if (e.shiftKey !== needShift) return false;
|
||||
if (e.metaKey !== needMeta) return false;
|
||||
}
|
||||
|
||||
// Check key
|
||||
let eventKey = e.key;
|
||||
if (eventKey === ' ') eventKey = 'Space';
|
||||
else if (eventKey === 'ArrowUp') eventKey = '↑';
|
||||
else if (eventKey === 'ArrowDown') eventKey = '↓';
|
||||
else if (eventKey === 'ArrowLeft') eventKey = '←';
|
||||
else if (eventKey === 'ArrowRight') eventKey = '→';
|
||||
else if (eventKey === 'Escape') eventKey = 'Esc';
|
||||
else if (eventKey === '[') eventKey = '[';
|
||||
else if (eventKey === ']') eventKey = ']';
|
||||
|
||||
return eventKey.toLowerCase() === key.toLowerCase();
|
||||
};
|
||||
|
||||
export const DEFAULT_KEY_BINDINGS: KeyBinding[] = [
|
||||
// Tab Management
|
||||
{ id: 'switch-tab-1-9', action: 'switchToTab', label: 'Switch to Tab [1...9]', mac: '⌘ + [1...9]', pc: 'Ctrl + [1...9]', category: 'tabs' },
|
||||
{ id: 'next-tab', action: 'nextTab', label: 'Next Tab', mac: '⌘ + Shift + ]', pc: 'Ctrl + Tab', category: 'tabs' },
|
||||
{ id: 'prev-tab', action: 'prevTab', label: 'Previous Tab', mac: '⌘ + Shift + [', pc: 'Ctrl + Shift + Tab', category: 'tabs' },
|
||||
{ id: 'close-tab', action: 'closeTab', label: 'Close Tab', mac: '⌘ + W', pc: 'Ctrl + W', category: 'tabs' },
|
||||
{ id: 'new-tab', action: 'newTab', label: 'New Local Tab', mac: '⌘ + T', pc: 'Ctrl + T', category: 'tabs' },
|
||||
|
||||
// Terminal Operations
|
||||
{ id: 'copy', action: 'copy', label: 'Copy from Terminal', mac: '⌘ + C', pc: 'Ctrl + Shift + C', category: 'terminal' },
|
||||
{ id: 'paste', action: 'paste', label: 'Paste to Terminal', mac: '⌘ + V', pc: 'Ctrl + Shift + V', category: 'terminal' },
|
||||
{ id: 'select-all', action: 'selectAll', label: 'Select All in Terminal', mac: '⌘ + A', pc: 'Ctrl + Shift + A', category: 'terminal' },
|
||||
{ id: 'clear-buffer', action: 'clearBuffer', label: 'Clear Terminal Buffer', mac: '⌘ + K', pc: 'Ctrl + L', category: 'terminal' },
|
||||
{ id: 'search-terminal', action: 'searchTerminal', label: 'Open Terminal Search', mac: '⌘ + F', pc: 'Ctrl + Shift + F', category: 'terminal' },
|
||||
|
||||
// Navigation / Split View
|
||||
{ id: 'move-focus', action: 'moveFocus', label: 'Move focus between Split View panes', mac: '⌘ + ⌥ + arrows', pc: 'Ctrl + Alt + arrows', category: 'navigation' },
|
||||
{ id: 'split-horizontal', action: 'splitHorizontal', label: 'Split Horizontal', mac: '⌘ + D', pc: 'Ctrl + Shift + D', category: 'navigation' },
|
||||
{ id: 'split-vertical', action: 'splitVertical', label: 'Split Vertical', mac: '⌘ + Shift + D', pc: 'Ctrl + Shift + E', category: 'navigation' },
|
||||
|
||||
// App Features
|
||||
{ id: 'open-hosts', action: 'openHosts', label: 'Open Hosts Page', mac: 'Disabled', pc: 'Disabled', category: 'app' },
|
||||
{ id: 'open-local', action: 'openLocal', label: 'Open Local Terminal', mac: '⌘ + L', pc: 'Ctrl + L', category: 'app' },
|
||||
{ id: 'open-sftp', action: 'openSftp', label: 'Open SFTP', mac: '⌘ + Shift + S', pc: 'Ctrl + Shift + S', category: 'app' },
|
||||
{ id: 'port-forwarding', action: 'portForwarding', label: 'Open Port Forwarding', mac: '⌘ + P', pc: 'Ctrl + P', category: 'app' },
|
||||
{ id: 'command-palette', action: 'commandPalette', label: 'Open Command Palette', mac: '⌘ + K', pc: 'Ctrl + K', category: 'app' },
|
||||
{ id: 'quick-switch', action: 'quickSwitch', label: 'Quick Switch', mac: '⌘ + J', pc: 'Ctrl + J', category: 'app' },
|
||||
{ id: 'snippets', action: 'snippets', label: 'Open Snippets', mac: '⌘ + Shift + S', pc: 'Ctrl + Alt + S', category: 'app' },
|
||||
{ id: 'broadcast', action: 'broadcast', label: 'Switch the Broadcast Mode', mac: '⌘ + B', pc: 'Ctrl + B', category: 'app' },
|
||||
{ id: 'side-panel', action: 'sidePanel', label: 'Show Terminal Side-panel', mac: '⌘ + S', pc: 'Ctrl + S', category: 'app' },
|
||||
];
|
||||
|
||||
// Terminal appearance settings
|
||||
export type CursorShape = 'block' | 'bar' | 'underline';
|
||||
export type RightClickBehavior = 'context-menu' | 'paste' | 'select-word';
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
Tailwind CSS v4 Theme Configuration
|
||||
============================================ */
|
||||
@theme {
|
||||
/* Default border color - ensures 'border' class uses theme color instead of currentColor */
|
||||
--default-border-color: var(--color-border);
|
||||
|
||||
/* Colors - mapped from CSS variables */
|
||||
--color-border: hsl(var(--border));
|
||||
--color-input: hsl(var(--input));
|
||||
@@ -81,6 +84,13 @@
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
/* Global default border color - ensures 'border' class always uses theme color */
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
border-color: hsl(var(--border));
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
background:
|
||||
@@ -131,13 +141,13 @@ body {
|
||||
background: hsl(var(--secondary) / 0.95);
|
||||
border: 1px solid hsl(var(--border) / 0.8);
|
||||
backdrop-filter: blur(12px);
|
||||
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
|
||||
box-shadow: 0 14px 40px hsl(var(--foreground) / 0.12);
|
||||
}
|
||||
|
||||
.soft-card {
|
||||
background: hsl(var(--card));
|
||||
border: 1px solid hsl(var(--border) / 0.8);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02), 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
box-shadow: 0 4px 12px hsl(var(--foreground) / 0.06);
|
||||
}
|
||||
|
||||
.card-highlight {
|
||||
|
||||
@@ -11,6 +11,8 @@ export const STORAGE_KEY_TERM_THEME = 'netcatty_term_theme_v1';
|
||||
export const STORAGE_KEY_TERM_FONT_FAMILY = 'netcatty_term_font_family_v1';
|
||||
export const STORAGE_KEY_TERM_FONT_SIZE = 'netcatty_term_font_size_v1';
|
||||
export const STORAGE_KEY_TERM_SETTINGS = 'netcatty_term_settings_v1';
|
||||
export const STORAGE_KEY_HOTKEY_SCHEME = 'netcatty_hotkey_scheme_v1';
|
||||
export const STORAGE_KEY_CUSTOM_KEY_BINDINGS = 'netcatty_custom_key_bindings_v1';
|
||||
export const STORAGE_KEY_PORT_FORWARDING = 'netcatty_port_forwarding_v1';
|
||||
export const STORAGE_KEY_KNOWN_HOSTS = 'netcatty_known_hosts_v1';
|
||||
export const STORAGE_KEY_SHELL_HISTORY = 'netcatty_shell_history_v1';
|
||||
Reference in new issue
Block a user