import { useAppState } from '../state/context'; import { colors } from '../theme'; /** * Find the best position to highlight the key character within a label. * Prefers matching at the start of a word; falls back to any position. * Returns -1 if not found. */ function findKeyIndex(key: string, label: string): number { const lowerKey = key.toLowerCase(); let offset = 0; for (const part of label.split(/(\s+)/)) { if (part.trim() && part.toLowerCase().startsWith(lowerKey)) { return offset; } offset += part.length; } return label.toLowerCase().indexOf(lowerKey); } function Shortcut({ keyName, label }: { keyName: string; label: string }) { // Single-char keys: highlight the key letter inline within the label if (keyName.length === 1) { const idx = findKeyIndex(keyName, label); if (idx >= 0) { const before = label.slice(0, idx); const after = label.slice(idx + 1); return ( {before ? {before} : null} {keyName} {after} ); } } // Fallback for special/multi-char keys or when key not found in label return ( {keyName} {label} ); } export function StatusBar() { const state = useAppState(); if (state.overlay !== 'none') return null; const feedShortcuts = ( ); const articleShortcuts = ( ); const readerShortcuts = ( ); return ( {state.activePanel === 'feeds' && feedShortcuts} {state.activePanel === 'articles' && articleShortcuts} {state.activePanel === 'reader' && readerShortcuts} ); }