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