1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! Search pane event handling module.
//!
//! This module handles all keyboard input events when the Search pane is focused.
//! It supports two modes:
//! - **Insert mode** (default): Direct text input for searching packages
//! - **Normal mode**: Vim-like navigation and editing commands
//!
//! The module is split into submodules for maintainability:
//! - `helpers`: Shared utility functions for key matching and pane navigation
//! - `insert_mode`: Insert mode key event handling
//! - `normal_mode`: Normal mode key event handling
//! - `preflight_helpers`: Preflight modal opening logic
use KeyEvent;
use mpsc;
use crate;
/// Helper functions for search event handling.
/// Insert mode search event handling.
/// Normal mode search event handling.
/// Preflight modal helper functions for search.
// Re-export preflight modal opener for use in other modules
pub use open_preflight_modal;
// Re-export shift keybind handler for use in other modules
pub use handle_shift_keybinds;
/// What: Handle key events while the Search pane is focused.
///
/// Inputs:
/// - `ke`: Key event received from the terminal
/// - `app`: Mutable application state (input, selection, sort, modes)
/// - `query_tx`: Channel to send debounced search queries
/// - `details_tx`: Channel to request details for the focused item
/// - `add_tx`: Channel to add items to the Install/Remove lists
/// - `preview_tx`: Channel to request preview details when moving focus
///
/// Output:
/// - `true` to request application exit (e.g., Ctrl+C); `false` to continue processing.
///
/// Details:
/// - Insert mode (default): typing edits the query, triggers debounced network/idx search, and
/// moves caret; Backspace edits; Space adds to list (Install by default, Remove in installed-only).
/// - Normal mode: toggled via configured chord; supports selection (h/l), deletion (d), navigation
/// (j/k, Ctrl+U/D), and list add/remove with Space/ Ctrl+Space (downgrade).
/// - Pane navigation: Left/Right and configured `pane_next` cycle focus across panes and subpanes,
/// differing slightly when installed-only mode is active.
/// - PKGBUILD reload is handled via debounced requests scheduled in the selection logic.
/// - Comments are automatically updated when package changes and comments are visible.