use crate::AppModel;
use crate::search::{self, Found};
use super::ShellState;
const OPEN_HINT: &str = "Go to this result: select the thing it names, exactly as clicking it in \
the roster would. Nothing is changed. No key of its own: Tab reaches the row, \
Space presses it — and Ctrl+F asks the next `/search`.";
pub(super) fn pane(
ui: &mut egui::Ui,
model: &mut AppModel,
state: &mut ShellState,
found: &Found,
searching: bool,
) {
if searching {
ui.weak("searching…");
}
let mut open = None;
egui::ScrollArea::vertical()
.id_salt("search-hits")
.show(ui, |ui| {
if !searching && found.hits.is_empty() {
ui.label(search::no_matches(&found.needle));
ui.weak(search::SEARCHED_EVERYTHING);
}
for hit in &found.hits {
if ui
.button(egui::RichText::new(search::label(hit)).monospace())
.on_hover_text(OPEN_HINT)
.clicked()
{
open = Some(hit.at.clone());
}
}
for note in &found.unreadable {
ui.weak(format!("unreadable — {note}"));
}
});
if let Some(at) = open {
model.open(&at);
super::focus::request(state);
}
}