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