Deploy FindBar when hitting cmd-f

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Antonio Scandurra
2022-01-27 17:56:50 +01:00
co-authored by Nathan Sobo Max Brunsfeld
parent e7d4c385d5
commit bebde782fa
6 changed files with 99 additions and 2 deletions
+45
View File
@@ -0,0 +1,45 @@
use gpui::{
action, color::Color, elements::*, keymap::Binding, Entity, MutableAppContext, RenderContext,
View, ViewContext,
};
use workspace::Workspace;
action!(Deploy);
pub fn init(cx: &mut MutableAppContext) {
cx.add_bindings([Binding::new(
"cmd-f",
Deploy,
Some("Editor && mode == full"),
)]);
cx.add_action(FindBar::deploy);
}
struct FindBar;
impl Entity for FindBar {
type Event = ();
}
impl View for FindBar {
fn ui_name() -> &'static str {
"FindBar"
}
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
Empty::new()
.contained()
.with_background_color(Color::red())
.constrained()
.with_height(30.)
.boxed()
}
}
impl FindBar {
fn deploy(workspace: &mut Workspace, _: &Deploy, cx: &mut ViewContext<Workspace>) {
workspace
.active_pane()
.update(cx, |pane, cx| pane.show_toolbar(cx, |_| FindBar));
}
}