Expand description
FolderPickerController — engine-level folder/workspace directory picker.
Owns all state for an interactive directory-browsing modal:
filesystem walking, fuzzy filtering, scroll, and selection. Renders
via the existing Palette primitive (no new
Backend trait method needed) and accepts backend-neutral
UiEvents.
§Relation to vimcode
Extracted verbatim from vimcode’s TUI-local FolderPickerState
(src/tui_main/mod.rs, ~285 lines). After the quadraui PR lands,
vimcode removes the TUI-local code and rewires both TUI and GTK
OpenFolderDialog through this controller.
§Adoption status
The vimcode migration above hasn’t landed as of #825’s audit — no
confirmed external adopter yet. Kept public rather than demoted:
full TUI + GTK demo coverage already exists
(examples/tui_folder_picker.rs, examples/gtk_folder_picker.rs,
examples/common/folder_picker_app.rs) plus a TuiDriver end-to-end
test in tests/tui_example_driver.rs, and the extraction above is a
concrete, named migration target, not a speculative one.
§Usage pattern
// Instantiate when the user triggers "Open Folder":
let mut picker = FolderPickerController::new(
std::env::current_dir().unwrap(),
vec![], // no extra file names to surface
false, // don't show hidden dirs
);
// In AppLogic::render:
let rect = /* palette popup bounds */;
picker.render(rect, backend);
// In AppLogic::handle:
let visible_rows = /* rect.height as usize - PALETTE_CHROME_ROWS */;
match picker.handle(&event, visible_rows) {
FolderPickerEvent::Confirmed { path } => { /* open workspace */ },
FolderPickerEvent::Cancelled => { /* dismiss modal */ },
FolderPickerEvent::Consumed => { /* redraw */ },
FolderPickerEvent::Ignored => {},
}§Scroll accounting
handle() requires visible_rows — the number of list rows visible
inside the palette chrome (title row + query row + optional scrollbar
row). Consumers typically compute this as
rect.height as usize - PALETTE_CHROME_ROWS where
PALETTE_CHROME_ROWS = 4.
Structs§
- Folder
Picker Controller - Cross-backend compose controller for a directory-browsing picker modal.
Enums§
- Folder
Picker Event - What happened after
FolderPickerController::handleprocessed an event.
Constants§
- DEFAULT_
IGNORE_ DIRS - Default heavy build/dependency directory names that are skipped during the filesystem walk.
- DEFAULT_
MAX_ DEPTH - Default recursion depth for
FolderPickerController::new. - PALETTE_
CHROME_ ROWS - Overhead rows consumed by the
Palettechrome (title + query + borders).