actions.rs

  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 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    #[serde(default)]
 84    pub ignore_indent: bool,
 85}
 86
 87#[derive(PartialEq, Clone, Deserialize, Default)]
 88pub struct FoldAt {
 89    pub buffer_row: MultiBufferRow,
 90}
 91
 92#[derive(PartialEq, Clone, Deserialize, Default)]
 93pub struct UnfoldAt {
 94    pub buffer_row: MultiBufferRow,
 95}
 96
 97#[derive(PartialEq, Clone, Deserialize, Default)]
 98pub struct MoveUpByLines {
 99    #[serde(default)]
100    pub(super) lines: u32,
101}
102
103#[derive(PartialEq, Clone, Deserialize, Default)]
104pub struct MoveDownByLines {
105    #[serde(default)]
106    pub(super) lines: u32,
107}
108#[derive(PartialEq, Clone, Deserialize, Default)]
109pub struct SelectUpByLines {
110    #[serde(default)]
111    pub(super) lines: u32,
112}
113
114#[derive(PartialEq, Clone, Deserialize, Default)]
115pub struct SelectDownByLines {
116    #[serde(default)]
117    pub(super) lines: u32,
118}
119
120#[derive(PartialEq, Clone, Deserialize, Default)]
121pub struct ExpandExcerpts {
122    #[serde(default)]
123    pub(super) lines: u32,
124}
125
126#[derive(PartialEq, Clone, Deserialize, Default)]
127pub struct ExpandExcerptsUp {
128    #[serde(default)]
129    pub(super) lines: u32,
130}
131
132#[derive(PartialEq, Clone, Deserialize, Default)]
133pub struct ExpandExcerptsDown {
134    #[serde(default)]
135    pub(super) lines: u32,
136}
137#[derive(PartialEq, Clone, Deserialize, Default)]
138pub struct ShowCompletions {
139    #[serde(default)]
140    pub(super) trigger: Option<String>,
141}
142
143#[derive(PartialEq, Clone, Deserialize, Default)]
144pub struct HandleInput(pub String);
145
146#[derive(PartialEq, Clone, Deserialize, Default)]
147pub struct DeleteToNextWordEnd {
148    #[serde(default)]
149    pub ignore_newlines: bool,
150}
151
152#[derive(PartialEq, Clone, Deserialize, Default)]
153pub struct DeleteToPreviousWordStart {
154    #[serde(default)]
155    pub ignore_newlines: bool,
156}
157
158#[derive(PartialEq, Clone, Deserialize, Default)]
159pub struct FoldAtLevel {
160    pub level: u32,
161}
162
163#[derive(PartialEq, Clone, Deserialize, Default)]
164pub struct SpawnNearestTask {
165    #[serde(default)]
166    pub reveal: task::RevealStrategy,
167}
168
169impl_actions!(
170    editor,
171    [
172        ComposeCompletion,
173        ConfirmCodeAction,
174        ConfirmCompletion,
175        DeleteToNextWordEnd,
176        DeleteToPreviousWordStart,
177        ExpandExcerpts,
178        ExpandExcerptsDown,
179        ExpandExcerptsUp,
180        FoldAt,
181        HandleInput,
182        MoveDownByLines,
183        MovePageDown,
184        MovePageUp,
185        MoveToBeginningOfLine,
186        MoveToEndOfLine,
187        MoveUpByLines,
188        SelectDownByLines,
189        SelectNext,
190        SelectPrevious,
191        SelectToBeginningOfLine,
192        SelectToEndOfLine,
193        SelectUpByLines,
194        SpawnNearestTask,
195        ShowCompletions,
196        ToggleCodeActions,
197        ToggleComments,
198        UnfoldAt,
199        FoldAtLevel
200    ]
201);
202
203gpui::actions!(
204    editor,
205    [
206        AcceptInlineCompletion,
207        AcceptPartialCopilotSuggestion,
208        AcceptPartialInlineCompletion,
209        AddSelectionAbove,
210        AddSelectionBelow,
211        ApplyAllDiffHunks,
212        ApplyDiffHunk,
213        Backspace,
214        Cancel,
215        CancelLanguageServerWork,
216        ConfirmRename,
217        ContextMenuFirst,
218        ContextMenuLast,
219        ContextMenuNext,
220        ContextMenuPrev,
221        ConvertToKebabCase,
222        ConvertToLowerCamelCase,
223        ConvertToLowerCase,
224        ConvertToOppositeCase,
225        ConvertToSnakeCase,
226        ConvertToTitleCase,
227        ConvertToUpperCamelCase,
228        ConvertToUpperCase,
229        Copy,
230        CopyFileLocation,
231        CopyHighlightJson,
232        CopyPath,
233        CopyPermalinkToLine,
234        CopyRelativePath,
235        Cut,
236        CutToEndOfLine,
237        Delete,
238        DeleteLine,
239        DeleteToBeginningOfLine,
240        DeleteToEndOfLine,
241        DeleteToNextSubwordEnd,
242        DeleteToPreviousSubwordStart,
243        DisplayCursorNames,
244        DuplicateLineDown,
245        DuplicateLineUp,
246        ExpandAllHunkDiffs,
247        ExpandMacroRecursively,
248        FindAllReferences,
249        Fold,
250        FoldAll,
251        FoldFunctionBodies,
252        FoldRecursive,
253        FoldSelectedRanges,
254        ToggleFold,
255        ToggleFoldRecursive,
256        Format,
257        FormatSelections,
258        GoToDeclaration,
259        GoToDeclarationSplit,
260        GoToDefinition,
261        GoToDefinitionSplit,
262        GoToDiagnostic,
263        GoToHunk,
264        GoToImplementation,
265        GoToImplementationSplit,
266        GoToPrevDiagnostic,
267        GoToPrevHunk,
268        GoToTypeDefinition,
269        GoToTypeDefinitionSplit,
270        HalfPageDown,
271        HalfPageUp,
272        Hover,
273        Indent,
274        JoinLines,
275        KillRingCut,
276        KillRingYank,
277        LineDown,
278        LineUp,
279        MoveDown,
280        MoveLeft,
281        MoveLineDown,
282        MoveLineUp,
283        MoveRight,
284        MoveToBeginning,
285        MoveToEnclosingBracket,
286        MoveToEnd,
287        MoveToEndOfParagraph,
288        MoveToNextSubwordEnd,
289        MoveToNextWordEnd,
290        MoveToPreviousSubwordStart,
291        MoveToPreviousWordStart,
292        MoveToStartOfParagraph,
293        MoveUp,
294        Newline,
295        NewlineAbove,
296        NewlineBelow,
297        NextInlineCompletion,
298        NextScreen,
299        OpenContextMenu,
300        OpenExcerpts,
301        OpenExcerptsSplit,
302        OpenProposedChangesEditor,
303        OpenFile,
304        OpenDocs,
305        OpenPermalinkToLine,
306        OpenUrl,
307        Outdent,
308        AutoIndent,
309        PageDown,
310        PageUp,
311        Paste,
312        PreviousInlineCompletion,
313        Redo,
314        RedoSelection,
315        Rename,
316        RestartLanguageServer,
317        RevealInFileManager,
318        ReverseLines,
319        RevertFile,
320        ReloadFile,
321        RevertSelectedHunks,
322        Rewrap,
323        ScrollCursorBottom,
324        ScrollCursorCenter,
325        ScrollCursorCenterTopBottom,
326        ScrollCursorTop,
327        SelectAll,
328        SelectAllMatches,
329        SelectDown,
330        SelectEnclosingSymbol,
331        SelectLargerSyntaxNode,
332        SelectLeft,
333        SelectLine,
334        SelectPageDown,
335        SelectPageUp,
336        SelectRight,
337        SelectSmallerSyntaxNode,
338        SelectToBeginning,
339        SelectToEnd,
340        SelectToEndOfParagraph,
341        SelectToNextSubwordEnd,
342        SelectToNextWordEnd,
343        SelectToPreviousSubwordStart,
344        SelectToPreviousWordStart,
345        SelectToStartOfParagraph,
346        SelectUp,
347        ShowCharacterPalette,
348        ShowInlineCompletion,
349        ShowSignatureHelp,
350        ShuffleLines,
351        SortLinesCaseInsensitive,
352        SortLinesCaseSensitive,
353        SplitSelectionIntoLines,
354        SwitchSourceHeader,
355        Tab,
356        TabPrev,
357        ToggleAutoSignatureHelp,
358        ToggleGitBlame,
359        ToggleGitBlameInline,
360        ToggleHunkDiff,
361        ToggleIndentGuides,
362        ToggleInlayHints,
363        ToggleInlineCompletions,
364        ToggleLineNumbers,
365        ToggleRelativeLineNumbers,
366        ToggleSelectionMenu,
367        ToggleSoftWrap,
368        ToggleTabBar,
369        Transpose,
370        Undo,
371        UndoSelection,
372        UnfoldAll,
373        UnfoldLines,
374        UnfoldRecursive,
375        UniqueLinesCaseInsensitive,
376        UniqueLinesCaseSensitive,
377    ]
378);
379
380action_as!(outline, ToggleOutline as Toggle);
381
382action_as!(go_to_line, ToggleGoToLine as Toggle);