Restructure action macro to assign a namespace to every action
Also, allow arbitrary types to be used as Actions via the impl_actions macro Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
Keith Simmons
parent
206b0f0f8c
commit
5242a3a6dc
@@ -2,7 +2,7 @@ use crate::{active_match_index, match_index_for_direction, Direction, SearchOpti
|
||||
use collections::HashMap;
|
||||
use editor::{display_map::ToDisplayPoint, Anchor, Autoscroll, Bias, Editor};
|
||||
use gpui::{
|
||||
action, elements::*, keymap::Binding, platform::CursorStyle, AppContext, Entity,
|
||||
actions, elements::*, impl_actions, keymap::Binding, platform::CursorStyle, AppContext, Entity,
|
||||
MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
|
||||
WeakViewHandle,
|
||||
};
|
||||
@@ -12,10 +12,14 @@ use settings::Settings;
|
||||
use std::ops::Range;
|
||||
use workspace::{ItemHandle, Pane, ToolbarItemLocation, ToolbarItemView};
|
||||
|
||||
action!(Deploy, bool);
|
||||
action!(Dismiss);
|
||||
action!(FocusEditor);
|
||||
action!(ToggleSearchOption, SearchOption);
|
||||
#[derive(Clone)]
|
||||
pub struct Deploy(pub bool);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ToggleSearchOption(pub SearchOption);
|
||||
|
||||
actions!(buffer_search, [Dismiss, FocusEditor]);
|
||||
impl_actions!(buffer_search, [Deploy, ToggleSearchOption]);
|
||||
|
||||
pub enum Event {
|
||||
UpdateLocation,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
use collections::HashMap;
|
||||
use editor::{Anchor, Autoscroll, Editor, MultiBuffer, SelectAll};
|
||||
use gpui::{
|
||||
action, elements::*, keymap::Binding, platform::CursorStyle, AppContext, ElementBox, Entity,
|
||||
actions, elements::*, keymap::Binding, platform::CursorStyle, AppContext, ElementBox, Entity,
|
||||
ModelContext, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View,
|
||||
ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
|
||||
};
|
||||
@@ -19,10 +19,7 @@ use std::{
|
||||
use util::ResultExt as _;
|
||||
use workspace::{Item, ItemNavHistory, Pane, ToolbarItemLocation, ToolbarItemView, Workspace};
|
||||
|
||||
action!(Deploy);
|
||||
action!(Search);
|
||||
action!(SearchInNew);
|
||||
action!(ToggleFocus);
|
||||
actions!(project_search, [Deploy, Search, SearchInNew, ToggleFocus]);
|
||||
|
||||
const MAX_TAB_TITLE_LEN: usize = 24;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub use buffer_search::BufferSearchBar;
|
||||
use editor::{Anchor, MultiBufferSnapshot};
|
||||
use gpui::{action, MutableAppContext};
|
||||
use gpui::{impl_actions, MutableAppContext};
|
||||
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
||||
use std::{
|
||||
cmp::{self, Ordering},
|
||||
@@ -15,8 +15,13 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||
project_search::init(cx);
|
||||
}
|
||||
|
||||
action!(ToggleSearchOption, SearchOption);
|
||||
action!(SelectMatch, Direction);
|
||||
#[derive(Clone)]
|
||||
pub struct ToggleSearchOption(pub SearchOption);
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SelectMatch(pub Direction);
|
||||
|
||||
impl_actions!(search, [ToggleSearchOption, SelectMatch]);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum SearchOption {
|
||||
|
||||
Reference in New Issue
Block a user