Capsule: Undo is click-only, Escape never claimed after a send; sends hide when the Undo window ends
@@ -157,11 +157,12 @@ The capsule // capture.capsule (rune_ui/capture_cap
|
||||
│ only the send going (its tone), Queued (then Sent), how an Undo ended,
|
||||
│ and a failed send
|
||||
│ ├── A rule Kit saved -> the only send that goes by itself, at once, with
|
||||
│ │ no countdown: "Sent to X" and the same quiet Undo (esc) for 5 s that a
|
||||
│ │ no countdown: "Sent to X" and the same quiet Undo button (click only, no key) for 5 s that a
|
||||
│ │ 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; once the Undo window ends, an "Elsewhere…" chip
|
||||
│ │ opens the list. Picking the rule's own session there (without
|
||||
│ │ 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
|
||||
│ │ "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
|
||||
@@ -173,16 +174,17 @@ The capsule // capture.capsule (rune_ui/capture_cap
|
||||
│ │ ├── "Always send <site> here" (a guess with a site) -> ticked, the pick
|
||||
│ │ │ also saves that rule
|
||||
│ │ ├── 1-3 or a click -> sends at once: "Sent to X", the Sent tone, and a
|
||||
│ │ │ quiet Undo (esc) for the same 5 s, with no ring or drain; ✕ closes
|
||||
│ │ │ 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
|
||||
│ │ ├── Esc -> folds them to a "Send to…" ask
|
||||
│ │ ├── 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. Esc or ✕ dismisses: "Kept ·
|
||||
│ │ and it leaves after the done hold. ✕ (or Esc in its open 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
|
||||
@@ -190,7 +192,7 @@ The capsule // capture.capsule (rune_ui/capture_cap
|
||||
│ │ stands: the Undo's answer and the earlier send's news never take it back
|
||||
│ ├── Too late to take back -> the same list, the session marked "has it",
|
||||
│ │ folded "Sent to X · too late to take back"; a pick sends a copy there,
|
||||
│ │ and Esc or ✕ just closes. Closed, it doesn't wait for the list shortcut.
|
||||
│ │ and ✕ just closes (it leaves by itself after the brief hold). Closed, it doesn't wait for the list shortcut.
|
||||
│ │ An Undo OpenCode refuses (an error) reads as too late
|
||||
│ ├── Sends -> CaptureCommand::Send{to} and Undo, naming the
|
||||
│ │ session by id (`RouteDest.session`), so sessions sharing a title never
|
||||
@@ -198,18 +200,19 @@ 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; Esc too while a send
|
||||
│ │ │ can be undone or a taken-back list is open.
|
||||
│ │ │ "Elsewhere…" 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
|
||||
│ │ │ by Esc, ✕, or its hold, with nothing sent) -> the list shortcut
|
||||
│ │ │ by ✕ or its hold, with nothing sent) -> the list shortcut
|
||||
│ │ │ brings the capsule back with its list open, until a pick, Paste,
|
||||
│ │ │ Inspect, a send from `hex capture send`, or the next capture
|
||||
│ │ ├── Otherwise -> the list shortcut isn't Hex's: runtime_hotkeys has it
|
||||
│ │ │ only while the capsule takes it (capture_host::list_key_wanted),
|
||||
│ │ │ so suppression passes it through
|
||||
│ │ ├── A send from the list still undoable -> Esc only (CapsuleKeys::Undo)
|
||||
│ │ ├── Suggestions -> Esc and the list shortcut through the listener,
|
||||
│ │ ├── A send from the list still undoable -> no keys; Esc and ⌥⇧V go to the
|
||||
│ │ │ 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
|
||||
@@ -359,7 +362,7 @@ Where it goes // capture.route; capture.routing's aut
|
||||
│ deadline, down, or refusing); a warning in process.log with the error, and
|
||||
│ the capsule reads "Couldn't reach OpenCode" with why ("didn't answer in
|
||||
│ time"), keeping Paste and Inspect
|
||||
├── An answer for a capsule already closed (dismissed, or past its 25 s hold)
|
||||
├── An answer for a capsule already closed (dismissed, or past its hold)
|
||||
│ leaves it closed; `hex capture list` and `send` still offer the capture
|
||||
├── The capsule's commands act only on `last`, the newest routed capture:
|
||||
│ ├── Send{to} -> the Rule's own session, already sent, does nothing; any
|
||||
@@ -371,7 +374,8 @@ Where it goes // capture.route; capture.routing's aut
|
||||
│ send straight there
|
||||
├── 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
|
||||
│ 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
|
||||
└── autoSend off -> no look, no route; the capture is only copied
|
||||
|
||||
hex capture list|show|send|route // capture.cli; docs/cli.md
|
||||
|
||||
@@ -2420,10 +2420,7 @@ mod tests {
|
||||
..RuntimeHotkeys::default()
|
||||
};
|
||||
assert_eq!(runtime_hotkeys().capture_list, None);
|
||||
let grab = crate::capture_host::take_keys(
|
||||
crate::capture_host::CapsuleKeys::Route { escape: false },
|
||||
|_| {},
|
||||
);
|
||||
let grab = crate::capture_host::take_keys(crate::capture_host::CapsuleKeys::Route, |_| {});
|
||||
assert_eq!(runtime_hotkeys().capture_list, Some(list));
|
||||
grab.set(crate::capture_host::CapsuleKeys::Picker);
|
||||
assert_eq!(runtime_hotkeys().capture_list, None);
|
||||
|
||||
@@ -2177,16 +2177,14 @@ pub enum CapsuleKeys {
|
||||
Picker,
|
||||
/// A routed capsule, or a hidden one whose capture still waits for a
|
||||
/// pick: the send-to list shortcut (`capture.list_hotkey`) opens its
|
||||
/// list ([`CapsuleKey::OpenList`]), and Escape too while `escape` (a
|
||||
/// send that can still be undone).
|
||||
Route { escape: bool },
|
||||
/// A send from the list waiting out its Undo: Escape takes it back.
|
||||
Undo,
|
||||
/// list ([`CapsuleKey::OpenList`]). Never Escape: it goes to the app in
|
||||
/// front, and a send is taken back only by clicking Undo.
|
||||
Route,
|
||||
/// The open list: every key press without ⌘ or ⌃ that isn't one of
|
||||
/// Hex's shortcuts.
|
||||
List,
|
||||
/// A capture's suggestions: Escape, the send-to list shortcut (search
|
||||
/// every session), and 1 to `rows` with no modifier
|
||||
/// A capture's suggestions: the send-to list shortcut (search every
|
||||
/// session), and 1 to `rows` with no modifier
|
||||
/// ([`CapsuleKey::Digit`]).
|
||||
Suggest { rows: u8 },
|
||||
}
|
||||
@@ -2233,10 +2231,8 @@ fn keys_code(keys: Option<CapsuleKeys>) -> u8 {
|
||||
match keys {
|
||||
None => 0,
|
||||
Some(CapsuleKeys::Picker) => 1,
|
||||
Some(CapsuleKeys::Route { escape: false }) => 2,
|
||||
Some(CapsuleKeys::Route { escape: true }) => 3,
|
||||
Some(CapsuleKeys::Route) => 2,
|
||||
Some(CapsuleKeys::List) => 4,
|
||||
Some(CapsuleKeys::Undo) => 5,
|
||||
Some(CapsuleKeys::Suggest { .. }) => 6,
|
||||
}
|
||||
}
|
||||
@@ -2292,9 +2288,10 @@ pub fn picking() -> bool {
|
||||
GRAB_KEYS.load(Ordering::Acquire) == keys_code(Some(CapsuleKeys::Picker))
|
||||
}
|
||||
|
||||
/// Whether the capsule takes Escape from the listener.
|
||||
/// Whether the capsule takes Escape from the listener: only the picker
|
||||
/// (the open list takes it at the tap).
|
||||
pub fn wants_escape() -> bool {
|
||||
matches!(GRAB_KEYS.load(Ordering::Acquire), 1 | 3 | 5 | 6)
|
||||
GRAB_KEYS.load(Ordering::Acquire) == keys_code(Some(CapsuleKeys::Picker))
|
||||
}
|
||||
|
||||
/// Whether the open list takes every key press at the tap.
|
||||
@@ -2326,10 +2323,8 @@ pub fn capsule_key(key: CapsuleKey) -> bool {
|
||||
fn takes(keys: CapsuleKeys, key: &CapsuleKey) -> bool {
|
||||
match (keys, key) {
|
||||
(CapsuleKeys::Picker, CapsuleKey::Shortcut | CapsuleKey::Escape) => true,
|
||||
(CapsuleKeys::Route { escape }, CapsuleKey::Escape) => escape,
|
||||
(CapsuleKeys::Undo | CapsuleKeys::Suggest { .. }, CapsuleKey::Escape) => true,
|
||||
(
|
||||
CapsuleKeys::Route { .. } | CapsuleKeys::List | CapsuleKeys::Suggest { .. },
|
||||
CapsuleKeys::Route | CapsuleKeys::List | CapsuleKeys::Suggest { .. },
|
||||
CapsuleKey::OpenList,
|
||||
) => true,
|
||||
(CapsuleKeys::Suggest { rows }, CapsuleKey::Digit(digit)) => (1..=rows).contains(digit),
|
||||
@@ -4196,7 +4191,7 @@ mod tests {
|
||||
|
||||
// A routed capsule: the list shortcut opens the list; Escape only
|
||||
// while a send can be undone.
|
||||
second.set(CapsuleKeys::Route { escape: false });
|
||||
second.set(CapsuleKeys::Route);
|
||||
assert!(!picking() && !wants_escape() && list_key_wanted());
|
||||
assert!(!capsule_key(CapsuleKey::Shortcut));
|
||||
assert!(!capsule_key(CapsuleKey::Escape));
|
||||
@@ -4205,15 +4200,13 @@ mod tests {
|
||||
!capsule_key(CapsuleKey::Press),
|
||||
"a press matters only to the list"
|
||||
);
|
||||
second.set(CapsuleKeys::Route { escape: true });
|
||||
assert!(wants_escape());
|
||||
// A send from the list counting down: Escape, and ⌥⇧V goes to the app.
|
||||
second.set(CapsuleKeys::Undo);
|
||||
assert!(wants_escape() && !list_key_wanted() && !suggesting());
|
||||
assert!(!capsule_key(CapsuleKey::OpenList));
|
||||
// Suggestions: Escape, the list shortcut, and only their own digits.
|
||||
second.set(CapsuleKeys::Route);
|
||||
assert!(!wants_escape() && !capsule_key(CapsuleKey::Escape));
|
||||
// Suggestions: the list shortcut and only their own digits, never
|
||||
// Escape.
|
||||
second.set(CapsuleKeys::Suggest { rows: 2 });
|
||||
assert!(suggesting() && wants_escape() && list_key_wanted() && !list_open());
|
||||
assert!(suggesting() && !wants_escape() && list_key_wanted() && !list_open());
|
||||
assert!(!capsule_key(CapsuleKey::Escape));
|
||||
assert!(capsule_key(CapsuleKey::Digit(2)));
|
||||
assert!(!capsule_key(CapsuleKey::Digit(3)), "no third row");
|
||||
assert!(!capsule_key(CapsuleKey::Text("h".into())));
|
||||
|
||||
@@ -8,7 +8,7 @@ use scrawl_capture::capture::Stage;
|
||||
|
||||
use super::tuning;
|
||||
|
||||
/// A send, a rule's or a pick's, can be taken back with Escape for this
|
||||
/// A send, a rule's or a pick's, can be taken back with the Undo button for this
|
||||
/// long (Scrawl's `SMART_SEND_UNDO`).
|
||||
pub(crate) fn undo_s() -> f64 {
|
||||
tuning::get().undo_s
|
||||
@@ -197,6 +197,8 @@ pub(crate) enum Input {
|
||||
/// "Always send <site> here" in the suggestions, ticked or not.
|
||||
ToggleAlways,
|
||||
Escape,
|
||||
/// The Undo button: the only way to take a send back.
|
||||
Undo,
|
||||
Undone(Undone),
|
||||
/// The ✕, or anything that should just close it.
|
||||
Dismiss,
|
||||
@@ -269,9 +271,9 @@ pub(crate) enum Cue {
|
||||
/// The second footer hint in the open list.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Footer {
|
||||
/// esc keeps it copied.
|
||||
/// Escape keeps it copied (the list is open, so it is Hex's).
|
||||
KeepCopied,
|
||||
/// esc keeps it where the rule sent it.
|
||||
/// Escape keeps it where the rule sent it.
|
||||
Keep(String),
|
||||
/// ⇧⏎ always sends this site to the selected session.
|
||||
Always(String),
|
||||
@@ -913,34 +915,41 @@ impl Flow {
|
||||
Phase::Routed(routed)
|
||||
}
|
||||
(phase, Input::ClickAway) => phase,
|
||||
// Taken back, Escape is the dismissal: the bundle is kept. Too
|
||||
// late, it's where it went.
|
||||
// Taken back, ✕ (or Escape in its open list) is the dismissal:
|
||||
// the bundle is kept. Too late, it's where it went.
|
||||
(
|
||||
Phase::Routed(Routed {
|
||||
taken_back: true,
|
||||
already_with,
|
||||
open,
|
||||
..
|
||||
}),
|
||||
Input::Escape | Input::Dismiss,
|
||||
) => match already_with {
|
||||
input @ (Input::Escape | Input::Dismiss),
|
||||
) if input == Input::Dismiss || open.is_some() => 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) => {
|
||||
if routed.open.take().is_some() {
|
||||
Phase::Routed(routed)
|
||||
} else if let (Some(to), true) =
|
||||
(rule_to(&routed.route).cloned(), now - routed.at < undo_s())
|
||||
{
|
||||
actions.push(Action::Undo {
|
||||
to: to.name.clone(),
|
||||
});
|
||||
taking_back(Some(routed.route), &to, now)
|
||||
} else {
|
||||
Phase::Hidden
|
||||
routed.open = None;
|
||||
Phase::Routed(routed)
|
||||
}
|
||||
(Phase::Routed(mut routed), Input::Undo) => {
|
||||
match (rule_to(&routed.route).cloned(), now - routed.at < undo_s()) {
|
||||
(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::Sent(sent), Input::Escape) if sent.undoable && now - sent.at < undo_s() => {
|
||||
(Phase::Sent(sent), Input::Undo) if sent.undoable && now - sent.at < undo_s() => {
|
||||
actions.push(Action::Undo {
|
||||
to: sent.to.clone(),
|
||||
});
|
||||
@@ -948,7 +957,7 @@ impl Flow {
|
||||
taking_back(sent.back, &from, now)
|
||||
}
|
||||
// Nothing to list: dismissing says where the bundle is.
|
||||
(Phase::TakenBack { .. }, Input::Escape | Input::Dismiss) => Phase::Kept { at: now },
|
||||
(Phase::TakenBack { .. }, Input::Dismiss) => Phase::Kept { at: now },
|
||||
// Escape closes the picker, but never ends a recording: it may be
|
||||
// meant for the app being recorded.
|
||||
(Phase::Selecting(_), Input::Escape) => {
|
||||
@@ -1016,8 +1025,10 @@ impl Flow {
|
||||
Phase::Routed,
|
||||
)
|
||||
}
|
||||
(phase @ Phase::Recording { .. }, Input::Escape) => phase,
|
||||
(_, Input::Escape | Input::Dismiss) => Phase::Hidden,
|
||||
// Escape is the app's everywhere else: it is never claimed, so
|
||||
// one that arrives is ignored.
|
||||
(phase, Input::Escape | Input::Undo) => phase,
|
||||
(_, Input::Dismiss) => Phase::Hidden,
|
||||
(phase, _) => phase,
|
||||
};
|
||||
actions
|
||||
@@ -1113,7 +1124,7 @@ impl Flow {
|
||||
self.phase = Phase::Hidden;
|
||||
vec![Action::Inspect]
|
||||
}
|
||||
(_, Id::Undo) => self.input(Input::Escape, now),
|
||||
(_, Id::Undo) => self.input(Input::Undo, now),
|
||||
(_, Id::Ask) => self.input(Input::OpenList, now),
|
||||
(_, Id::Row(row)) => self.input(Input::SendRow(row), now),
|
||||
(_, Id::Always) => self.input(Input::ToggleAlways, now),
|
||||
@@ -1125,20 +1136,17 @@ impl Flow {
|
||||
}
|
||||
|
||||
/// The keys the capsule takes from Hex's tap: the picker's, an open
|
||||
/// list's, or a routed capture's list shortcut and, while a send can be
|
||||
/// taken back, Escape; closed, the list shortcut while the capture
|
||||
/// list's (Escape only in a list Kit opened or the picker), or a routed
|
||||
/// capture's list shortcut; closed, the list shortcut while the capture
|
||||
/// waits for a pick. With no sessions to list, the list shortcut goes
|
||||
/// to the app in front.
|
||||
pub(crate) fn keys(&self, now: f64) -> Option<crate::capture_host::CapsuleKeys> {
|
||||
pub(crate) fn keys(&self) -> Option<crate::capture_host::CapsuleKeys> {
|
||||
use crate::capture_host::CapsuleKeys;
|
||||
match &self.phase {
|
||||
Phase::Hidden | Phase::Kept { .. } => self
|
||||
.waiting
|
||||
.as_ref()
|
||||
.map(|_| CapsuleKeys::Route { escape: false }),
|
||||
Phase::Hidden | Phase::Kept { .. } => self.waiting.as_ref().map(|_| CapsuleKeys::Route),
|
||||
Phase::Selecting(_) => Some(CapsuleKeys::Picker),
|
||||
// Taken back with nothing to list: Escape is the dismissal.
|
||||
Phase::TakenBack { .. } => Some(CapsuleKeys::Route { escape: true }),
|
||||
// Taken back with nothing to list: ✕ dismisses, or it leaves.
|
||||
Phase::TakenBack { .. } => Some(CapsuleKeys::Route),
|
||||
Phase::Routed(Routed {
|
||||
open: Some(open),
|
||||
route,
|
||||
@@ -1155,13 +1163,11 @@ impl Flow {
|
||||
route: Route::Unreachable { .. },
|
||||
..
|
||||
}) => None,
|
||||
// Folded after a take-back, Escape goes back to the app in front;
|
||||
// ✕ dismisses it, or it leaves by itself.
|
||||
Phase::Routed(_) => Some(CapsuleKeys::Route {
|
||||
escape: self.undoable(now).is_some(),
|
||||
}),
|
||||
// Never Escape here: it goes to the app in front, and a send is
|
||||
// taken back only by clicking Undo.
|
||||
Phase::Routed(_) => Some(CapsuleKeys::Route),
|
||||
// A send from the list has no list to open: ⌥⇧V goes to the app.
|
||||
Phase::Sent(_) => self.undoable(now).map(|_| CapsuleKeys::Undo),
|
||||
Phase::Sent(_) => None,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -1340,13 +1346,32 @@ fn waits(routed: Routed) -> Option<Routed> {
|
||||
|
||||
fn hold_until(phase: &Phase) -> Option<f64> {
|
||||
match phase {
|
||||
Phase::Saved { at } | Phase::Queued { at, .. } | Phase::TooLate { at, .. } => {
|
||||
Some(at + tuning::get().done_hold_s)
|
||||
Phase::Saved { at } => Some(at + tuning::get().done_hold_s),
|
||||
Phase::Queued { at, .. } | Phase::TooLate { at, .. } => {
|
||||
Some(at + tuning::get().brief_hold_s)
|
||||
}
|
||||
Phase::Sent(sent) => Some(sent.at + tuning::get().done_hold_s),
|
||||
// A send leaves once its Undo window ends (a send with none, and
|
||||
// a queued one, after the brief hold).
|
||||
Phase::Sent(sent) if sent.undoable => Some(sent.at + undo_s()),
|
||||
Phase::Sent(sent) => Some(sent.at + tuning::get().brief_hold_s),
|
||||
// The suggestions leave like any finished capsule, and so does a
|
||||
// take-back once folded (from when it folded); a search, or a
|
||||
// take-back's open list, stays.
|
||||
Phase::Routed(Routed {
|
||||
route: Route::Rule { .. },
|
||||
at,
|
||||
open: None,
|
||||
taken_back: false,
|
||||
..
|
||||
}) => Some(at + undo_s()),
|
||||
// Too late to take back, folded: it's where it went, so it leaves
|
||||
// as the other settled sends do.
|
||||
Phase::Routed(Routed {
|
||||
at,
|
||||
open: None,
|
||||
already_with: Some(_),
|
||||
..
|
||||
}) => Some(at + tuning::get().brief_hold_s),
|
||||
Phase::Routed(Routed {
|
||||
at,
|
||||
open,
|
||||
@@ -1756,29 +1781,24 @@ mod tests {
|
||||
use crate::capture_host::CapsuleKeys;
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Stage(Stage::Recording), 0.0);
|
||||
assert_eq!(flow.keys(0.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
flow.input(Input::Chips, 0.5);
|
||||
flow.click(super::super::surface::Id::Mode(Mode::Window), 1.0);
|
||||
assert_eq!(flow.keys(1.0), Some(CapsuleKeys::Picker));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Picker));
|
||||
|
||||
flow.input(Input::Routed(rule()), 2.0);
|
||||
assert_eq!(flow.keys(2.5), Some(CapsuleKeys::Route { escape: true }));
|
||||
assert_eq!(
|
||||
flow.keys(2.0 + undo_s()),
|
||||
Some(CapsuleKeys::Route { escape: false })
|
||||
);
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Route));
|
||||
flow.input(Input::OpenList, 9.0);
|
||||
assert_eq!(flow.keys(9.0), Some(CapsuleKeys::List));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::List));
|
||||
flow.input(Input::Type("ho".into()), 9.1);
|
||||
flow.input(Input::Type("x".into()), 9.2);
|
||||
flow.input(Input::Backspace, 9.3);
|
||||
assert_eq!(done(&flow, 9.3).open.unwrap().0, "ho");
|
||||
flow.input(Input::SendRow(0), 9.4);
|
||||
assert_eq!(flow.keys(9.5), Some(CapsuleKeys::Undo));
|
||||
assert_eq!(flow.keys(9.4 + undo_s()), None, "sent, nothing to undo");
|
||||
assert_eq!(flow.keys(), None, "a send takes no keys: Undo is a click");
|
||||
|
||||
flow.input(Input::Stage(Stage::Done), 20.0);
|
||||
assert_eq!(flow.keys(20.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1903,7 +1923,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rule_sends_at_once_with_a_plain_undo_and_escape_takes_it_back() {
|
||||
fn a_rule_sends_at_once_with_a_plain_undo_and_leaves_when_its_window_ends() {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule()), 10.0);
|
||||
let at = |t| done(&flow, t).undo;
|
||||
@@ -1915,18 +1935,73 @@ mod tests {
|
||||
assert_eq!(done(&flow, 15.0).ask.as_deref(), Some("Elsewhere…"));
|
||||
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::Escape, 11.0);
|
||||
let actions = flow.input(Input::Undo, 11.0);
|
||||
assert_eq!(actions, vec![Action::Undo { to: "SEER".into() }]);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 11.4);
|
||||
assert!(
|
||||
done(&flow, 11.4).open.is_some(),
|
||||
"taken back, the list opens"
|
||||
);
|
||||
// After the window, Escape just closes.
|
||||
// Escape never takes a send back or closes it, in the window or
|
||||
// after it: it was never Hex's.
|
||||
for at in [1.0, 5.5] {
|
||||
let mut late = Flow::new();
|
||||
late.input(Input::Routed(rule()), 0.0);
|
||||
assert!(late.input(Input::Escape, at).is_empty());
|
||||
assert!(matches!(late.pres(at), Pres::Done(_)));
|
||||
}
|
||||
assert_eq!(flow_keys_after_send(), None);
|
||||
// Time alone takes it away once the Undo window ends.
|
||||
let mut late = Flow::new();
|
||||
late.input(Input::Routed(rule()), 0.0);
|
||||
assert!(late.input(Input::Escape, 5.5).is_empty());
|
||||
assert_eq!(late.pres(5.5), Pres::Hidden);
|
||||
assert!(!late.tick(undo_s() - 0.1));
|
||||
assert_eq!(late.next_due(0.0), Some(undo_s()));
|
||||
assert!(late.tick(undo_s()));
|
||||
assert_eq!(late.pres(undo_s()), Pres::Hidden);
|
||||
}
|
||||
|
||||
fn flow_keys_after_send() -> Option<crate::capture_host::CapsuleKeys> {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::SendRow(0), 1.0);
|
||||
flow.keys()
|
||||
}
|
||||
|
||||
/// A pick leaves on its own when its Undo window ends, and a send
|
||||
/// that queued or came too late leaves after the brief hold.
|
||||
#[test]
|
||||
fn a_sent_capsule_hides_by_itself() {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::SendRow(0), 1.0);
|
||||
assert!(matches!(
|
||||
flow.pres(1.0),
|
||||
Pres::Done(Done { undo: true, .. })
|
||||
));
|
||||
assert_eq!(flow.next_due(1.0), Some(1.0 + undo_s()));
|
||||
assert!(!flow.tick(1.0 + undo_s() - 0.1));
|
||||
assert!(flow.tick(1.0 + undo_s()));
|
||||
assert_eq!(flow.pres(1.0 + undo_s()), Pres::Hidden);
|
||||
|
||||
let brief = tuning::get().brief_hold_s;
|
||||
let mut queued = Flow::new();
|
||||
queued.input(
|
||||
Input::Delivered(Delivered::Queued {
|
||||
to: "SEER".into(),
|
||||
why: "will retry".into(),
|
||||
}),
|
||||
0.0,
|
||||
);
|
||||
assert!(queued.tick(brief));
|
||||
assert_eq!(queued.pres(brief), Pres::Hidden);
|
||||
|
||||
let mut late = Flow::new();
|
||||
late.input(Input::Routed(rule_of_three()), 0.0);
|
||||
late.input(Input::Undo, 1.0);
|
||||
late.input(Input::Undone(Undone::TooLate), 1.2);
|
||||
late.input(Input::ClickAway, 2.0);
|
||||
assert!(late.tick(2.0 + brief));
|
||||
assert_eq!(late.pres(2.0 + brief), Pres::Hidden);
|
||||
}
|
||||
|
||||
fn rule_of_three() -> Route {
|
||||
@@ -1956,7 +2031,7 @@ mod tests {
|
||||
use crate::capture_host::CapsuleKeys;
|
||||
type Undo = fn(&mut Flow, f64) -> Vec<Action>;
|
||||
let ways: [(&str, Undo); 2] = [
|
||||
("esc", |flow, now| flow.input(Input::Escape, now)),
|
||||
("Undo input", |flow, now| flow.input(Input::Undo, now)),
|
||||
("Undo chip", |flow, now| flow.click(Id::Undo, now)),
|
||||
];
|
||||
for (how, undo) in ways {
|
||||
@@ -1969,12 +2044,8 @@ mod tests {
|
||||
);
|
||||
// At once, the same suggestions, the wrong one last.
|
||||
assert_eq!(rows(&flow, 1.0), ["HEX", "HOME", "SEER"], "{how}");
|
||||
// 1-3 pick, the list shortcut searches, Escape dismisses.
|
||||
assert_eq!(
|
||||
flow.keys(1.0),
|
||||
Some(CapsuleKeys::Suggest { rows: 3 }),
|
||||
"{how}"
|
||||
);
|
||||
// 1-3 pick, the list shortcut searches; Escape stays the app's.
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Suggest { rows: 3 }), "{how}");
|
||||
// The router's answer changes nothing, and nothing times out.
|
||||
flow.input(Input::Undone(Undone::TakenBack), 1.3);
|
||||
assert_eq!(rows(&flow, 1.3), ["HEX", "HOME", "SEER"], "{how}");
|
||||
@@ -2002,15 +2073,12 @@ mod tests {
|
||||
site: None,
|
||||
};
|
||||
flow.input(Input::Routed(lone), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
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(1_000.0),
|
||||
Some(CapsuleKeys::Route { escape: true })
|
||||
);
|
||||
flow.input(Input::Escape, 1_000.0);
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Route));
|
||||
flow.input(Input::Dismiss, 1_000.0);
|
||||
let kept = done(&flow, 1_000.0);
|
||||
assert_eq!(
|
||||
(kept.text.as_str(), kept.why.as_deref()),
|
||||
@@ -2024,7 +2092,7 @@ mod tests {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
assert_eq!(
|
||||
flow.input(Input::Escape, 1.0),
|
||||
flow.input(Input::Undo, 1.0),
|
||||
[Action::Undo { to: "SEER".into() }]
|
||||
);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 1.2);
|
||||
@@ -2034,7 +2102,7 @@ mod tests {
|
||||
assert_eq!(list.suggested[2].why, "taken back");
|
||||
assert_eq!(list.selected, 0);
|
||||
assert_eq!(
|
||||
flow.keys(1.2),
|
||||
flow.keys(),
|
||||
Some(crate::capture_host::CapsuleKeys::Suggest { rows: 3 })
|
||||
);
|
||||
// It never leaves by itself.
|
||||
@@ -2057,19 +2125,19 @@ mod tests {
|
||||
let hold = tuning::get().done_hold_s;
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 1.2);
|
||||
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…"));
|
||||
let waiting = Some(crate::capture_host::CapsuleKeys::Route { escape: false });
|
||||
assert_eq!(flow.keys(2.0), waiting);
|
||||
let waiting = Some(crate::capture_host::CapsuleKeys::Route);
|
||||
assert_eq!(flow.keys(), waiting);
|
||||
assert_eq!(flow.next_due(2.0), Some(2.0 + hold));
|
||||
assert!(!flow.tick(2.0 + hold - 0.1));
|
||||
assert!(flow.tick(2.0 + hold));
|
||||
assert_eq!(flow.pres(1_000.0), Pres::Hidden);
|
||||
assert_eq!(flow.keys(1_000.0), waiting);
|
||||
assert_eq!(flow.keys(), waiting);
|
||||
flow.input(Input::OpenList, 1_000.0);
|
||||
assert_eq!(rows(&flow, 1_000.0)[0], "HEX");
|
||||
assert!(flow.input(Input::Escape, 1_001.0).is_empty());
|
||||
@@ -2083,7 +2151,7 @@ mod tests {
|
||||
// Taken back, ✕ is the dismissal too.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 1.2);
|
||||
assert!(flow.click(Id::Close, 2.0).is_empty());
|
||||
assert_eq!(done(&flow, 2.0).text, "Kept");
|
||||
@@ -2105,7 +2173,7 @@ mod tests {
|
||||
fn too_late_to_take_back_offers_the_list_for_a_copy() {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Undone(Undone::TooLate), 1.2);
|
||||
let shown = done(&flow, 1.2);
|
||||
assert_eq!(shown.text, "Sent to SEER");
|
||||
@@ -2127,26 +2195,26 @@ mod tests {
|
||||
// Folded, it says where it is; dismissed, it just goes.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Undone(Undone::TooLate), 1.2);
|
||||
flow.input(Input::ClickAway, 2.0);
|
||||
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…"));
|
||||
flow.input(Input::Escape, 3.0);
|
||||
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.
|
||||
assert_eq!(flow.keys(3.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
|
||||
// Folded, it leaves by itself, and the list shortcut stays the app's.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Undone(Undone::TooLate), 1.2);
|
||||
flow.input(Input::ClickAway, 2.0);
|
||||
assert!(flow.tick(2.0 + tuning::get().done_hold_s));
|
||||
assert_eq!(flow.keys(1_000.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2156,7 +2224,7 @@ mod tests {
|
||||
flow.input(Input::OpenList, 0.5);
|
||||
flow.input(Input::SendRow(0), 1.0);
|
||||
assert_eq!(
|
||||
flow.input(Input::Escape, 2.0),
|
||||
flow.input(Input::Undo, 2.0),
|
||||
[Action::Undo { to: "SEER".into() }]
|
||||
);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 2.2);
|
||||
@@ -2182,7 +2250,7 @@ mod tests {
|
||||
};
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(route), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
let Phase::Routed(Routed {
|
||||
route: Route::Guess {
|
||||
suggested, recent, ..
|
||||
@@ -2206,23 +2274,19 @@ mod tests {
|
||||
#[test]
|
||||
fn a_pick_taken_back_waits_for_a_pick_again() {
|
||||
use crate::capture_host::CapsuleKeys;
|
||||
for dismiss in [Input::Escape, Input::ClickAway] {
|
||||
for dismiss in [Input::Dismiss, Input::ClickAway] {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::SendRow(0), 1.0);
|
||||
flow.input(Input::Settled, 1.1);
|
||||
flow.input(Input::Escape, 2.0);
|
||||
flow.input(Input::Undo, 2.0);
|
||||
// The send it took back, reported late, settles nothing.
|
||||
flow.input(Input::Settled, 2.1);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 2.2);
|
||||
flow.input(dismiss.clone(), 3.0);
|
||||
flow.tick(3.0 + tuning::get().done_hold_s);
|
||||
assert_eq!(flow.pres(100.0), Pres::Hidden, "{dismiss:?}");
|
||||
assert_eq!(
|
||||
flow.keys(100.0),
|
||||
Some(CapsuleKeys::Route { escape: false }),
|
||||
"{dismiss:?}"
|
||||
);
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Route), "{dismiss:?}");
|
||||
flow.input(Input::OpenList, 100.0);
|
||||
assert!(done(&flow, 100.0).open.is_some(), "{dismiss:?}");
|
||||
}
|
||||
@@ -2235,15 +2299,15 @@ mod tests {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::SendRow(0), 1.0);
|
||||
flow.input(Input::Escape, 2.0);
|
||||
flow.input(Input::Undo, 2.0);
|
||||
assert_eq!(flow.take_cues(), [Cue::Sent, Cue::TakenBack]);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 2.2);
|
||||
// Kept, then back.
|
||||
flow.input(Input::Escape, 3.0);
|
||||
flow.input(Input::Dismiss, 3.0);
|
||||
flow.input(Input::OpenList, 4.0);
|
||||
assert!(done(&flow, 4.0).open.is_some());
|
||||
// Hidden, then back.
|
||||
flow.input(Input::Escape, 5.0);
|
||||
flow.input(Input::Dismiss, 5.0);
|
||||
flow.tick(5.0 + tuning::get().brief_hold_s);
|
||||
flow.input(Input::OpenList, 20.0);
|
||||
assert!(done(&flow, 20.0).open.is_some());
|
||||
@@ -2259,7 +2323,7 @@ mod tests {
|
||||
let shown = done(&flow, 0.5);
|
||||
assert_eq!(shown.text, "Sent to SEER");
|
||||
assert!(!shown.undo);
|
||||
assert_eq!(flow.keys(0.5), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
assert!(flow.input(Input::Escape, 0.5).is_empty());
|
||||
assert_eq!(
|
||||
flow.click(super::super::surface::Id::Paste, 0.6),
|
||||
@@ -2357,7 +2421,7 @@ mod tests {
|
||||
fn a_pick_during_an_undo_stands_when_the_undo_answers() {
|
||||
let picked = |flow: &mut Flow| {
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
assert_eq!(rows(flow, 1.0), ["HEX", "HOME", "SEER"]);
|
||||
flow.input(Input::SendRow(0), 1.1);
|
||||
assert_eq!(done(flow, 1.1).text, "Sent to HEX");
|
||||
@@ -2401,7 +2465,7 @@ mod tests {
|
||||
] {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 0.5);
|
||||
flow.input(Input::Undo, 0.5);
|
||||
flow.input(ended.clone(), 0.6);
|
||||
assert_eq!(rows(&flow, 0.6), ["HEX", "HOME", "SEER"], "{ended:?}");
|
||||
flow.input(Input::Undone(Undone::TakenBack), 0.8);
|
||||
@@ -2475,14 +2539,14 @@ mod tests {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::OpenList, 0.5);
|
||||
assert_eq!(flow.keys(0.6), Some(CapsuleKeys::List));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::List));
|
||||
// A press on the capsule is the capsule's own click.
|
||||
flow.hover(true, 0.6);
|
||||
flow.input(Input::ClickAway, 0.6);
|
||||
assert_eq!(flow.keys(0.6), Some(CapsuleKeys::List));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::List));
|
||||
flow.hover(false, 0.65);
|
||||
assert!(flow.input(Input::ClickAway, 0.7).is_empty());
|
||||
assert_eq!(flow.keys(0.8), Some(CapsuleKeys::Route { escape: false }));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Route));
|
||||
assert!(matches!(flow.pres(0.8), Pres::Done(_)));
|
||||
flow.input(Input::ClickAway, 0.9);
|
||||
assert!(matches!(flow.pres(0.9), Pres::Done(_)), "the chips stay");
|
||||
@@ -2659,7 +2723,7 @@ mod tests {
|
||||
assert_eq!(list.selected, 0, "the best is marked");
|
||||
assert_eq!(list.footer, Footer::Elsewhere);
|
||||
assert_eq!(list.always, Some(("problems.kitlangton.com".into(), false)));
|
||||
assert_eq!(flow.keys(0.0), Some(CapsuleKeys::Suggest { rows: 3 }));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Suggest { rows: 3 }));
|
||||
assert!(flow.take_cues().is_empty(), "nothing sent, nothing heard");
|
||||
flow.tick(4.0);
|
||||
assert!(matches!(flow.pres(4.0), Pres::Done(_)), "no countdown runs");
|
||||
@@ -2681,11 +2745,11 @@ mod tests {
|
||||
use crate::capture_host::CapsuleKeys;
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
let folded = done(&flow, 1.0);
|
||||
assert_eq!(folded.open, None);
|
||||
assert_eq!(folded.ask.as_deref(), Some("Send to…"));
|
||||
assert_eq!(flow.keys(1.0), Some(CapsuleKeys::Route { escape: false }));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Route));
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.tick(tuning::get().done_hold_s);
|
||||
@@ -2742,27 +2806,24 @@ mod tests {
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Stage(Stage::Done), 0.0);
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
assert_eq!(flow.keys(1.0), Some(CapsuleKeys::Suggest { rows: 3 }));
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Suggest { rows: 3 }));
|
||||
// Its hold runs out: hidden, but ⌥⇧V is still the capsule's.
|
||||
assert!(flow.tick(hold + 1.0));
|
||||
assert_eq!(flow.pres(hold + 1.0), Pres::Hidden);
|
||||
assert_eq!(
|
||||
flow.keys(hold + 1.0),
|
||||
Some(CapsuleKeys::Route { escape: false })
|
||||
);
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::Route));
|
||||
assert!(flow.input(Input::OpenList, 30.0).is_empty());
|
||||
let (query, list) = done(&flow, 30.0).open.expect("the list is open");
|
||||
assert_eq!(query, "");
|
||||
assert_eq!(list.selected_dest().unwrap().name, "SEER");
|
||||
assert_eq!(flow.keys(30.0), Some(CapsuleKeys::List));
|
||||
// Escape folds the list, then dismisses: it waits again.
|
||||
assert_eq!(flow.keys(), Some(CapsuleKeys::List));
|
||||
// Escape folds the list; it then leaves with its hold and waits again.
|
||||
flow.input(Input::Escape, 31.0);
|
||||
flow.input(Input::Escape, 32.0);
|
||||
assert_eq!(flow.pres(32.0), Pres::Hidden);
|
||||
assert!(matches!(flow.pres(32.0), Pres::Done(_)));
|
||||
flow.tick(31.0 + hold + 1.0);
|
||||
assert_eq!(flow.pres(32.0 + hold), Pres::Hidden);
|
||||
flow.input(Input::OpenList, 40.0);
|
||||
assert!(done(&flow, 40.0).open.is_some());
|
||||
// A pick settles it: Escape while it counts down, and ⌥⇧V goes to
|
||||
// the app.
|
||||
// A pick settles it: no key is Hex's, Escape and ⌥⇧V go to the app.
|
||||
assert_eq!(
|
||||
flow.input(Input::SendRow(1), 41.0),
|
||||
[Action::Send {
|
||||
@@ -2770,18 +2831,18 @@ mod tests {
|
||||
always: None
|
||||
}]
|
||||
);
|
||||
assert_eq!(flow.keys(41.0), Some(CapsuleKeys::Undo));
|
||||
assert_eq!(flow.keys(), None);
|
||||
flow.tick(41.0 + hold + 1.0);
|
||||
assert_eq!(flow.keys(41.0 + hold + 1.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
|
||||
// `hex capture send` while it's closed settles it too.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Stage(Stage::Done), 0.0);
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::Dismiss, 1.0);
|
||||
assert!(flow.keys(1.0).is_some());
|
||||
assert!(flow.keys().is_some());
|
||||
flow.input(Input::Settled, 2.0);
|
||||
assert_eq!(flow.keys(2.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
flow.input(Input::OpenList, 3.0);
|
||||
assert_eq!(flow.pres(3.0), Pres::Hidden);
|
||||
// As it does while the capsule shows.
|
||||
@@ -2790,22 +2851,22 @@ mod tests {
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.input(Input::Settled, 1.0);
|
||||
flow.input(Input::Dismiss, 2.0);
|
||||
assert_eq!(flow.keys(2.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
|
||||
// So do a paste and the next capture; a rule's send never waits.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(guess()), 0.0);
|
||||
flow.click(super::super::surface::Id::Paste, 1.0);
|
||||
assert_eq!(flow.keys(1.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
flow.input(Input::Routed(guess()), 2.0);
|
||||
flow.input(Input::Dismiss, 3.0);
|
||||
flow.input(Input::Stage(Stage::Recording), 4.0);
|
||||
flow.input(Input::Stage(Stage::Done), 5.0);
|
||||
assert_eq!(flow.keys(5.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
flow.input(Input::Routed(rule()), 5.0);
|
||||
flow.tick(5.0 + hold + 1.0);
|
||||
assert_eq!(flow.pres(5.0 + hold + 1.0), Pres::Hidden);
|
||||
assert_eq!(flow.keys(5.0 + hold + 1.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
|
||||
// An answer that came after the capsule closed waits as well.
|
||||
let mut flow = Flow::new();
|
||||
@@ -2835,7 +2896,7 @@ mod tests {
|
||||
// And in the list an Undo of the rule's send reopens.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule_of_three()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 1.2);
|
||||
assert_eq!(
|
||||
flow.input(Input::Send { always: true }, 2.0),
|
||||
@@ -2867,7 +2928,7 @@ mod tests {
|
||||
// the router says it went before the take-back.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Routed(rule()), 0.0);
|
||||
flow.input(Input::Escape, 1.0);
|
||||
flow.input(Input::Undo, 1.0);
|
||||
flow.input(Input::Settled, 1.1);
|
||||
flow.input(Input::Undone(Undone::TakenBack), 1.2);
|
||||
flow.tick(9.0);
|
||||
@@ -2876,7 +2937,7 @@ mod tests {
|
||||
// A discarded recording (Escape sounds nothing), and a failure.
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Stage(Stage::Recording), 0.0);
|
||||
flow.input(Input::Escape, 0.5);
|
||||
flow.input(Input::Undo, 0.5);
|
||||
flow.click(super::super::surface::Id::Cancel, 0.8);
|
||||
assert_eq!(flow.take_cues(), [Cue::Start]);
|
||||
flow.click(super::super::surface::Id::Discard, 1.0);
|
||||
@@ -2962,7 +3023,7 @@ mod tests {
|
||||
assert!(shown.hand_off);
|
||||
// Nothing to list, so ⌥⇧V reaches the app, and a stray OpenList opens
|
||||
// nothing.
|
||||
assert_eq!(flow.keys(0.0), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
flow.input(Input::OpenList, 0.5);
|
||||
assert_eq!(done(&flow, 0.5).open, None);
|
||||
}
|
||||
@@ -2984,7 +3045,7 @@ mod tests {
|
||||
};
|
||||
let mut flow = Flow::new();
|
||||
flow.input(Input::Stage(Stage::Recording), 0.0);
|
||||
assert_eq!(flow.keys(0.5), None, "Escape stays the app's");
|
||||
assert_eq!(flow.keys(), None, "Escape stays the app's");
|
||||
assert!(flow.input(Input::Escape, 0.5).is_empty());
|
||||
assert!(matches!(flow.pres(0.5), Pres::Recording { .. }));
|
||||
assert!(flow.click(Id::Discard, 0.6).is_empty(), "not asked yet");
|
||||
@@ -2993,7 +3054,7 @@ mod tests {
|
||||
assert!(discarding(&flow, 1.0));
|
||||
assert!(flow.input(Input::Escape, 1.5).is_empty());
|
||||
assert!(discarding(&flow, 1.5));
|
||||
assert_eq!(flow.keys(1.5), None);
|
||||
assert_eq!(flow.keys(), None);
|
||||
// Nothing clicked: back to recording on its own.
|
||||
assert_eq!(flow.next_due(1.0), Some(1.0 + DISCARD_ASK_S));
|
||||
assert!(!flow.tick(1.0 + DISCARD_ASK_S - 0.1));
|
||||
@@ -3029,10 +3090,7 @@ mod tests {
|
||||
flow.input(Input::Stage(Stage::Recording), 0.0);
|
||||
flow.input(Input::Chips, 0.5);
|
||||
flow.click(Id::Mode(Mode::Window), 1.0);
|
||||
assert_eq!(
|
||||
flow.keys(1.0),
|
||||
Some(crate::capture_host::CapsuleKeys::Picker)
|
||||
);
|
||||
assert_eq!(flow.keys(), Some(crate::capture_host::CapsuleKeys::Picker));
|
||||
if close == Input::Escape {
|
||||
assert_eq!(flow.input(close, 2.0), [Action::Cancel]);
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ use self::flow::{Action, Cue, Done, Flow, Footer, Input, Lead, List, Mode, Pres}
|
||||
use self::surface::{
|
||||
CHIP_H, CHIP_PX, DONE_TEXT_X, HEADER_H, Id, KEYCAP_GAP, LEAD_TEXT_X, LIST_PAD, LIST_Y, MEDIUM,
|
||||
PANEL_H, PANEL_W, PROCESSING, PROCESSING_TEXT_X, ROW_H, SEG_ICON, SEG_ICON_GAP, SMALL, STRONG,
|
||||
Shown, Surface, TIMER, UNDO_KEYS, UNDO_LABEL, clock_width, ellipsize, keycaps_width, measure,
|
||||
Shown, Surface, TIMER, UNDO_LABEL, clock_width, ellipsize, keycaps_width, measure,
|
||||
};
|
||||
use super::controls::{Paint, keycaps};
|
||||
|
||||
@@ -533,7 +533,7 @@ fn poll(s: &mut CapsuleState, now: f64, tx: &mut Tx) -> bool {
|
||||
overlay.set_follow_pointer(follow);
|
||||
}
|
||||
}
|
||||
take_keys(s, now);
|
||||
take_keys(s);
|
||||
// The on-screen picker shows what the capsule picks.
|
||||
let picking = match s.surface.pres {
|
||||
Pres::Selecting { mode, .. } => Some(mode),
|
||||
@@ -558,8 +558,8 @@ fn poll(s: &mut CapsuleState, now: f64, tx: &mut Tx) -> bool {
|
||||
}
|
||||
|
||||
/// Takes, changes, or lets go of the keys the capsule wants from Hex's tap.
|
||||
fn take_keys(s: &mut CapsuleState, now: f64) {
|
||||
let wanted = s.flow.keys(now);
|
||||
fn take_keys(s: &mut CapsuleState) {
|
||||
let wanted = s.flow.keys();
|
||||
match (wanted, &mut s.keys) {
|
||||
(None, held) => *held = None,
|
||||
(Some(keys), Some((held, grab))) => {
|
||||
@@ -946,19 +946,7 @@ fn item(p: Paint, surface: &Surface, live: &Animated, shown: &Shown) -> El {
|
||||
.trace_name("why")
|
||||
.child(label(shown.text(), SMALL, p.faint())),
|
||||
// The quiet way out of a send that just went.
|
||||
Id::Undo => {
|
||||
let keys: Vec<String> = UNDO_KEYS.iter().map(|k| (*k).to_owned()).collect();
|
||||
base.radius(CHIP_H * 0.5)
|
||||
.gap(KEYCAP_GAP)
|
||||
.hover(c.hover)
|
||||
.press(c.pressed)
|
||||
.child(keycaps(p, "keys", &keys).w(keycaps_width(UNDO_KEYS)))
|
||||
.child(label(UNDO_LABEL, MEDIUM, p.muted()))
|
||||
.role("button")
|
||||
.label("Undo")
|
||||
.hit()
|
||||
.on_press_tx(press(id))
|
||||
}
|
||||
Id::Undo => keyed(p, base, &[], UNDO_LABEL, MEDIUM).on_press_tx(press(id)),
|
||||
// The first says what it does and carries a faint fill, as
|
||||
// Scrawl's does; the rest are names beside it.
|
||||
Id::Route(index) => {
|
||||
|
||||
@@ -169,7 +169,7 @@ fn rule_sent() -> Vec<Step> {
|
||||
]
|
||||
}
|
||||
|
||||
/// A saved rule's send, taken back at once (esc, after the inputs before
|
||||
/// A saved rule's send, taken back at once (Undo, after the inputs before
|
||||
/// it, where a click would jump the queue): the suggestions again.
|
||||
fn taken_back() -> Vec<Step> {
|
||||
let mut steps = rule_sent();
|
||||
@@ -353,8 +353,7 @@ fn poll(s: &mut CapsuleState, wall: f64, tx: &mut Tx) -> bool {
|
||||
/// The keys Hex's tap would hand the capsule, from the window instead.
|
||||
fn on_key(s: &mut CapsuleState, key: &KeyEvent, tx: &mut Tx) -> bool {
|
||||
use rune::Key;
|
||||
let now = s.now;
|
||||
let Some(keys) = s.flow.keys(now) else {
|
||||
let Some(keys) = s.flow.keys() else {
|
||||
return false;
|
||||
};
|
||||
let list = keys == crate::capture_host::CapsuleKeys::List;
|
||||
@@ -365,11 +364,7 @@ fn on_key(s: &mut CapsuleState, key: &KeyEvent, tx: &mut Tx) -> bool {
|
||||
};
|
||||
let escape = matches!(
|
||||
keys,
|
||||
crate::capture_host::CapsuleKeys::List
|
||||
| crate::capture_host::CapsuleKeys::Picker
|
||||
| crate::capture_host::CapsuleKeys::Route { escape: true }
|
||||
| crate::capture_host::CapsuleKeys::Undo
|
||||
| crate::capture_host::CapsuleKeys::Suggest { .. }
|
||||
crate::capture_host::CapsuleKeys::List | crate::capture_host::CapsuleKeys::Picker
|
||||
);
|
||||
let digit = match &key.key {
|
||||
Key::Text(t) if !key.mods.alt => {
|
||||
|
||||
@@ -64,7 +64,6 @@ pub(crate) const STRONG: TextStyle = TextStyle::new(13.0, 600.0);
|
||||
pub(crate) const TIMER: TextStyle = STRONG.features("'tnum' 1");
|
||||
pub(crate) const SMALL: TextStyle = TextStyle::new(11.5, 530.0);
|
||||
pub(crate) const PROCESSING: &str = "Processing…";
|
||||
pub(crate) const UNDO_KEYS: &[&str] = &["esc"];
|
||||
|
||||
/// The Ask chip's keycaps: the send-to list's shortcut
|
||||
/// (`capture.list_hotkey`); none while it has none.
|
||||
@@ -333,7 +332,7 @@ fn done_row(done: &Done, routes: &[String], cap: f32, raw: &mut Vec<(Id, String,
|
||||
raw.push((
|
||||
Id::Undo,
|
||||
String::new(),
|
||||
keyed_width(UNDO_KEYS, UNDO_LABEL, MEDIUM),
|
||||
keyed_width(&[], UNDO_LABEL, MEDIUM),
|
||||
false,
|
||||
));
|
||||
}
|
||||
@@ -1094,10 +1093,10 @@ mod tests {
|
||||
fn the_undo_chip_is_as_wide_as_its_label_is_drawn() {
|
||||
let (_, items) = layout(&ruled(true), "0:00");
|
||||
let undo = items.iter().find(|i| i.id == Id::Undo).unwrap();
|
||||
assert_eq!(undo.rect[2], keyed_width(UNDO_KEYS, UNDO_LABEL, MEDIUM));
|
||||
assert_eq!(undo.rect[2], keyed_width(&[], UNDO_LABEL, MEDIUM));
|
||||
assert_ne!(
|
||||
keyed_width(UNDO_KEYS, UNDO_LABEL, MEDIUM),
|
||||
keyed_width(UNDO_KEYS, UNDO_LABEL, STRONG)
|
||||
keyed_width(&[], UNDO_LABEL, MEDIUM),
|
||||
keyed_width(&[], UNDO_LABEL, STRONG)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 15 KiB |