### line_start_offset example Source: https://docs.rs/gpui-component/latest/gpui_component/trait.RopeExt.html?search=std%3A%3Avec Example for line_start_offset: returns the start offset of the line at the given 0-based row index. ```rust use gpui_base::input::{Rope, RopeExt}; let rope = Rope::from("Hello\nWorld\r\nThis is a test 中文\nRope"); assert_eq!(rope.line_start_offset(0), 0); assert_eq!(rope.line_start_offset(1), 6); ``` -------------------------------- ### List source example Source: https://docs.rs/gpui-component/latest/gpui_component/text/markdown_ast/struct.List.html?search=u32+-%3E+bool Example showing the source representation of a list item with a marker. ```text > | * a ^^^ ``` -------------------------------- ### Command palette usage example Source: https://docs.rs/gpui-component/latest/gpui_component/command/struct.Command.html Creates a CommandState and a Command with a group of items and a placeholder. The example shows how to set up a command palette with a labeled group and a search placeholder. ```rust let state = cx.new(|cx| CommandState::new(window, cx)); Command::new(&state) .group( CommandGroup::new().label("Suggestions") .item(CommandItem::new().label("Calendar").icon(IconName::Calendar)), ) .placeholder("Type a command or search...") ``` -------------------------------- ### Install DockSkin on DockArea Source: https://docs.rs/gpui-component/latest/gpui_component/dock/struct.DockSkin.html Shows how to create a DockSkin and install it on a DockArea using with_renderer. The skin is created with DockSkin::new(cx) and passed to DockArea::new. ```rust let skin = DockSkin::new(cx); DockArea::new("main", None, window, cx).with_renderer(skin) ``` -------------------------------- ### Rc::from_raw example with string Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html?search= Example showing how to convert a raw pointer back to an Rc using `from_raw`. ```rust use std::rc::Rc; let x = Rc::new("hello".to_owned()); let x_ptr = Rc::into_raw(x); unsafe { // Convert back to an `Rc` to prevent leak. let x = Rc::from_raw(x_ptr); assert_eq!(&*x, "hello"); // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe! } // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling! ``` -------------------------------- ### Rc::into_raw example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example of consuming an Rc and returning a raw pointer. ```rust use std::rc::Rc; let x = Rc::new("hello".to_owned()); let x_ptr = Rc::into_raw(x); assert_eq!(unsafe { &*x_ptr }, "hello"); ``` -------------------------------- ### Rc::from_raw example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example of converting a raw pointer back to an Rc, with safety notes. ```rust use std::rc::Rc; let x = Rc::new("hello".to_owned()); let x_ptr = Rc::into_raw(x); unsafe { // Convert back to an `Rc` to prevent leak. let x = Rc::from_raw(x_ptr); assert_eq!(&*x, "hello"); // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe. } // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling! ``` -------------------------------- ### Rc::try_clone_from_ref example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example of using Rc::try_clone_from_ref, which returns a Result and may fail on allocation. ```rust #![feature(clone_from_ref)] use std::rc::Rc; let hello: Rc = Rc::try_clone_from_ref("hello")?; ``` -------------------------------- ### RadarChart label examples Source: https://docs.rs/gpui-component/latest/gpui_component/chart/struct.RadarChart.html Two examples for the label method. The first returns a plain string label. The second returns a custom element label using v_flex, an Icon, and into_any_element(). The second example is marked with a warning icon in the source. ```rust RadarChart::new(data).label(|d| d.month.clone()) ``` ```rust RadarChart::new(data).label(|d| { v_flex() .items_center() .child(Icon::new(IconName::Star).xsmall()) .child(d.month.clone()) .into_any_element() }) ``` -------------------------------- ### line_start_offset example Source: https://docs.rs/gpui-component/latest/gpui_component/input/trait.RopeExt.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example for line_start_offset. It returns the start offset of the line at the given 0-based row index. ```rust use gpui_base::input::{Rope, RopeExt}; let rope = Rope::from("Hello\nWorld\r\nThis is a test 中文\nRope"); assert_eq!(rope.line_start_offset(0), 0); assert_eq!(rope.line_start_offset(1), 6); ``` -------------------------------- ### init(cx: &mut App) Source: https://docs.rs/gpui-component/latest/gpui_component/theme/fn.init.html Initializes the theme system for the gpui_component library. Call this function during application setup to enable theme support. ```APIDOC ## init(cx: &mut App) ### Description Initializes the theme system for the gpui_component library. Call this function during application setup to enable theme support. ### Method Function ### Signature ```rust pub fn init(cx: &mut App) ``` ### Parameters - **cx** (`&mut App`) - Required - A mutable reference to the application context. ### Return Value - `()` - Returns nothing. ### Example ```rust use gpui_component::theme::init; init(&mut app); ``` ``` -------------------------------- ### theme::init Source: https://docs.rs/gpui-component/latest/gpui_component/all.html?search= Initializes the theme system. ```APIDOC ## theme::init ### Description Initializes the theme system. ### Function theme::init ``` -------------------------------- ### init(cx: &mut App) Source: https://docs.rs/gpui-component/latest/gpui_component/fn.init.html?search= Initializes the components. This function must be called at the application's entry point before using any components. ```APIDOC ## init(cx: &mut App) ### Description Initializes the components. This function must be called at the application's entry point before using any components. ### Function Signature ```rust pub fn init(cx: &mut App) ``` ### Parameters - **cx** (&mut App) - Required - The application context used for initialization. ### Usage Call this function at the entry point of your application to initialize the components. ### Return Value This function does not return a value. ``` -------------------------------- ### Rc::try_map example (nightly) Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example for the nightly-only experimental API `Rc::try_map`. It attempts to map the value in an `Rc`, reusing the allocation if possible. The closure returns a `Result` and the example unwraps it to get the new `Rc`. ```rust #![feature(smart_pointer_try_map)] use std::rc::Rc; let b = Rc::new(7); let new = Rc::try_map(b, |&i| u32::try_from(i)).unwrap(); assert_eq!(*new, 7); ``` -------------------------------- ### init Source: https://docs.rs/gpui-component/latest/gpui_component/fn.init.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the init function that initializes the components. ```APIDOC ## Function init ### Description Initializes the components. Must be called at the application's entry point. ### Signature ```rust pub fn init(cx: &mut App) ``` ### Parameters - **cx** (`&mut App`) - Required - The application context. ### Usage Call this function at the start of your application to initialize the components. ``` -------------------------------- ### Rc::strong_count example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Shows how to use Rc::strong_count to get the number of strong (Rc) pointers to an allocation. The example creates an Rc, clones it, and asserts the count is 2. ```rust use std::rc::Rc; let five = Rc::new(5); let _also_five = Rc::clone(&five); assert_eq!(2, Rc::strong_count(&five)); ``` -------------------------------- ### Grid::new Source: https://docs.rs/gpui-component/latest/gpui_component/plot/struct.Grid.html?search= Creates a new Grid instance with default settings. ```APIDOC ## Grid::new ### Description Creates a new Grid instance with default settings. ### Method new ### Signature pub fn new() -> Grid ### Parameters None ### Returns - **Grid** - A new Grid instance. ``` -------------------------------- ### Rc::weak_count example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Shows how to use Rc::weak_count to get the number of Weak pointers to an allocation. The example creates an Rc, downgrades it to a Weak, and asserts the count is 1. ```rust use std::rc::Rc; let five = Rc::new(5); let _weak_five = Rc::downgrade(&five); assert_eq!(1, Rc::weak_count(&five)); ``` -------------------------------- ### Rc::get_mut example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Shows how to use Rc::get_mut to get a mutable reference when there are no other Rc or Weak pointers. The example mutates the value, then clones the Rc and verifies that get_mut returns None. ```rust use std::rc::Rc; let mut x = Rc::new(3); *Rc::get_mut(&mut x).unwrap() = 4; assert_eq!(*x, 4); let _y = Rc::clone(&x); assert!(Rc::get_mut(&mut x).is_none()); ``` -------------------------------- ### Grid::new Source: https://docs.rs/gpui-component/latest/gpui_component/plot/struct.Grid.html?search=u32+-%3E+bool Creates a new Grid instance with default settings. ```APIDOC ## Grid::new ### Description Creates a new Grid instance. ### Method `pub fn new() -> Grid` ### Parameters None. ### Returns - **Grid** - A new Grid instance. ### Example ```rust let grid = Grid::new(); ``` ``` -------------------------------- ### Grid::new Source: https://docs.rs/gpui-component/latest/gpui_component/plot/struct.Grid.html?search=std%3A%3Avec Creates a new Grid instance with default settings. ```APIDOC ## Grid::new ### Description Creates a new `Grid` instance. ### Method `pub fn new() -> Grid` ### Parameters None. ### Returns - `Grid` - A new grid instance. ``` -------------------------------- ### SliderValue::start Source: https://docs.rs/gpui-component/latest/gpui_component/slider/enum.SliderValue.html?search=std%3A%3Avec Gets the start value of the slider. For a single value, returns that value; for a range, returns the first element. ```APIDOC ## SliderValue::start ### Description Gets the start value of the slider. For a single value, returns that value; for a range, returns the first element. ### Method `pub fn start(&self) -> f32` ### Returns - **f32** - The start value. ``` -------------------------------- ### Slice Rope Source: https://docs.rs/gpui-component/latest/gpui_component/input/struct.Rope.html Gets an immutable slice of the Rope using range syntax. Runs in O(log N) time. Panics if range start is greater than end, end is out of bounds, or ends are not on char boundaries. ```rust let rope = Rope::from_str("Hello world!"); let slice = rope.slice(..5); assert_eq!("Hello", slice); ``` -------------------------------- ### init Source: https://docs.rs/gpui-component/latest/gpui_component/fn.init.html Initializes the gpui-component library. Must be called at the application's entry point. ```APIDOC ## init ### Description Initializes the gpui-component library. This function must be called at the application's entry point before using any components. ### Function Signature ```rust pub fn init(cx: &mut App) ``` ### Parameters - **cx** (`&mut App`) - Required - The application context used for initialization. ### Usage Call this function once at the start of your application to set up the component library. ### Example ```rust use gpui_component::init; fn main() { // ... init(&mut app); } ``` ``` -------------------------------- ### Rc::get_mut_unchecked basic example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Shows how to use the nightly-only Rc::get_mut_unchecked to get a mutable reference without checks. Requires the get_mut_unchecked feature. Safety: if other Rc or Weak pointers exist, they must not be dereferenced or have active borrows during the returned borrow. ```rust #![feature(get_mut_unchecked)] use std::rc::Rc; let mut x = Rc::new(String::new()); unsafe { Rc::get_mut_unchecked(&mut x).push_str("foo") } assert_eq!(*x, "foo"); ``` -------------------------------- ### Pie::new Source: https://docs.rs/gpui-component/latest/gpui_component/plot/shape/struct.Pie.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new Pie instance. ```APIDOC ## Pie::new ### Description Creates a new `Pie` instance. ### Method `pub fn new() -> Pie` ### Parameters None. ### Returns - `Pie` - A new `Pie` instance. ``` -------------------------------- ### lines_len example Source: https://docs.rs/gpui-component/latest/gpui_component/input/trait.RopeExt.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example for lines_len. It returns the number of lines in the rope. ```rust use gpui_base::input::{Rope, RopeExt}; let rope = Rope::from("Hello\nWorld\r\nThis is a test 中文\nRope"); assert_eq!(rope.lines_len(), 4); ``` -------------------------------- ### new Source: https://docs.rs/gpui-component/latest/gpui_component/setting/struct.Settings.html Creates a new Settings instance with a given ID. ```APIDOC ## pub fn new(id: impl Into) -> Self ### Description Creates a new `Settings` instance with the given ID. ### Method `new` ### Parameters - **id** (`impl Into`) - Required - The ID for the settings instance. ### Returns - `Self` - A new `Settings` instance. ``` -------------------------------- ### row_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/empty/struct.EmptyHeader.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Sets the row start of this element. ```APIDOC ## row_start(self, start: i16) -> Self ### Description Sets the row start of this element. ### Method fn row_start(self, start: i16) -> Self ### Parameters - **start** (i16) - Required - The row start position. ### Returns - **Self** - The updated EmptyHeader instance for chaining. ``` -------------------------------- ### init Source: https://docs.rs/gpui-component/latest/gpui_component/fn.init.html?search=u32+-%3E+bool Initializes the gpui-component library. Must be called at the application's entry point before using any components. ```APIDOC ## init ### Description Initializes the components. Must be called at the application's entry point. ### Signature ```rust pub fn init(cx: &mut App) ``` ### Parameters - **cx** (`&mut App`) - Required - The application context. ### Returns - `()` - No return value. ``` -------------------------------- ### pub fn show(&mut self, window: &mut Window, cx: &mut Context<'_, PopoverState>) Source: https://docs.rs/gpui-component/latest/gpui_component/popover/struct.PopoverState.html?search= Shows the popover, opening it and capturing focus. ```APIDOC ## pub fn show(&mut self, window: &mut Window, cx: &mut Context<'_, PopoverState>) ### Description Shows the popover, opening it and capturing focus. ### Method Action ### Parameters - **self** (&mut self) - Required - The PopoverState instance. - **window** (&mut Window) - Required - The window context. - **cx** (&mut Context<'_, PopoverState>) - Required - The context for the PopoverState. ``` -------------------------------- ### Rc::increment_strong_count example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example of incrementing the strong reference count on an Rc pointer. ```rust use std::rc::Rc; let five = Rc::new(5); unsafe { let ptr = Rc::into_raw(five); Rc::increment_strong_count(ptr); let five = Rc::from_raw(ptr); assert_eq!(2, Rc::strong_count(&five)); } ``` -------------------------------- ### Create a NativeMenu with items and show it Source: https://docs.rs/gpui-component/latest/gpui_component/native_menu/index.html Builds a `NativeMenu` with menu items for Copy, Paste, and Delete, separated by a separator, and shows it at a given position. The menu is rendered by the OS and can extend beyond the window. The `show` method takes a position, window, and context. ```rust use gpui_kit::component::native_menu::NativeMenu; NativeMenu::new() .menu("Copy", Box::new(Copy)) .menu("Paste", Box::new(Paste)) .separator() .menu("Delete", Box::new(Delete)) .show(position, window, cx); ``` -------------------------------- ### Rc::clone_from_ref example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example of using Rc::clone_from_ref to clone a reference-counted value. ```rust #![feature(clone_from_ref)] use std::rc::Rc; let hello: Rc = Rc::clone_from_ref("hello"); ``` -------------------------------- ### Root::new Source: https://docs.rs/gpui-component/latest/gpui_component/struct.Root.html Creates a new Root instance with the given view, window, and context. ```APIDOC ## new ### Description Creates a new Root instance with the given view, window, and context. ### Method new ### Signature pub fn new(view: impl Into, window: &mut Window, cx: &mut Context<'_, Root>) -> Root ### Parameters - `view` (impl Into) - Required - The content view to be hosted. - `window` (&mut Window) - Required - The window in which the root is created. - `cx` (&mut Context<'_, Root>) - Required - The context for the root. ### Returns - `Root` - The newly created Root instance. ``` -------------------------------- ### fn row_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/tab/struct.TabBar.html Sets the row start of this element. ```APIDOC ## fn row_start(self, start: i16) -> Self ### Description Sets the row start of this element. ### Parameters - **start** (i16) - Required - The row start value. ### Returns - **Self** - The element with the row start applied. ``` -------------------------------- ### NativeMenu::new Source: https://docs.rs/gpui-component/latest/gpui_component/native_menu/index.html Creates a new NativeMenu instance. The example shows chaining menu items, a separator, and calling show to display the menu. ```APIDOC ## NativeMenu::new ### Description Creates a new `NativeMenu` instance. The example shows chaining menu items, a separator, and calling `show` to display the menu. ### Method Constructor ### Syntax ```rust NativeMenu::new() ``` ### Parameters None ### Returns A new `NativeMenu` instance. ### Example ```rust use gpui_kit::component::native_menu::NativeMenu; NativeMenu::new() .menu("Copy", Box::new(Copy)) .menu("Paste", Box::new(Paste)) .separator() .menu("Delete", Box::new(Delete)) .show(position, window, cx); ``` ``` -------------------------------- ### fn row_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/tab/struct.TabBar.html?search=std%3A%3Avec Sets the row start of this element. ```APIDOC ## fn row_start(self, start: i16) -> Self ### Description Sets the row start of this element. ### Signature `fn row_start(self, start: i16) -> Self` ### Parameters - **start** (i16) - Required - The row start position. ``` -------------------------------- ### fn col_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/list/struct.ListItem.html Sets the column start of this element. ```APIDOC ## fn col_start(self, start: i16) -> Self ### Description Sets the column start of this element. ### Method fn col_start(self, start: i16) -> Self ### Parameters - **self** - The element to modify. - **start** (i16) - The column start position. ### Returns - **Self** - The modified element. ``` -------------------------------- ### Opacity method example Source: https://docs.rs/gpui-component/latest/gpui_component/theme/struct.ThemeToken.html?search= Shows how to use the opacity method to multiply the alpha value of a color by a factor, returning a new HSLA color. ```rust let color = gpui::red(); let faded_color = color.opacity(0.5); assert_eq!(faded_color.a, 0.5); ``` -------------------------------- ### fn row_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/combobox/struct.Combobox.html?search= Sets the row start of this element. ```APIDOC ## fn row_start(self, start: i16) -> Self ### Description Sets the row start of this element. ### Method fn ### Signature `fn row_start(self, start: i16) -> Self` ### Parameters - **start** (i16) - Required - The row start position. ### Returns - **Self** - The updated element for chaining. ``` -------------------------------- ### init Source: https://docs.rs/gpui-component/latest/gpui_component/button/struct.ButtonGroup.html Method to initialize a pointer. ```APIDOC ## init ### Description Initializes a with the given initializer. This method is part of the `Pointable` trait. ### Method init ### Parameters - **init** (`::Init`) - Required - The initializer. ### Returns - `usize` - The pointer address. ``` -------------------------------- ### fn col_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/alert/struct.Alert.html Sets the column start of this element. ```APIDOC ## fn col_start(self, start: i16) -> Self ### Description Sets the column start of this element. ### Method col_start ### Parameters - **start** (i16) - Required - The column start position. ### Returns Self - The element with the column start set. ``` -------------------------------- ### NativeMenu::new Source: https://docs.rs/gpui-component/latest/gpui_component/native_menu/index.html?search= Creates a new NativeMenu instance. ```APIDOC ## NativeMenu::new ### Description Creates a new `NativeMenu` instance that will be rendered by the operating system. ### Method `NativeMenu::new()` ### Parameters None. ### Returns A new `NativeMenu` instance. ### Example ```rust use gpui_kit::component::native_menu::NativeMenu; let menu = NativeMenu::new(); ``` ``` -------------------------------- ### InputBaseState Methods Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputState.html?search= Documentation for the InputBaseState methods, covering configuration, content editing, and state queries. ```APIDOC ## InputBaseState Methods ### Description Methods for configuring and manipulating an input field's state, including text alignment, masking, context menus, placeholders, highlighting, and content editing. ### Methods #### input_bounds - **Signature**: `pub fn input_bounds(&self) -> Bounds` - **Description**: Returns the bounds of the input field. #### text_bounds - **Signature**: `pub fn text_bounds(&self) -> Option>` - **Description**: Returns the bounds of the text area, if available. #### diagnostic_popover - **Signature**: `pub fn diagnostic_popover(&self) -> Option>` - **Description**: Returns the diagnostic popover entry, if any. #### presentation - **Signature**: `pub fn presentation(&self) -> InputPresentation` - **Description**: Returns the input presentation mode. #### is_multi_line - **Signature**: `pub fn is_multi_line(&self) -> bool` - **Description**: Returns whether the input is multi-line. #### is_single_line - **Signature**: `pub fn is_single_line(&self) -> bool` - **Description**: Returns whether the input is a single-line text field. #### is_code_editor - **Signature**: `pub fn is_code_editor(&self) -> bool` - **Description**: Returns whether the input is a source-code editor. #### is_copyable - **Signature**: `pub fn is_copyable(&self) -> bool` - **Description**: Returns whether the user is allowed to copy the selection out. A masked input keeps its value out of the clipboard. #### context_menu_capabilities - **Signature**: `pub fn context_menu_capabilities(&self) -> InputContextMenuCapabilities` - **Description**: Returns the context menu capabilities. #### set_text_align - **Signature**: `pub fn set_text_align(&mut self, text_align: TextAlign, cx: &mut Context<'_, InputBaseState>)` - **Description**: Sets the text alignment. #### toggle_masked - **Signature**: `pub fn toggle_masked(&mut self, _: &mut Window, cx: &mut Context<'_, InputBaseState>)` - **Description**: Flips the password mask. The reveal button is rendered from the generic path and can only be switched on through `crate::input::InputState`. #### on_context_menu - **Signature**: `pub fn on_context_menu(&mut self, handler: Rc, &mut Window, &mut App)>)` - **Description**: Sets a custom context menu handler. #### context_menu - **Signature**: `pub fn context_menu(self, enable: bool) -> InputBaseState` - **Description**: Sets whether the context menu that shows on right-click is enabled. The context menu is enabled by default. Disabling it turns off the right-click menu entirely, including a custom menu set on the element. #### set_context_menu_enabled - **Signature**: `pub fn set_context_menu_enabled(&mut self, enabled: bool)` - **Description**: Sets whether the context menu is enabled. #### placeholder - **Signature**: `pub fn placeholder(self, placeholder: impl Into) -> InputBaseState` - **Description**: Sets the placeholder text. #### set_highlighter - **Signature**: `pub fn set_highlighter(&mut self, new_language: impl Into, cx: &mut Context<'_, InputBaseState>)` - **Description**: Sets the highlighter language for `LayoutMode::CodeEditor` mode. #### set_highlighter_factory - **Signature**: `pub fn set_highlighter_factory(&mut self, factory: Rc Option>>, cx: &mut Context<'_, InputBaseState>)` - **Description**: Installs the parser/highlighter adapter used by code-editor mode. #### ensure_highlighter_factory - **Signature**: `pub fn ensure_highlighter_factory(&mut self, factory: Rc Option>>)` - **Description**: Installs a default adapter without replacing an application-provided one. #### set_editor_style - **Signature**: `pub fn set_editor_style(&mut self, style: InputEditorStyle)` - **Description**: Sets the editor style. #### apply_highlighter_fold_candidates - **Signature**: `pub fn apply_highlighter_fold_candidates(&mut self, candidates: Vec, cx: &mut Context<'_, InputBaseState>)` - **Description**: Applies highlighter fold candidates. #### diagnostics - **Signature**: `pub fn diagnostics(&self) -> Option<&DiagnosticSet>` - **Description**: Returns the current diagnostics, if any. #### diagnostics_mut - **Signature**: `pub fn diagnostics_mut(&mut self) -> Option<&mut DiagnosticSet>` - **Description**: Returns a mutable reference to the current diagnostics, if any. #### set_placeholder - **Signature**: `pub fn set_placeholder(&mut self, placeholder: impl Into, _: &mut Window, cx: &mut Context<'_, InputBaseState>)` - **Description**: Sets the placeholder text. #### set_value - **Signature**: `pub fn set_value(&mut self, value: impl Into, window: &mut Window, cx: &mut Context<'_, InputBaseState>)` - **Description**: Sets the value of the input field: plain text, or `InputContent` to restore text together with its inline tokens. Editing history is cleared and no `InputEvent::Change` is emitted. For single-line inputs the caret is placed at the end of the text while the view is scrolled back to the start. Multi-line inputs reset the selection to `0..0`. #### replace_all - **Signature**: `pub fn replace_all(&mut self, text: impl Into, window: &mut Window, cx: &mut Context<'_, InputBaseState>)` - **Description**: Replaces the entire text content while preserving undo history. Unlike `set_value`, this method records the replacement in the undo stack. The selection is placed at the end of the new text for single-line inputs, or cleared (0..0) for multi-line inputs. Use this when programmatically replacing the full text but the user should still be able to undo the operation — e.g. formatting. #### insert - **Signature**: `pub fn insert(&mut self, text: impl Into, window: &mut Window, cx: &mut Context<'_, InputBaseState>)` - **Description**: Inserts text at the current cursor position. The cursor will be moved to the end of inserted text. #### replace - **Signature**: `pub fn replace(&mut self, text: impl Into, window: &mut Window, cx: &mut Context<'_, InputBaseState>)` - **Description**: Replaces text at the current cursor position. The cursor will be moved to the end of replaced text. #### set_disabled - **Signature**: `pub fn set_disabled(&mut self, disabled: bool, cx: &mut Context<'_, InputBaseState>)` - **Description**: Sets whether the input is disabled. #### set_readonly - **Signature**: `pub fn set_readonly(&mut self, readonly: bool, cx: &mut Context<'_, InputBaseState>)` - **Description**: Sets whether the input is read-only. ``` -------------------------------- ### EffectTransition usage example Source: https://docs.rs/gpui-component/latest/gpui_component/animation/struct.EffectTransition.html Example usage of EffectTransition to apply a fade and slide effect to an element. ```rust EffectTransition::new(Duration::from_millis(150)) .ease(ease_out_cubic) .slide_y(px(-4.), px(0.)) .fade(0.0, 1.0) .apply(element, "enter-anim") ``` -------------------------------- ### StatusBar::new Source: https://docs.rs/gpui-component/latest/gpui_component/status_bar/struct.StatusBar.html Creates a new, empty StatusBar instance. ```APIDOC ## StatusBar::new ### Description Creates a new, empty `StatusBar`. ### Method `pub fn new() -> Self` ### Parameters None. ### Returns A new `StatusBar` instance. ### Example ```rust use gpui_kit::component::status_bar::StatusBar; let status_bar = StatusBar::new(); ``` ``` -------------------------------- ### fn row_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/button/struct.Toggle.html Sets the row start position for the element. ```APIDOC ## fn row_start(self, start: i16) -> Self ### Description Sets the row start of this element. ### Method fn row_start(self, start: i16) -> Self ### Parameters - **start** (i16) - The row start position. ### Returns Self - The modified element. ``` -------------------------------- ### Icon Constructors and Configuration Methods Source: https://docs.rs/gpui-component/latest/gpui_component/struct.Icon.html?search= Methods for constructing and configuring an `Icon` instance in the gpui-component library. ```APIDOC ## Icon::new ### Description Creates a new `Icon` instance from any value that can be converted into an `Icon`. ### Method `pub fn new(icon: impl Into) -> Self` ### Parameters - **icon** (`impl Into`) - Required - The value to convert into an `Icon`. ### Returns - **Self** - A new `Icon` instance. ``` ```APIDOC ## Icon::path ### Description Sets the icon path of the Assets bundle. Replaces any previously set path or SVG data. ### Method `pub fn path(self, path: impl Into) -> Self` ### Parameters - **path** (`impl Into`) - Required - The icon path, for example `icons/foo.svg`. ### Returns - **Self** - The `Icon` with the path set. ``` ```APIDOC ## Icon::data ### Description Sets raw SVG bytes without registering an asset path. Copies the bytes into shared storage; the input need not be static. Cloning the icon shares those bytes. Replaces any previously set path or data. Parsing and rendering follow GPUI's SVG behavior. ### Method `pub fn data(self, data: &[u8]) -> Self` ### Parameters - **data** (`&[u8]`) - Required - The raw SVG bytes. ### Returns - **Self** - The `Icon` with the SVG data set. ### Example ```rust use gpui_component::Icon; let bytes = br#" "#; let icon = Icon::default().data(bytes); ``` ``` ```APIDOC ## Icon::view ### Description Creates a new view for the icon. ### Method `pub fn view(self, cx: &mut App) -> Entity` ### Parameters - **cx** (`&mut App`) - Required - The application context. ### Returns - **Entity** - A new view entity for the icon. ``` ```APIDOC ## Icon::transform ### Description Sets the SVG transformation, replacing any previous transformation or rotation. ### Method `pub fn transform(self, transformation: Transformation) -> Self` ### Parameters - **transformation** (`Transformation`) - Required - The SVG transformation to apply. ### Returns - **Self** - The `Icon` with the transformation set. ``` ```APIDOC ## Icon::empty ### Description Creates an empty `Icon`. ### Method `pub fn empty() -> Self` ### Returns - **Self** - An empty `Icon` instance. ``` ```APIDOC ## Icon::rotate ### Description Rotates the icon by the given angle. Replaces any previous transformation or rotation. ### Method `pub fn rotate(self, radians: impl Into) -> Self` ### Parameters - **radians** (`impl Into`) - Required - The rotation angle in radians. ### Returns - **Self** - The `Icon` with the rotation applied. ``` -------------------------------- ### fn row_start(self, start: i16) -> Self Source: https://docs.rs/gpui-component/latest/gpui_component/attachment/struct.AttachmentMedia.html Sets the row start position for the element. ```APIDOC ## fn row_start(self, start: i16) -> Self ### Description Sets the row start of this element. ### Method fn row_start(self, start: i16) -> Self ### Parameters - **start** (i16) - Required - The row start position. ### Returns Self - The element with the row start applied. ``` -------------------------------- ### open_dialog(&mut self, cx: &mut App, build: F) Source: https://docs.rs/gpui-component/latest/gpui_component/trait.WindowExt.html Opens a Dialog. ```APIDOC ## open_dialog(&mut self, cx: &mut App, build: F) ### Description Opens a Dialog. ### Method Trait method ### Signature ```rust fn open_dialog(&mut self, cx: &mut App, build: F) where F: Fn(Dialog, &mut Window, &mut App) -> Dialog + 'static, ``` ### Parameters - **cx** (&mut App) - Required - The application context. - **build** (F) - Required - A closure that receives a Dialog, a mutable Window, and a mutable App, and returns a Dialog. ### Returns None ``` -------------------------------- ### Rc::default example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example for the `Default` implementation of `Rc`. It creates a new `Rc` with the `Default` value for `T`. ```rust use std::rc::Rc; let x: Rc = Default::default(); assert_eq!(*x, 0); ``` -------------------------------- ### ToggleZoom::documentation Source: https://docs.rs/gpui-component/latest/gpui_component/dock/struct.ToggleZoom.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns the documentation for this action, if any. ```APIDOC ## ToggleZoom::documentation ### Description Returns the documentation for this action, if any. ### Method fn documentation() -> Option<&'static str> ### Parameters None ### Returns - **Option<&'static str>** - The documentation string, if any. ``` -------------------------------- ### EmptyMedia::new Source: https://docs.rs/gpui-component/latest/gpui_component/empty/struct.EmptyMedia.html?search=std%3A%3Avec Creates an unframed media slot. ```APIDOC ## EmptyMedia::new ### Description Creates an unframed media slot. ### Method `pub fn new() -> Self` ### Parameters None. ### Returns - `Self` - A new `EmptyMedia` instance. ``` -------------------------------- ### Root::new Source: https://docs.rs/gpui-component/latest/gpui_component/struct.Root.html?search=u32+-%3E+bool Creates a new Root instance with the given application content view. ```APIDOC ## Root::new ### Description Creates a new Root instance with the given application content view. ### Method new ### Signature pub fn new(view: impl Into, window: &mut Window, cx: &mut Context<'_, Root>) -> Root ### Parameters - **view** (impl Into) - Required - The application content view. - **window** (&mut Window) - Required - The window context. - **cx** (&mut Context<'_, Root>) - Required - The context for the Root. ### Return Value Root - The newly created Root instance. ``` -------------------------------- ### NativeMenu Methods Source: https://docs.rs/gpui-component/latest/gpui_component/native_menu/struct.NativeMenu.html?search=u32+-%3E+bool Methods for building and showing a native operating system menu. ```APIDOC ## NativeMenu::new ### Description Creates an empty native menu. ### Method `pub fn new() -> Self` ### Parameters None. ### Returns A new empty `NativeMenu` instance. ``` ```APIDOC ## NativeMenu::menu ### Description Appends a clickable item that dispatches `action` when selected. ### Method `pub fn menu(self, label: impl Into, action: Box) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the menu item. - **action** (`Box`) - Required - The action to dispatch when the item is selected. ``` ```APIDOC ## NativeMenu::menu_with_disabled ### Description Appends an item, controlling its `disabled` state. ### Method `pub fn menu_with_disabled(self, label: impl Into, disabled: bool, action: Box) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the menu item. - **disabled** (`bool`) - Required - Whether the item is disabled. - **action** (`Box`) - Required - The action to dispatch when the item is selected. ``` ```APIDOC ## NativeMenu::menu_with_check ### Description Appends an item, controlling its `checked` state (a check mark is shown). ### Method `pub fn menu_with_check(self, label: impl Into, checked: bool, action: Box) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the menu item. - **checked** (`bool`) - Required - Whether the item is checked. - **action** (`Box`) - Required - The action to dispatch when the item is selected. ``` ```APIDOC ## NativeMenu::menu_with_icon ### Description Appends an item showing `icon` next to its label. Native platform menus load absolute paths from the filesystem, and every other path through the application `gpui::AssetSource`. Icons created with `Icon::data` use their SVG bytes directly, without an asset lookup. `crate::IconName` resolves as an asset and works across all backends. ### Method `pub fn menu_with_icon(self, label: impl Into, icon: impl Into, action: Box) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the menu item. - **icon** (`impl Into`) - Required - The icon to display next to the label. - **action** (`Box`) - Required - The action to dispatch when the item is selected. ``` ```APIDOC ## NativeMenu::menu_with_icon_disabled ### Description Appends an item showing `icon` next to its label, controlling its `disabled` state. Same icon behavior as `Self::menu_with_icon`. Use this when an item carries an icon but should be greyed out. ### Method `pub fn menu_with_icon_disabled(self, label: impl Into, icon: impl Into, disabled: bool, action: Box) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the menu item. - **icon** (`impl Into`) - Required - The icon to display next to the label. - **disabled** (`bool`) - Required - Whether the item is disabled. - **action** (`Box`) - Required - The action to dispatch when the item is selected. ``` ```APIDOC ## NativeMenu::menu_with_icon_and_disabled ### Description Adds a menu item with icon and disabled state. Alias for `Self::menu_with_icon_disabled`, matching `crate::menu::PopupMenu`. ### Method `pub fn menu_with_icon_and_disabled(self, label: impl Into, icon: impl Into, action: Box, disabled: bool) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the menu item. - **icon** (`impl Into`) - Required - The icon to display next to the label. - **action** (`Box`) - Required - The action to dispatch when the item is selected. - **disabled** (`bool`) - Required - Whether the item is disabled. ``` ```APIDOC ## NativeMenu::separator ### Description Appends a separator line. ### Method `pub fn separator(self) -> Self` ### Parameters None. ``` ```APIDOC ## NativeMenu::submenu ### Description Appends a submenu built from another `NativeMenu`. ### Method `pub fn submenu(self, label: impl Into, submenu: NativeMenu) -> Self` ### Parameters - **label** (`impl Into`) - Required - The label of the submenu. - **submenu** (`NativeMenu`) - Required - The submenu to append. ``` ```APIDOC ## NativeMenu::is_empty ### Description Returns whether the menu has no items. ### Method `pub fn is_empty(&self) -> bool` ### Parameters None. ### Returns `true` if the menu has no items, `false` otherwise. ``` ```APIDOC ## NativeMenu::show ### Description Pops up the menu at `position` (window coordinates, in logical pixels). The menu is shown without blocking the caller: the OS tracking loop runs off GPUI’s call stack, so GPUI is not borrowed while it is open. When an item is selected, its action is dispatched via `Window::dispatch_action`. ### Method `pub fn show(self, position: Point, window: &mut Window, cx: &mut App)` ### Parameters - **position** (`Point`) - Required - The position in window coordinates (logical pixels) where the menu should appear. - **window** (`&mut Window`) - Required - The window in which the menu is shown. - **cx** (`&mut App`) - Required - The application context. ``` -------------------------------- ### set_indent_guides Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.EditorState.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Sets whether indent guides are displayed in the editor. This method can be called at runtime to toggle indent guides. ```APIDOC ## set_indent_guides ### Description Sets whether indent guides are displayed in the editor. This method can be called at runtime to toggle indent guides. ### Method pub fn set_indent_guides(&mut self, indent_guides: bool, _: &mut Window, cx: &mut Context<'_, InputBaseState>) ### Parameters - **indent_guides** (bool) - Required - Whether to enable indent guides. - **_**: &mut Window - Required - The window context. - **cx**: &mut Context<'_, InputBaseState> - Required - The context for the input base state. ### Return Value None ``` -------------------------------- ### Markdown footnote definition example Source: https://docs.rs/gpui-component/latest/gpui_component/text/markdown_ast/struct.FootnoteDefinition.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E An example of a GFM footnote definition in markdown, showing the syntax and the part that is the footnote definition. ```markdown > | [^a]: b ^^^^^^^ ``` -------------------------------- ### icon_named! macro usage examples Source: https://docs.rs/gpui-component/latest/gpui_component/macro.icon_named.html Example usage of the icon_named! macro with a literal path, an env-var reference, and custom derives. ```rust // Literal path (relative to the calling crate's CARGO_MANIFEST_DIR) icon_named!(IconName, "icons"); // Env-var reference (resolved at macro expansion time) icon_named!(IconName, "$CUSTOM_ICONS_DIR"); // With custom derives icon_named!(IconName, "icons", [Debug, Copy, PartialEq, Eq]); ``` -------------------------------- ### Rc::ge example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example for the `ge` method of `Rc` when `T: PartialOrd`. It compares two `Rc`s by calling `>=` on their inner values. ```rust use std::rc::Rc; let five = Rc::new(5); assert!(five >= Rc::new(5)); ``` -------------------------------- ### Toolbar::new Source: https://docs.rs/gpui-component/latest/gpui_component/toolbar/struct.Toolbar.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new, empty Toolbar at Size::Small. ```APIDOC ## Toolbar::new ### Description Creates a new, empty `Toolbar` at `Size::Small`. ### Method `pub fn new(id: impl Into) -> Self` ### Parameters - **id** (impl Into) - Required - The identifier for the toolbar, used to keep keyboard-focus state stable across frames. ### Returns - **Self** - A new `Toolbar` instance. ### Example ```rust use gpui_kit::component::toolbar::Toolbar; let _ = Toolbar::new("document-toolbar"); ``` ``` -------------------------------- ### Rc::gt example Source: https://docs.rs/gpui-component/latest/gpui_component/input/type.InputHighlighterFactory.html Example for the `gt` method of `Rc` when `T: PartialOrd`. It compares two `Rc`s by calling `>` on their inner values. ```rust use std::rc::Rc; let five = Rc::new(5); assert!(five > Rc::new(4)); ```