Skip to main content

VirtualTable

Struct VirtualTable 

Source
pub struct VirtualTable<S> { /* private fields */ }
Expand description

One window of a VirtualRows source as a table; see the module docs.

The frame (title, caption, box, edges, expand, border style) is set with the same builders as TableData.

Implementations§

Source§

impl<S> VirtualTable<S>

Source

pub fn title(self, title: impl Into<String>) -> Self

A centered title above the table (console markup, as the core Table::title).

Source

pub fn caption(self, caption: impl Into<String>) -> Self

A centered caption below the table (console markup).

Source

pub fn box_set(self, box_set: Box) -> Self

The box-drawing set (default HEAVY_HEAD, as the core table).

Source

pub fn without_box(self) -> Self

Draw no borders and no column dividers.

Source

pub fn show_edge(self, show: bool) -> Self

Draw the outer edges (default on).

Source

pub fn expand(self, expand: bool) -> Self

Expand to the full available width.

Source

pub fn border_style(self, style: Style) -> Self

Style the box border.

Source§

impl<S: VirtualRows> VirtualTable<S>

Source

pub fn new(columns: impl IntoIterator<Item = Column>, source: S) -> Self

A window of 20 rows from the top of source, under columns.

Source

pub fn offset(self, offset: usize) -> Self

Start the window at row offset (0-based).

Source

pub fn height(self, rows: usize) -> Self

Show rows rows (at most MAX_HEIGHT).

Source

pub fn widths( self, widths: impl IntoIterator<Item = impl Into<Option<usize>>>, ) -> Self

Fix the column widths, in cells, in column order. A missing or None entry leaves that column to its ColumnOptions::width, or to the sample.

Source

pub fn sample(self, rows: usize) -> Self

Sample the header and the first rows rows for column widths (default DEFAULT_SAMPLE, at most MAX_SAMPLE). Zero samples only the header.

Source

pub fn max_column_width(self, cells: usize) -> Self

Cap sampled widths at cells (default DEFAULT_MAX_COLUMN_WIDTH, at least 1). Fixed widths are not capped.

Source

pub fn wrap(self, wrap: bool) -> Self

Wrap long cells onto more lines instead of cutting them short with an ellipsis (default off, so a row is one line).

Source

pub fn show_position(self, show: bool) -> Self

Show the position line under the table (default on).

Source

pub fn fit_window(self, fit: bool) -> Self

Also widen sampled columns to fit the rows shown (default off), up to max_column_width. For a window that is rendered once: scrolling such a table can change its widths.

Source

pub fn row_numbers(self, show: bool) -> Self

Show each row’s 1-based number in a first # column (default off).

Source

pub fn null_marker(self, marker: impl Into<String>) -> Self

Show null cells as marker in the table.null style, instead of empty like an empty string. Column formatters are not called for them.

Source

pub fn footnote(self, note: impl Into<String>) -> Self

A line under the position line, in the table.position style: a row count, a timing, a note.

Source

pub fn column_offset(self, offset: usize) -> Self

Start the column window at column offset, counted from 0 after the frozen ones. With a column window only the columns it shows are fetched, sampled and laid out; the position line adds columns 41–60 of 2,000 when some are left out.

Source

pub fn visible_columns(self, count: usize) -> Self

Show count columns (at least 1) from the column offset, besides the frozen ones. With fit_columns, at most count.

Source

pub fn fit_columns(self, fit: bool) -> Self

Show as many columns from the column offset as fit the width, besides the frozen ones, and always one (default off). Columns are measured by their widths (fixed, or sampled), sampled a few at a time, so a fit samples at most one column past those it shows.

Source

pub fn frozen_columns(self, count: usize) -> Self

Keep the first count columns on the left, whatever the column offset (an id column, a name): they are always shown and never scrolled.

Source

pub fn set_column_offset(&mut self, offset: usize)

Move the column window to column offset (after the frozen ones).

Source

pub fn set_visible_columns(&mut self, count: Option<usize>)

Show count columns from the offset, or None for all of them (or as many as fit).

Source

pub fn scroll_columns_by(&mut self, columns: isize)

Move the column window by columns (negative is left), stopping at the first column and at the last offset.

Source

pub fn window_column_offset(&self) -> usize

The column window’s first column, after the frozen ones, as set.

Source

pub fn max_column_offset(&self) -> usize

The largest column offset: the one whose window of visible_columns ends at the last column, or that shows the last column alone without a count.

Source

pub fn shown_columns(&self, width: usize) -> Vec<usize>

The 0-based indices of the columns a render width cells wide shows: the frozen ones, then the window’s. Every column without a column window.

Source

pub fn set_offset(&mut self, offset: usize)

Move the window to row offset (0-based).

Source

pub fn set_height(&mut self, rows: usize)

Change how many rows the window shows (at most MAX_HEIGHT).

Source

pub fn scroll_by(&mut self, rows: isize)

Move the window by rows (negative is up), stopping at the top and, when the source knows its length, at the last full window.

Source

pub fn window_offset(&self) -> usize

The window’s first row (0-based), as set.

Source

pub fn window_height(&self) -> usize

How many rows the window shows.

Source

pub fn row_count(&self) -> Option<usize>

The source’s row count, when it knows.

Source

pub fn max_offset(&self) -> Option<usize>

The offset of the last full window, when the source knows its length.

Source

pub fn columns(&self) -> &[Column]

The columns.

Source

pub fn source(&self) -> &S

The source.

Source

pub fn source_mut(&mut self) -> &mut S

The source, to change. Call resample if the first rows changed.

Source

pub fn resample(&self)

Forget the sampled widths, so the next render samples again.

Source

pub fn page(&self) -> Page

The rows the window shows, fetched from the source. An offset past the end of a source that knows its length moves back to the last full window; one past the end of a source that does not shows no rows. A window that fits its columns to the width is laid out for 80 cells; page_at takes the width.

Source

pub fn page_at(&self, width: usize) -> Page

The rows the window shows, with the columns a render width cells wide shows (shown_columns): only those cells are fetched.

Source

pub fn column_widths(&self) -> Vec<usize>

Each column’s width in cells: fixed, or sampled from the header and the first rows (and cached until resample). This samples every column; a column window samples only those it shows.

Source

pub fn chrome_lines(&self, console: &Console, width: usize) -> usize

How many lines the table takes around its rows at width cells: the title, edges, header, caption, position line and footnote. A viewport of lines lines holds lines - chrome_lines rows when cells do not wrap.

Source

pub fn to_table(&self, console: &Console) -> Table

The window as a core table (without the position line and footnote), its columns as many as the console’s width shows.

Trait Implementations§

Source§

impl<S: VirtualRows> AccessibleText for VirtualTable<S>

Source§

fn accessible_text(&self, width: usize) -> String

The content as plain lines, laid out for width where layout matters.
Source§

impl<S> Debug for VirtualTable<S>

Source§

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

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

impl<S: VirtualRows> Renderable for VirtualTable<S>

Source§

fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement

The table’s measurement, widened to the position line and footnote: every line rich_render emits.

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn fit_to_measurement(&self) -> bool

Whether a top-level Console::print shrinks this renderable to its measured width. Upstream renders every top-level renderable at the full console width, so the default is false; an extension may opt in.
Source§

fn vertical(&self) -> Option<VerticalAlign>

The vertical alignment a Table cell holding this renderable uses in place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.
Source§

fn print_end_line(&self, _options: &ConsoleOptions) -> bool

Whether a top-level print ends this renderable’s last line. This port’s renderables separate lines, where upstream’s end each line with "\n", so a print adds the final line break. A renderable whose upstream output stops without one (Screen, LiveRender, a Rule whose end has no newline) returns false, and the next output continues its last line. options are the print’s options.

Auto Trait Implementations§

§

impl<S> !Freeze for VirtualTable<S>

§

impl<S> !RefUnwindSafe for VirtualTable<S>

§

impl<S> !UnwindSafe for VirtualTable<S>

§

impl<S> Send for VirtualTable<S>
where S: Send,

§

impl<S> Sync for VirtualTable<S>
where S: Sync,

§

impl<S> Unpin for VirtualTable<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for VirtualTable<S>
where S: UnsafeUnpin,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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