#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
#![allow(clippy::type_complexity)] #![allow(clippy::collapsible_else_if)] #![allow(unused_mut)]
extern crate self as rgpui;
#[doc(hidden)]
pub static GPUI_MANIFEST_DIR: &'static str = env!("CARGO_MANIFEST_DIR");
#[macro_use]
mod action;
mod app;
mod arena;
mod asset_cache;
mod assets;
mod bounds_tree;
pub mod collections;
mod color;
#[cfg(feature = "dom-backend")]
mod dom;
pub mod colors;
pub mod theme;
pub mod component_text;
pub use component_text::{ComponentText, ComponentTextViewStyle};
mod element;
mod elements;
mod executor;
mod platform_scheduler;
pub mod refineable;
pub mod scheduler;
pub mod sum_tree;
pub(crate) use platform_scheduler::PlatformScheduler;
mod geometry;
mod gestures;
mod global;
pub mod http_client;
mod input;
mod inspector;
#[cfg(any(feature = "inspector", debug_assertions))]
pub mod inspector_panel;
mod interactive;
mod key_dispatch;
mod keymap;
mod path_builder;
pub mod perf;
mod platform;
pub mod prelude;
pub mod profiler;
#[cfg(any(target_os = "windows", target_os = "linux", target_family = "wasm"))]
pub mod queue;
mod rgpui_util;
mod scene;
mod shared_string;
mod shared_uri;
pub mod single_instance;
mod style;
mod styled;
mod styled_ext;
mod size;
mod subscription;
pub mod runtime_stats;
mod taffy;
#[cfg(any(test, feature = "test-support"))]
pub mod test;
mod text_system;
mod transition;
mod system;
mod root;
mod dialog;
pub mod menu;
mod form;
pub mod input_ui;
mod init;
pub use init::init_all;
pub mod index_path;
pub mod list;
pub mod table;
pub mod tabs;
pub mod title_bar;
pub mod animation;
pub mod components;
#[cfg(feature = "lsp")]
pub mod lsp;
#[cfg(feature = "webview")]
pub mod webview;
pub mod highlight;
pub mod tree;
pub mod mouse_gestures;
pub mod scroll_physics;
pub mod file_watcher;
pub mod config_store;
pub mod chat;
pub mod fps_hud;
pub mod i18n;
pub mod theme_watcher;
pub mod block_render;
pub mod virtual_scroll;
pub mod source_map;
pub mod markdown_ext;
#[cfg(feature = "tokio")]
pub mod tokio;
#[allow(missing_docs)]
pub mod util;
mod view;
mod window;
pub mod window_positioner;
#[cfg(any(test, feature = "test-support"))]
pub use proptest;
#[cfg(doc)]
pub mod _accessibility;
#[cfg(doc)]
pub mod _ownership_and_data_flow;
#[doc(hidden)]
pub mod private {
pub use anyhow;
pub use inventory;
pub use schemars;
pub use serde;
pub use serde_json;
}
mod seal {
pub trait Sealed {}
}
pub use accesskit;
pub use accesskit::Action as AccessibleAction;
pub use accesskit::{Orientation, Role, Toggled};
pub use crate::collections::*;
pub use action::*;
pub use anyhow::Result;
pub use app::*;
pub(crate) use arena::*;
pub use asset_cache::*;
pub use assets::*;
pub use color::*;
#[cfg(feature = "dom-backend")]
pub use dom::*;
#[cfg(not(feature = "dom-backend"))]
pub(crate) type DomNodeKey = ();
pub use theme::color::{ColorName, Colorize, hsl, try_parse_background, try_parse_color};
pub use ctor::ctor;
pub use element::*;
pub use elements::*;
pub use executor::*;
pub use geometry::*;
pub use gestures::*;
pub use global::*;
pub use rgpui_macros::{
AppContext, IntoElement, Render, VisualContext, bench, icon_named, property_test,
register_action, test,
};
pub use system::focus_trap::*;
pub use theme::registry::DEFAULT_THEME_COLORS;
pub use theme::{
ActiveTheme, HighlightTheme, HighlightThemeStyle, ListSettings, NotificationSettings,
ScrollbarShow, SheetSettings, StatusColors, SyntaxColors, TITLE_BAR_HEIGHT, Theme, ThemeColor,
ThemeConfig, ThemeConfigColors, ThemeMode, ThemeRegistry, ThemeSet, ThemeToken, ThemeTokens,
};
pub use theme::{
amber_50, amber_100, amber_200, amber_300, amber_400, amber_500, amber_600, amber_700,
amber_800, amber_900, amber_950, blue_50, blue_100, blue_200, blue_300, blue_400, blue_500,
blue_600, blue_700, blue_800, blue_900, blue_950, cyan_50, cyan_100, cyan_200, cyan_300,
cyan_400, cyan_500, cyan_600, cyan_700, cyan_800, cyan_900, cyan_950, emerald_50, emerald_100,
emerald_200, emerald_300, emerald_400, emerald_500, emerald_600, emerald_700, emerald_800,
emerald_900, emerald_950, fuchsia_50, fuchsia_100, fuchsia_200, fuchsia_300, fuchsia_400,
fuchsia_500, fuchsia_600, fuchsia_700, fuchsia_800, fuchsia_900, fuchsia_950, gray_50,
gray_100, gray_200, gray_300, gray_400, gray_500, gray_600, gray_700, gray_800, gray_900,
gray_950, green_50, green_100, green_200, green_300, green_400, green_500, green_600,
green_700, green_800, green_900, green_950, indigo_50, indigo_100, indigo_200, indigo_300,
indigo_400, indigo_500, indigo_600, indigo_700, indigo_800, indigo_900, indigo_950, lime_50,
lime_100, lime_200, lime_300, lime_400, lime_500, lime_600, lime_700, lime_800, lime_900,
lime_950, neutral_50, neutral_100, neutral_200, neutral_300, neutral_400, neutral_500,
neutral_600, neutral_700, neutral_800, neutral_900, neutral_950, orange_50, orange_100,
orange_200, orange_300, orange_400, orange_500, orange_600, orange_700, orange_800, orange_900,
orange_950, pink_50, pink_100, pink_200, pink_300, pink_400, pink_500, pink_600, pink_700,
pink_800, pink_900, pink_950, purple_50, purple_100, purple_200, purple_300, purple_400,
purple_500, purple_600, purple_700, purple_800, purple_900, purple_950, red_50, red_100,
red_200, red_300, red_400, red_500, red_600, red_700, red_800, red_900, red_950, rose_50,
rose_100, rose_200, rose_300, rose_400, rose_500, rose_600, rose_700, rose_800, rose_900,
rose_950, sky_50, sky_100, sky_200, sky_300, sky_400, sky_500, sky_600, sky_700, sky_800,
sky_900, sky_950, slate_50, slate_100, slate_200, slate_300, slate_400, slate_500, slate_600,
slate_700, slate_800, slate_900, slate_950, stone_50, stone_100, stone_200, stone_300,
stone_400, stone_500, stone_600, stone_700, stone_800, stone_900, stone_950, teal_50, teal_100,
teal_200, teal_300, teal_400, teal_500, teal_600, teal_700, teal_800, teal_900, teal_950,
violet_50, violet_100, violet_200, violet_300, violet_400, violet_500, violet_600, violet_700,
violet_800, violet_900, violet_950, yellow_50, yellow_100, yellow_200, yellow_300, yellow_400,
yellow_500, yellow_600, yellow_700, yellow_800, yellow_900, yellow_950, zinc_50, zinc_100,
zinc_200, zinc_300, zinc_400, zinc_500, zinc_600, zinc_700, zinc_800, zinc_900, zinc_950,
};
#[macro_export]
macro_rules! bench_group {
($($tokens:tt)*) => {
criterion::criterion_group!($($tokens)*);
};
}
#[macro_export]
macro_rules! bench_main {
($($tokens:tt)*) => {
criterion::criterion_main!($($tokens)*);
};
}
pub use rgpui_util::arc_cow::ArcCow;
pub use shared_string::*;
pub use crate::refineable::*;
pub use input::*;
pub use inspector::*;
#[cfg(any(feature = "inspector", debug_assertions))]
pub use inspector_panel::{
InspectorHeaderSlot, InspectorPanelSlots, InspectorSectionSlot, default_inspector_header,
default_inspector_panel, default_inspector_section, render_div_inspector_state,
};
pub use interactive::*;
use key_dispatch::*;
pub use keymap::*;
pub use path_builder::*;
pub use platform::*;
pub use profiler::*;
#[cfg(any(target_os = "windows", target_os = "linux", target_family = "wasm"))]
pub use queue::{PriorityQueueReceiver, PriorityQueueSender};
pub use rgpui_util::{
Deferred as UtilDeferred, ResultExt, TryFutureExt, TryFutureExtBacktrace, defer, log_err,
measure, post_inc, some_or_debug_panic,
};
pub use scene::*;
pub use shared_uri::*;
pub use single_instance::*;
use std::{any::Any, future::Future};
pub use style::*;
pub use styled::*;
pub use styled_ext::*;
pub use transition::*;
pub use dialog::*;
pub use form::*;
pub use index_path::*;
pub use menu::*;
pub use root::*;
pub use runtime_stats::{GpuInfo, gpu_info, set_gpu_info};
pub use size::*;
pub use subscription::*;
pub use system::svg_renderer::*;
pub(crate) use system::tab_stop::*;
pub use system::tray::*;
pub use system::window_border::*;
pub use system::window_ext::*;
use taffy::TaffyLayoutEngine;
pub use taffy::{AvailableSpace, LayoutId};
#[cfg(any(test, feature = "test-support"))]
pub use test::*;
pub use text_system::*;
pub use util::{FutureExt, SafeStrSlice, Timeout};
pub use view::*;
pub use window::*;
pub use pollster::block_on;
pub trait AppContext {
#[expect(
clippy::wrong_self_convention,
reason = "`App::new` is an ubiquitous function for creating entities"
)]
fn new<T: 'static>(&mut self, build_entity: impl FnOnce(&mut Context<T>) -> T) -> Entity<T>;
fn reserve_entity<T: 'static>(&mut self) -> Reservation<T>;
fn insert_entity<T: 'static>(
&mut self,
reservation: Reservation<T>,
build_entity: impl FnOnce(&mut Context<T>) -> T,
) -> Entity<T>;
fn update_entity<T, R>(
&mut self,
handle: &Entity<T>,
update: impl FnOnce(&mut T, &mut Context<T>) -> R,
) -> R
where
T: 'static;
fn as_mut<'a, T>(&'a mut self, handle: &Entity<T>) -> GpuiBorrow<'a, T>
where
T: 'static;
fn read_entity<T, R>(&self, handle: &Entity<T>, read: impl FnOnce(&T, &App) -> R) -> R
where
T: 'static;
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Result<T>
where
F: FnOnce(AnyView, &mut Window, &mut App) -> T;
fn with_window<R>(
&mut self,
entity_id: EntityId,
f: impl FnOnce(&mut Window, &mut App) -> R,
) -> Option<R>;
fn read_window<T, R>(
&self,
window: &WindowHandle<T>,
read: impl FnOnce(Entity<T>, &App) -> R,
) -> Result<R>
where
T: 'static;
fn background_spawn<R>(&self, future: impl Future<Output = R> + Send + 'static) -> Task<R>
where
R: Send + 'static;
fn read_global<G, R>(&self, callback: impl FnOnce(&G, &App) -> R) -> R
where
G: Global;
}
pub struct Reservation<T>(pub(crate) Slot<T>);
impl<T: 'static> Reservation<T> {
pub fn entity_id(&self) -> EntityId {
self.0.entity_id()
}
}
pub trait VisualContext: AppContext {
type Result<T>;
fn window_handle(&self) -> AnyWindowHandle;
fn update_window_entity<T: 'static, R>(
&mut self,
entity: &Entity<T>,
update: impl FnOnce(&mut T, &mut Window, &mut Context<T>) -> R,
) -> Self::Result<R>;
fn new_window_entity<T: 'static>(
&mut self,
build_entity: impl FnOnce(&mut Window, &mut Context<T>) -> T,
) -> Self::Result<Entity<T>>;
fn replace_root_view<V>(
&mut self,
build_view: impl FnOnce(&mut Window, &mut Context<V>) -> V,
) -> Self::Result<Entity<V>>
where
V: 'static + Render;
fn focus<V>(&mut self, entity: &Entity<V>) -> Self::Result<()>
where
V: Focusable;
}
pub trait EventEmitter<E: Any>: 'static {}
pub trait BorrowAppContext {
fn set_global<T: Global>(&mut self, global: T);
fn update_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
where
G: Global;
fn update_default_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
where
G: Global + Default;
}
impl<C> BorrowAppContext for C
where
C: std::borrow::BorrowMut<App>,
{
fn set_global<G: Global>(&mut self, global: G) {
self.borrow_mut().set_global(global)
}
#[track_caller]
fn update_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
where
G: Global,
{
let mut global = self.borrow_mut().lease_global::<G>();
let result = f(&mut global, self);
self.borrow_mut().end_global_lease(global);
result
}
fn update_default_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
where
G: Global + Default,
{
self.borrow_mut().default_global::<G>();
self.update_global(f)
}
}
#[derive(Default, Debug, serde::Serialize, serde::Deserialize, Clone)]
pub struct GpuSpecs {
pub is_software_emulated: bool,
pub device_name: String,
pub driver_name: String,
pub driver_info: String,
}