Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:26:22.437Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

ui_input.rs

46 lines · 1.6 KB · rust
1//! This crate provides UI components that can be used for form-like scenarios, such as a input and number field.
2//!
3//! It can't be located in the `ui` crate because it depends on `editor`.
4//!
5mod input_field;
6
7use std::{
8    any::Any,
9    sync::{Arc, OnceLock},
10};
11
12use gpui::{FocusHandle, Subscription};
13pub use input_field::*;
14use ui::{AnyElement, App, Window};
15
16pub trait ErasedEditor: 'static {
17    fn text(&self, cx: &App) -> String;
18    fn set_text(&self, text: &str, window: &mut Window, cx: &mut App);
19    fn clear(&self, window: &mut Window, cx: &mut App);
20    fn set_placeholder_text(&self, text: &str, window: &mut Window, _: &mut App);
21    fn move_selection_to_end(&self, window: &mut Window, _: &mut App);
22    fn select_all(&self, window: &mut Window, cx: &mut App);
23    fn set_masked(&self, masked: bool, window: &mut Window, cx: &mut App);
24    fn set_read_only(&self, read_only: bool, cx: &mut App);
25    fn set_multiline(&self, max_lines: Option<usize>, window: &mut Window, cx: &mut App);
26
27    fn focus_handle(&self, cx: &App) -> FocusHandle;
28
29    fn subscribe(
30        &self,
31        callback: Box<dyn FnMut(ErasedEditorEvent, &mut Window, &mut App) + 'static>,
32        window: &mut Window,
33        cx: &mut App,
34    ) -> Subscription;
35    fn render(&self, window: &mut Window, cx: &App) -> AnyElement;
36    fn as_any(&self) -> &dyn Any;
37}
38
39#[derive(Copy, Clone, Debug, PartialEq, Eq)]
40pub enum ErasedEditorEvent {
41    BufferEdited,
42    Blurred,
43}
44pub static ERASED_EDITOR_FACTORY: OnceLock<fn(&mut Window, &mut App) -> Arc<dyn ErasedEditor>> =
45    OnceLock::new();
46
Served at tenant.openagents/omega Member data and write actions are omitted.