Skip to main content

ChatView

Struct ChatView 

Source
pub struct ChatView { /* private fields */ }
Expand description

Chat view component for displaying conversation messages

Implementations§

Source§

impl ChatView

Source

pub fn new() -> Self

Source

pub fn add_message(&mut self, message: Message)

Add a message to the chat

Source

pub fn append_to_last_assistant(&mut self, content: &str)

Append content to the last assistant message, or create a new one if none exists

Source

pub fn message_count(&self) -> usize

Get the number of messages

Source

pub fn messages(&self) -> &[Message]

Get a reference to the messages

Source

pub fn scroll_up(&mut self)

Scroll up by multiple lines (better UX than single line)

Source

pub fn scroll_down(&mut self)

Scroll down by multiple lines

Source

pub fn scroll_page_up(&mut self, viewport_height: u16)

Scroll up by one page (viewport height)

Source

pub fn scroll_page_down(&mut self, viewport_height: u16)

Scroll down by one page

Source

pub fn scroll_to_bottom(&mut self)

Scroll to the bottom (show newest messages)

Source

pub fn scroll_to_top(&mut self)

Scroll to the top (show oldest messages)

Source

pub fn start_selection(&mut self, message_idx: usize, byte_offset: usize)

Start text selection at position

Source

pub fn extend_selection(&mut self, message_idx: usize, byte_offset: usize)

Extend selection to position

Source

pub fn clear_selection(&mut self)

Clear text selection

Source

pub fn has_selection(&self) -> bool

Check if there is an active selection

Source

pub fn screen_to_text_pos(&self, col: u16, row: u16) -> Option<(usize, usize)>

Map screen coordinates to text position for mouse selection Returns (message_idx, char_offset) if a valid position is found

Source

pub fn is_selected(&self, message_idx: usize, char_offset: usize) -> bool

Check if a byte position is within the current selection

Source

pub fn get_selected_text(&self) -> Option<String>

Get selected text (character-precise)

Source

pub fn clear(&mut self)

Clear all messages

Trait Implementations§

Source§

impl Clone for ChatView

Source§

fn clone(&self) -> ChatView

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChatView

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChatView

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Widget for &ChatView

Source§

fn render(self, area: Rect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom widget.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more