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 ConfirmCodeAction {
69 #[serde(default)]
70 pub item_ix: Option<usize>,
71}
72
73#[derive(PartialEq, Clone, Deserialize, Default)]
74pub struct ToggleComments {
75 #[serde(default)]
76 pub advance_downwards: bool,
77}
78
79#[derive(PartialEq, Clone, Deserialize, Default)]
80pub struct FoldAt {
81 pub buffer_row: MultiBufferRow,
82}
83
84#[derive(PartialEq, Clone, Deserialize, Default)]
85pub struct UnfoldAt {
86 pub buffer_row: MultiBufferRow,
87}
88
89#[derive(PartialEq, Clone, Deserialize, Default)]
90pub struct MoveUpByLines {
91 #[serde(default)]
92 pub(super) lines: u32,
93}
94
95#[derive(PartialEq, Clone, Deserialize, Default)]
96pub struct MoveDownByLines {
97 #[serde(default)]
98 pub(super) lines: u32,
99}
100#[derive(PartialEq, Clone, Deserialize, Default)]
101pub struct SelectUpByLines {
102 #[serde(default)]
103 pub(super) lines: u32,
104}
105
106#[derive(PartialEq, Clone, Deserialize, Default)]
107pub struct SelectDownByLines {
108 #[serde(default)]
109 pub(super) lines: u32,
110}
111
112#[derive(PartialEq, Clone, Deserialize, Default)]
113pub struct ExpandExcerpts {
114 #[serde(default)]
115 pub(super) lines: u32,
116}
117
118#[derive(PartialEq, Clone, Deserialize, Default)]
119pub struct ExpandExcerptsUp {
120 #[serde(default)]
121 pub(super) lines: u32,
122}
123
124#[derive(PartialEq, Clone, Deserialize, Default)]
125pub struct ExpandExcerptsDown {
126 #[serde(default)]
127 pub(super) lines: u32,
128}
129#[derive(PartialEq, Clone, Deserialize, Default)]
130pub struct ShowCompletions {
131 #[serde(default)]
132 pub(super) trigger: Option<String>,
133}
134
135impl_actions!(
136 editor,
137 [
138 ConfirmCodeAction,
139 ConfirmCompletion,
140 ExpandExcerpts,
141 ExpandExcerptsUp,
142 ExpandExcerptsDown,
143 FoldAt,
144 MoveDownByLines,
145 MovePageDown,
146 MovePageUp,
147 MoveToBeginningOfLine,
148 MoveToEndOfLine,
149 MoveUpByLines,
150 SelectDownByLines,
151 SelectNext,
152 SelectPrevious,
153 SelectToBeginningOfLine,
154 SelectToEndOfLine,
155 SelectUpByLines,
156 ShowCompletions,
157 ToggleCodeActions,
158 ToggleComments,
159 UnfoldAt,
160 ]
161);
162
163gpui::actions!(
164 editor,
165 [
166 AcceptPartialCopilotSuggestion,
167 AcceptInlineCompletion,
168 AcceptPartialInlineCompletion,
169 AddSelectionAbove,
170 AddSelectionBelow,
171 Backspace,
172 Cancel,
173 CancelLanguageServerWork,
174 ConfirmRename,
175 ContextMenuFirst,
176 ContextMenuLast,
177 ContextMenuNext,
178 ContextMenuPrev,
179 ConvertToKebabCase,
180 ConvertToLowerCamelCase,
181 ConvertToLowerCase,
182 ConvertToOppositeCase,
183 ConvertToSnakeCase,
184 ConvertToTitleCase,
185 ConvertToUpperCamelCase,
186 ConvertToUpperCase,
187 Copy,
188 CopyHighlightJson,
189 CopyPath,
190 CopyPermalinkToLine,
191 CopyRelativePath,
192 Cut,
193 CutToEndOfLine,
194 Delete,
195 DeleteLine,
196 DeleteToBeginningOfLine,
197 DeleteToEndOfLine,
198 DeleteToNextSubwordEnd,
199 DeleteToNextWordEnd,
200 DeleteToPreviousSubwordStart,
201 DeleteToPreviousWordStart,
202 DisplayCursorNames,
203 DuplicateLineDown,
204 DuplicateLineUp,
205 ExpandAllHunkDiffs,
206 ExpandMacroRecursively,
207 FindAllReferences,
208 Fold,
209 FoldSelectedRanges,
210 Format,
211 GoToDefinition,
212 GoToDefinitionSplit,
213 GoToDeclaration,
214 GoToDeclarationSplit,
215 GoToDiagnostic,
216 GoToHunk,
217 GoToImplementation,
218 GoToImplementationSplit,
219 GoToPrevDiagnostic,
220 GoToPrevHunk,
221 GoToTypeDefinition,
222 GoToTypeDefinitionSplit,
223 HalfPageDown,
224 HalfPageUp,
225 Hover,
226 Indent,
227 JoinLines,
228 LineDown,
229 LineUp,
230 MoveDown,
231 MoveLeft,
232 MoveLineDown,
233 MoveLineUp,
234 MoveRight,
235 MoveToBeginning,
236 MoveToEnclosingBracket,
237 MoveToEnd,
238 MoveToEndOfParagraph,
239 MoveToNextSubwordEnd,
240 MoveToNextWordEnd,
241 MoveToPreviousSubwordStart,
242 MoveToPreviousWordStart,
243 MoveToStartOfParagraph,
244 MoveUp,
245 Newline,
246 NewlineAbove,
247 NewlineBelow,
248 NextInlineCompletion,
249 NextScreen,
250 OpenExcerpts,
251 OpenExcerptsSplit,
252 OpenPermalinkToLine,
253 OpenUrl,
254 Outdent,
255 PageDown,
256 PageUp,
257 Paste,
258 PreviousInlineCompletion,
259 Redo,
260 RedoSelection,
261 Rename,
262 RestartLanguageServer,
263 RevealInFileManager,
264 ReverseLines,
265 RevertSelectedHunks,
266 ScrollCursorBottom,
267 ScrollCursorCenter,
268 ScrollCursorTop,
269 SelectAll,
270 SelectAllMatches,
271 SelectDown,
272 SelectLargerSyntaxNode,
273 SelectEnclosingSymbol,
274 SelectLeft,
275 SelectLine,
276 SelectRight,
277 SelectSmallerSyntaxNode,
278 SelectToBeginning,
279 SelectToEnd,
280 SelectToEndOfParagraph,
281 SelectToNextSubwordEnd,
282 SelectToNextWordEnd,
283 SelectToPreviousSubwordStart,
284 SelectToPreviousWordStart,
285 SelectToStartOfParagraph,
286 SelectUp,
287 SelectPageDown,
288 SelectPageUp,
289 ShowCharacterPalette,
290 ShowInlineCompletion,
291 ShowSignatureHelp,
292 ShuffleLines,
293 SortLinesCaseInsensitive,
294 SortLinesCaseSensitive,
295 SplitSelectionIntoLines,
296 Tab,
297 TabPrev,
298 ToggleAutoSignatureHelp,
299 ToggleGitBlame,
300 ToggleGitBlameInline,
301 ToggleSelectionMenu,
302 ToggleHunkDiff,
303 ToggleInlayHints,
304 ToggleLineNumbers,
305 ToggleIndentGuides,
306 ToggleSoftWrap,
307 ToggleTabBar,
308 Transpose,
309 Undo,
310 UndoSelection,
311 UnfoldLines,
312 UniqueLinesCaseInsensitive,
313 UniqueLinesCaseSensitive,
314 ]
315);
316
317action_as!(outline, ToggleOutline as Toggle);
318
319action_as!(go_to_line, ToggleGoToLine as Toggle);