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        FoldSelectedRanges,
234        Format,
235        GoToDeclaration,
236        GoToDeclarationSplit,
237        GoToDefinition,
238        GoToDefinitionSplit,
239        GoToDiagnostic,
240        GoToHunk,
241        GoToImplementation,
242        GoToImplementationSplit,
243        GoToPrevDiagnostic,
244        GoToPrevHunk,
245        GoToTypeDefinition,
246        GoToTypeDefinitionSplit,
247        HalfPageDown,
248        HalfPageUp,
249        Hover,
250        Indent,
251        JoinLines,
252        LineDown,
253        LineUp,
254        MoveDown,
255        MoveLeft,
256        MoveLineDown,
257        MoveLineUp,
258        MoveRight,
259        MoveToBeginning,
260        MoveToEnclosingBracket,
261        MoveToEnd,
262        MoveToEndOfParagraph,
263        MoveToNextSubwordEnd,
264        MoveToNextWordEnd,
265        MoveToPreviousSubwordStart,
266        MoveToPreviousWordStart,
267        MoveToStartOfParagraph,
268        MoveUp,
269        Newline,
270        NewlineAbove,
271        NewlineBelow,
272        NextInlineCompletion,
273        NextScreen,
274        OpenExcerpts,
275        OpenExcerptsSplit,
276        OpenFile,
277        OpenPermalinkToLine,
278        OpenUrl,
279        Outdent,
280        PageDown,
281        PageUp,
282        Paste,
283        PreviousInlineCompletion,
284        Redo,
285        RedoSelection,
286        Rename,
287        RestartLanguageServer,
288        RevealInFileManager,
289        ReverseLines,
290        RevertFile,
291        RevertSelectedHunks,
292        Rewrap,
293        ScrollCursorBottom,
294        ScrollCursorCenter,
295        ScrollCursorCenterTopBottom,
296        ScrollCursorTop,
297        SelectAll,
298        SelectAllMatches,
299        SelectDown,
300        SelectEnclosingSymbol,
301        SelectLargerSyntaxNode,
302        SelectLeft,
303        SelectLine,
304        SelectPageDown,
305        SelectPageUp,
306        SelectRight,
307        SelectSmallerSyntaxNode,
308        SelectToBeginning,
309        SelectToEnd,
310        SelectToEndOfParagraph,
311        SelectToNextSubwordEnd,
312        SelectToNextWordEnd,
313        SelectToPreviousSubwordStart,
314        SelectToPreviousWordStart,
315        SelectToStartOfParagraph,
316        SelectUp,
317        ShowCharacterPalette,
318        ShowInlineCompletion,
319        ShowSignatureHelp,
320        ShuffleLines,
321        SortLinesCaseInsensitive,
322        SortLinesCaseSensitive,
323        SplitSelectionIntoLines,
324        SwitchSourceHeader,
325        Tab,
326        TabPrev,
327        ToggleAutoSignatureHelp,
328        ToggleGitBlame,
329        ToggleGitBlameInline,
330        ToggleHunkDiff,
331        ToggleIndentGuides,
332        ToggleInlayHints,
333        ToggleInlineCompletions,
334        ToggleLineNumbers,
335        ToggleRelativeLineNumbers,
336        ToggleSelectionMenu,
337        ToggleSoftWrap,
338        ToggleTabBar,
339        Transpose,
340        Undo,
341        UndoSelection,
342        UnfoldLines,
343        UniqueLinesCaseInsensitive,
344        UniqueLinesCaseSensitive,
345    ]
346);
347
348action_as!(outline, ToggleOutline as Toggle);
349
350action_as!(go_to_line, ToggleGoToLine as Toggle);