gpui hello world
This commit is contained in:
parent
603dc124dd
commit
1cc652384e
4996
Cargo.lock
generated
4996
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -6,3 +6,4 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
gpui = { git = "https://github.com/zed-industries/zed", tag = "v0.129.2" }
|
||||||
|
|
24
flake.nix
24
flake.nix
|
@ -10,13 +10,14 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, fenix, nixpkgs }:
|
outputs = { self, fenix, nixpkgs }:
|
||||||
let
|
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
|
||||||
in {
|
in {
|
||||||
devShell.x86_64-linux = with pkgs;
|
devShell.x86_64-linux = with pkgs;
|
||||||
mkShell {
|
mkShell {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
just
|
just
|
||||||
|
pkg-config
|
||||||
|
protobuf
|
||||||
(fenix.packages.x86_64-linux.fromToolchainFile {
|
(fenix.packages.x86_64-linux.fromToolchainFile {
|
||||||
dir = ./.;
|
dir = ./.;
|
||||||
sha256 = "sha256-3St/9/UKo/6lz2Kfq2VmlzHyufduALpiIKaaKX4Pq0g=";
|
sha256 = "sha256-3St/9/UKo/6lz2Kfq2VmlzHyufduALpiIKaaKX4Pq0g=";
|
||||||
|
@ -24,7 +25,26 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
curl
|
||||||
|
fontconfig
|
||||||
|
freetype
|
||||||
|
libgit2
|
||||||
|
openssl
|
||||||
|
sqlite
|
||||||
|
zlib
|
||||||
|
zstd
|
||||||
|
vulkan-loader
|
||||||
|
] ++ lib.optionals stdenv.isLinux [
|
||||||
|
alsa-lib
|
||||||
|
libxkbcommon
|
||||||
|
wayland
|
||||||
|
xorg.libxcb
|
||||||
];
|
];
|
||||||
|
|
||||||
|
env = {
|
||||||
|
WAYLAND_DISPLAY = ""; # Window has nor decoration on Wayland
|
||||||
|
LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [ vulkan-loader ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
||||||
|
|
5
justfile
5
justfile
|
@ -4,4 +4,7 @@ build:
|
||||||
|
|
||||||
alias r := run
|
alias r := run
|
||||||
run:
|
run:
|
||||||
cargo run
|
nixVulkanIntel cargo run
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
nix fmt flake.nix
|
||||||
|
|
40
src/main.rs
40
src/main.rs
|
@ -1,3 +1,39 @@
|
||||||
fn main() {
|
use gpui::*;
|
||||||
println!("Hello, world!");
|
|
||||||
|
struct HelloWorld {
|
||||||
|
text: SharedString,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Render for HelloWorld {
|
||||||
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||||
|
div()
|
||||||
|
.flex()
|
||||||
|
.bg(rgb(0x2e7d32))
|
||||||
|
.size(Length::Definite(Pixels(300.0).into()))
|
||||||
|
.justify_center()
|
||||||
|
.items_center()
|
||||||
|
.shadow_lg()
|
||||||
|
.border()
|
||||||
|
.border_color(rgb(0x0000ff))
|
||||||
|
.text_xl()
|
||||||
|
.text_color(rgb(0xffffff))
|
||||||
|
.child(format!("Hello, {}!", &self.text))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
App::new().run(|cx: &mut AppContext| {
|
||||||
|
let bounds = Bounds::centered(None, size(px(600.0), px(600.0)), cx);
|
||||||
|
cx.open_window(
|
||||||
|
WindowOptions {
|
||||||
|
bounds: Some(bounds),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
|cx| {
|
||||||
|
cx.new_view(|_cx| HelloWorld {
|
||||||
|
text: "World".into(),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue