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<char>,
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 GoToDiagnostic,
214 GoToHunk,
215 GoToImplementation,
216 GoToImplementationSplit,
217 GoToPrevDiagnostic,
218 GoToPrevHunk,
219 GoToTypeDefinition,
220 GoToTypeDefinitionSplit,
221 HalfPageDown,
222 HalfPageUp,
223 Hover,
224 Indent,
225 JoinLines,
226 LineDown,
227 LineUp,
228 MoveDown,
229 MoveLeft,
230 MoveLineDown,
231 MoveLineUp,
232 MoveRight,
233 MoveToBeginning,
234 MoveToEnclosingBracket,
235 MoveToEnd,
236 MoveToEndOfParagraph,
237 MoveToNextSubwordEnd,
238 MoveToNextWordEnd,
239 MoveToPreviousSubwordStart,
240 MoveToPreviousWordStart,
241 MoveToStartOfParagraph,
242 MoveUp,
243 Newline,
244 NewlineAbove,
245 NewlineBelow,
246 NextInlineCompletion,
247 NextScreen,
248 OpenExcerpts,
249 OpenExcerptsSplit,
250 OpenPermalinkToLine,
251 OpenUrl,
252 Outdent,
253 PageDown,
254 PageUp,
255 Paste,
256 PreviousInlineCompletion,
257 Redo,
258 RedoSelection,
259 Rename,
260 RestartLanguageServer,
261 RevealInFinder,
262 ReverseLines,
263 RevertSelectedHunks,
264 ScrollCursorBottom,
265 ScrollCursorCenter,
266 ScrollCursorTop,
267 SelectAll,
268 SelectAllMatches,
269 SelectDown,
270 SelectLargerSyntaxNode,
271 SelectLeft,
272 SelectLine,
273 SelectRight,
274 SelectSmallerSyntaxNode,
275 SelectToBeginning,
276 SelectToEnd,
277 SelectToEndOfParagraph,
278 SelectToNextSubwordEnd,
279 SelectToNextWordEnd,
280 SelectToPreviousSubwordStart,
281 SelectToPreviousWordStart,
282 SelectToStartOfParagraph,
283 SelectUp,
284 SelectPageDown,
285 SelectPageUp,
286 ShowCharacterPalette,
287 ShowInlineCompletion,
288 ShuffleLines,
289 SortLinesCaseInsensitive,
290 SortLinesCaseSensitive,
291 SplitSelectionIntoLines,
292 Tab,
293 TabPrev,
294 ToggleGitBlame,
295 ToggleGitBlameInline,
296 ToggleSelectionMenu,
297 ToggleHunkDiff,
298 ToggleInlayHints,
299 ToggleLineNumbers,
300 ToggleIndentGuides,
301 ToggleSoftWrap,
302 ToggleTabBar,
303 Transpose,
304 Undo,
305 UndoSelection,
306 UnfoldLines,
307 UniqueLinesCaseInsensitive,
308 UniqueLinesCaseSensitive,
309 ]
310);
311
312action_as!(outline, ToggleOutline as Toggle);
313
314action_as!(go_to_line, ToggleGoToLine as Toggle);