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 ConfirmCodeAction,
160 ConfirmCompletion,
161 ComposeCompletion,
162 DeleteToNextWordEnd,
163 DeleteToPreviousWordStart,
164 ExpandExcerpts,
165 ExpandExcerptsUp,
166 ExpandExcerptsDown,
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 AcceptPartialCopilotSuggestion,
192 AcceptInlineCompletion,
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 CopyHighlightJson,
214 CopyPath,
215 CopyPermalinkToLine,
216 CopyFileLocation,
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 GoToDefinition,
236 GoToDefinitionSplit,
237 GoToDeclaration,
238 GoToDeclarationSplit,
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 OpenPermalinkToLine,
277 OpenUrl,
278 OpenFile,
279 Outdent,
280 PageDown,
281 PageUp,
282 Paste,
283 PreviousInlineCompletion,
284 Redo,
285 RedoSelection,
286 Rename,
287 RestartLanguageServer,
288 RevealInFileManager,
289 ReverseLines,
290 RevertFile,
291 RevertSelectedHunks,
292 ScrollCursorBottom,
293 ScrollCursorCenter,
294 ScrollCursorTop,
295 ScrollCursorCenterTopBottom,
296 SelectAll,
297 SelectAllMatches,
298 SelectDown,
299 SelectLargerSyntaxNode,
300 SelectEnclosingSymbol,
301 SelectLeft,
302 SelectLine,
303 SelectRight,
304 SelectSmallerSyntaxNode,
305 SelectToBeginning,
306 SelectToEnd,
307 SelectToEndOfParagraph,
308 SelectToNextSubwordEnd,
309 SelectToNextWordEnd,
310 SelectToPreviousSubwordStart,
311 SelectToPreviousWordStart,
312 SelectToStartOfParagraph,
313 SelectUp,
314 SelectPageDown,
315 SelectPageUp,
316 ShowCharacterPalette,
317 ShowInlineCompletion,
318 ShowSignatureHelp,
319 ShuffleLines,
320 SortLinesCaseInsensitive,
321 SortLinesCaseSensitive,
322 SplitSelectionIntoLines,
323 SwitchSourceHeader,
324 Tab,
325 TabPrev,
326 ToggleAutoSignatureHelp,
327 ToggleGitBlame,
328 ToggleGitBlameInline,
329 ToggleSelectionMenu,
330 ToggleHunkDiff,
331 ToggleInlayHints,
332 ToggleInlineCompletions,
333 ToggleLineNumbers,
334 ToggleRelativeLineNumbers,
335 ToggleIndentGuides,
336 ToggleSoftWrap,
337 ToggleTabBar,
338 Transpose,
339 Undo,
340 UndoSelection,
341 UnfoldLines,
342 UniqueLinesCaseInsensitive,
343 UniqueLinesCaseSensitive,
344 ]
345);
346
347action_as!(outline, ToggleOutline as Toggle);
348
349action_as!(go_to_line, ToggleGoToLine as Toggle);