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