diff --git a/README.md b/README.md index 5b0a15d..6cef45b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ see [Screen capture](#screen-capture). frame), and **Ctrl-Shift-C** its full path. Neither acts while you type in the search box. They are `copy_image` and `copy_path` in `[hotkeys]` in `settings.config`. Copying images is Windows only so far. +- **Ctrl-F** puts the keyboard in the search box, its text selected (`focus_search` in `[hotkeys]`). - **Files added or deleted outside the app** (in Explorer, by another program) appear in the grid or leave it on their own, folders added, renamed or deleted too: the library is watched. **Refresh** looks at the whole folder again, should the watcher have missed something. diff --git a/assets/data/default_hotkeys.config b/assets/data/default_hotkeys.config index 06059d1..6ee4cf9 100644 --- a/assets/data/default_hotkeys.config +++ b/assets/data/default_hotkeys.config @@ -22,6 +22,9 @@ Ctrl-Shift-Alt-R reset_layout Ctrl-C copy_image Ctrl-Shift-C copy_path +# Library +Ctrl-F focus_search + # Debug Ctrl-Shift-D toggle_debug_panel Ctrl-Shift-L toggle_logger_panel diff --git a/assets/data/default_hotkeys_macos.config b/assets/data/default_hotkeys_macos.config index 6823966..7d6c9a6 100644 --- a/assets/data/default_hotkeys_macos.config +++ b/assets/data/default_hotkeys_macos.config @@ -22,6 +22,9 @@ Cmd-Shift-Opt-R reset_layout Cmd-C copy_image Cmd-Shift-C copy_path +# Library +Cmd-F focus_search + # Debug Cmd-Shift-D toggle_debug_panel Cmd-Shift-L toggle_logger_panel diff --git a/check_targets.jai b/check_targets.jai index e616f22..e416c87 100644 --- a/check_targets.jai +++ b/check_targets.jai @@ -47,7 +47,7 @@ APP_NAME :: "mcap"; APP_FOLDER_NAME :: "mcap"; GIT_BRANCH :: "check"; GIT_HASH :: "-"; -VERSION :: "0.1.17"; +VERSION :: "0.1.18"; BUILD_DATE :: "-"; DEBUG :: true; COMPILE_TESTS :: true; diff --git a/first.jai b/first.jai index bc74161..121cbb9 100644 --- a/first.jai +++ b/first.jai @@ -8,7 +8,7 @@ APP_NAME :: "mcap"; APP_FOLDER_NAME :: "mcap"; APP_BUNDLE_IDENTIFIER :: "com.example.mcap"; -VERSION :: "0.1.17"; +VERSION :: "0.1.18"; // Where everything goes: bin/, or bin-headless/ for builds made with no_crash_dialog, so automated // builds never write over the ones you run by hand. build_directory := "bin"; diff --git a/src/app/viewer.jai b/src/app/viewer.jai index 42f01d4..44f518b 100644 --- a/src/app/viewer.jai +++ b/src/app/viewer.jai @@ -134,6 +134,7 @@ viewer: struct { visible_generation: s64; // counts rebuilds of visible sorted_by_date: bool; search_buffer: [256] u8; + focus_search: bool; // Ctrl-F (focus_search in [hotkeys]): the search box takes the keyboard next frame search_terms: [..] Search_Term; folders: [..] string; // the library's folders holding captures, sorted; "" for its top folder_filter: string; // the folder the grid shows; "" for all (heap) @@ -1059,6 +1060,11 @@ viewer_ui :: () { using ImGui; return; } + if viewer.focus_search { + viewer.focus_search = false; + SetWindowFocus(); // SetKeyboardFocusHere alone leaves another window in front + SetKeyboardFocusHere(); // tabbing in: its text is selected, so typing replaces the query + } SetNextItemWidth(min(GetContentRegionAvail().x * 0.5, 520)); if InputTextWithHint("##search", "Search text, titles, URLs, apps, notes, labels. \"a phrase\" ocr: title: url: app: note: label: like: folder: has:", viewer.search_buffer.data, viewer.search_buffer.count) { viewer_search_changed(); diff --git a/src/ui/imgui_keyboard.jai b/src/ui/imgui_keyboard.jai index 4342718..b3fc40a 100644 --- a/src/ui/imgui_keyboard.jai +++ b/src/ui/imgui_keyboard.jai @@ -167,6 +167,9 @@ reset_layout_hotkey: Hotkey; copy_image_hotkey: Hotkey = .{ignore_when_text_field_active = true}; copy_path_hotkey: Hotkey = .{ignore_when_text_field_active = true}; +// The search box (app/viewer.jai). Also while typing elsewhere, as in the Import window's fields. +focus_search_hotkey: Hotkey; + Hotkey_Action :: struct { name: string; // as written in [hotkeys] hotkey: *Hotkey; @@ -189,6 +192,7 @@ hotkey_actions_build :: (out: *[..] Hotkey_Action) { add(out, "reset_layout", *reset_layout_hotkey); add(out, "copy_image", *copy_image_hotkey); add(out, "copy_path", *copy_path_hotkey); + add(out, "focus_search", *focus_search_hotkey); } hotkey_actions: [..] Hotkey_Action; @@ -637,6 +641,7 @@ app_check_key_combinations :: () { // The viewer is the shutdown thread's once shutdown has started. View mode has the file alone (app/open_file.jai). if check_key_combination(*copy_image_hotkey) && !app_exit_shutdown_started() { if app.view_mode open_file_copy_image(); else viewer_copy_image(); } if check_key_combination(*copy_path_hotkey) && !app_exit_shutdown_started() { if app.view_mode open_file_copy_path(); else viewer_copy_path(); } + if check_key_combination(*focus_search_hotkey) && !app_exit_shutdown_started() && !app.view_mode viewer.focus_search = true; // view mode has no search if should_exit_this_frame { log("Calling exit hotkey... exiting program!");