Mainline GPUI2 UI work (#3079)
This PR mainlines the current state of new GPUI2-based UI from the `gpui2-ui` branch. Release Notes: - N/A --------- Co-authored-by: Nate Butler <iamnbutler@gmail.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Nate <nate@zed.dev>
This commit is contained in:
parent
08361eb84e
commit
9e1f7c4c18
39 changed files with 1047 additions and 399 deletions
|
@ -4,7 +4,7 @@ mod stories;
|
|||
mod story;
|
||||
mod story_selector;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::{process::Command, sync::Arc};
|
||||
|
||||
use ::theme as legacy_theme;
|
||||
use clap::Parser;
|
||||
|
@ -38,11 +38,44 @@ struct Args {
|
|||
theme: Option<String>,
|
||||
}
|
||||
|
||||
async fn watch_zed_changes(fs: Arc<dyn fs::Fs>) -> Option<()> {
|
||||
if std::env::var("ZED_HOT_RELOAD").is_err() {
|
||||
return None;
|
||||
}
|
||||
use futures::StreamExt;
|
||||
let mut events = fs
|
||||
.watch(".".as_ref(), std::time::Duration::from_millis(100))
|
||||
.await;
|
||||
let mut current_child: Option<std::process::Child> = None;
|
||||
while let Some(events) = events.next().await {
|
||||
if !events.iter().any(|event| {
|
||||
event
|
||||
.path
|
||||
.to_str()
|
||||
.map(|path| path.contains("/crates/"))
|
||||
.unwrap_or_default()
|
||||
}) {
|
||||
continue;
|
||||
}
|
||||
let child = current_child.take().map(|mut child| child.kill());
|
||||
log::info!("Storybook changed, rebuilding...");
|
||||
current_child = Some(
|
||||
Command::new("cargo")
|
||||
.args(["run", "-p", "storybook"])
|
||||
.spawn()
|
||||
.ok()?,
|
||||
);
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
|
||||
|
||||
let args = Args::parse();
|
||||
|
||||
let fs = Arc::new(fs::RealFs);
|
||||
|
||||
gpui2::App::new(Assets).unwrap().run(move |cx| {
|
||||
let mut store = SettingsStore::default();
|
||||
store
|
||||
|
@ -63,6 +96,10 @@ fn main() {
|
|||
})
|
||||
.and_then(|theme_name| theme_registry.get(&theme_name).ok());
|
||||
|
||||
cx.spawn(|_| async move {
|
||||
watch_zed_changes(fs).await;
|
||||
})
|
||||
.detach();
|
||||
cx.add_window(
|
||||
gpui2::WindowOptions {
|
||||
bounds: WindowBounds::Fixed(RectF::new(vec2f(0., 0.), vec2f(1700., 980.))),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue