use crate::ui::{Fill, Model};
pub const HINT: &str = "new workspace: <name> <what it is for> — Enter founds it";
pub const BOX_HELP: &str =
"the new workspace's name and purpose on one line; Enter founds it and begins";
pub const SEND_HELP: &str =
"founds the workspace the box names and begins its first conversation, as Enter does";
pub fn render(ui: &mut egui::Ui, model: &mut Model) {
let wanted = model.filling() == Some(Fill::Goal);
let slashed = crate::ui::slash::parsed(&model.draft).is_some();
let ops: &[&str] = &[crate::verbs::PREPARE, crate::verbs::PROMPT];
let send = super::pills::Send {
live: !model.draft.trim().is_empty(),
help: SEND_HELP,
ops,
};
let trail = super::pills::Trail::new(ui, model, false, (!slashed).then_some(send));
let reserve = trail.width(ui);
let mut clicks = super::pills::Clicks::default();
let entry = crate::ui::theme::paint::prompt(
ui,
egui::Id::new(crate::ui::keys::BOX_ID),
&mut model.draft,
HINT,
None,
BOX_HELP,
(reserve, |ui: &mut egui::Ui| trail.paint(ui, &mut clicks)),
);
let pressed = clicks.sent;
crate::ui::act::tag(&entry, ops);
if wanted {
entry.request_focus();
}
if slashed {
return;
}
if super::entered(ui, &entry) || pressed {
model.found();
}
}
#[cfg(test)]
mod tests;