Skip to main content

gpui_base/input/textarea/
mod.rs

1use gpui::{App, Entity, IntoElement, RenderOnce, Window};
2
3use super::{InputBaseState, TextareaMode};
4
5/// State for editing ordinary multi-line text.
6///
7/// This is the shared editing engine in its multi-line kind. Code-editor
8/// facilities such as languages, diagnostics, folding, and LSP do not exist on
9/// this type — those methods live on [`super::EditorState`].
10pub type TextareaState = InputBaseState<TextareaMode>;
11
12/// An unstyled ordinary multi-line text input.
13#[derive(IntoElement)]
14pub struct Textarea {
15    state: Entity<TextareaState>,
16}
17
18impl Textarea {
19    pub fn new(state: &Entity<TextareaState>) -> Self {
20        Self {
21            state: state.clone(),
22        }
23    }
24}
25
26impl RenderOnce for Textarea {
27    fn render(self, _: &mut Window, _: &mut App) -> impl IntoElement {
28        self.state
29    }
30}