2024-01-17 23:48:37 +00:00
|
|
|
//! This module contains all actions supported by [`Editor`].
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct SelectNext {
|
|
|
|
#[serde(default)]
|
|
|
|
pub replace_newest: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct SelectPrevious {
|
|
|
|
#[serde(default)]
|
|
|
|
pub replace_newest: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct SelectToBeginningOfLine {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) stop_at_soft_wraps: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct MovePageUp {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) center_cursor: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct MovePageDown {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) center_cursor: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct SelectToEndOfLine {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) stop_at_soft_wraps: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct ToggleCodeActions {
|
|
|
|
#[serde(default)]
|
|
|
|
pub deployed_from_indicator: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct ConfirmCompletion {
|
|
|
|
#[serde(default)]
|
|
|
|
pub item_ix: Option<usize>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct ConfirmCodeAction {
|
|
|
|
#[serde(default)]
|
|
|
|
pub item_ix: Option<usize>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct ToggleComments {
|
|
|
|
#[serde(default)]
|
|
|
|
pub advance_downwards: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct FoldAt {
|
|
|
|
pub buffer_row: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct UnfoldAt {
|
|
|
|
pub buffer_row: u32,
|
|
|
|
}
|
editor: Add MoveUpByLines and MoveDownByLines actions (#7208)
This adds four new actions:
- `editor::MoveUpByLines`
- `editor::MoveDownByLines`
- `editor::SelectUpByLines`
- `editor::SelectDownByLines`
They all take a count by which to move the cursor up and down.
(Requested by Adam here:
https://twitter.com/adamwathan/status/1753017094248018302)
Example `keymap.json` entries:
```json
{
"context": "Editor",
"bindings": [
"alt-up": [ "editor::MoveUpByLines", { "lines": 3 } ],
"alt-down": [ "editor::MoveDownByLines", { "lines": 3 } ],
"alt-shift-up": [ "editor::SelectUpByLines", { "lines": 3 } ],
"alt-shift-down": [ "editor::SelectDownByLines", { "lines": 3 } ]
]
}
```
They are *not* bound by default, so as to not conflict with the
`alt-up/down` bindings that already exist.
Release Notes:
- Added four new actions: `editor::MoveUpByLines`,
`editor::MoveDownByLines`, `editor::SelectUpByLines`,
`editor::SelectDownByLines` that can take a line count configuration and
move the cursor up by the count.
### Demo
https://github.com/zed-industries/zed/assets/1185253/e78d4077-5bd5-4d72-a806-67695698af5d
https://github.com/zed-industries/zed/assets/1185253/0b086ec9-eb90-40a2-9009-844a215e6378
2024-02-02 15:48:04 +00:00
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct MoveUpByLines {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) lines: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct MoveDownByLines {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) lines: u32,
|
|
|
|
}
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct SelectUpByLines {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) lines: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
|
|
|
pub struct SelectDownByLines {
|
|
|
|
#[serde(default)]
|
|
|
|
pub(super) lines: u32,
|
|
|
|
}
|
|
|
|
|
2024-01-17 23:48:37 +00:00
|
|
|
impl_actions!(
|
|
|
|
editor,
|
|
|
|
[
|
|
|
|
SelectNext,
|
|
|
|
SelectPrevious,
|
|
|
|
SelectToBeginningOfLine,
|
|
|
|
MovePageUp,
|
|
|
|
MovePageDown,
|
|
|
|
SelectToEndOfLine,
|
|
|
|
ToggleCodeActions,
|
|
|
|
ConfirmCompletion,
|
|
|
|
ConfirmCodeAction,
|
|
|
|
ToggleComments,
|
|
|
|
FoldAt,
|
editor: Add MoveUpByLines and MoveDownByLines actions (#7208)
This adds four new actions:
- `editor::MoveUpByLines`
- `editor::MoveDownByLines`
- `editor::SelectUpByLines`
- `editor::SelectDownByLines`
They all take a count by which to move the cursor up and down.
(Requested by Adam here:
https://twitter.com/adamwathan/status/1753017094248018302)
Example `keymap.json` entries:
```json
{
"context": "Editor",
"bindings": [
"alt-up": [ "editor::MoveUpByLines", { "lines": 3 } ],
"alt-down": [ "editor::MoveDownByLines", { "lines": 3 } ],
"alt-shift-up": [ "editor::SelectUpByLines", { "lines": 3 } ],
"alt-shift-down": [ "editor::SelectDownByLines", { "lines": 3 } ]
]
}
```
They are *not* bound by default, so as to not conflict with the
`alt-up/down` bindings that already exist.
Release Notes:
- Added four new actions: `editor::MoveUpByLines`,
`editor::MoveDownByLines`, `editor::SelectUpByLines`,
`editor::SelectDownByLines` that can take a line count configuration and
move the cursor up by the count.
### Demo
https://github.com/zed-industries/zed/assets/1185253/e78d4077-5bd5-4d72-a806-67695698af5d
https://github.com/zed-industries/zed/assets/1185253/0b086ec9-eb90-40a2-9009-844a215e6378
2024-02-02 15:48:04 +00:00
|
|
|
UnfoldAt,
|
|
|
|
MoveUpByLines,
|
|
|
|
MoveDownByLines,
|
|
|
|
SelectUpByLines,
|
2024-02-07 11:50:22 +00:00
|
|
|
SelectDownByLines
|
2024-01-17 23:48:37 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
gpui::actions!(
|
|
|
|
editor,
|
|
|
|
[
|
|
|
|
AddSelectionAbove,
|
|
|
|
AddSelectionBelow,
|
|
|
|
Backspace,
|
|
|
|
Cancel,
|
|
|
|
ConfirmRename,
|
|
|
|
ContextMenuFirst,
|
|
|
|
ContextMenuLast,
|
|
|
|
ContextMenuNext,
|
|
|
|
ContextMenuPrev,
|
|
|
|
ConvertToKebabCase,
|
|
|
|
ConvertToLowerCamelCase,
|
|
|
|
ConvertToLowerCase,
|
|
|
|
ConvertToSnakeCase,
|
|
|
|
ConvertToTitleCase,
|
|
|
|
ConvertToUpperCamelCase,
|
|
|
|
ConvertToUpperCase,
|
|
|
|
Copy,
|
|
|
|
CopyHighlightJson,
|
|
|
|
CopyPath,
|
2024-01-31 00:20:15 +00:00
|
|
|
CopyPermalinkToLine,
|
2024-01-17 23:48:37 +00:00
|
|
|
CopyRelativePath,
|
|
|
|
Cut,
|
|
|
|
CutToEndOfLine,
|
|
|
|
Delete,
|
|
|
|
DeleteLine,
|
|
|
|
DeleteToBeginningOfLine,
|
|
|
|
DeleteToEndOfLine,
|
|
|
|
DeleteToNextSubwordEnd,
|
|
|
|
DeleteToNextWordEnd,
|
|
|
|
DeleteToPreviousSubwordStart,
|
|
|
|
DeleteToPreviousWordStart,
|
2024-01-25 11:56:12 +00:00
|
|
|
DisplayCursorNames,
|
2024-01-17 23:48:37 +00:00
|
|
|
DuplicateLine,
|
|
|
|
ExpandMacroRecursively,
|
|
|
|
FindAllReferences,
|
|
|
|
Fold,
|
|
|
|
FoldSelectedRanges,
|
|
|
|
Format,
|
|
|
|
GoToDefinition,
|
|
|
|
GoToDefinitionSplit,
|
|
|
|
GoToDiagnostic,
|
|
|
|
GoToHunk,
|
|
|
|
GoToPrevDiagnostic,
|
|
|
|
GoToPrevHunk,
|
|
|
|
GoToTypeDefinition,
|
|
|
|
GoToTypeDefinitionSplit,
|
|
|
|
HalfPageDown,
|
|
|
|
HalfPageUp,
|
|
|
|
Hover,
|
|
|
|
Indent,
|
|
|
|
JoinLines,
|
|
|
|
LineDown,
|
|
|
|
LineUp,
|
|
|
|
MoveDown,
|
|
|
|
MoveLeft,
|
|
|
|
MoveLineDown,
|
|
|
|
MoveLineUp,
|
|
|
|
MoveRight,
|
|
|
|
MoveToBeginning,
|
|
|
|
MoveToBeginningOfLine,
|
|
|
|
MoveToEnclosingBracket,
|
|
|
|
MoveToEnd,
|
|
|
|
MoveToEndOfLine,
|
|
|
|
MoveToEndOfParagraph,
|
|
|
|
MoveToNextSubwordEnd,
|
|
|
|
MoveToNextWordEnd,
|
|
|
|
MoveToPreviousSubwordStart,
|
|
|
|
MoveToPreviousWordStart,
|
|
|
|
MoveToStartOfParagraph,
|
|
|
|
MoveUp,
|
|
|
|
Newline,
|
|
|
|
NewlineAbove,
|
|
|
|
NewlineBelow,
|
|
|
|
NextScreen,
|
|
|
|
OpenExcerpts,
|
|
|
|
Outdent,
|
|
|
|
PageDown,
|
|
|
|
PageUp,
|
|
|
|
Paste,
|
|
|
|
Redo,
|
|
|
|
RedoSelection,
|
|
|
|
Rename,
|
|
|
|
RestartLanguageServer,
|
|
|
|
RevealInFinder,
|
|
|
|
ReverseLines,
|
|
|
|
ScrollCursorBottom,
|
|
|
|
ScrollCursorCenter,
|
|
|
|
ScrollCursorTop,
|
|
|
|
SelectAll,
|
2024-01-25 11:56:12 +00:00
|
|
|
SelectAllMatches,
|
2024-01-17 23:48:37 +00:00
|
|
|
SelectDown,
|
|
|
|
SelectLargerSyntaxNode,
|
|
|
|
SelectLeft,
|
|
|
|
SelectLine,
|
|
|
|
SelectRight,
|
|
|
|
SelectSmallerSyntaxNode,
|
|
|
|
SelectToBeginning,
|
|
|
|
SelectToEnd,
|
|
|
|
SelectToEndOfParagraph,
|
|
|
|
SelectToNextSubwordEnd,
|
|
|
|
SelectToNextWordEnd,
|
|
|
|
SelectToPreviousSubwordStart,
|
|
|
|
SelectToPreviousWordStart,
|
|
|
|
SelectToStartOfParagraph,
|
|
|
|
SelectUp,
|
|
|
|
ShowCharacterPalette,
|
|
|
|
ShowCompletions,
|
|
|
|
ShuffleLines,
|
|
|
|
SortLinesCaseInsensitive,
|
|
|
|
SortLinesCaseSensitive,
|
|
|
|
SplitSelectionIntoLines,
|
|
|
|
Tab,
|
|
|
|
TabPrev,
|
|
|
|
ToggleInlayHints,
|
|
|
|
ToggleSoftWrap,
|
|
|
|
Transpose,
|
|
|
|
Undo,
|
|
|
|
UndoSelection,
|
|
|
|
UnfoldLines,
|
|
|
|
]
|
|
|
|
);
|