1//! This module contains all actions supported by [`Editor`].
2use super::*;
3use util::serde::default_true;
4
5#[derive(PartialEq, Clone, Deserialize, Default)]
6pub struct SelectNext {
7 #[serde(default)]
8 pub replace_newest: bool,
9}
10
11#[derive(PartialEq, Clone, Deserialize, Default)]
12pub struct SelectPrevious {
13 #[serde(default)]
14 pub replace_newest: bool,
15}
16
17#[derive(PartialEq, Clone, Deserialize, Default)]
18pub struct MoveToBeginningOfLine {
19 #[serde(default = "default_true")]
20 pub(super) stop_at_soft_wraps: bool,
21}
22
23#[derive(PartialEq, Clone, Deserialize, Default)]
24pub struct SelectToBeginningOfLine {
25 #[serde(default)]
26 pub(super) stop_at_soft_wraps: bool,
27}
28
29#[derive(PartialEq, Clone, Deserialize, Default)]
30pub struct MovePageUp {
31 #[serde(default)]
32 pub(super) center_cursor: bool,
33}
34
35#[derive(PartialEq, Clone, Deserialize, Default)]
36pub struct MovePageDown {
37 #[serde(default)]
38 pub(super) center_cursor: bool,
39}
40
41#[derive(PartialEq, Clone, Deserialize, Default)]
42pub struct MoveToEndOfLine {
43 #[serde(default = "default_true")]
44 pub stop_at_soft_wraps: bool,
45}
46
47#[derive(PartialEq, Clone, Deserialize, Default)]
48pub struct SelectToEndOfLine {
49 #[serde(default)]
50 pub(super) stop_at_soft_wraps: bool,
51}
52
53#[derive(PartialEq, Clone, Deserialize, Default)]
54pub struct ToggleCodeActions {
55 // Display row from which the action was deployed.
56 #[serde(default)]
57 pub deployed_from_indicator: Option<DisplayRow>,
58}
59
60#[derive(PartialEq, Clone, Deserialize, Default)]
61pub struct ConfirmCompletion {
62 #[serde(default)]
63 pub item_ix: Option<usize>,
64}
65
66#[derive(PartialEq, Clone, Deserialize, Default)]
67pub struct ConfirmCodeAction {
68 #[serde(default)]
69 pub item_ix: Option<usize>,
70}
71
72#[derive(PartialEq, Clone, Deserialize, Default)]
73pub struct ToggleComments {
74 #[serde(default)]
75 pub advance_downwards: bool,
76}
77
78#[derive(PartialEq, Clone, Deserialize, Default)]
79pub struct FoldAt {
80 pub buffer_row: MultiBufferRow,
81}
82
83#[derive(PartialEq, Clone, Deserialize, Default)]
84pub struct UnfoldAt {
85 pub buffer_row: MultiBufferRow,
86}
87
88#[derive(PartialEq, Clone, Deserialize, Default)]
89pub struct MoveUpByLines {
90 #[serde(default)]
91 pub(super) lines: u32,
92}
93
94#[derive(PartialEq, Clone, Deserialize, Default)]
95pub struct MoveDownByLines {
96 #[serde(default)]
97 pub(super) lines: u32,
98}
99#[derive(PartialEq, Clone, Deserialize, Default)]
100pub struct SelectUpByLines {
101 #[serde(default)]
102 pub(super) lines: u32,
103}
104
105#[derive(PartialEq, Clone, Deserialize, Default)]
106pub struct SelectDownByLines {
107 #[serde(default)]
108 pub(super) lines: u32,
109}
110
111#[derive(PartialEq, Clone, Deserialize, Default)]
112pub struct ExpandExcerpts {
113 #[serde(default)]
114 pub(super) lines: u32,
115}
116
117#[derive(PartialEq, Clone, Deserialize, Default)]
118pub struct ExpandExcerptsUp {
119 #[serde(default)]
120 pub(super) lines: u32,
121}
122
123#[derive(PartialEq, Clone, Deserialize, Default)]
124pub struct ExpandExcerptsDown {
125 #[serde(default)]
126 pub(super) lines: u32,
127}
128#[derive(PartialEq, Clone, Deserialize, Default)]
129pub struct ShowCompletions {
130 #[serde(default)]
131 pub(super) trigger: Option<char>,
132}
133
134impl_actions!(
135 editor,
136 [
137 ConfirmCodeAction,
138 ConfirmCompletion,
139 ExpandExcerpts,
140 ExpandExcerptsUp,
141 ExpandExcerptsDown,
142 FoldAt,
143 MoveDownByLines,
144 MovePageDown,
145 MovePageUp,
146 MoveToBeginningOfLine,
147 MoveToEndOfLine,
148 MoveUpByLines,
149 SelectDownByLines,
150 SelectNext,
151 SelectPrevious,
152 SelectToBeginningOfLine,
153 SelectToEndOfLine,
154 SelectUpByLines,
155 ShowCompletions,
156 ToggleCodeActions,
157 ToggleComments,
158 UnfoldAt,
159 ]
160);
161
162gpui::actions!(
163 editor,
164 [
165 AcceptPartialCopilotSuggestion,
166 AcceptInlineCompletion,
167 AcceptPartialInlineCompletion,
168 AddSelectionAbove,
169 AddSelectionBelow,
170 Backspace,
171 Cancel,
172 ConfirmRename,
173 ContextMenuFirst,
174 ContextMenuLast,
175 ContextMenuNext,
176 ContextMenuPrev,
177 ConvertToKebabCase,
178 ConvertToLowerCamelCase,
179 ConvertToLowerCase,
180 ConvertToOppositeCase,
181 ConvertToSnakeCase,
182 ConvertToTitleCase,
183 ConvertToUpperCamelCase,
184 ConvertToUpperCase,
185 Copy,
186 CopyHighlightJson,
187 CopyPath,
188 CopyPermalinkToLine,
189 CopyRelativePath,
190 Cut,
191 CutToEndOfLine,
192 Delete,
193 DeleteLine,
194 DeleteToBeginningOfLine,
195 DeleteToEndOfLine,
196 DeleteToNextSubwordEnd,
197 DeleteToNextWordEnd,
198 DeleteToPreviousSubwordStart,
199 DeleteToPreviousWordStart,
200 DisplayCursorNames,
201 DuplicateLineDown,
202 DuplicateLineUp,
203 ExpandAllHunkDiffs,
204 ExpandMacroRecursively,
205 FindAllReferences,
206 Fold,
207 FoldSelectedRanges,
208 Format,
209 GoToDefinition,
210 GoToDefinitionSplit,
211 GoToDiagnostic,
212 GoToHunk,
213 GoToImplementation,
214 GoToImplementationSplit,
215 GoToPrevDiagnostic,
216 GoToPrevHunk,
217 GoToTypeDefinition,
218 GoToTypeDefinitionSplit,
219 HalfPageDown,
220 HalfPageUp,
221 Hover,
222 Indent,
223 JoinLines,
224 LineDown,
225 LineUp,
226 MoveDown,
227 MoveLeft,
228 MoveLineDown,
229 MoveLineUp,
230 MoveRight,
231 MoveToBeginning,
232 MoveToEnclosingBracket,
233 MoveToEnd,
234 MoveToEndOfParagraph,
235 MoveToNextSubwordEnd,
236 MoveToNextWordEnd,
237 MoveToPreviousSubwordStart,
238 MoveToPreviousWordStart,
239 MoveToStartOfParagraph,
240 MoveUp,
241 Newline,
242 NewlineAbove,
243 NewlineBelow,
244 NextInlineCompletion,
245 NextScreen,
246 OpenExcerpts,
247 OpenExcerptsSplit,
248 OpenPermalinkToLine,
249 OpenUrl,
250 Outdent,
251 PageDown,
252 PageUp,
253 Paste,
254 PreviousInlineCompletion,
255 Redo,
256 RedoSelection,
257 Rename,
258 RestartLanguageServer,
259 RevealInFinder,
260 ReverseLines,
261 RevertSelectedHunks,
262 ScrollCursorBottom,
263 ScrollCursorCenter,
264 ScrollCursorTop,
265 SelectAll,
266 SelectAllMatches,
267 SelectDown,
268 SelectLargerSyntaxNode,
269 SelectLeft,
270 SelectLine,
271 SelectRight,
272 SelectSmallerSyntaxNode,
273 SelectToBeginning,
274 SelectToEnd,
275 SelectToEndOfParagraph,
276 SelectToNextSubwordEnd,
277 SelectToNextWordEnd,
278 SelectToPreviousSubwordStart,
279 SelectToPreviousWordStart,
280 SelectToStartOfParagraph,
281 SelectUp,
282 ShowCharacterPalette,
283 ShowInlineCompletion,
284 ShuffleLines,
285 SortLinesCaseInsensitive,
286 SortLinesCaseSensitive,
287 SplitSelectionIntoLines,
288 Tab,
289 TabPrev,
290 ToggleGitBlame,
291 ToggleGitBlameInline,
292 ToggleHunkDiff,
293 ToggleInlayHints,
294 ToggleLineNumbers,
295 ToggleIndentGuides,
296 ToggleSoftWrap,
297 ToggleTabBar,
298 Transpose,
299 Undo,
300 UndoSelection,
301 UnfoldLines,
302 UniqueLinesCaseInsensitive,
303 UniqueLinesCaseSensitive,
304 ]
305);