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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//! What the application calls its actions and its failures.
//!
//! **Two words, and they are not the same thing.** An *action* is what the application decides to
//! do about an event; a *failure* is what the application reports when it cannot carry on. The two
//! are kept apart because the rule the whole application rests on is that an event becomes a reply
//! and the action the reply carries is the only thing that changes the session — and a failure ends
//! the loop instead of becoming one.
//!
//! **An action need not change anything.** `Action::Command` performs a mutation where one is
//! valid and owes a paint either way; `Action::Undo` and `Action::Redo` walk the session's
//! history and owe a paint whether or not there is a step to give back; and `Action::About` and
//! `Action::ShowError` open the chrome's dialog. **The way out is not an action**: nothing about
//! the state changes, so there is nothing to carry out, and it is [`Reply::Quit`], which says
//! whether it is the forced one.
//!
//! **A handler says an action rather than doing one**, so that an entry of the menu and the key
//! that means the same thing are decided in one place. A handler answers with a [`Reply`], which
//! keeps "not mine" apart from "mine, and nothing changed": only [`Reply::Ignored`] lets the next
//! handler be asked.
//!
//! The event itself is not here: it is what the loop polls, and it lives in `crate::event`
//! beside the two translations into it.
/// What the application reports when it cannot carry on.
pub type AppError = ;
/// What the application does about an event.
///
/// **Every action is a meaning the state must show.** `Delete` takes a shape out, `Undo` and
/// `Redo` give a step back, `Move` displaces what is selected, and `About` and `ShowError` open the
/// chrome's dialog. **Ending the application is not one of them**: it changes no state, so there is
/// nothing to carry out, and it is an answer of the [`Reply`]'s own instead.
///
/// **A meaning that is carried out leaves the keyboard on the region** (rule 13 of #189), and the
/// drop-down the bar was showing closes with it. **So a meaning does not say where the keyboard is
/// left** — `callbacks::apply` says it once — which is why this is a table of meanings and not a
/// table of leaves.
///
/// **No action names a leaf** (D1 of #189): the keyboard moves where the event is addressed — a
/// press by its position, the bar's own three keys inside [`crate::menu::handle`] — so there is no
/// action for reaching the bar and none for leaving it.
///
/// **A change of the screen is not a meaning of a person's, and undo will never hold one.** It is
/// what [`Reply::Repaint`] says instead; see _The action model_ in
/// [`docs/application-model.md`](../../../docs/application-model.md).
///
/// **It is not `Copy`**: a meaning may carry what a person is told, and that text is owned.
pub
/// What a handler says about an event.
///
/// **The five answers are the protocol.** `Ignored` lets the next handler be asked; the other four
/// stop the chain. `Consumed` is the event taken with no frame owed, `Repaint` is the event taken
/// with one, `Act` carries a meaning for `callbacks::apply` to carry out, and `Quit` ends the loop:
/// nothing about the state changes, so there is nothing to apply and no frame to owe.
///
/// **"Not mine" and "mine, and nothing changed" are different answers**, which is what the
/// protocol this replaced could not say: `None` meant both, so a handler that had consumed an
/// event left the next one to answer it as well. **A change of the screen is not a meaning of a
/// person's**, so it is `Repaint` rather than a variant of [`Action`].
///
/// **It travels by value but is not `Copy`**: an answer can carry an [`Action`] that owns text, so
/// [`and_repaint`](Self::and_repaint) and [`or_else`](Self::or_else) take it and give it back
/// rather than borrowing it, and a caller that keeps one clones it.
pub