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 Backspace,
197 Cancel,
198 CancelLanguageServerWork,
199 ConfirmRename,
200 ContextMenuFirst,
201 ContextMenuLast,
202 ContextMenuNext,
203 ContextMenuPrev,
204 ConvertToKebabCase,
205 ConvertToLowerCamelCase,
206 ConvertToLowerCase,
207 ConvertToOppositeCase,
208 ConvertToSnakeCase,
209 ConvertToTitleCase,
210 ConvertToUpperCamelCase,
211 ConvertToUpperCase,
212 Copy,
213 CopyFileLocation,
214 CopyHighlightJson,
215 CopyPath,
216 CopyPermalinkToLine,
217 CopyRelativePath,
218 Cut,
219 CutToEndOfLine,
220 Delete,
221 DeleteLine,
222 DeleteToBeginningOfLine,
223 DeleteToEndOfLine,
224 DeleteToNextSubwordEnd,
225 DeleteToPreviousSubwordStart,
226 DisplayCursorNames,
227 DuplicateLineDown,
228 DuplicateLineUp,
229 ExpandAllHunkDiffs,
230 ExpandMacroRecursively,
231 FindAllReferences,
232 Fold,
233 FoldSelectedRanges,
234 Format,
235 GoToDeclaration,
236 GoToDeclarationSplit,
237 GoToDefinition,
238 GoToDefinitionSplit,
239 GoToDiagnostic,
240 GoToHunk,
241 GoToImplementation,
242 GoToImplementationSplit,
243 GoToPrevDiagnostic,
244 GoToPrevHunk,
245 GoToTypeDefinition,
246 GoToTypeDefinitionSplit,
247 HalfPageDown,
248 HalfPageUp,
249 Hover,
250 Indent,
251 JoinLines,
252 LineDown,
253 LineUp,
254 MoveDown,
255 MoveLeft,
256 MoveLineDown,
257 MoveLineUp,
258 MoveRight,
259 MoveToBeginning,
260 MoveToEnclosingBracket,
261 MoveToEnd,
262 MoveToEndOfParagraph,
263 MoveToNextSubwordEnd,
264 MoveToNextWordEnd,
265 MoveToPreviousSubwordStart,
266 MoveToPreviousWordStart,
267 MoveToStartOfParagraph,
268 MoveUp,
269 Newline,
270 NewlineAbove,
271 NewlineBelow,
272 NextInlineCompletion,
273 NextScreen,
274 OpenExcerpts,
275 OpenExcerptsSplit,
276 OpenProposedChangesEditor,
277 OpenFile,
278 OpenPermalinkToLine,
279 OpenUrl,
280 Outdent,
281 PageDown,
282 PageUp,
283 Paste,
284 PreviousInlineCompletion,
285 Redo,
286 RedoSelection,
287 Rename,
288 RestartLanguageServer,
289 RevealInFileManager,
290 ReverseLines,
291 RevertFile,
292 RevertSelectedHunks,
293 Rewrap,
294 ScrollCursorBottom,
295 ScrollCursorCenter,
296 ScrollCursorCenterTopBottom,
297 ScrollCursorTop,
298 SelectAll,
299 SelectAllMatches,
300 SelectDown,
301 SelectEnclosingSymbol,
302 SelectLargerSyntaxNode,
303 SelectLeft,
304 SelectLine,
305 SelectPageDown,
306 SelectPageUp,
307 SelectRight,
308 SelectSmallerSyntaxNode,
309 SelectToBeginning,
310 SelectToEnd,
311 SelectToEndOfParagraph,
312 SelectToNextSubwordEnd,
313 SelectToNextWordEnd,
314 SelectToPreviousSubwordStart,
315 SelectToPreviousWordStart,
316 SelectToStartOfParagraph,
317 SelectUp,
318 ShowCharacterPalette,
319 ShowInlineCompletion,
320 ShowSignatureHelp,
321 ShuffleLines,
322 SortLinesCaseInsensitive,
323 SortLinesCaseSensitive,
324 SplitSelectionIntoLines,
325 SwitchSourceHeader,
326 Tab,
327 TabPrev,
328 ToggleAutoSignatureHelp,
329 ToggleGitBlame,
330 ToggleGitBlameInline,
331 ToggleHunkDiff,
332 ToggleIndentGuides,
333 ToggleInlayHints,
334 ToggleInlineCompletions,
335 ToggleLineNumbers,
336 ToggleRelativeLineNumbers,
337 ToggleSelectionMenu,
338 ToggleSoftWrap,
339 ToggleTabBar,
340 Transpose,
341 Undo,
342 UndoSelection,
343 UnfoldLines,
344 UniqueLinesCaseInsensitive,
345 UniqueLinesCaseSensitive,
346 ]
347);
348
349action_as!(outline, ToggleOutline as Toggle);
350
351action_as!(go_to_line, ToggleGoToLine as Toggle);