TTYGrid

Struct TTYGrid 

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

Usually constructed by crate::grid!, this is the outer object of the whole library, all things are held by it in some form. Please review the impl for methods which can be used to adjust the properties of the grid once created.

Implementations§

Source§

impl TTYGrid

Source

pub fn new(headers: Vec<SafeGridHeader>) -> Result<Self>

Source

pub fn set_delimiter_color(&mut self, colors: Colors)

Sets the delimiter color; the dashes between the header and the content.

Source

pub fn set_header_color(&mut self, colors: Colors)

Sets the header color.

Source

pub fn set_primary_color(&mut self, colors: Colors)

Sets the primary color; colors will alternate between primary and secondary per row as the table is built.

Source

pub fn set_secondary_color(&mut self, colors: Colors)

Sets the secondary color; colors will alternate between primary and secondary per row as the table is built.

Source

pub fn add_line(&mut self, item: GridLine)

Source

pub fn clear_lines(&mut self)

Source

pub fn headers(&self) -> HeaderList

Source

pub fn select(&mut self, header: SafeGridHeader, idx: usize)

Source

pub fn is_selected(&self, header: SafeGridHeader) -> bool

Source

pub fn select_all_headers(&mut self)

Source

pub fn deselect_all_headers(&mut self)

Source

pub fn display(&mut self) -> Result<String>

Yield a string which is suitable for passing to println!, but does not make any attempt to add terminal styling, which may be better for situations where data is piped. Unlike std::fmt::Display, this display method returns Result<String, anyhow::Error>.

Source

pub fn write(&mut self, writer: impl Write) -> Result<()>

Write to the writer, typically std::io::stdout. Terminal colors will be set.

Trait Implementations§

Source§

impl Clone for TTYGrid

Source§

fn clone(&self) -> TTYGrid

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 Display for TTYGrid

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for TTYGrid

§

impl !RefUnwindSafe for TTYGrid

§

impl !Send for TTYGrid

§

impl !Sync for TTYGrid

§

impl Unpin for TTYGrid

§

impl !UnwindSafe for TTYGrid

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, 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.