| 1 | use gpui::App; |
| 2 | use std::ops::Deref; |
| 3 | use std::sync::LazyLock; |
| 4 | |
| 5 | mod component_traits; |
| 6 | mod element_ext; |
| 7 | pub mod global_state; |
| 8 | mod icon; |
| 9 | mod index_path; |
| 10 | #[cfg(any(feature = "inspector", debug_assertions))] |
| 11 | mod inspector; |
| 12 | mod root; |
| 13 | mod sizing; |
| 14 | mod styled; |
| 15 | mod time; |
| 16 | mod title_bar; |
| 17 | mod touch_selection; |
| 18 | mod virtual_list; |
| 19 | mod window_border; |
| 20 | mod window_ext; |
| 21 | |
| 22 | pub(crate) mod actions { |
| 23 | pub use gpui_base::actions::*; |
| 24 | } |
| 25 | |
| 26 | pub mod accordion; |
| 27 | pub mod alert; |
| 28 | pub mod attachment; |
| 29 | pub mod avatar; |
| 30 | pub mod badge; |
| 31 | pub mod breadcrumb; |
| 32 | pub mod bubble; |
| 33 | pub mod button; |
| 34 | pub mod carousel; |
| 35 | pub mod chart; |
| 36 | pub mod checkbox; |
| 37 | pub mod clipboard; |
| 38 | pub mod collapsible; |
| 39 | pub mod color_picker; |
| 40 | pub mod combobox; |
| 41 | pub mod command; |
| 42 | pub mod description_list; |
| 43 | pub mod dialog; |
| 44 | pub mod dock; |
| 45 | pub mod empty; |
| 46 | pub mod form; |
| 47 | pub mod group_box; |
| 48 | pub mod highlighter; |
| 49 | pub mod history; |
| 50 | pub mod hover_card; |
| 51 | pub mod input; |
| 52 | pub mod kbd; |
| 53 | pub mod label; |
| 54 | pub mod link; |
| 55 | pub mod list; |
| 56 | pub mod marker; |
| 57 | pub mod menu; |
| 58 | pub mod message; |
| 59 | pub mod message_scroller; |
| 60 | pub mod native_menu; |
| 61 | pub mod notification; |
| 62 | pub mod pagination; |
| 63 | pub mod plot; |
| 64 | pub mod popover; |
| 65 | pub mod progress; |
| 66 | pub mod questionnaire; |
| 67 | pub mod radio; |
| 68 | pub mod rating; |
| 69 | pub mod resizable; |
| 70 | pub mod scroll; |
| 71 | pub mod searchable_list; |
| 72 | pub mod select; |
| 73 | pub mod separator; |
| 74 | pub mod setting; |
| 75 | pub mod sheet; |
| 76 | pub mod shimmer; |
| 77 | pub mod sidebar; |
| 78 | pub mod skeleton; |
| 79 | pub mod slider; |
| 80 | pub mod speech; |
| 81 | pub mod spinner; |
| 82 | pub mod status_bar; |
| 83 | pub mod stepper; |
| 84 | pub mod switch; |
| 85 | pub mod tab; |
| 86 | pub mod table; |
| 87 | pub mod tag; |
| 88 | pub mod text; |
| 89 | pub mod theme; |
| 90 | pub mod toolbar; |
| 91 | pub mod tooltip; |
| 92 | pub mod tree; |
| 93 | |
| 94 | pub use crate::Disableable; |
| 95 | pub use element_ext::*; |
| 96 | pub use global_state::GlobalState; |
| 97 | pub use gpui_base::Root; |
| 98 | pub use gpui_base::animation; |
| 99 | #[doc(hidden)] |
| 100 | pub(crate) use gpui_base::resize_handle; |
| 101 | pub use gpui_base::{ |
| 102 | AxisExt, Edges, FocusTrapElement, InteractiveElementExt, LengthExt, Measure, OngoingScrollExt, |
| 103 | Placement, Side, measure, measure_if, |
| 104 | }; |
| 105 | pub use gpui_component_macros::icon_named; |
| 106 | pub use icon::*; |
| 107 | pub use index_path::IndexPath; |
| 108 | pub use input::{Rope, RopeExt, RopeLines}; |
| 109 | #[cfg(any(feature = "inspector", debug_assertions))] |
| 110 | pub use inspector::*; |
| 111 | pub use resizable::{ |
| 112 | ResizablePanel, ResizablePanelEvent, ResizablePanelGroup, ResizableState, h_resizable, |
| 113 | resizable_panel, resize_handle_appearance, v_resizable, |
| 114 | }; |
| 115 | pub use styled::*; |
| 116 | pub use theme::*; |
| 117 | pub use time::{calendar, date_picker, time_field}; |
| 118 | pub use title_bar::*; |
| 119 | pub use virtual_list::{VirtualList, VirtualListScrollHandle, h_virtual_list, v_virtual_list}; |
| 120 | pub use window_border::{WindowBorder, window_border, window_paddings}; |
| 121 | pub use window_ext::WindowExt; |
| 122 | |
| 123 | rust_i18n::i18n!("locales", fallback = "en"); |
| 124 | |
| 125 | /// Initialize the components. |
| 126 | /// |
| 127 | /// You must initialize the components at your application's entry point. |
| 128 | pub fn init(cx: &mut App) { |
| 129 | theme::init(cx); |
| 130 | global_state::init(cx); |
| 131 | #[cfg(any(feature = "inspector", debug_assertions))] |
| 132 | inspector::init(cx); |
| 133 | root::init(cx); |
| 134 | gpui_base::init(cx); |
| 135 | input::init(cx); |
| 136 | date_picker::init(cx); |
| 137 | dock::init(cx); |
| 138 | sheet::init(cx); |
| 139 | list::init(cx); |
| 140 | command::init(cx); |
| 141 | carousel::init(cx); |
| 142 | notification::init(cx); |
| 143 | popover::init(cx); |
| 144 | questionnaire::init(cx); |
| 145 | menu::init(cx); |
| 146 | table::init(cx); |
| 147 | tooltip::init(cx); |
| 148 | } |
| 149 | |
| 150 | #[inline] |
| 151 | pub fn locale() -> impl Deref<Target = str> { |
| 152 | rust_i18n::locale() |
| 153 | } |
| 154 | |
| 155 | #[inline] |
| 156 | pub fn set_locale(locale: &str) { |
| 157 | rust_i18n::set_locale(locale) |
| 158 | } |
| 159 | |
| 160 | /// Whether measurement logging is enabled, read once per process. |
| 161 | /// |
| 162 | /// Measurement is a startup debug flag, and the table queries it for every |
| 163 | /// rendered cell, so cache it instead of reading the environment each call. |
| 164 | #[inline] |
| 165 | pub(crate) fn measure_enable() -> bool { |
| 166 | static MEASURE_ENABLED: LazyLock<bool> = LazyLock::new(gpui_base::measurement_enabled); |
| 167 | *MEASURE_ENABLED |
| 168 | } |