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
144impl_actions!(
145 editor,
146 [
147 ConfirmCodeAction,
148 ConfirmCompletion,
149 ComposeCompletion,
150 ExpandExcerpts,
151 ExpandExcerptsUp,
152 ExpandExcerptsDown,
153 FoldAt,
154 HandleInput,
155 MoveDownByLines,
156 MovePageDown,
157 MovePageUp,
158 MoveToBeginningOfLine,
159 MoveToEndOfLine,
160 MoveUpByLines,
161 SelectDownByLines,
162 SelectNext,
163 SelectPrevious,
164 SelectToBeginningOfLine,
165 SelectToEndOfLine,
166 SelectUpByLines,
167 ShowCompletions,
168 ToggleCodeActions,
169 ToggleComments,
170 UnfoldAt,
171 ]
172);
173
174gpui::actions!(
175 editor,
176 [
177 AcceptPartialCopilotSuggestion,
178 AcceptInlineCompletion,
179 AcceptPartialInlineCompletion,
180 AddSelectionAbove,
181 AddSelectionBelow,
182 Backspace,
183 Cancel,
184 CancelLanguageServerWork,
185 ConfirmRename,
186 ContextMenuFirst,
187 ContextMenuLast,
188 ContextMenuNext,
189 ContextMenuPrev,
190 ConvertToKebabCase,
191 ConvertToLowerCamelCase,
192 ConvertToLowerCase,
193 ConvertToOppositeCase,
194 ConvertToSnakeCase,
195 ConvertToTitleCase,
196 ConvertToUpperCamelCase,
197 ConvertToUpperCase,
198 Copy,
199 CopyHighlightJson,
200 CopyPath,
201 CopyPermalinkToLine,
202 CopyRelativePath,
203 Cut,
204 CutToEndOfLine,
205 Delete,
206 DeleteLine,
207 DeleteToBeginningOfLine,
208 DeleteToEndOfLine,
209 DeleteToNextSubwordEnd,
210 DeleteToNextWordEnd,
211 DeleteToPreviousSubwordStart,
212 DeleteToPreviousWordStart,
213 DisplayCursorNames,
214 DuplicateLineDown,
215 DuplicateLineUp,
216 ExpandAllHunkDiffs,
217 ExpandMacroRecursively,
218 FindAllReferences,
219 Fold,
220 FoldSelectedRanges,
221 Format,
222 GoToDefinition,
223 GoToDefinitionSplit,
224 GoToDeclaration,
225 GoToDeclarationSplit,
226 GoToDiagnostic,
227 GoToHunk,
228 GoToImplementation,
229 GoToImplementationSplit,
230 GoToPrevDiagnostic,
231 GoToPrevHunk,
232 GoToTypeDefinition,
233 GoToTypeDefinitionSplit,
234 HalfPageDown,
235 HalfPageUp,
236 Hover,
237 Indent,
238 JoinLines,
239 LineDown,
240 LineUp,
241 MoveDown,
242 MoveLeft,
243 MoveLineDown,
244 MoveLineUp,
245 MoveRight,
246 MoveToBeginning,
247 MoveToEnclosingBracket,
248 MoveToEnd,
249 MoveToEndOfParagraph,
250 MoveToNextSubwordEnd,
251 MoveToNextWordEnd,
252 MoveToPreviousSubwordStart,
253 MoveToPreviousWordStart,
254 MoveToStartOfParagraph,
255 MoveUp,
256 Newline,
257 NewlineAbove,
258 NewlineBelow,
259 NextInlineCompletion,
260 NextScreen,
261 OpenExcerpts,
262 OpenExcerptsSplit,
263 OpenPermalinkToLine,
264 OpenUrl,
265 OpenFile,
266 Outdent,
267 PageDown,
268 PageUp,
269 Paste,
270 PreviousInlineCompletion,
271 Redo,
272 RedoSelection,
273 Rename,
274 RestartLanguageServer,
275 RevealInFileManager,
276 ReverseLines,
277 RevertFile,
278 RevertSelectedHunks,
279 ScrollCursorBottom,
280 ScrollCursorCenter,
281 ScrollCursorTop,
282 ScrollCursorCenterTopBottom,
283 SelectAll,
284 SelectAllMatches,
285 SelectDown,
286 SelectLargerSyntaxNode,
287 SelectEnclosingSymbol,
288 SelectLeft,
289 SelectLine,
290 SelectRight,
291 SelectSmallerSyntaxNode,
292 SelectToBeginning,
293 SelectToEnd,
294 SelectToEndOfParagraph,
295 SelectToNextSubwordEnd,
296 SelectToNextWordEnd,
297 SelectToPreviousSubwordStart,
298 SelectToPreviousWordStart,
299 SelectToStartOfParagraph,
300 SelectUp,
301 SelectPageDown,
302 SelectPageUp,
303 ShowCharacterPalette,
304 ShowInlineCompletion,
305 ShowSignatureHelp,
306 ShuffleLines,
307 SortLinesCaseInsensitive,
308 SortLinesCaseSensitive,
309 SplitSelectionIntoLines,
310 SwitchSourceHeader,
311 Tab,
312 TabPrev,
313 ToggleAutoSignatureHelp,
314 ToggleGitBlame,
315 ToggleGitBlameInline,
316 ToggleSelectionMenu,
317 ToggleHunkDiff,
318 ToggleInlayHints,
319 ToggleLineNumbers,
320 ToggleIndentGuides,
321 ToggleSoftWrap,
322 ToggleTabBar,
323 Transpose,
324 Undo,
325 UndoSelection,
326 UnfoldLines,
327 UniqueLinesCaseInsensitive,
328 UniqueLinesCaseSensitive,
329 ]
330);
331
332action_as!(outline, ToggleOutline as Toggle);
333
334action_as!(go_to_line, ToggleGoToLine as Toggle);