Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Add hello world example (#6465)

Sean Aye5fcc75be1fe6
diff --git a/crates/gpui/examples/hello_world.rs b/crates/gpui/examples/hello_world.rs
new file mode 100644
index 00000000000..736fd144502
--- /dev/null
+++ b/crates/gpui/examples/hello_world.rs
@@ -0,0 +1,29 @@
+use gpui::*;
+
+struct HelloWorld {
+ text: SharedString,
+}
+
+impl Render for HelloWorld {
+ fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
+ div()
+ .flex()
+ .bg(rgb(0x2e7d32))
+ .size_full()
+ .justify_center()
+ .items_center()
+ .text_xl()
+ .text_color(rgb(0xffffff))
+ .child(format!("Hello, {}!", &self.text))
+ }
+}
+
+fn main() {
+ App::new().run(|cx: &mut AppContext| {
+ cx.open_window(WindowOptions::default(), |cx| {
+ cx.new_view(|_cx| HelloWorld {
+ text: "World".into(),
+ })
+ });
+ });
+}