Find in page: the shell's find bar per pane (Ctrl+F, the app menu, the palette) over the engine's own find
Host: `tab_find {id, action, query}` (shell-only; start, next, previous, stop). On Windows it drives WebView2's own find (`ICoreWebView2Find` from `ICoreWebView2_28`, find options from `ICoreWebView2Environment15`; its built-in find bar suppressed, all matches highlighted) and reports the engine's match count and active match to the shell as `tab-find` events. On macOS, Linux and an older WebView2 Runtime native code evaluates the engine's `window.find` in the tab instead (next and previous work, no count); WKWebView's and WebKitGTK's native find are not wired here because this tree cannot be compiled or run for them on this machine. The query is one typed line (1..=256 characters, no control characters), goes to the engine and is kept nowhere. Tabs gain no command: a tab forwards the existing key name `find` (Ctrl+F) through tab_shortcut.
Frame: FindBar.tsx takes the address field's place in its pane's toolbar while open, so the page does not move and in split view the bar is the searched pane's. "3/17" where the engine counts, "No matches" for none; Enter / F3 next, Shift+Enter / Shift+F3 previous, Esc closes, clears the highlights and gives the page the keyboard. `features.find` (on by default) gates the menu row, the palette entry and the keys. Only what the page has rendered can be found, as in a browser.
Also: this makes `pub mod find` in lib.rs (already in HEAD) resolve again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
832396801c
commit
b31fa6b1d2
17 changed files with 449 additions and 19 deletions
|
|
@ -20,6 +20,7 @@ import { openAppMenu } from './AppMenu.tsx';
|
|||
import { invoke, listen } from './bridge.ts';
|
||||
import { CommandPalette } from './CommandPalette.tsx';
|
||||
import { DeckTabBadge, DeckView, focusColumn, runDeckCommand } from './DeckView.tsx';
|
||||
import { openFind, stepFind } from './FindBar.tsx';
|
||||
import { columnSourceUrl, createDeck, deckById, decks, findColumnTab, loadDecks, setRuntime } from './deckStore.ts';
|
||||
import { installDevHost } from './devHost.ts';
|
||||
import { useProfiles, useT } from './hooks.ts';
|
||||
|
|
@ -264,6 +265,7 @@ function runPalette(action: PaletteAction) {
|
|||
case 'plugin-command': runPluginCommand(action.tab, action.command); break;
|
||||
case 'workspace': void restoreWorkspace(action.id); break;
|
||||
case 'workspace-save': openWorkspaceSave(); break;
|
||||
case 'find': runShortcut('find'); break;
|
||||
case 'menu': openAppMenu({ keyboard: true }); break;
|
||||
}
|
||||
}
|
||||
|
|
@ -290,6 +292,9 @@ function runShortcut(shortcut: string, id?: string) {
|
|||
const panel = id === undefined ? api.activePanel : api.getPanel(id);
|
||||
switch (shortcut) {
|
||||
case 'new-tab': addStart(); break;
|
||||
// Find in page: the find bar of that tab (the one the keys were pressed in, else the one in front).
|
||||
case 'find': if (panel && isWeb(panel) && hasFeature('find')) { panel.api.setActive(); openFind(panel.id); } break;
|
||||
case 'find-next': case 'find-previous': if (panel && isWeb(panel)) stepFind(panel.id, shortcut === 'find-next' ? 1 : -1); break;
|
||||
case 'close-tab': if (panel) closeTab(panel); break;
|
||||
case 'reopen-tab': { const tab = shell.closed.pop(); if (tab) addWeb(tab.url, undefined, true, tab.profile); break; }
|
||||
case 'focus-address': if (panel && (isWeb(panel) || (panel.params as TabParams).kind === 'start')) focusAddress(panel.id); break;
|
||||
|
|
@ -340,6 +345,7 @@ function shortcutFor(event: KeyboardEvent): string | null {
|
|||
if (key === 'l') return 'focus-address';
|
||||
if (key === 'g' && event.shiftKey) return 'media-panel';
|
||||
if (key === 'k' && !event.shiftKey) return 'command-palette';
|
||||
if (key === 'f' && !event.shiftKey && hasFeature('find')) return 'find';
|
||||
if (key === 'tab') return event.shiftKey ? 'prev-tab' : 'next-tab';
|
||||
if (key === 'r') return 'reload';
|
||||
if (event.code === 'Backslash' || event.code === 'IntlBackslash') return event.shiftKey ? 'split-down' : 'split-right';
|
||||
|
|
@ -349,6 +355,7 @@ function shortcutFor(event: KeyboardEvent): string | null {
|
|||
if (key === '0' || event.code === 'Numpad0') return 'zoom-reset';
|
||||
}
|
||||
}
|
||||
if (event.key === 'F3' && !mod && !event.altKey) return event.shiftKey ? 'find-previous' : 'find-next';
|
||||
// The app menu, like a browser's: F10, and Alt+F where Alt is not a typing key (not on macOS).
|
||||
if (event.key === 'F10' && !mod && !event.altKey && !event.shiftKey) return 'app-menu';
|
||||
if (event.altKey && !mod && !event.shiftKey && event.code === 'KeyF' && os !== 'macos') return 'app-menu';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue