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