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
//! # Application Customization
//!
//! ## Overview
//!
//! This module contains traits that library consumers can use for extending modalkit to better fit
//! their own needs.
//!
//! ## Example
//!
//! ```
//! use std::fmt;
//! use std::path::PathBuf;
//!
//! use editor_types::{
//! application::{
//! ApplicationAction,
//! ApplicationError,
//! ApplicationWindowId,
//! ApplicationContentId,
//! ApplicationInfo,
//! ApplicationStore,
//! },
//! context::EditContext,
//! prelude::*,
//! };
//! use keybindings::SequenceStatus;
//!
//! // Unique identifier for a review.
//! #[derive(Clone, Debug, Eq, Hash, PartialEq)]
//! struct ReviewId(usize);
//!
//! // Unique identifier for a user.
//! #[derive(Clone, Debug, Eq, Hash, PartialEq)]
//! struct UserId(usize);
//!
//! #[derive(Clone, Debug, Eq, PartialEq)]
//! enum CodeReviewAction {
//! // Approve a review for merging.
//! Approve(ReviewId),
//!
//! // Leave a comment on a line in a file in a review.
//! Comment(ReviewId, PathBuf, usize, String),
//!
//! // Show more lines around the hunk.
//! ExpandHunk(Count),
//!
//! // Merge changes after review and approval.
//! Merge(ReviewId),
//! }
//!
//! impl ApplicationAction for CodeReviewAction {
//! fn is_edit_sequence(&self, _: &EditContext) -> SequenceStatus {
//! match self {
//! CodeReviewAction::Approve(..) => SequenceStatus::Break,
//! CodeReviewAction::Comment(..) => SequenceStatus::Break,
//! CodeReviewAction::ExpandHunk(..) => SequenceStatus::Atom,
//! CodeReviewAction::Merge(..) => SequenceStatus::Break,
//! }
//! }
//!
//! fn is_last_action(&self, _: &EditContext) -> SequenceStatus {
//! match self {
//! CodeReviewAction::Approve(..) => SequenceStatus::Atom,
//! CodeReviewAction::Comment(..) => SequenceStatus::Atom,
//! CodeReviewAction::ExpandHunk(..) => SequenceStatus::Atom,
//! CodeReviewAction::Merge(..) => SequenceStatus::Atom,
//! }
//! }
//!
//! fn is_last_selection(&self, _: &EditContext) -> SequenceStatus {
//! match self {
//! CodeReviewAction::Approve(..) => SequenceStatus::Ignore,
//! CodeReviewAction::Comment(..) => SequenceStatus::Ignore,
//! CodeReviewAction::ExpandHunk(..) => SequenceStatus::Ignore,
//! CodeReviewAction::Merge(..) => SequenceStatus::Ignore,
//! }
//! }
//!
//! fn is_switchable(&self, _: &EditContext) -> bool {
//! match self {
//! CodeReviewAction::Approve(..) => false,
//! CodeReviewAction::Comment(..) => false,
//! CodeReviewAction::ExpandHunk(..) => false,
//! CodeReviewAction::Merge(..) => false,
//! }
//! }
//! }
//!
//! struct CodeReviewStore {
//! user: UserId,
//! }
//!
//! impl ApplicationStore for CodeReviewStore {}
//!
//! #[derive(Clone, Debug, Eq, Hash, PartialEq)]
//! enum CodeReviewWindowId {
//! // A window that shows a code review.
//! Review(ReviewId),
//!
//! // A window that shows a user's open reviews.
//! User(UserId),
//! }
//!
//! impl ApplicationWindowId for CodeReviewWindowId {}
//!
//! #[derive(Clone, Debug, Eq, Hash, PartialEq)]
//! enum CodeReviewContentId {
//! // Different buffer used by the command bar.
//! Command(CommandType),
//!
//! // Buffer for a comment left on a line.
//! Review(ReviewId, usize),
//! }
//!
//! impl ApplicationContentId for CodeReviewContentId {}
//!
//! #[derive(Debug)]
//! enum CodeReviewError {
//! NoReview(ReviewId),
//! }
//!
//! impl fmt::Display for CodeReviewError {
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//! match self {
//! CodeReviewError::NoReview(id) => write!(f, "No review with ID {:?}", id),
//! }
//! }
//! }
//!
//! impl ApplicationError for CodeReviewError {}
//!
//! #[derive(Clone, Debug, Eq, PartialEq)]
//! enum CodeReviewInfo {}
//!
//! impl ApplicationInfo for CodeReviewInfo {
//! type Error = CodeReviewError;
//! type Action = CodeReviewAction;
//! type Store = CodeReviewStore;
//! type WindowId = CodeReviewWindowId;
//! type ContentId = CodeReviewContentId;
//!
//! fn content_of_command(ct: CommandType) -> CodeReviewContentId {
//! CodeReviewContentId::Command(ct)
//! }
//! }
//! ```
use ;
use Hash;
use crateEditContext;
use crateCommandType;
use SequenceStatus;
/// Trait for objects that describe application-specific actions.
///
/// Implementors of this trait can be used with [Action::Application]. This can then be used to
/// create additional keybindings and commands on top of the more editing-specific ones provided
/// by this crate.
///
/// [Action::Application]: crate::Action::Application
/// Trait for application-specific errors.
/// Trait for objects that hold application-specific information.
/// Trait for window identifiers in an application.
/// Trait for identifiers of specific content within a window in an application.
/// Trait for objects that describe application-specific behaviour and types.
/// A default implementor of [ApplicationInfo] for consumers that don't require any customization.