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