gpuikit/lib.rs
1//! gpuikit
2//!
3//! A comprehensive UI component library for GPUI applications.
4//!
5//! # Quick Start
6//!
7//! ```ignore
8//! use gpui::Application;
9//! use gpuikit::init;
10//!
11//! fn main() {
12//! Application::new()
13//! .with_assets(gpuikit::assets())
14//! .run(|cx| {
15//! init(cx);
16//! // ... your app code
17//! });
18//! }
19//! ```
20//!
21//! # Feature Flags
22//!
23//! - `editor` - Enables the editor component with syntax highlighting support
24
25use gpui::App;
26use rust_embed::RustEmbed;
27
28// Core modules
29pub mod elements;
30pub mod error;
31pub mod fs;
32pub mod icons;
33pub mod keymap;
34pub mod layout;
35pub mod markdown;
36pub mod resource;
37pub mod theme;
38pub mod traits;
39pub mod utils;
40
41// Feature-gated editor module
42#[cfg(feature = "editor")]
43pub mod editor;
44
45pub use icons::Icons as DefaultIcons;
46
47/// Embedded assets for gpuikit (icons, fonts, etc.)
48#[derive(RustEmbed)]
49#[folder = "assets"]
50pub struct Assets;
51
52/// Returns the gpuikit asset source for use with `Application::new().with_assets()`.
53///
54/// # Example
55/// ```ignore
56/// Application::new()
57/// .with_assets(gpuikit::assets())
58/// .run(|cx| {
59/// gpuikit::init(cx);
60/// // ...
61/// });
62/// ```
63pub fn assets() -> resource::ResourceSource<Assets> {
64 resource::ResourceSource::new()
65}
66
67/// Initialize gpuikit - sets up themes and global state.
68///
69/// This must be called as soon as possible after your `gpui::Application` is created.
70/// Make sure to also call `.with_assets(gpuikit::Assets)` on your Application.
71///
72/// # Panics
73/// Calling a gpuikit component before initialization will panic.
74pub fn init(cx: &mut App) {
75 theme::init(cx);
76 utils::element_manager::init(cx);
77}