pub struct ChatComponent { /* private fields */ }
Expand description
Chat component for interactive messaging
Implementations§
Source§impl ChatComponent
impl ChatComponent
Sourcepub fn new(config: &ChatConfig, theme: &dyn Theme) -> Self
pub fn new(config: &ChatConfig, theme: &dyn Theme) -> Self
Create a new chat component
Sourcepub fn add_message(&mut self, message: ChatMessage)
pub fn add_message(&mut self, message: ChatMessage)
Add a new message
Sourcepub async fn send_message(&mut self) -> Result<()>
pub async fn send_message(&mut self) -> Result<()>
Send the current message
Sourcepub fn clear_input(&mut self)
pub fn clear_input(&mut self)
Clear the input area
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Insert a newline in the input
Sourcepub async fn handle_paste(&mut self, data: String) -> Result<()>
pub async fn handle_paste(&mut self, data: String) -> Result<()>
Handle paste event
Sourcepub async fn handle_key_event(&mut self, key: KeyEvent) -> Result<()>
pub async fn handle_key_event(&mut self, key: KeyEvent) -> Result<()>
Handle key events
Sourcepub fn scroll_down(&mut self)
pub fn scroll_down(&mut self)
Scroll down in the message history
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Scroll to the bottom of the message history
Sourcepub fn update_theme(&mut self, theme: &dyn Theme)
pub fn update_theme(&mut self, theme: &dyn Theme)
Update theme
Sourcepub fn render(&mut self, renderer: &Renderer<'_>, area: Rect)
pub fn render(&mut self, renderer: &Renderer<'_>, area: Rect)
Render the main chat area (messages)
Sourcepub fn render_input(&mut self, renderer: &Renderer<'_>, area: Rect)
pub fn render_input(&mut self, renderer: &Renderer<'_>, area: Rect)
Render the input area
Auto Trait Implementations§
impl !Freeze for ChatComponent
impl !RefUnwindSafe for ChatComponent
impl Send for ChatComponent
impl Sync for ChatComponent
impl Unpin for ChatComponent
impl !UnwindSafe for ChatComponent
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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