gpui_deck/input/textarea/mod.rs
1// Modified for GPUI Deck: expose the existing multiline engine without editor
2// presentation or a second focus owner.
3use gpui::{App, Entity, IntoElement, RenderOnce, Window};
4
5use super::{InputBaseState, TextareaMode};
6
7/// State for editing ordinary multi-line text.
8///
9/// This is the shared editing engine in its multi-line kind. Code-editor
10/// facilities such as languages, diagnostics, folding, and LSP do not exist on
11/// this type — those methods live on [`super::EditorState`].
12pub type TextareaState = InputBaseState<TextareaMode>;
13
14/// An unstyled ordinary multi-line text input.
15///
16/// The retained state owns text, selection, undo, wrapping, scrolling, and the
17/// native text-input interface. Enter inserts a newline by default; Tab and
18/// Shift-Tab follow normal form navigation through [`crate::Root`].
19///
20/// Wrap this element in [`super::InputBase`] for application-owned frame styling.
21/// Give the state an [`super::InputAccessibility`] with
22/// [`gpui::Role::MultilineTextInput`] and a label; leave the surrounding frame's
23/// role unset so the state remains the only text focus and semantic owner.
24#[derive(IntoElement)]
25pub struct Textarea {
26 state: Entity<TextareaState>,
27}
28
29impl Textarea {
30 pub fn new(state: &Entity<TextareaState>) -> Self {
31 Self {
32 state: state.clone(),
33 }
34 }
35}
36
37impl RenderOnce for Textarea {
38 fn render(self, _: &mut Window, _: &mut App) -> impl IntoElement {
39 self.state
40 }
41}