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(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<String>,
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        RevealInFileManager,
262        ReverseLines,
263        RevertSelectedHunks,
264        ScrollCursorBottom,
265        ScrollCursorCenter,
266        ScrollCursorTop,
267        SelectAll,
268        SelectAllMatches,
269        SelectDown,
270        SelectLargerSyntaxNode,
271        SelectEnclosingSymbol,
272        SelectLeft,
273        SelectLine,
274        SelectRight,
275        SelectSmallerSyntaxNode,
276        SelectToBeginning,
277        SelectToEnd,
278        SelectToEndOfParagraph,
279        SelectToNextSubwordEnd,
280        SelectToNextWordEnd,
281        SelectToPreviousSubwordStart,
282        SelectToPreviousWordStart,
283        SelectToStartOfParagraph,
284        SelectUp,
285        SelectPageDown,
286        SelectPageUp,
287        ShowCharacterPalette,
288        ShowInlineCompletion,
289        ShowSignatureHelp,
290        ShuffleLines,
291        SortLinesCaseInsensitive,
292        SortLinesCaseSensitive,
293        SplitSelectionIntoLines,
294        Tab,
295        TabPrev,
296        ToggleAutoSignatureHelp,
297        ToggleGitBlame,
298        ToggleGitBlameInline,
299        ToggleSelectionMenu,
300        ToggleHunkDiff,
301        ToggleInlayHints,
302        ToggleLineNumbers,
303        ToggleIndentGuides,
304        ToggleSoftWrap,
305        ToggleTabBar,
306        Transpose,
307        Undo,
308        UndoSelection,
309        UnfoldLines,
310        UniqueLinesCaseInsensitive,
311        UniqueLinesCaseSensitive,
312    ]
313);
314
315action_as!(outline, ToggleOutline as Toggle);
316
317action_as!(go_to_line, ToggleGoToLine as Toggle);