Skip to main content

gpui_base/input/input/
mod.rs

1use gpui::{App, Entity, IntoElement, RenderOnce, Window};
2
3use super::{InputBaseState, InputMode};
4
5/// State for a single-line text input.
6///
7/// This is the shared editing engine in its single-line kind. Multi-line
8/// layout, auto-grow, and code-editor configuration do not exist on this type —
9/// those methods live on [`super::TextareaState`] and [`super::EditorState`].
10pub type InputState = InputBaseState<InputMode>;
11
12/// An unstyled single-line text input.
13///
14/// Applications that need a fully styled control can wrap this state with
15/// their own presentation or use `gpui-component::Input`.
16#[derive(IntoElement)]
17pub struct Input {
18    state: Entity<InputState>,
19}
20
21impl Input {
22    pub fn new(state: &Entity<InputState>) -> Self {
23        Self {
24            state: state.clone(),
25        }
26    }
27}
28
29impl RenderOnce for Input {
30    fn render(self, _: &mut Window, _: &mut App) -> impl IntoElement {
31        self.state
32    }
33}