actions.rs

  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(super) 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
117impl_actions!(
118    editor,
119    [
120        ConfirmCodeAction,
121        ConfirmCompletion,
122        ExpandExcerpts,
123        FoldAt,
124        MoveDownByLines,
125        MovePageDown,
126        MovePageUp,
127        MoveToBeginningOfLine,
128        MoveToEndOfLine,
129        MoveUpByLines,
130        SelectDownByLines,
131        SelectNext,
132        SelectPrevious,
133        SelectToBeginningOfLine,
134        SelectToEndOfLine,
135        SelectUpByLines,
136        ToggleCodeActions,
137        ToggleComments,
138        UnfoldAt,
139    ]
140);
141
142gpui::actions!(
143    editor,
144    [
145        AcceptPartialCopilotSuggestion,
146        AcceptInlineCompletion,
147        AcceptPartialInlineCompletion,
148        AddSelectionAbove,
149        AddSelectionBelow,
150        Backspace,
151        Cancel,
152        ConfirmRename,
153        ContextMenuFirst,
154        ContextMenuLast,
155        ContextMenuNext,
156        ContextMenuPrev,
157        ConvertToKebabCase,
158        ConvertToLowerCamelCase,
159        ConvertToLowerCase,
160        ConvertToOppositeCase,
161        ConvertToSnakeCase,
162        ConvertToTitleCase,
163        ConvertToUpperCamelCase,
164        ConvertToUpperCase,
165        Copy,
166        CopyHighlightJson,
167        CopyPath,
168        CopyPermalinkToLine,
169        CopyRelativePath,
170        Cut,
171        CutToEndOfLine,
172        Delete,
173        DeleteLine,
174        DeleteToBeginningOfLine,
175        DeleteToEndOfLine,
176        DeleteToNextSubwordEnd,
177        DeleteToNextWordEnd,
178        DeleteToPreviousSubwordStart,
179        DeleteToPreviousWordStart,
180        DisplayCursorNames,
181        DuplicateLineDown,
182        DuplicateLineUp,
183        ExpandAllHunkDiffs,
184        ExpandMacroRecursively,
185        FindAllReferences,
186        Fold,
187        FoldSelectedRanges,
188        Format,
189        GoToDefinition,
190        GoToDefinitionSplit,
191        GoToDiagnostic,
192        GoToHunk,
193        GoToImplementation,
194        GoToImplementationSplit,
195        GoToPrevDiagnostic,
196        GoToPrevHunk,
197        GoToTypeDefinition,
198        GoToTypeDefinitionSplit,
199        HalfPageDown,
200        HalfPageUp,
201        Hover,
202        Indent,
203        JoinLines,
204        LineDown,
205        LineUp,
206        MoveDown,
207        MoveLeft,
208        MoveLineDown,
209        MoveLineUp,
210        MoveRight,
211        MoveToBeginning,
212        MoveToEnclosingBracket,
213        MoveToEnd,
214        MoveToEndOfParagraph,
215        MoveToNextSubwordEnd,
216        MoveToNextWordEnd,
217        MoveToPreviousSubwordStart,
218        MoveToPreviousWordStart,
219        MoveToStartOfParagraph,
220        MoveUp,
221        Newline,
222        NewlineAbove,
223        NewlineBelow,
224        NextInlineCompletion,
225        NextScreen,
226        OpenExcerpts,
227        OpenExcerptsSplit,
228        OpenPermalinkToLine,
229        OpenUrl,
230        Outdent,
231        PageDown,
232        PageUp,
233        Paste,
234        PreviousInlineCompletion,
235        Redo,
236        RedoSelection,
237        Rename,
238        RestartLanguageServer,
239        RevealInFinder,
240        ReverseLines,
241        RevertSelectedHunks,
242        ScrollCursorBottom,
243        ScrollCursorCenter,
244        ScrollCursorTop,
245        SelectAll,
246        SelectAllMatches,
247        SelectDown,
248        SelectLargerSyntaxNode,
249        SelectLeft,
250        SelectLine,
251        SelectRight,
252        SelectSmallerSyntaxNode,
253        SelectToBeginning,
254        SelectToEnd,
255        SelectToEndOfParagraph,
256        SelectToNextSubwordEnd,
257        SelectToNextWordEnd,
258        SelectToPreviousSubwordStart,
259        SelectToPreviousWordStart,
260        SelectToStartOfParagraph,
261        SelectUp,
262        ShowCharacterPalette,
263        ShowCompletions,
264        ShowInlineCompletion,
265        ShuffleLines,
266        SortLinesCaseInsensitive,
267        SortLinesCaseSensitive,
268        SplitSelectionIntoLines,
269        Tab,
270        TabPrev,
271        ToggleGitBlame,
272        ToggleGitBlameInline,
273        ToggleHunkDiff,
274        ToggleInlayHints,
275        ToggleLineNumbers,
276        ToggleSoftWrap,
277        Transpose,
278        Undo,
279        UndoSelection,
280        UnfoldLines,
281        UniqueLinesCaseInsensitive,
282        UniqueLinesCaseSensitive,
283    ]
284);