pub struct TextPrompt<'a> { /* private fields */ }Expand description
A prompt widget that displays a message and a text input.
By default, the prompt reserves space for the TextState status symbol before the prompt
message. Use TextPrompt::without_status_symbol when the surrounding UI owns completion or
cancellation state and the prompt should start directly with the message.
TextPrompt can be rendered by value when it is built inline, or by reference when prompt
configuration is stored and reused across frames. Rendering by reference keeps the prompt
configuration available for later frames while still updating the external TextState.
§Examples
use ratatui::Frame;
use ratatui::layout::Rect;
use tui_prompts::{Prompt, TextPrompt, TextState};
struct App<'a> {
prompt: TextPrompt<'a>,
state: TextState<'a>,
}
impl App<'_> {
fn draw(&mut self, frame: &mut Frame, area: Rect) {
(&self.prompt).draw(frame, area, &mut self.state);
}
}Implementations§
Source§impl<'a> TextPrompt<'a>
impl<'a> TextPrompt<'a>
pub const fn new(message: Cow<'a, str>) -> TextPrompt<'a>
pub fn with_block(self, block: Block<'a>) -> TextPrompt<'a>
pub const fn with_render_style( self, render_style: TextRenderStyle, ) -> TextPrompt<'a>
Sourcepub const fn without_status_symbol(self) -> TextPrompt<'a>
pub const fn without_status_symbol(self) -> TextPrompt<'a>
Renders the prompt without the status symbol or its following space.
The prompt state’s Status is still updated and available through TextState. This
only changes the rendered prefix, so the prompt message, input value, wrapping width, and
cursor position all move left by the width of the hidden status symbol prefix.
Trait Implementations§
Source§impl<'a> Clone for TextPrompt<'a>
impl<'a> Clone for TextPrompt<'a>
Source§fn clone(&self) -> TextPrompt<'a>
fn clone(&self) -> TextPrompt<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for TextPrompt<'a>
impl<'a> Debug for TextPrompt<'a>
Source§impl Default for TextPrompt<'_>
impl Default for TextPrompt<'_>
Source§fn default() -> TextPrompt<'_>
fn default() -> TextPrompt<'_>
impl<'a> Eq for TextPrompt<'a>
Source§impl<T> From<T> for TextPrompt<'static>
impl<T> From<T> for TextPrompt<'static>
Source§fn from(message: T) -> TextPrompt<'static>
fn from(message: T) -> TextPrompt<'static>
Source§impl<'a> PartialEq for TextPrompt<'a>
impl<'a> PartialEq for TextPrompt<'a>
Source§fn eq(&self, other: &TextPrompt<'a>) -> bool
fn eq(&self, other: &TextPrompt<'a>) -> bool
self and other values to be equal, and is used by ==.Source§impl Prompt for TextPrompt<'_>
impl Prompt for TextPrompt<'_>
Source§fn draw(
self,
frame: &mut Frame<'_>,
area: Rect,
state: &mut <TextPrompt<'_> as StatefulWidget>::State,
)
fn draw( self, frame: &mut Frame<'_>, area: Rect, state: &mut <TextPrompt<'_> as StatefulWidget>::State, )
Draws the prompt widget.
This is in addition to the Widget trait implementation as we need the Frame to set the
cursor position.
Source§impl Prompt for &TextPrompt<'_>
impl Prompt for &TextPrompt<'_>
Source§fn draw(
self,
frame: &mut Frame<'_>,
area: Rect,
state: &mut <&TextPrompt<'_> as StatefulWidget>::State,
)
fn draw( self, frame: &mut Frame<'_>, area: Rect, state: &mut <&TextPrompt<'_> as StatefulWidget>::State, )
Draws the prompt widget.
This is in addition to the Widget trait implementation as we need the Frame to set the
cursor position.
Source§impl<'a> StatefulWidget for TextPrompt<'a>
impl<'a> StatefulWidget for TextPrompt<'a>
Source§fn render(
self,
area: Rect,
buf: &mut Buffer,
state: &mut <TextPrompt<'a> as StatefulWidget>::State,
)
fn render( self, area: Rect, buf: &mut Buffer, state: &mut <TextPrompt<'a> as StatefulWidget>::State, )
Source§impl<'a> StatefulWidget for &TextPrompt<'a>
impl<'a> StatefulWidget for &TextPrompt<'a>
Source§fn render(
self,
area: Rect,
buf: &mut Buffer,
state: &mut <&TextPrompt<'a> as StatefulWidget>::State,
)
fn render( self, area: Rect, buf: &mut Buffer, state: &mut <&TextPrompt<'a> as StatefulWidget>::State, )
impl<'a> StructuralPartialEq for TextPrompt<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for TextPrompt<'a>
impl<'a> !Send for TextPrompt<'a>
impl<'a> !Sync for TextPrompt<'a>
impl<'a> !UnwindSafe for TextPrompt<'a>
impl<'a> Freeze for TextPrompt<'a>
impl<'a> Unpin for TextPrompt<'a>
impl<'a> UnsafeUnpin for TextPrompt<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more