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