1//! This module contains all actions supported by [`Editor`].
2use super::*;
3use util::serde::default_true;
4
5#[derive(PartialEq, Clone, Deserialize, Default)]
6pub struct SelectNext {
7 #[serde(default)]
8 pub replace_newest: bool,
9}
10
11#[derive(PartialEq, Clone, Deserialize, Default)]
12pub struct SelectPrevious {
13 #[serde(default)]
14 pub replace_newest: bool,
15}
16
17#[derive(PartialEq, Clone, Deserialize, Default)]
18pub struct MoveToBeginningOfLine {
19 #[serde(default = "default_true")]
20 pub(super) stop_at_soft_wraps: bool,
21}
22
23#[derive(PartialEq, Clone, Deserialize, Default)]
24pub struct SelectToBeginningOfLine {
25 #[serde(default)]
26 pub(super) stop_at_soft_wraps: bool,
27}
28
29#[derive(PartialEq, Clone, Deserialize, Default)]
30pub struct MovePageUp {
31 #[serde(default)]
32 pub(super) center_cursor: bool,
33}
34
35#[derive(PartialEq, Clone, Deserialize, Default)]
36pub struct MovePageDown {
37 #[serde(default)]
38 pub(super) center_cursor: bool,
39}
40
41#[derive(PartialEq, Clone, Deserialize, Default)]
42pub struct MoveToEndOfLine {
43 #[serde(default = "default_true")]
44 pub stop_at_soft_wraps: bool,
45}
46
47#[derive(PartialEq, Clone, Deserialize, Default)]
48pub struct SelectToEndOfLine {
49 #[serde(default)]
50 pub(super) stop_at_soft_wraps: bool,
51}
52
53#[derive(PartialEq, Clone, Deserialize, Default)]
54pub struct ToggleCodeActions {
55 // Display row from which the action was deployed.
56 #[serde(default)]
57 pub deployed_from_indicator: Option<DisplayRow>,
58}
59
60#[derive(PartialEq, Clone, Deserialize, Default)]
61pub struct ConfirmCompletion {
62 #[serde(default)]
63 pub item_ix: Option<usize>,
64}
65
66#[derive(PartialEq, Clone, Deserialize, Default)]
67pub struct ConfirmCodeAction {
68 #[serde(default)]
69 pub item_ix: Option<usize>,
70}
71
72#[derive(PartialEq, Clone, Deserialize, Default)]
73pub struct ToggleComments {
74 #[serde(default)]
75 pub advance_downwards: bool,
76}
77
78#[derive(PartialEq, Clone, Deserialize, Default)]
79pub struct FoldAt {
80 pub buffer_row: MultiBufferRow,
81}
82
83#[derive(PartialEq, Clone, Deserialize, Default)]
84pub struct UnfoldAt {
85 pub buffer_row: MultiBufferRow,
86}
87
88#[derive(PartialEq, Clone, Deserialize, Default)]
89pub struct MoveUpByLines {
90 #[serde(default)]
91 pub(super) lines: u32,
92}
93
94#[derive(PartialEq, Clone, Deserialize, Default)]
95pub struct MoveDownByLines {
96 #[serde(default)]
97 pub(super) lines: u32,
98}
99#[derive(PartialEq, Clone, Deserialize, Default)]
100pub struct SelectUpByLines {
101 #[serde(default)]
102 pub(super) lines: u32,
103}
104
105#[derive(PartialEq, Clone, Deserialize, Default)]
106pub struct SelectDownByLines {
107 #[serde(default)]
108 pub(super) lines: u32,
109}
110
111#[derive(PartialEq, Clone, Deserialize, Default)]
112pub struct ExpandExcerpts {
113 #[serde(default)]
114 pub(super) lines: u32,
115}
116
117#[derive(PartialEq, Clone, Deserialize, Default)]
118pub struct ExpandExcerptsUp {
119 #[serde(default)]
120 pub(super) lines: u32,
121}
122
123#[derive(PartialEq, Clone, Deserialize, Default)]
124pub struct ExpandExcerptsDown {
125 #[serde(default)]
126 pub(super) lines: u32,
127}
128
129impl_actions!(
130 editor,
131 [
132 ConfirmCodeAction,
133 ConfirmCompletion,
134 ExpandExcerpts,
135 ExpandExcerptsUp,
136 ExpandExcerptsDown,
137 FoldAt,
138 MoveDownByLines,
139 MovePageDown,
140 MovePageUp,
141 MoveToBeginningOfLine,
142 MoveToEndOfLine,
143 MoveUpByLines,
144 SelectDownByLines,
145 SelectNext,
146 SelectPrevious,
147 SelectToBeginningOfLine,
148 SelectToEndOfLine,
149 SelectUpByLines,
150 ToggleCodeActions,
151 ToggleComments,
152 UnfoldAt,
153 ]
154);
155
156gpui::actions!(
157 editor,
158 [
159 AcceptPartialCopilotSuggestion,
160 AcceptInlineCompletion,
161 AcceptPartialInlineCompletion,
162 AddSelectionAbove,
163 AddSelectionBelow,
164 Backspace,
165 Cancel,
166 ConfirmRename,
167 ContextMenuFirst,
168 ContextMenuLast,
169 ContextMenuNext,
170 ContextMenuPrev,
171 ConvertToKebabCase,
172 ConvertToLowerCamelCase,
173 ConvertToLowerCase,
174 ConvertToOppositeCase,
175 ConvertToSnakeCase,
176 ConvertToTitleCase,
177 ConvertToUpperCamelCase,
178 ConvertToUpperCase,
179 Copy,
180 CopyHighlightJson,
181 CopyPath,
182 CopyPermalinkToLine,
183 CopyRelativePath,
184 Cut,
185 CutToEndOfLine,
186 Delete,
187 DeleteLine,
188 DeleteToBeginningOfLine,
189 DeleteToEndOfLine,
190 DeleteToNextSubwordEnd,
191 DeleteToNextWordEnd,
192 DeleteToPreviousSubwordStart,
193 DeleteToPreviousWordStart,
194 DisplayCursorNames,
195 DuplicateLineDown,
196 DuplicateLineUp,
197 ExpandAllHunkDiffs,
198 ExpandMacroRecursively,
199 FindAllReferences,
200 Fold,
201 FoldSelectedRanges,
202 Format,
203 GoToDefinition,
204 GoToDefinitionSplit,
205 GoToDiagnostic,
206 GoToHunk,
207 GoToImplementation,
208 GoToImplementationSplit,
209 GoToPrevDiagnostic,
210 GoToPrevHunk,
211 GoToTypeDefinition,
212 GoToTypeDefinitionSplit,
213 HalfPageDown,
214 HalfPageUp,
215 Hover,
216 Indent,
217 JoinLines,
218 LineDown,
219 LineUp,
220 MoveDown,
221 MoveLeft,
222 MoveLineDown,
223 MoveLineUp,
224 MoveRight,
225 MoveToBeginning,
226 MoveToEnclosingBracket,
227 MoveToEnd,
228 MoveToEndOfParagraph,
229 MoveToNextSubwordEnd,
230 MoveToNextWordEnd,
231 MoveToPreviousSubwordStart,
232 MoveToPreviousWordStart,
233 MoveToStartOfParagraph,
234 MoveUp,
235 Newline,
236 NewlineAbove,
237 NewlineBelow,
238 NextInlineCompletion,
239 NextScreen,
240 OpenExcerpts,
241 OpenExcerptsSplit,
242 OpenPermalinkToLine,
243 OpenUrl,
244 Outdent,
245 PageDown,
246 PageUp,
247 Paste,
248 PreviousInlineCompletion,
249 Redo,
250 RedoSelection,
251 Rename,
252 RestartLanguageServer,
253 RevealInFinder,
254 ReverseLines,
255 RevertSelectedHunks,
256 ScrollCursorBottom,
257 ScrollCursorCenter,
258 ScrollCursorTop,
259 SelectAll,
260 SelectAllMatches,
261 SelectDown,
262 SelectLargerSyntaxNode,
263 SelectLeft,
264 SelectLine,
265 SelectRight,
266 SelectSmallerSyntaxNode,
267 SelectToBeginning,
268 SelectToEnd,
269 SelectToEndOfParagraph,
270 SelectToNextSubwordEnd,
271 SelectToNextWordEnd,
272 SelectToPreviousSubwordStart,
273 SelectToPreviousWordStart,
274 SelectToStartOfParagraph,
275 SelectUp,
276 ShowCharacterPalette,
277 ShowCompletions,
278 ShowInlineCompletion,
279 ShuffleLines,
280 SortLinesCaseInsensitive,
281 SortLinesCaseSensitive,
282 SplitSelectionIntoLines,
283 Tab,
284 TabPrev,
285 ToggleGitBlame,
286 ToggleGitBlameInline,
287 ToggleHunkDiff,
288 ToggleInlayHints,
289 ToggleLineNumbers,
290 ToggleIndentGuides,
291 ToggleSoftWrap,
292 ToggleTabBar,
293 Transpose,
294 Undo,
295 UndoSelection,
296 UnfoldLines,
297 UniqueLinesCaseInsensitive,
298 UniqueLinesCaseSensitive,
299 ]
300);