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