pub struct ChatState {
pub image_click_map: Vec<(u16, ImageClickTarget)>,
pub last_scroll_position: u16,
pub last_chat_area: Option<(u16, u16, u16, u16)>,
/* private fields */
}Expand description
State for the chat widget
Fields§
§image_click_map: Vec<(u16, ImageClickTarget)>Click map: content line number → image target (rebuilt every render)
last_scroll_position: u16Scroll position used in last render (for coordinate mapping)
last_chat_area: Option<(u16, u16, u16, u16)>Chat area rect from last render
Implementations§
Source§impl ChatState
impl ChatState
Sourcepub fn get_scroll_position(
&self,
content_height: u16,
viewport_height: u16,
) -> u16
pub fn get_scroll_position( &self, content_height: u16, viewport_height: u16, ) -> u16
Get the scroll position for rendering scroll_offset represents distance from bottom, convert to ratatui scroll position
Sourcepub fn scroll_up(&mut self, amount: u16)
pub fn scroll_up(&mut self, amount: u16)
Scroll viewport up (shows older messages further from bottom)
Sourcepub fn scroll_down(&mut self, amount: u16)
pub fn scroll_down(&mut self, amount: u16)
Scroll viewport down (shows newer messages closer to bottom) Automatically resumes auto-scroll when reaching the bottom
Sourcepub fn resume_auto_scroll(&mut self)
pub fn resume_auto_scroll(&mut self)
Force resume auto-scroll mode (jump to bottom)
Sourcepub fn is_manually_scrolling(&self) -> bool
pub fn is_manually_scrolling(&self) -> bool
Check if user is manually scrolling (not following bottom)
Sourcepub fn find_image_at_screen_pos(
&self,
screen_row: u16,
) -> Option<&ImageClickTarget>
pub fn find_image_at_screen_pos( &self, screen_row: u16, ) -> Option<&ImageClickTarget>
Find an image click target at the given screen coordinates. Returns Some((message_index, image_index)) if an image indicator was clicked.
Sourcepub fn begin_selection(&mut self, screen_row: u16, screen_col: u16)
pub fn begin_selection(&mut self, screen_row: u16, screen_col: u16)
Begin a drag selection at the given screen position (mouse-down). Anchors and cursor both start here; a plain click with no drag selects nothing.
Sourcepub fn update_selection(&mut self, screen_row: u16, screen_col: u16)
pub fn update_selection(&mut self, screen_row: u16, screen_col: u16)
Extend the in-progress selection to the given screen position (drag).
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Drop any active selection (and its highlight).
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
Extract the currently-selected text from the last rendered frame, or
None if there’s no selection or it’s empty (e.g. a plain click).
Walks the retained per-row text and slices each row by display cells so
CJK / wide glyphs are never split mid-cell.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChatState
impl RefUnwindSafe for ChatState
impl Send for ChatState
impl Sync for ChatState
impl Unpin for ChatState
impl UnsafeUnpin for ChatState
impl UnwindSafe for ChatState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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