1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! **The box a menu item sends the operator to** (bl-dbc9): which of the
//! composer's two parameter boxes wants filling, and the one door that names a
//! conversation and asks for it.
//!
//! # Why a menu item ever needs this
//!
//! `crate::ui::convs::menu` fires the acts on a conversation row that take the
//! workspace and the conversation and nothing else. Two of the acts on that row take
//! a **third** parameter — `flag`'s reason and `delete-agent`'s arming — and
//! each has a box of its own on the composer's second row
//! (`crate::ui::composer::acts`). A menu cannot hold that box: the composer is
//! a bottom panel that stands down off the conversation's own column in the
//! narrow shape (`crate::ui::shell`), so a box in a list row's menu would be a
//! parameter reachable at one width and not the other, and firing without one
//! would be an act composed from a control that never asked for it.
//!
//! So the menu item is a **navigation**: it names the conversation, goes to
//! where the box is, and puts the cursor in it. It crosses no wire and carries
//! no `act:` token, which is `Model::go_to`'s division exactly (§4.16: an aim,
//! a selection and a focus are views, and views are out of the parity
//! contract).
//!
//! # It is taken once, by the frame that paints the box
//!
//! [`Model::filling`] is `Model::revealing`'s shape one noun over: the field is
//! set by the surface that asked and **taken** by the surface that answers, so
//! a request cannot fight the next frame's focus. Taking it in one read rather
//! than one per box is what keeps a frame that paints the row from leaving half
//! a request standing.
//!
//! In the broad shape the composer paints later in the same frame as the list,
//! so the cursor lands on the keypress. In the narrow shape the list is the
//! central panel and the composer is already behind it, so it lands on the next
//! frame — which is the reason this is a field at all rather than a call.
use super::Model;
/// **Which box on the composer wants the cursor.**
///
/// Two of them are the acts on a conversation whose extra parameter has a box
/// of its OWN. `message` and `interrupt` share the composer's one draft, so
/// pointing at it would name neither — which is why neither is on the row's
/// menu (`crate::ui::convs::menu`).
///
/// **The third is the draft itself, in the composer's other mode** (DESIGN
/// §4.39, bl-b9a3): the `+` on a server's row lands the caret in the box that
/// begins a conversation, which is the same navigation the menu items are and
/// wanted no second field to say so.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Fill {
/// The words a flag is raised with (`crate::ui::composer::acts::WHY`).
Reason,
/// The name that admits a conversation's descendants into its deletion
/// (`crate::ui::composer::acts::ARM`).
Arming,
/// What a conversation is begun FOR
/// (`crate::ui::composer::start::goal`), asked for by a workspace's `+ new`
/// (`crate::ui::model::Model::begin_at`).
Goal,
}
impl Fill {
/// **The verb a fill types into the box**, where it types one: the flag's
/// and the deletion's words; the goal types nothing, the box is the goal.
pub fn typed(self) -> Option<&'static str> {
match self {
Fill::Reason => Some(crate::verbs::FLAG.word),
Fill::Arming => Some(crate::ui::slash::DELETE),
Fill::Goal => None,
}
}
}
impl Model {
/// **Go to the box that fills an act on `root_id`.**
///
/// Three doors and no fourth: the selection, because the composer acts on
/// the selected conversation and a box filled against another row would
/// compose a gesture about something else; the column, because in the
/// narrow shape the composer is on the conversation's own column and
/// nowhere else; and the request itself.
///
/// It unmakes nothing and asks for nothing. That is the whole of the row
/// menu's answer to DESIGN §4.20 — *a routine surface is one an operator
/// moves through quickly, and a mis-aimed click there must not be able to
/// land on a destruction* — read on a control rather than on a pane.
pub fn fill_in(&mut self, root_id: &str, fill: Fill) {
self.select(root_id);
// **Going to the box is a choosing** (`crate::ui::switcher`): the
// row menu lives in the switcher, and the box is under it.
self.chose();
// **The two verbs are typed, not boxed** (DESIGN §4.42): the menu item
// puts the verb in the box with the caret after it, and what the
// operator types next is the reason or the name — the one box, with
// the words a verb takes on its line.
self.draft = fill
.typed()
.map_or_else(String::new, |word| format!("/{word} "));
self.fill = Some(fill);
}
/// **Which box this frame owes the cursor**, answered once.
///
/// Taken rather than read, for [`Model::revealing`]'s reason: a request
/// that survived the frame that answered it would drag the focus back every
/// time the operator moved it.
pub fn filling(&mut self) -> Option<Fill> {
self.fill.take()
}
}
#[cfg(test)]
mod tests;