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