pub struct Screen {
pub lines: VecDeque<Vec<ScreenCell>>,
pub cursor_position: (usize, usize),
pub columns: usize,
pub cursor_visible: bool,
pub max_lines: usize,
/* private fields */
}Expand description
Represents the current state of a terminal screen
Fields§
§lines: VecDeque<Vec<ScreenCell>>Lines of characters with attributes
cursor_position: (usize, usize)Current cursor position (row, column)
columns: usizeNumber of columns in the screen
cursor_visible: boolWhether the cursor should be visible
max_lines: usizeMaximum number of lines to keep
Implementations§
Source§impl Screen
impl Screen
Sourcepub fn new_with_max_lines(columns: usize, max_lines: usize) -> Self
pub fn new_with_max_lines(columns: usize, max_lines: usize) -> Self
Creates a new screen with specified dimensions and maximum lines
Sourcepub fn cursor_row(&self) -> usize
pub fn cursor_row(&self) -> usize
Get the current cursor row
Sourcepub fn cursor_col(&self) -> usize
pub fn cursor_col(&self) -> usize
Get the current cursor column
Sourcepub fn put_char(&mut self, c: char, attributes: ScreenCellAttributes)
pub fn put_char(&mut self, c: char, attributes: ScreenCellAttributes)
Put a character at the current cursor position and advance the cursor
Sourcepub fn put_char_basic(
&mut self,
c: char,
style: CellStyle,
fg_color: Option<TerminalColor>,
bg_color: Option<TerminalColor>,
)
pub fn put_char_basic( &mut self, c: char, style: CellStyle, fg_color: Option<TerminalColor>, bg_color: Option<TerminalColor>, )
Put a character at the current cursor position with basic attributes
Sourcepub fn move_cursor(&mut self, row: usize, col: usize)
pub fn move_cursor(&mut self, row: usize, col: usize)
Move the cursor to a specific position
Sourcepub fn carriage_return(&mut self)
pub fn carriage_return(&mut self)
Return the cursor to the first column
Sourcepub fn clear_line_forward(&mut self)
pub fn clear_line_forward(&mut self)
Clear from the cursor to the end of the line
Sourcepub fn clear_line(&mut self)
pub fn clear_line(&mut self)
Clear the current line
Sourcepub fn smart_truncate(&mut self, max_size: usize)
pub fn smart_truncate(&mut self, max_size: usize)
Smart truncate the screen buffer to keep it within reasonable limits
Sourcepub fn to_plain_text(&self) -> String
pub fn to_plain_text(&self) -> String
Get the screen as plain text
Sourcepub fn display(&self) -> Vec<String>
pub fn display(&self) -> Vec<String>
Get the screen as a vector of strings, with each string representing a line
Sourcepub fn last_modified(&self) -> Instant
pub fn last_modified(&self) -> Instant
Returns the last time the screen was modified
Sourcepub fn time_since_last_modified(&self) -> f64
pub fn time_since_last_modified(&self) -> f64
Time since last modification in seconds
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Screen
impl RefUnwindSafe for Screen
impl Send for Screen
impl Sync for Screen
impl Unpin for Screen
impl UnsafeUnpin for Screen
impl UnwindSafe for Screen
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<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