Capsule: fold on click-away, hover/fold holds, TakenBack leaves, drop Elsewhere…, stale Escape notes

This commit is contained in:
Kit Langton
2026-10-27 09:50:01 -07:00
parent e2e5b1df87
commit b298ae4bb5
20 changed files with 162 additions and 130 deletions
+12 -10
View File
@@ -161,8 +161,8 @@ The capsule // capture.capsule (rune_ui/capture_cap
│ │ pick gets, no ring or drain; ✕ closes. The Sent tone plays when the
│ │ router says it went. No runner-up chip, since the router names none
│ │ beside a saved rule; when the Undo window ends the capsule leaves by
│ │ itself (with the list open it stays). The list shortcut's "Elsewhere…"
│ │ chip opens the list while it shows. Picking the rule's own session there (without
│ │ itself (with the list open it stays; the pointer on it holds it, and a
│ │ folded list gives it a brief hold). Picking the rule's own session there (without
│ │ "Always") only closes the list; nothing is sent again
│ ├── The Undo chip counts nothing down: the capsule reads the same for the
│ │ whole window and wakes once, when it ends
@@ -176,15 +176,15 @@ The capsule // capture.capsule (rune_ui/capture_cap
│ │ ├── 1-3 or a click -> sends at once: "Sent to X", the Sent tone, and a
│ │ │ quiet Undo button for the same 5 s, with no ring or drain; ✕ closes;
│ │ │ the capsule then leaves by itself with its exit
│ │ ├── The list shortcut or "Elsewhere…" -> the full list with its search field
│ │ ├── The list shortcut -> the full list with its search field
│ │ ├── Esc -> not Hex's here: it goes to the app in front
│ │ └── Unpicked -> they leave with the capsule after the done hold
│ ├── Taken back (a rule's send or a pick) -> never
│ │ ends the capture: the list opens again with the same sessions, the one
│ │ it went to (by session id) once, last of all ("taken back"), with 1-9,
│ │ typing, and ⇧⏎ as before. Open, it stays, sent nowhere; a click away
│ │ folds it to "Taken back" with "Elsewhere…", gives Esc back to the app,
│ │ and it leaves after the done hold. ✕ (or Esc in its open list) dismisses: "Kept ·
│ │ folds it to "Taken back" with "Send to…", and it leaves after the done
│ │ hold; nothing here takes Esc. ✕ (or Esc in the typed list) dismisses: "Kept ·
│ │ hex capture send latest", the bundle untouched. Either way it then
│ │ waits for the list shortcut, even after the router said the pick went.
│ │ News of the send being taken back (it went, queued, or failed) leaves
@@ -200,7 +200,7 @@ The capsule // capture.capsule (rune_ui/capture_cap
│ ├── Keys (capture_host::take_keys), never taking focus:
│ │ ├── Picker -> ⌥⇧S and Esc through the listener
│ │ ├── Routed -> the send-to list shortcut (capture.list_hotkey; the
│ │ │ "Elsewhere…" chip shows it) opens the list; never Esc, so a send is
│ │ │ "Send to…" chip shows it) opens the list; never Esc, so a send is
│ │ │ taken back only by clicking Undo.
│ │ │ Unreachable has no list, so the shortcut reaches the app in front
│ │ ├── Closed, waiting for a pick (a guess or taken-back capture closed
@@ -214,8 +214,9 @@ The capsule // capture.capsule (rune_ui/capture_cap
│ │ │ app, and the Undo button is the only way back
│ │ ├── Suggestions -> the list shortcut through the listener,
│ │ │ and at the session tap only 1 to the number of rows with no
│ │ │ modifier (`capture_host::suggesting`); every other key goes on to
│ │ │ the app
│ │ │ modifier (`capture_host::suggesting`) and a mouse press, which folds
│ │ │ them (the click still reaches the app); every other key, Esc
│ │ │ included, goes on to the app
│ │ └── List open -> the session tap takes every key press without ⌘ or ⌃
│ │ that isn't a Hex shortcut: text in the active layout, ⌫, ↑↓, ⏎,
│ │ ⇧⏎ (always), 1-9, Esc; their releases too. A send, Esc, or a
@@ -375,7 +376,8 @@ Where it goes // capture.route; capture.routing's aut
├── Queued sends -> retried every 15 s, unless Scrawl.app runs or something
│ serves the ingest port (that process retries); a retried send can't be
│ undone, so its "Sent to X" has no Undo. A queued or too-late-to-undo send
│ leaves after the brief hold (4 s) rather than the 25 s done hold
│ leaves after the brief hold (4 s) rather than the 25 s done hold; a taken
│ back capture with nothing to list ('Taken back') does too
└── autoSend off -> no look, no route; the capture is only copied
hex capture list|show|send|route // capture.cli; docs/cli.md
@@ -544,7 +546,7 @@ Checks:
"Copy values" copies its `DEFAULT`). It reads and writes no Hex data and
records or sends nothing. The whole flow picks the first suggestion;
its "Saved rule" toggle plays a rule's send, sent at once, instead.
`--snap --scene suggestions|always|elsewhere|picked|rule|recording`
`--snap --scene suggestions|always|search|picked|rule|recording`
renders it. The tones were checked by waveform and level only, never on
speakers.
- Picker, in capture_capsule/picker.rs and tests.rs: geometry, label, and
+2 -2
View File
@@ -2226,7 +2226,7 @@ pub(crate) fn publish_list_keycaps(binding: Option<&HotkeyBinding>) {
}
/// The send-to list shortcut's keycaps (`["⌥", "⇧", "V"]`) for the
/// capsule's Elsewhere chip; empty while the list has no shortcut
/// capsule's ask chip and footer hint; empty while the list has no shortcut
/// ([`AppSettings::capture_list_hotkey`]), and the default's before settings
/// are applied (scenes and tests).
#[cfg(hex_capture)]
@@ -2392,7 +2392,7 @@ pub(crate) fn migrate_legacy_settings(path: &std::path::Path) -> Result<()> {
mod tests {
use super::*;
/// The capsule's Elsewhere chip shows the send-to list's own shortcut,
/// The capsule's ask chip and footer hint show the send-to list's own shortcut,
/// ⌥⇧V unless rebound, and no keys while the list has none.
#[cfg(hex_capture)]
#[test]
+10 -7
View File
@@ -2154,8 +2154,9 @@ impl CaptureShortcut {
}
/// Whether Hex's tap keeps Escape from the app for captures: only for
/// this press before it records, and for the capsule's picker, list,
/// and Undo. A recording capture never takes it.
/// this press before it records, and for the capsule's picker. (An open
/// list takes Escape at the session tap.) A recording capture never
/// takes it, and a send's Undo is a click.
pub fn takes_escape(&self) -> bool {
self.armed() || wants_escape()
}
@@ -2184,8 +2185,8 @@ pub enum CapsuleKeys {
/// Hex's shortcuts.
List,
/// A capture's suggestions: the send-to list shortcut (search every
/// session), and 1 to `rows` with no modifier
/// ([`CapsuleKey::Digit`]).
/// session), 1 to `rows` with no modifier ([`CapsuleKey::Digit`]), and
/// a mouse press ([`CapsuleKey::Press`]) that may fold them.
Suggest { rows: u8 },
}
@@ -2303,7 +2304,7 @@ pub fn list_open() -> bool {
/// match it (`app_settings::runtime_hotkeys`), so it reaches the app in
/// front the rest of the time.
pub fn list_key_wanted() -> bool {
matches!(GRAB_KEYS.load(Ordering::Acquire), 2..=4 | 6)
matches!(GRAB_KEYS.load(Ordering::Acquire), 2 | 4 | 6)
}
/// Whether the capsule's suggestions take their digit keys at the tap.
@@ -2328,6 +2329,7 @@ fn takes(keys: CapsuleKeys, key: &CapsuleKey) -> bool {
CapsuleKey::OpenList,
) => true,
(CapsuleKeys::Suggest { rows }, CapsuleKey::Digit(digit)) => (1..=rows).contains(digit),
(CapsuleKeys::Suggest { .. }, CapsuleKey::Press) => true,
(CapsuleKeys::List, key) => !matches!(key, CapsuleKey::Shortcut),
_ => false,
}
@@ -4189,8 +4191,7 @@ mod tests {
drop(first);
assert!(capsule_key(CapsuleKey::Escape));
// A routed capsule: the list shortcut opens the list; Escape only
// while a send can be undone.
// A routed capsule: the list shortcut opens the list; never Escape.
second.set(CapsuleKeys::Route);
assert!(!picking() && !wants_escape() && list_key_wanted());
assert!(!capsule_key(CapsuleKey::Shortcut));
@@ -4207,6 +4208,7 @@ mod tests {
second.set(CapsuleKeys::Suggest { rows: 2 });
assert!(suggesting() && !wants_escape() && list_key_wanted() && !list_open());
assert!(!capsule_key(CapsuleKey::Escape));
assert!(capsule_key(CapsuleKey::Press), "a press may fold them");
assert!(capsule_key(CapsuleKey::Digit(2)));
assert!(!capsule_key(CapsuleKey::Digit(3)), "no third row");
assert!(!capsule_key(CapsuleKey::Text("h".into())));
@@ -4224,6 +4226,7 @@ mod tests {
(2, CapsuleKey::Shortcut),
(2, CapsuleKey::Escape),
(2, CapsuleKey::OpenList),
(2, CapsuleKey::Press),
(2, CapsuleKey::Digit(2)),
(2, CapsuleKey::Text("ho".into())),
(2, CapsuleKey::Press),
+3 -3
View File
@@ -1070,7 +1070,8 @@ pub fn listen(
continue;
}
// Escape ends a dictation or Voice Action hold first, then
// closes the capsule's picker, list, or Undo, then cancels queued
// closes the capsule's picker or open list (never an Undo: that is a
// click), then cancels queued
// dictation. It never ends a recording capture: it may be meant
// for the app being recorded (the capsule's ✕ discards).
#[cfg(hex_capture)]
@@ -1308,8 +1309,7 @@ pub fn listen(
}
}
// A recording capture never takes Escape: only the capture
// shortcut's press before it starts, and the capsule's picker, list,
// and Undo.
// shortcut's press before it starts, and the capsule's picker.
#[cfg(hex_capture)]
let capture_escape = capture_host.is_some() && capture_shortcut.takes_escape();
#[cfg(not(hex_capture))]
+99 -40
View File
@@ -278,7 +278,7 @@ pub(crate) enum Footer {
/// ⇧⏎ always sends this site to the selected session.
Always(String),
/// The suggestions: 1–3 send, the list shortcut searches every session.
Elsewhere,
Suggesting,
}
/// The list under the open capsule.
@@ -296,7 +296,7 @@ pub(crate) struct List {
impl List {
/// The suggestions a capture opens with, not a search.
pub(crate) fn suggesting(&self) -> bool {
self.footer == Footer::Elsewhere
self.footer == Footer::Suggesting
}
}
@@ -448,7 +448,7 @@ struct Routed {
struct Open {
query: String,
selected: usize,
/// Searching every session (the list shortcut, "Elsewhere…"): the field
/// Searching every session (the list shortcut): the field
/// takes typing. Otherwise it's the suggestions a capture opens with.
typing: bool,
/// "Always send <site> here" is ticked: the pick saves a rule.
@@ -505,6 +505,9 @@ pub(crate) struct Flow {
phase: Phase,
/// The pointer is on the capsule.
hovered: bool,
/// No finished capsule leaves before this: a fold or the pointer's
/// leaving gives it a moment more.
hold_floor: f64,
/// An iPhone is cabled.
phone: bool,
/// The iPhone chip asked to switch, and its new recording hasn't shown:
@@ -546,6 +549,7 @@ impl Flow {
Self {
phase: Phase::Hidden,
hovered: false,
hold_floor: 0.0,
phone: false,
switching: false,
cues: Vec::new(),
@@ -604,6 +608,9 @@ impl Flow {
/// The pointer came onto the capsule or left it.
pub(crate) fn hover(&mut self, on: bool, now: f64) {
self.hovered = on;
if !on {
self.hold_floor = self.hold_floor.max(now + CHIPS_LINGER_S);
}
if let (
false,
Phase::Recording {
@@ -911,7 +918,9 @@ impl Flow {
if routed.taken_back {
routed.at = now;
}
routed.open = None;
if routed.open.take().is_some() {
self.fold_hold(now);
}
Phase::Routed(routed)
}
(phase, Input::ClickAway) => phase,
@@ -925,31 +934,37 @@ impl Flow {
..
}),
input @ (Input::Escape | Input::Dismiss),
) if input == Input::Dismiss || open.is_some() => match already_with {
None => Phase::Kept { at: now },
Some(_) => Phase::Hidden,
},
) if input == Input::Dismiss || open.as_ref().is_some_and(|open| open.typing) => {
match already_with {
None => Phase::Kept { at: now },
Some(_) => Phase::Hidden,
}
}
// Escape only reaches an open list; it folds it. It never takes
// a send back: that is the Undo button's.
(Phase::Routed(mut routed), Input::Escape) => {
routed.open = None;
(Phase::Routed(mut routed), Input::Escape)
if routed.open.as_ref().is_some_and(|open| open.typing) =>
{
if routed.open.take().is_some() {
self.fold_hold(now);
}
Phase::Routed(routed)
}
(Phase::Routed(mut routed), Input::Undo) => {
match (rule_to(&routed.route).cloned(), now - routed.at < undo_s()) {
(Phase::Routed(routed), Input::Undo) => {
// The chip is only there while the window runs; a click that
// lands as it ends still counts, and the router answers too
// late if it was.
match (rule_to(&routed.route).cloned(), !routed.taken_back) {
(Some(to), true) => {
actions.push(Action::Undo {
to: to.name.clone(),
});
taking_back(Some(routed.route), &to, now)
}
_ => {
routed.open = None;
Phase::Routed(routed)
}
_ => Phase::Routed(routed),
}
}
(Phase::Sent(sent), Input::Undo) if sent.undoable && now - sent.at < undo_s() => {
(Phase::Sent(sent), Input::Undo) if sent.undoable => {
actions.push(Action::Undo {
to: sent.to.clone(),
});
@@ -1128,7 +1143,6 @@ impl Flow {
(_, Id::Ask) => self.input(Input::OpenList, now),
(_, Id::Row(row)) => self.input(Input::SendRow(row), now),
(_, Id::Always) => self.input(Input::ToggleAlways, now),
(_, Id::Elsewhere) => self.input(Input::OpenList, now),
// ✕ beside "Sent to X" just closes, a rule's as a pick's.
(_, Id::Close) => self.input(Input::Dismiss, now),
_ => Vec::new(),
@@ -1145,8 +1159,9 @@ impl Flow {
match &self.phase {
Phase::Hidden | Phase::Kept { .. } => self.waiting.as_ref().map(|_| CapsuleKeys::Route),
Phase::Selecting(_) => Some(CapsuleKeys::Picker),
// Taken back with nothing to list: ✕ dismisses, or it leaves.
Phase::TakenBack { .. } => Some(CapsuleKeys::Route),
// Nothing to list, so ⌥⇧V reaches the app; ✕ dismisses, or it
// leaves by itself.
Phase::TakenBack { .. } => None,
Phase::Routed(Routed {
open: Some(open),
route,
@@ -1209,7 +1224,8 @@ impl Flow {
due
}
phase => {
let due = hold_until(phase).is_some_and(|at| now >= at);
let due = !self.hovered
&& hold_until(phase).is_some_and(|at| now >= at.max(self.hold_floor));
if due {
let before = std::mem::replace(&mut self.phase, Phase::Hidden);
self.closed = true;
@@ -1220,6 +1236,12 @@ impl Flow {
}
}
/// A folded list leaves the capsule up a brief moment more, not
/// at once.
fn fold_hold(&mut self, now: f64) {
self.hold_floor = self.hold_floor.max(now + tuning::get().brief_hold_s);
}
/// When `tick` next has something to do.
pub(crate) fn next_due(&self, now: f64) -> Option<f64> {
// The Undo chip leaves when the window ends; it counts nothing down.
@@ -1244,10 +1266,10 @@ impl Flow {
Phase::Sent(sent) if sent.undoable => undo_at(sent.at),
_ => None,
};
[due, hold_until(&self.phase)]
.into_iter()
.flatten()
.min_by(f64::total_cmp)
let hold = hold_until(&self.phase)
.map(|at| at.max(self.hold_floor))
.filter(|_| !self.hovered);
[due, hold].into_iter().flatten().min_by(f64::total_cmp)
}
/// What the capsule draws at `now`.
@@ -1380,7 +1402,9 @@ fn hold_until(phase: &Phase) -> Option<f64> {
}) if open.as_ref().is_none_or(|open| !open.typing && !taken_back) => {
Some(at + tuning::get().done_hold_s)
}
Phase::Kept { at } | Phase::Failed { at, .. } => Some(at + tuning::get().brief_hold_s),
Phase::Kept { at } | Phase::TakenBack { at } | Phase::Failed { at, .. } => {
Some(at + tuning::get().brief_hold_s)
}
_ => None,
}
}
@@ -1423,7 +1447,7 @@ fn list(route: &Route, open: &Open) -> List {
.collect(),
recent: Vec::new(),
selected: open.selected,
footer: Footer::Elsewhere,
footer: Footer::Suggesting,
always: site.map(|site| (site, open.always)),
};
}
@@ -1585,7 +1609,8 @@ fn routed_done(routed: &Routed, undo: bool) -> Done {
let base = match &routed.route {
// Sent nowhere, it waits for a pick: ⌥⇧V or a click reopens the list.
_ if routed.taken_back => Done {
ask: Some("Elsewhere…".into()),
// Too late, it's where it went: nothing to offer.
ask: routed.already_with.is_none().then(|| "Send to…".into()),
why: routed
.already_with
.as_ref()
@@ -1599,11 +1624,10 @@ fn routed_done(routed: &Routed, undo: bool) -> Done {
)
},
// Sent at once, with a pick's plain Undo while it can be taken
// back, then Elsewhere…; ⌥⇧V opens the list throughout.
// back; ⌥⇧V opens the list throughout.
Route::Rule { to, .. } => Done {
why: Some("rule".into()),
undo,
ask: (!undo).then(|| "Elsewhere…".into()),
..Done::plain(Lead::Check, sent_to(&to.name))
},
// The suggestions are the ask (closed, the list shortcut opens them).
@@ -1932,7 +1956,7 @@ mod tests {
assert_eq!(done(&flow, 10.0).text, "Sent to SEER");
assert_eq!(done(&flow, 10.0).lead, Lead::Check);
assert_eq!(done(&flow, 10.0).ask, None, "Undo, as a pick has");
assert_eq!(done(&flow, 15.0).ask.as_deref(), Some("Elsewhere…"));
assert_eq!(done(&flow, 15.0).ask, None, "nothing after the window");
assert!(done(&flow, 10.0).routes.is_empty(), "no runner-up");
assert_eq!(done(&flow, 10.0).why.as_deref(), Some("rule"));
let actions = flow.input(Input::Undo, 11.0);
@@ -1960,6 +1984,36 @@ mod tests {
assert_eq!(late.pres(undo_s()), Pres::Hidden);
}
/// The pointer on a finished capsule holds it; leaving gives it a moment.
/// A click on Undo at the window's edge still counts, and folding a list
/// gives a brief hold rather than hiding it at once.
#[test]
fn hover_and_folding_hold_a_finished_capsule_and_a_late_undo_counts() {
let mut flow = Flow::new();
flow.input(Input::Routed(rule()), 0.0);
flow.hover(true, 4.0);
assert!(!flow.tick(undo_s() + 10.0));
assert_eq!(flow.next_due(undo_s() + 10.0), None);
flow.hover(false, 20.0);
assert!(!flow.tick(20.0 + CHIPS_LINGER_S - 0.1));
assert!(flow.tick(20.0 + CHIPS_LINGER_S));
let mut flow = Flow::new();
flow.input(Input::Routed(rule()), 0.0);
assert_eq!(
flow.input(Input::Undo, undo_s() + 0.01),
[Action::Undo { to: "SEER".into() }]
);
let brief = tuning::get().brief_hold_s;
let mut flow = Flow::new();
flow.input(Input::Routed(rule()), 0.0);
flow.input(Input::OpenList, 4.0);
flow.input(Input::Escape, 9.0);
assert!(!flow.tick(9.0 + brief - 0.1));
assert!(flow.tick(9.0 + brief));
}
fn flow_keys_after_send() -> Option<crate::capture_host::CapsuleKeys> {
let mut flow = Flow::new();
flow.input(Input::Routed(guess()), 0.0);
@@ -2076,10 +2130,12 @@ mod tests {
flow.input(Input::Undo, 1.0);
flow.input(Input::Undone(Undone::TakenBack), 1.2);
assert_eq!(done(&flow, 1.2).text, "Taken back");
assert!(!flow.tick(1_000.0));
assert_eq!(flow.keys(), Some(CapsuleKeys::Route));
flow.input(Input::Dismiss, 1_000.0);
let kept = done(&flow, 1_000.0);
// Nothing to list: no keys are Hex's, and it leaves by itself.
assert_eq!(flow.keys(), None);
let brief = tuning::get().brief_hold_s;
assert!(!flow.tick(1.0 + brief - 0.1));
flow.input(Input::Dismiss, 3.0);
let kept = done(&flow, 3.0);
assert_eq!(
(kept.text.as_str(), kept.why.as_deref()),
("Kept", Some(SEND_LATER))
@@ -2130,7 +2186,7 @@ mod tests {
flow.input(Input::ClickAway, 2.0);
let closed = done(&flow, 2.0);
assert_eq!(closed.text, "Taken back");
assert_eq!(closed.ask.as_deref(), Some("Elsewhere…"));
assert_eq!(closed.ask.as_deref(), Some("Send to…"));
let waiting = Some(crate::capture_host::CapsuleKeys::Route);
assert_eq!(flow.keys(), waiting);
assert_eq!(flow.next_due(2.0), Some(2.0 + hold));
@@ -2201,7 +2257,7 @@ mod tests {
let folded = done(&flow, 2.0);
assert_eq!(folded.text, "Sent to SEER");
assert_eq!(folded.why.as_deref(), Some("too late to take back"));
assert_eq!(folded.ask.as_deref(), Some("Elsewhere…"));
assert_eq!(folded.ask, None, "it is where it went");
flow.input(Input::Dismiss, 3.0);
assert_eq!(flow.pres(3.0), Pres::Hidden);
// It's where it went: once gone, nothing waits for a pick.
@@ -2721,7 +2777,7 @@ mod tests {
let names: Vec<_> = list.rows().map(|dest| dest.name.as_str()).collect();
assert_eq!(names, ["SEER", "HEX", "HOME"], "suggested, then recent");
assert_eq!(list.selected, 0, "the best is marked");
assert_eq!(list.footer, Footer::Elsewhere);
assert_eq!(list.footer, Footer::Suggesting);
assert_eq!(list.always, Some(("problems.kitlangton.com".into(), false)));
assert_eq!(flow.keys(), Some(CapsuleKeys::Suggest { rows: 3 }));
assert!(flow.take_cues().is_empty(), "nothing sent, nothing heard");
@@ -2741,11 +2797,14 @@ mod tests {
}
#[test]
fn escape_folds_the_suggestions_and_they_leave_like_any_capsule() {
fn a_click_away_folds_the_suggestions_and_they_leave_like_any_capsule() {
use crate::capture_host::CapsuleKeys;
let mut flow = Flow::new();
flow.input(Input::Routed(guess()), 0.0);
flow.input(Input::Undo, 1.0);
// Escape is never Hex's here: it changes nothing.
assert!(flow.input(Input::Escape, 0.5).is_empty());
assert!(done(&flow, 0.5).open.is_some());
flow.input(Input::ClickAway, 1.0);
let folded = done(&flow, 1.0);
assert_eq!(folded.open, None);
assert_eq!(folded.ask.as_deref(), Some("Send to…"));
+27 -40
View File
@@ -57,8 +57,6 @@ pub(crate) const FOOTER_H: f32 = surface::FOOTER_H;
const FOOTER_GAP: f32 = 24.0;
/// rune-kit's checkbox.
const CHECKBOX: f32 = 16.0;
/// "Elsewhere…"'s hover inset.
const ELSEWHERE_PX: f32 = 6.0;
/// The list slides down this far as it fades in.
const LIST_DROP: f32 = 6.0;
const LIST_MOVE: rune::Spring = rune::Spring::new(0.32, 0.0);
@@ -1004,7 +1002,7 @@ fn item(p: Paint, surface: &Surface, live: &Animated, shown: &Shown) -> El {
field(p, base, typed)
}
// Rows live in the list, never in the capsule.
Id::Row(_) | Id::Always | Id::Elsewhere => base,
Id::Row(_) | Id::Always => base,
}
}
@@ -1270,7 +1268,7 @@ fn list_view(p: Paint, list: &List, x: f32, w: f32, reduced: bool) -> El {
Footer::KeepCopied => (&["esc"], "Keep copied".to_owned()),
Footer::Keep(to) => (&["esc"], format!("Keep {to}")),
Footer::Always(site) => (&["⇧", "⏎"], format!("Always for {site}")),
Footer::Elsewhere => (&["esc"], "Keep copied".to_owned()),
Footer::Suggesting => (&["esc"], "Keep copied".to_owned()),
};
let used = keycaps_width(&["⏎"]) + 5.0 + measure(&send, SMALL) + FOOTER_GAP;
let second = ellipsize(&second, SMALL, room - used - keycaps_width(keys) - 5.0);
@@ -1303,8 +1301,8 @@ fn list_view(p: Paint, list: &List, x: f32, w: f32, reduced: bool) -> El {
list_panel(p, body, x, w, h, blur)
}
/// The suggestions' footer: the digits that send, and the list shortcut's
/// search of every session.
/// The suggestions' footer: the digits that send, and a hint that the list
/// shortcut searches every session.
fn suggest_footer(p: Paint, list: &List, w: f32) -> El {
let rows = list.rows().count();
let digits = if rows > 1 {
@@ -1314,16 +1312,16 @@ fn suggest_footer(p: Paint, list: &List, w: f32) -> El {
};
let list_keys = surface::ask_keys();
let room = w - 2.0 * LIST_PAD - 2.0 * ROW_PX;
let elsewhere_w = 2.0 * ELSEWHERE_PX
+ measure("Elsewhere…", SMALL)
+ if list_keys.is_empty() {
0.0
} else {
keycaps_width(&list_keys.iter().map(String::as_str).collect::<Vec<_>>()) + 5.0
};
let search_w = if list_keys.is_empty() {
0.0
} else {
keycaps_width(&list_keys.iter().map(String::as_str).collect::<Vec<_>>())
+ 5.0
+ measure("Search", SMALL)
};
// "Send" goes before anything is cut.
let say_send =
keycaps_width(&[digits.as_str()]) + 5.0 + measure("Send", SMALL) + FOOTER_GAP + elsewhere_w
keycaps_width(&[digits.as_str()]) + 5.0 + measure("Send", SMALL) + FOOTER_GAP + search_w
<= room;
let mut send = row()
.key("send")
@@ -1333,24 +1331,23 @@ fn suggest_footer(p: Paint, list: &List, w: f32) -> El {
if say_send {
send = send.child(label("Send", SMALL, p.faint()));
}
let mut elsewhere = row()
.key("elsewhere")
let mut footer = row()
.key("footer")
.center_y()
.gap(5.0)
.h(FOOTER_H - 6.0)
.px(ELSEWHERE_PX)
.radius(ROW_RADIUS)
.hover(p.k.c.hover)
.press(p.k.c.pressed);
.h(FOOTER_H)
.px(ROW_PX)
.child(send)
.child(el().grow(1.0));
if !list_keys.is_empty() {
elsewhere = elsewhere.child(keycaps(p, "keys", &list_keys));
footer = footer.child(
row()
.key("search")
.center_y()
.gap(5.0)
.child(keycaps(p, "keys", &list_keys))
.child(label("Search", SMALL, p.faint())),
);
}
let elsewhere = elsewhere
.child(label("Elsewhere…", SMALL, p.muted()))
.role("button")
.label("Elsewhere…")
.hit()
.on_press_tx(press(Id::Elsewhere));
col()
.w(w - 2.0 * LIST_PAD)
.child(
@@ -1360,17 +1357,7 @@ fn suggest_footer(p: Paint, list: &List, w: f32) -> El {
.mt(LIST_PAD)
.fill(p.k.c.border_base),
)
.child(
row()
.key("footer")
.center_y()
.h(FOOTER_H)
.pl(ROW_PX)
.pr(ROW_PX - ELSEWHERE_PX)
.child(send)
.child(el().grow(1.0))
.child(elsewhere),
)
.child(footer)
}
fn list_panel(p: Paint, body: El, x: f32, w: f32, h: f32, blur: f32) -> El {
+2 -2
View File
@@ -125,7 +125,7 @@ const SCENES: &[Scene] = &[
steps.push(Step::Click(Id::Always));
scene(s, &steps)
}),
("elsewhere", |s| {
("search", |s| {
scene(
s,
&[
@@ -513,7 +513,7 @@ fn states(p: Paint) -> El {
.child(state_button(p, "Pick 1", || {
vec![Step::Input(Input::SendRow(0))]
}))
.child(state_button(p, "Elsewhere…", || {
.child(state_button(p, "Search all", || {
vec![Step::Input(Input::OpenList)]
}))
.child(state_button(p, "Saved rule", rule_sent))
+2 -6
View File
@@ -148,9 +148,6 @@ pub(crate) enum Id {
Row(usize),
/// The suggestions' "Always send <site> here".
Always,
/// The suggestions' "Elsewhere…": the send-to list shortcut searches
/// every session.
Elsewhere,
}
impl Id {
@@ -182,7 +179,6 @@ impl Id {
Id::Field => "field",
Id::Row(_) => "row",
Id::Always => "always",
Id::Elsewhere => "elsewhere",
}
}
@@ -216,7 +212,7 @@ impl Id {
Id::Ask => 18,
Id::Inspect => 19,
Id::Close => 20,
Id::Row(_) | Id::Always | Id::Elsewhere => 21,
Id::Row(_) | Id::Always => 21,
}
}
}
@@ -1015,7 +1011,7 @@ mod tests {
Pres::Done(Done {
why: Some("rule".into()),
undo,
ask: Some("Elsewhere…".into()),
ask: Some("Send to…".into()),
ask_keys: ask_keys(),
..Done::plain(Lead::Check, "Sent to SEER")
})
+3 -18
View File
@@ -296,18 +296,10 @@ fn every_state_draws_its_pieces() {
("saved", &["done", "paste", "inspect", "close"]),
("failed", &["done", "close"]),
("rule-sent", &["done", "why", "undo", "paste", "inspect"]),
("rule-final", &["done", "why", "paste", "ask", "inspect"]),
("rule-final", &["done", "why", "paste", "inspect"]),
(
"guess",
&[
"done",
"paste",
"inspect",
"list",
"row-SEER",
"always",
"elsewhere",
],
&["done", "paste", "inspect", "list", "row-SEER", "always"],
),
(
"guess-four",
@@ -322,14 +314,7 @@ fn every_state_draws_its_pieces() {
// Taken back, the suggestions again, the wrong one last.
(
"taken-back",
&[
"done",
"list",
"row-HOME",
"row-RUNE",
"row-SEER",
"elsewhere",
],
&["done", "list", "row-HOME", "row-RUNE", "row-SEER"],
),
("queued", &["done", "why", "paste", "inspect"]),
];
+2 -2
View File
@@ -690,13 +690,13 @@ unsafe extern "C" fn event_callback(
} else {
None
};
// A press anywhere while the list is open may close it; the click still
// A press anywhere while the list or suggestions are open may fold it; the click still
// goes to the app and to the listener as chord evidence.
#[cfg(hex_capture)]
if matches!(
event_type,
EVENT_LEFT_MOUSE_DOWN | EVENT_RIGHT_MOUSE_DOWN | EVENT_OTHER_MOUSE_DOWN
) && crate::capture_host::list_open()
) && (crate::capture_host::list_open() || crate::capture_host::suggesting())
{
crate::capture_host::capsule_key(crate::capture_host::CapsuleKey::Press);
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 15 KiB