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