Restore namespace parameter to actions!
This does not yet fix `derive(Action)`, but will conflict with a lot so wanted to merge quickly.
This commit is contained in:
parent
188d727d31
commit
4290c67b6a
43 changed files with 399 additions and 304 deletions
|
@ -14,7 +14,7 @@ use ui::h_stack;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{item::ItemHandle, StatusItemView, Workspace};
|
use workspace::{item::ItemHandle, StatusItemView, Workspace};
|
||||||
|
|
||||||
actions!(ShowErrorMessage);
|
actions!(activity_indicator, [ShowErrorMessage]);
|
||||||
|
|
||||||
const DOWNLOAD_ICON: &str = "icons/download.svg";
|
const DOWNLOAD_ICON: &str = "icons/download.svg";
|
||||||
const WARNING_ICON: &str = "icons/warning.svg";
|
const WARNING_ICON: &str = "icons/warning.svg";
|
||||||
|
|
|
@ -19,16 +19,19 @@ use std::{cmp::Reverse, ffi::OsStr, path::PathBuf, sync::Arc};
|
||||||
use util::paths::CONVERSATIONS_DIR;
|
use util::paths::CONVERSATIONS_DIR;
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
NewConversation,
|
assistant,
|
||||||
Assist,
|
[
|
||||||
Split,
|
NewConversation,
|
||||||
CycleMessageRole,
|
Assist,
|
||||||
QuoteSelection,
|
Split,
|
||||||
ToggleFocus,
|
CycleMessageRole,
|
||||||
ResetKey,
|
QuoteSelection,
|
||||||
InlineAssist,
|
ToggleFocus,
|
||||||
ToggleIncludeConversation,
|
ResetKey,
|
||||||
ToggleRetrieveContext,
|
InlineAssist,
|
||||||
|
ToggleIncludeConversation,
|
||||||
|
ToggleRetrieveContext,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
|
@ -26,10 +26,13 @@ const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
|
||||||
|
|
||||||
//todo!(remove CheckThatAutoUpdaterWorks)
|
//todo!(remove CheckThatAutoUpdaterWorks)
|
||||||
actions!(
|
actions!(
|
||||||
Check,
|
auto_update,
|
||||||
DismissErrorMessage,
|
[
|
||||||
ViewReleaseNotes,
|
Check,
|
||||||
CheckThatAutoUpdaterWorks
|
DismissErrorMessage,
|
||||||
|
ViewReleaseNotes,
|
||||||
|
CheckThatAutoUpdaterWorks
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub const ZED_SECRET_CLIENT_TOKEN: &str = "618033988749894";
|
||||||
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100);
|
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100);
|
||||||
pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);
|
pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
actions!(SignIn, SignOut, Reconnect);
|
actions!(client, [SignIn, SignOut, Reconnect]);
|
||||||
|
|
||||||
pub fn init_settings(cx: &mut AppContext) {
|
pub fn init_settings(cx: &mut AppContext) {
|
||||||
TelemetrySettings::register(cx);
|
TelemetrySettings::register(cx);
|
||||||
|
|
|
@ -26,7 +26,7 @@ use workspace::{
|
||||||
ItemNavHistory, Pane, SaveIntent, ViewId, Workspace, WorkspaceId,
|
ItemNavHistory, Pane, SaveIntent, ViewId, Workspace, WorkspaceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
actions!(Deploy);
|
actions!(collab, [Deploy]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
register_followable_item::<ChannelView>(cx)
|
register_followable_item::<ChannelView>(cx)
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub enum Event {
|
||||||
Dismissed,
|
Dismissed,
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(ToggleFocus);
|
actions!(chat_panel, [ToggleFocus]);
|
||||||
|
|
||||||
impl ChatPanel {
|
impl ChatPanel {
|
||||||
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||||
|
|
|
@ -123,14 +123,17 @@ pub struct OpenChannelNotes {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
ToggleFocus,
|
collab_panel,
|
||||||
Remove,
|
[
|
||||||
Secondary,
|
ToggleFocus,
|
||||||
CollapseSelectedChannel,
|
Remove,
|
||||||
ExpandSelectedChannel,
|
Secondary,
|
||||||
StartMoveChannel,
|
CollapseSelectedChannel,
|
||||||
MoveSelected,
|
ExpandSelectedChannel,
|
||||||
InsertSpace,
|
StartMoveChannel,
|
||||||
|
MoveSelected,
|
||||||
|
InsertSpace,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// impl_actions!(
|
// impl_actions!(
|
||||||
|
|
|
@ -16,10 +16,13 @@ use util::TryFutureExt;
|
||||||
use workspace::ModalView;
|
use workspace::ModalView;
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
SelectNextControl,
|
channel_modal,
|
||||||
ToggleMode,
|
[
|
||||||
ToggleMemberAdmin,
|
SelectNextControl,
|
||||||
RemoveMember
|
ToggleMode,
|
||||||
|
ToggleMemberAdmin,
|
||||||
|
RemoveMember
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// pub fn init(cx: &mut AppContext) {
|
// pub fn init(cx: &mut AppContext) {
|
||||||
|
|
|
@ -20,11 +20,14 @@ const MAX_PROJECT_NAME_LENGTH: usize = 40;
|
||||||
const MAX_BRANCH_NAME_LENGTH: usize = 40;
|
const MAX_BRANCH_NAME_LENGTH: usize = 40;
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
ShareProject,
|
collab,
|
||||||
UnshareProject,
|
[
|
||||||
ToggleUserMenu,
|
ShareProject,
|
||||||
ToggleProjectMenu,
|
UnshareProject,
|
||||||
SwitchBranch
|
ToggleUserMenu,
|
||||||
|
ToggleProjectMenu,
|
||||||
|
SwitchBranch
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
|
|
|
@ -24,7 +24,10 @@ use settings::Settings;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::AppState;
|
use workspace::AppState;
|
||||||
|
|
||||||
actions!(ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall);
|
actions!(
|
||||||
|
collab,
|
||||||
|
[ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall]
|
||||||
|
);
|
||||||
|
|
||||||
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||||
CollaborationPanelSettings::register(cx);
|
CollaborationPanelSettings::register(cx);
|
||||||
|
|
|
@ -19,7 +19,7 @@ use util::{
|
||||||
use workspace::{ModalView, Workspace};
|
use workspace::{ModalView, Workspace};
|
||||||
use zed_actions::OpenZedURL;
|
use zed_actions::OpenZedURL;
|
||||||
|
|
||||||
actions!(Toggle);
|
actions!(command_palette, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.set_global(HitCounts::default());
|
cx.set_global(HitCounts::default());
|
||||||
|
|
|
@ -34,12 +34,15 @@ use util::{
|
||||||
};
|
};
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
Suggest,
|
copilot,
|
||||||
NextSuggestion,
|
[
|
||||||
PreviousSuggestion,
|
Suggest,
|
||||||
Reinstall,
|
NextSuggestion,
|
||||||
SignIn,
|
PreviousSuggestion,
|
||||||
SignOut
|
Reinstall,
|
||||||
|
SignIn,
|
||||||
|
SignOut
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
|
|
|
@ -43,7 +43,7 @@ use workspace::{
|
||||||
ItemNavHistory, Pane, ToolbarItemLocation, Workspace,
|
ItemNavHistory, Pane, ToolbarItemLocation, Workspace,
|
||||||
};
|
};
|
||||||
|
|
||||||
actions!(Deploy, ToggleWarnings);
|
actions!(diagnostics, [Deploy, ToggleWarnings]);
|
||||||
|
|
||||||
const CONTEXT_LINE_COUNT: u32 = 1;
|
const CONTEXT_LINE_COUNT: u32 = 1;
|
||||||
|
|
||||||
|
|
|
@ -277,121 +277,124 @@ impl InlayId {
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
AddSelectionAbove,
|
editor,
|
||||||
AddSelectionBelow,
|
[
|
||||||
Backspace,
|
AddSelectionAbove,
|
||||||
Cancel,
|
AddSelectionBelow,
|
||||||
ConfirmRename,
|
Backspace,
|
||||||
ContextMenuFirst,
|
Cancel,
|
||||||
ContextMenuLast,
|
ConfirmRename,
|
||||||
ContextMenuNext,
|
ContextMenuFirst,
|
||||||
ContextMenuPrev,
|
ContextMenuLast,
|
||||||
ConvertToKebabCase,
|
ContextMenuNext,
|
||||||
ConvertToLowerCamelCase,
|
ContextMenuPrev,
|
||||||
ConvertToLowerCase,
|
ConvertToKebabCase,
|
||||||
ConvertToSnakeCase,
|
ConvertToLowerCamelCase,
|
||||||
ConvertToTitleCase,
|
ConvertToLowerCase,
|
||||||
ConvertToUpperCamelCase,
|
ConvertToSnakeCase,
|
||||||
ConvertToUpperCase,
|
ConvertToTitleCase,
|
||||||
Copy,
|
ConvertToUpperCamelCase,
|
||||||
CopyHighlightJson,
|
ConvertToUpperCase,
|
||||||
CopyPath,
|
Copy,
|
||||||
CopyRelativePath,
|
CopyHighlightJson,
|
||||||
Cut,
|
CopyPath,
|
||||||
CutToEndOfLine,
|
CopyRelativePath,
|
||||||
Delete,
|
Cut,
|
||||||
DeleteLine,
|
CutToEndOfLine,
|
||||||
DeleteToBeginningOfLine,
|
Delete,
|
||||||
DeleteToEndOfLine,
|
DeleteLine,
|
||||||
DeleteToNextSubwordEnd,
|
DeleteToBeginningOfLine,
|
||||||
DeleteToNextWordEnd,
|
DeleteToEndOfLine,
|
||||||
DeleteToPreviousSubwordStart,
|
DeleteToNextSubwordEnd,
|
||||||
DeleteToPreviousWordStart,
|
DeleteToNextWordEnd,
|
||||||
DuplicateLine,
|
DeleteToPreviousSubwordStart,
|
||||||
FindAllReferences,
|
DeleteToPreviousWordStart,
|
||||||
Fold,
|
DuplicateLine,
|
||||||
FoldSelectedRanges,
|
FindAllReferences,
|
||||||
Format,
|
Fold,
|
||||||
GoToDefinition,
|
FoldSelectedRanges,
|
||||||
GoToDefinitionSplit,
|
Format,
|
||||||
GoToDiagnostic,
|
GoToDefinition,
|
||||||
GoToHunk,
|
GoToDefinitionSplit,
|
||||||
GoToPrevDiagnostic,
|
GoToDiagnostic,
|
||||||
GoToPrevHunk,
|
GoToHunk,
|
||||||
GoToTypeDefinition,
|
GoToPrevDiagnostic,
|
||||||
GoToTypeDefinitionSplit,
|
GoToPrevHunk,
|
||||||
HalfPageDown,
|
GoToTypeDefinition,
|
||||||
HalfPageUp,
|
GoToTypeDefinitionSplit,
|
||||||
Hover,
|
HalfPageDown,
|
||||||
Indent,
|
HalfPageUp,
|
||||||
JoinLines,
|
Hover,
|
||||||
LineDown,
|
Indent,
|
||||||
LineUp,
|
JoinLines,
|
||||||
MoveDown,
|
LineDown,
|
||||||
MoveLeft,
|
LineUp,
|
||||||
MoveLineDown,
|
MoveDown,
|
||||||
MoveLineUp,
|
MoveLeft,
|
||||||
MoveRight,
|
MoveLineDown,
|
||||||
MoveToBeginning,
|
MoveLineUp,
|
||||||
MoveToBeginningOfLine,
|
MoveRight,
|
||||||
MoveToEnclosingBracket,
|
MoveToBeginning,
|
||||||
MoveToEnd,
|
MoveToBeginningOfLine,
|
||||||
MoveToEndOfLine,
|
MoveToEnclosingBracket,
|
||||||
MoveToEndOfParagraph,
|
MoveToEnd,
|
||||||
MoveToNextSubwordEnd,
|
MoveToEndOfLine,
|
||||||
MoveToNextWordEnd,
|
MoveToEndOfParagraph,
|
||||||
MoveToPreviousSubwordStart,
|
MoveToNextSubwordEnd,
|
||||||
MoveToPreviousWordStart,
|
MoveToNextWordEnd,
|
||||||
MoveToStartOfParagraph,
|
MoveToPreviousSubwordStart,
|
||||||
MoveUp,
|
MoveToPreviousWordStart,
|
||||||
Newline,
|
MoveToStartOfParagraph,
|
||||||
NewlineAbove,
|
MoveUp,
|
||||||
NewlineBelow,
|
Newline,
|
||||||
NextScreen,
|
NewlineAbove,
|
||||||
OpenExcerpts,
|
NewlineBelow,
|
||||||
Outdent,
|
NextScreen,
|
||||||
PageDown,
|
OpenExcerpts,
|
||||||
PageUp,
|
Outdent,
|
||||||
Paste,
|
PageDown,
|
||||||
Redo,
|
PageUp,
|
||||||
RedoSelection,
|
Paste,
|
||||||
Rename,
|
Redo,
|
||||||
RestartLanguageServer,
|
RedoSelection,
|
||||||
RevealInFinder,
|
Rename,
|
||||||
ReverseLines,
|
RestartLanguageServer,
|
||||||
ScrollCursorBottom,
|
RevealInFinder,
|
||||||
ScrollCursorCenter,
|
ReverseLines,
|
||||||
ScrollCursorTop,
|
ScrollCursorBottom,
|
||||||
SelectAll,
|
ScrollCursorCenter,
|
||||||
SelectDown,
|
ScrollCursorTop,
|
||||||
SelectLargerSyntaxNode,
|
SelectAll,
|
||||||
SelectLeft,
|
SelectDown,
|
||||||
SelectLine,
|
SelectLargerSyntaxNode,
|
||||||
SelectRight,
|
SelectLeft,
|
||||||
SelectSmallerSyntaxNode,
|
SelectLine,
|
||||||
SelectToBeginning,
|
SelectRight,
|
||||||
SelectToEnd,
|
SelectSmallerSyntaxNode,
|
||||||
SelectToEndOfParagraph,
|
SelectToBeginning,
|
||||||
SelectToNextSubwordEnd,
|
SelectToEnd,
|
||||||
SelectToNextWordEnd,
|
SelectToEndOfParagraph,
|
||||||
SelectToPreviousSubwordStart,
|
SelectToNextSubwordEnd,
|
||||||
SelectToPreviousWordStart,
|
SelectToNextWordEnd,
|
||||||
SelectToStartOfParagraph,
|
SelectToPreviousSubwordStart,
|
||||||
SelectUp,
|
SelectToPreviousWordStart,
|
||||||
ShowCharacterPalette,
|
SelectToStartOfParagraph,
|
||||||
ShowCompletions,
|
SelectUp,
|
||||||
ShuffleLines,
|
ShowCharacterPalette,
|
||||||
SortLinesCaseInsensitive,
|
ShowCompletions,
|
||||||
SortLinesCaseSensitive,
|
ShuffleLines,
|
||||||
SplitSelectionIntoLines,
|
SortLinesCaseInsensitive,
|
||||||
Tab,
|
SortLinesCaseSensitive,
|
||||||
TabPrev,
|
SplitSelectionIntoLines,
|
||||||
ToggleInlayHints,
|
Tab,
|
||||||
ToggleSoftWrap,
|
TabPrev,
|
||||||
Transpose,
|
ToggleInlayHints,
|
||||||
Undo,
|
ToggleSoftWrap,
|
||||||
UndoSelection,
|
Transpose,
|
||||||
UnfoldLines,
|
Undo,
|
||||||
|
UndoSelection,
|
||||||
|
UnfoldLines,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
enum DocumentHighlightRead {}
|
enum DocumentHighlightRead {}
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub const MIN_POPOVER_CHARACTER_WIDTH: f32 = 20.;
|
||||||
pub const MIN_POPOVER_LINE_HEIGHT: Pixels = px(4.);
|
pub const MIN_POPOVER_LINE_HEIGHT: Pixels = px(4.);
|
||||||
pub const HOVER_POPOVER_GAP: Pixels = px(10.);
|
pub const HOVER_POPOVER_GAP: Pixels = px(10.);
|
||||||
|
|
||||||
actions!(Hover);
|
actions!(editor, [Hover]);
|
||||||
|
|
||||||
/// Bindable action which uses the most recent selection head to trigger a hover
|
/// Bindable action which uses the most recent selection head to trigger a hover
|
||||||
pub fn hover(editor: &mut Editor, _: &Hover, cx: &mut ViewContext<Editor>) {
|
pub fn hover(editor: &mut Editor, _: &Hover, cx: &mut ViewContext<Editor>) {
|
||||||
|
|
|
@ -5,15 +5,18 @@ use workspace::Workspace;
|
||||||
pub mod deploy_feedback_button;
|
pub mod deploy_feedback_button;
|
||||||
pub mod feedback_modal;
|
pub mod feedback_modal;
|
||||||
|
|
||||||
actions!(GiveFeedback, SubmitFeedback);
|
actions!(feedback, [GiveFeedback, SubmitFeedback]);
|
||||||
|
|
||||||
mod system_specs;
|
mod system_specs;
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
CopySystemSpecsIntoClipboard,
|
zed,
|
||||||
FileBugReport,
|
[
|
||||||
RequestFeature,
|
CopySystemSpecsIntoClipboard,
|
||||||
OpenZedCommunityRepo
|
FileBugReport,
|
||||||
|
RequestFeature,
|
||||||
|
OpenZedCommunityRepo
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use ui::{prelude::*, HighlightedLabel, ListItem};
|
||||||
use util::{paths::PathLikeWithPosition, post_inc, ResultExt};
|
use util::{paths::PathLikeWithPosition, post_inc, ResultExt};
|
||||||
use workspace::{ModalView, Workspace};
|
use workspace::{ModalView, Workspace};
|
||||||
|
|
||||||
actions!(Toggle);
|
actions!(file_finder, [Toggle]);
|
||||||
|
|
||||||
impl ModalView for FileFinder {}
|
impl ModalView for FileFinder {}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use ui::{h_stack, prelude::*, v_stack, Label};
|
||||||
use util::paths::FILE_ROW_COLUMN_DELIMITER;
|
use util::paths::FILE_ROW_COLUMN_DELIMITER;
|
||||||
use workspace::ModalView;
|
use workspace::ModalView;
|
||||||
|
|
||||||
actions!(Toggle);
|
actions!(go_to_line, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(GoToLine::register).detach();
|
cx.observe_new_views(GoToLine::register).detach();
|
||||||
|
|
|
@ -22,7 +22,7 @@ Actions are frequently unit structs, for which we have a macro. The above could
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
mod menu {
|
mod menu {
|
||||||
actions!(MoveUp, MoveDown);
|
actions!(gpui, [MoveUp, MoveDown]);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -158,17 +158,65 @@ impl ActionRegistry {
|
||||||
/// To use more complex data types as actions, annotate your type with the #[action] macro.
|
/// To use more complex data types as actions, annotate your type with the #[action] macro.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! actions {
|
macro_rules! actions {
|
||||||
() => {};
|
($namespace:path, [ $($name:ident),* $(,)? ]) => {
|
||||||
|
$(
|
||||||
|
#[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, gpui::serde_derive::Deserialize)]
|
||||||
|
#[serde(crate = "gpui::serde")]
|
||||||
|
#[gpui::register_action]
|
||||||
|
pub struct $name;
|
||||||
|
|
||||||
( $name:ident ) => {
|
gpui::__impl_action!($namespace, $name,
|
||||||
#[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, gpui::serde_derive::Deserialize, gpui::Action)]
|
fn build(_: gpui::serde_json::Value) -> gpui::Result<::std::boxed::Box<dyn gpui::Action>> {
|
||||||
#[serde(crate = "gpui::serde")]
|
Ok(Box::new(Self))
|
||||||
pub struct $name;
|
}
|
||||||
|
);
|
||||||
|
)*
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
( $name:ident, $($rest:tt)* ) => {
|
#[doc(hidden)]
|
||||||
actions!($name);
|
#[macro_export]
|
||||||
actions!($($rest)*);
|
macro_rules! __impl_action {
|
||||||
|
($namespace:path, $name:ident, $build:item) => {
|
||||||
|
impl gpui::Action for $name {
|
||||||
|
fn name(&self) -> &'static str
|
||||||
|
{
|
||||||
|
concat!(
|
||||||
|
stringify!($namespace),
|
||||||
|
"::",
|
||||||
|
stringify!($name),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo!() why is this needed in addition to name?
|
||||||
|
fn debug_name() -> &'static str
|
||||||
|
where
|
||||||
|
Self: ::std::marker::Sized
|
||||||
|
{
|
||||||
|
concat!(
|
||||||
|
stringify!($namespace),
|
||||||
|
"::",
|
||||||
|
stringify!($name),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
$build
|
||||||
|
|
||||||
|
fn partial_eq(&self, action: &dyn gpui::Action) -> bool {
|
||||||
|
action
|
||||||
|
.as_any()
|
||||||
|
.downcast_ref::<Self>()
|
||||||
|
.map_or(false, |a| self == a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn boxed_clone(&self) -> std::boxed::Box<dyn gpui::Action> {
|
||||||
|
::std::boxed::Box::new(self.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_any(&self) -> &dyn ::std::any::Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,5 +234,5 @@ pub fn remove_the_2(action_name: &str) -> String {
|
||||||
mod no_action {
|
mod no_action {
|
||||||
use crate as gpui;
|
use crate as gpui;
|
||||||
|
|
||||||
actions!(NoAction);
|
actions!(zed, [NoAction]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ mod test {
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(TestAction);
|
actions!(test, [TestAction]);
|
||||||
|
|
||||||
impl Render for TestView {
|
impl Render for TestView {
|
||||||
type Element = Stateful<Div>;
|
type Element = Stateful<Div>;
|
||||||
|
|
|
@ -293,11 +293,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_actions_definition() {
|
fn test_actions_definition() {
|
||||||
{
|
{
|
||||||
actions!(A, B, C, D, E, F, G);
|
actions!(test, [A, B, C, D, E, F, G]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
actions!(
|
actions!(
|
||||||
|
test,
|
||||||
|
[
|
||||||
A,
|
A,
|
||||||
B,
|
B,
|
||||||
C,
|
C,
|
||||||
|
@ -305,6 +307,7 @@ mod tests {
|
||||||
E,
|
E,
|
||||||
F,
|
F,
|
||||||
G, // Don't wrap, test the trailing comma
|
G, // Don't wrap, test the trailing comma
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn #action_builder_fn_name() -> gpui::ActionData {
|
fn #action_builder_fn_name() -> gpui::ActionData {
|
||||||
gpui::ActionData {
|
gpui::ActionData {
|
||||||
name: ::std::any::type_name::<#type_name>(),
|
name: <#type_name as gpui::Action>::debug_name(),
|
||||||
type_id: ::std::any::TypeId::of::<#type_name>(),
|
type_id: ::std::any::TypeId::of::<#type_name>(),
|
||||||
build: <#type_name as gpui::Action>::build,
|
build: <#type_name as gpui::Action>::build,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use gpui::{actions, AsyncAppContext};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
actions!(Install);
|
actions!(cli, [Install]);
|
||||||
|
|
||||||
pub async fn install_cli(cx: &AsyncAppContext) -> Result<()> {
|
pub async fn install_cli(cx: &AsyncAppContext) -> Result<()> {
|
||||||
let cli_path = cx.update(|cx| cx.path_for_auxiliary_executable("cli"))??;
|
let cli_path = cx.update(|cx| cx.path_for_auxiliary_executable("cli"))??;
|
||||||
|
|
|
@ -16,7 +16,7 @@ use ui::{prelude::*, HighlightedLabel, ListItem};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{ModalView, Workspace};
|
use workspace::{ModalView, Workspace};
|
||||||
|
|
||||||
actions!(Toggle);
|
actions!(language_selector, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(LanguageSelector::register).detach();
|
cx.observe_new_views(LanguageSelector::register).detach();
|
||||||
|
|
|
@ -10,12 +10,15 @@ use gpui::actions;
|
||||||
pub fn init() {}
|
pub fn init() {}
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
Cancel,
|
menu,
|
||||||
Confirm,
|
[
|
||||||
SecondaryConfirm,
|
Cancel,
|
||||||
SelectPrev,
|
Confirm,
|
||||||
SelectNext,
|
SecondaryConfirm,
|
||||||
SelectFirst,
|
SelectPrev,
|
||||||
SelectLast,
|
SelectNext,
|
||||||
ShowContextMenu
|
SelectFirst,
|
||||||
|
SelectLast,
|
||||||
|
ShowContextMenu
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,7 +22,7 @@ use ui::{prelude::*, ListItem};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{ModalView, Workspace};
|
use workspace::{ModalView, Workspace};
|
||||||
|
|
||||||
actions!(Toggle);
|
actions!(outline, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(OutlineView::register).detach();
|
cx.observe_new_views(OutlineView::register).detach();
|
||||||
|
|
|
@ -103,23 +103,26 @@ pub struct EntryDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
ExpandSelectedEntry,
|
project_panel,
|
||||||
CollapseSelectedEntry,
|
[
|
||||||
CollapseAllEntries,
|
ExpandSelectedEntry,
|
||||||
NewDirectory,
|
CollapseSelectedEntry,
|
||||||
NewFile,
|
CollapseAllEntries,
|
||||||
Copy,
|
NewDirectory,
|
||||||
CopyPath,
|
NewFile,
|
||||||
CopyRelativePath,
|
Copy,
|
||||||
RevealInFinder,
|
CopyPath,
|
||||||
OpenInTerminal,
|
CopyRelativePath,
|
||||||
Cut,
|
RevealInFinder,
|
||||||
Paste,
|
OpenInTerminal,
|
||||||
Delete,
|
Cut,
|
||||||
Rename,
|
Paste,
|
||||||
Open,
|
Delete,
|
||||||
ToggleFocus,
|
Rename,
|
||||||
NewSearchInDirectory,
|
Open,
|
||||||
|
ToggleFocus,
|
||||||
|
NewSearchInDirectory,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn init_settings(cx: &mut AppContext) {
|
pub fn init_settings(cx: &mut AppContext) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
gpui::actions!(OpenRecent);
|
gpui::actions!(projects, [OpenRecent]);
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub struct Deploy {
|
||||||
pub focus: bool,
|
pub focus: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(Dismiss, FocusEditor);
|
actions!(buffer_search, [Dismiss, FocusEditor]);
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
UpdateLocation,
|
UpdateLocation,
|
||||||
|
|
|
@ -22,20 +22,23 @@ pub fn init(cx: &mut AppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
CycleMode,
|
search,
|
||||||
ToggleWholeWord,
|
[
|
||||||
ToggleCaseSensitive,
|
CycleMode,
|
||||||
ToggleReplace,
|
ToggleWholeWord,
|
||||||
SelectNextMatch,
|
ToggleCaseSensitive,
|
||||||
SelectPrevMatch,
|
ToggleReplace,
|
||||||
SelectAllMatches,
|
SelectNextMatch,
|
||||||
NextHistoryQuery,
|
SelectPrevMatch,
|
||||||
PreviousHistoryQuery,
|
SelectAllMatches,
|
||||||
ActivateTextMode,
|
NextHistoryQuery,
|
||||||
ActivateSemanticMode,
|
PreviousHistoryQuery,
|
||||||
ActivateRegexMode,
|
ActivateTextMode,
|
||||||
ReplaceAll,
|
ActivateSemanticMode,
|
||||||
ReplaceNext,
|
ActivateRegexMode,
|
||||||
|
ReplaceAll,
|
||||||
|
ReplaceNext,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{settings_store::parse_json_with_comments, SettingsAssets};
|
use crate::{settings_store::parse_json_with_comments, SettingsAssets};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use gpui::{actions, Action, AppContext, KeyBinding, SharedString};
|
use gpui::{Action, AppContext, KeyBinding, SharedString};
|
||||||
use schemars::{
|
use schemars::{
|
||||||
gen::{SchemaGenerator, SchemaSettings},
|
gen::{SchemaGenerator, SchemaSettings},
|
||||||
schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation},
|
schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation},
|
||||||
|
@ -137,10 +137,8 @@ impl KeymapFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actions!(NoAction);
|
|
||||||
|
|
||||||
fn no_action() -> Box<dyn gpui::Action> {
|
fn no_action() -> Box<dyn gpui::Action> {
|
||||||
NoAction.boxed_clone()
|
gpui::NoAction.boxed_clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -4,7 +4,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
|
||||||
actions!(ActionA, ActionB, ActionC);
|
actions!(focus, [ActionA, ActionB, ActionC]);
|
||||||
|
|
||||||
pub struct FocusStory {
|
pub struct FocusStory {
|
||||||
child_1_focus: FocusHandle,
|
child_1_focus: FocusHandle,
|
||||||
|
|
|
@ -59,13 +59,16 @@ use crate::mappings::{colors::to_alac_rgb, keys::to_esc_str};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
Clear,
|
terminal,
|
||||||
Copy,
|
[
|
||||||
Paste,
|
Clear,
|
||||||
ShowCharacterPalette,
|
Copy,
|
||||||
SearchTest,
|
Paste,
|
||||||
SendText,
|
ShowCharacterPalette,
|
||||||
SendKeystroke,
|
SearchTest,
|
||||||
|
SendText,
|
||||||
|
SendKeystroke,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
///Scrolling is unbearably sluggish by default. Alacritty supports a configurable
|
///Scrolling is unbearably sluggish by default. Alacritty supports a configurable
|
||||||
|
|
|
@ -24,7 +24,7 @@ use anyhow::Result;
|
||||||
|
|
||||||
const TERMINAL_PANEL_KEY: &'static str = "TerminalPanel";
|
const TERMINAL_PANEL_KEY: &'static str = "TerminalPanel";
|
||||||
|
|
||||||
actions!(ToggleFocus);
|
actions!(terminal_view, [ToggleFocus]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(
|
cx.observe_new_views(
|
||||||
|
|
|
@ -13,7 +13,7 @@ use ui::{prelude::*, v_stack, ListItem};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{ui::HighlightedLabel, ModalView, Workspace};
|
use workspace::{ui::HighlightedLabel, ModalView, Workspace};
|
||||||
|
|
||||||
actions!(Toggle, Reload);
|
actions!(theme_selector, [Toggle, Reload]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(
|
cx.observe_new_views(
|
||||||
|
|
|
@ -4,7 +4,7 @@ use story::Story;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{right_click_menu, ContextMenu, Label};
|
use crate::{right_click_menu, ContextMenu, Label};
|
||||||
|
|
||||||
actions!(PrintCurrentDate, PrintBestFood);
|
actions!(context_menu, [PrintCurrentDate, PrintBestFood]);
|
||||||
|
|
||||||
fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<ContextMenu> {
|
fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<ContextMenu> {
|
||||||
ContextMenu::build(cx, |menu, _| {
|
ContextMenu::build(cx, |menu, _| {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use gpui::{actions, Div, Render};
|
use gpui::NoAction;
|
||||||
|
use gpui::{Div, Render};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use story::Story;
|
use story::Story;
|
||||||
|
|
||||||
|
@ -7,8 +8,6 @@ use crate::KeyBinding;
|
||||||
|
|
||||||
pub struct KeybindingStory;
|
pub struct KeybindingStory;
|
||||||
|
|
||||||
actions!(NoAction);
|
|
||||||
|
|
||||||
pub fn binding(key: &str) -> gpui::KeyBinding {
|
pub fn binding(key: &str) -> gpui::KeyBinding {
|
||||||
gpui::KeyBinding::new(key, NoAction {}, None)
|
gpui::KeyBinding::new(key, NoAction {}, None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use ui::{prelude::*, ListItem};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{ui::HighlightedLabel, ModalView, Workspace};
|
use workspace::{ui::HighlightedLabel, ModalView, Workspace};
|
||||||
|
|
||||||
actions!(ToggleBaseKeymapSelector);
|
actions!(welcome, [ToggleBaseKeymapSelector]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
||||||
|
|
|
@ -770,7 +770,7 @@ pub mod test {
|
||||||
pub focus_handle: FocusHandle,
|
pub focus_handle: FocusHandle,
|
||||||
pub size: f32,
|
pub size: f32,
|
||||||
}
|
}
|
||||||
actions!(ToggleTestPanel);
|
actions!(test, [ToggleTestPanel]);
|
||||||
|
|
||||||
impl EventEmitter<PanelEvent> for TestPanel {}
|
impl EventEmitter<PanelEvent> for TestPanel {}
|
||||||
|
|
||||||
|
|
|
@ -87,22 +87,24 @@ pub struct CloseAllItems {
|
||||||
pub save_intent: Option<SaveIntent>,
|
pub save_intent: Option<SaveIntent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!(These used to be under pane::{Action}. Are they now workspace::pane::{Action}?)
|
|
||||||
actions!(
|
actions!(
|
||||||
ActivatePrevItem,
|
pane,
|
||||||
ActivateNextItem,
|
[
|
||||||
ActivateLastItem,
|
ActivatePrevItem,
|
||||||
CloseInactiveItems,
|
ActivateNextItem,
|
||||||
CloseCleanItems,
|
ActivateLastItem,
|
||||||
CloseItemsToTheLeft,
|
CloseInactiveItems,
|
||||||
CloseItemsToTheRight,
|
CloseCleanItems,
|
||||||
GoBack,
|
CloseItemsToTheLeft,
|
||||||
GoForward,
|
CloseItemsToTheRight,
|
||||||
ReopenClosedItem,
|
GoBack,
|
||||||
SplitLeft,
|
GoForward,
|
||||||
SplitUp,
|
ReopenClosedItem,
|
||||||
SplitRight,
|
SplitLeft,
|
||||||
SplitDown,
|
SplitUp,
|
||||||
|
SplitRight,
|
||||||
|
SplitDown,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
const MAX_NAVIGATION_HISTORY_LEN: usize = 1024;
|
const MAX_NAVIGATION_HISTORY_LEN: usize = 1024;
|
||||||
|
|
|
@ -91,30 +91,33 @@ lazy_static! {
|
||||||
pub struct RemoveWorktreeFromProject(pub WorktreeId);
|
pub struct RemoveWorktreeFromProject(pub WorktreeId);
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
Open,
|
workspace,
|
||||||
NewFile,
|
[
|
||||||
NewWindow,
|
Open,
|
||||||
CloseWindow,
|
NewFile,
|
||||||
CloseInactiveTabsAndPanes,
|
NewWindow,
|
||||||
AddFolderToProject,
|
CloseWindow,
|
||||||
Unfollow,
|
CloseInactiveTabsAndPanes,
|
||||||
SaveAs,
|
AddFolderToProject,
|
||||||
ReloadActiveItem,
|
Unfollow,
|
||||||
ActivatePreviousPane,
|
SaveAs,
|
||||||
ActivateNextPane,
|
ReloadActiveItem,
|
||||||
FollowNextCollaborator,
|
ActivatePreviousPane,
|
||||||
NewTerminal,
|
ActivateNextPane,
|
||||||
NewCenterTerminal,
|
FollowNextCollaborator,
|
||||||
ToggleTerminalFocus,
|
NewTerminal,
|
||||||
NewSearch,
|
NewCenterTerminal,
|
||||||
Feedback,
|
ToggleTerminalFocus,
|
||||||
Restart,
|
NewSearch,
|
||||||
Welcome,
|
Feedback,
|
||||||
ToggleZoom,
|
Restart,
|
||||||
ToggleLeftDock,
|
Welcome,
|
||||||
ToggleRightDock,
|
ToggleZoom,
|
||||||
ToggleBottomDock,
|
ToggleLeftDock,
|
||||||
CloseAllDocks,
|
ToggleRightDock,
|
||||||
|
ToggleBottomDock,
|
||||||
|
CloseAllDocks,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
|
|
|
@ -43,27 +43,30 @@ use workspace::{
|
||||||
use zed_actions::{OpenBrowser, OpenZedURL};
|
use zed_actions::{OpenBrowser, OpenZedURL};
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
About,
|
zed,
|
||||||
DebugElements,
|
[
|
||||||
DecreaseBufferFontSize,
|
About,
|
||||||
Hide,
|
DebugElements,
|
||||||
HideOthers,
|
DecreaseBufferFontSize,
|
||||||
IncreaseBufferFontSize,
|
Hide,
|
||||||
Minimize,
|
HideOthers,
|
||||||
OpenDefaultKeymap,
|
IncreaseBufferFontSize,
|
||||||
OpenDefaultSettings,
|
Minimize,
|
||||||
OpenKeymap,
|
OpenDefaultKeymap,
|
||||||
OpenLicenses,
|
OpenDefaultSettings,
|
||||||
OpenLocalSettings,
|
OpenKeymap,
|
||||||
OpenLog,
|
OpenLicenses,
|
||||||
OpenSettings,
|
OpenLocalSettings,
|
||||||
OpenTelemetryLog,
|
OpenLog,
|
||||||
Quit,
|
OpenSettings,
|
||||||
ResetBufferFontSize,
|
OpenTelemetryLog,
|
||||||
ResetDatabase,
|
Quit,
|
||||||
ShowAll,
|
ResetBufferFontSize,
|
||||||
ToggleFullScreen,
|
ResetDatabase,
|
||||||
Zoom,
|
ShowAll,
|
||||||
|
ToggleFullScreen,
|
||||||
|
Zoom,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn build_window_options(
|
pub fn build_window_options(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue