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>
impl<S> VirtualTable<S>
Sourcepub fn title(self, title: impl Into<String>) -> Self
pub fn title(self, title: impl Into<String>) -> Self
A centered title above the table (console markup, as the core
Table::title).
Sourcepub fn caption(self, caption: impl Into<String>) -> Self
pub fn caption(self, caption: impl Into<String>) -> Self
A centered caption below the table (console markup).
Sourcepub fn box_set(self, box_set: Box) -> Self
pub fn box_set(self, box_set: Box) -> Self
The box-drawing set (default HEAVY_HEAD, as the core table).
Sourcepub fn without_box(self) -> Self
pub fn without_box(self) -> Self
Draw no borders and no column dividers.
Sourcepub fn border_style(self, style: Style) -> Self
pub fn border_style(self, style: Style) -> Self
Style the box border.
Source§impl<S: VirtualRows> VirtualTable<S>
impl<S: VirtualRows> VirtualTable<S>
Sourcepub fn new(columns: impl IntoIterator<Item = Column>, source: S) -> Self
pub fn new(columns: impl IntoIterator<Item = Column>, source: S) -> Self
A window of 20 rows from the top of source, under columns.
Sourcepub fn height(self, rows: usize) -> Self
pub fn height(self, rows: usize) -> Self
Show rows rows (at most MAX_HEIGHT).
Sourcepub fn widths(
self,
widths: impl IntoIterator<Item = impl Into<Option<usize>>>,
) -> Self
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.
Sourcepub fn sample(self, rows: usize) -> Self
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.
Sourcepub fn max_column_width(self, cells: usize) -> Self
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.
Sourcepub fn wrap(self, wrap: bool) -> Self
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).
Sourcepub fn show_position(self, show: bool) -> Self
pub fn show_position(self, show: bool) -> Self
Show the position line under the table (default on).
Sourcepub fn fit_window(self, fit: bool) -> Self
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.
Sourcepub fn row_numbers(self, show: bool) -> Self
pub fn row_numbers(self, show: bool) -> Self
Show each row’s 1-based number in a first # column (default off).
Sourcepub fn null_marker(self, marker: impl Into<String>) -> Self
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.
Sourcepub fn footnote(self, note: impl Into<String>) -> Self
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.
Sourcepub fn column_offset(self, offset: usize) -> Self
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.
Sourcepub fn visible_columns(self, count: usize) -> Self
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.
Sourcepub fn fit_columns(self, fit: bool) -> Self
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.
Sourcepub fn frozen_columns(self, count: usize) -> Self
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.
Sourcepub fn set_column_offset(&mut self, offset: usize)
pub fn set_column_offset(&mut self, offset: usize)
Move the column window to column offset (after the frozen ones).
Sourcepub fn set_visible_columns(&mut self, count: Option<usize>)
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).
Sourcepub fn scroll_columns_by(&mut self, columns: isize)
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.
Sourcepub fn window_column_offset(&self) -> usize
pub fn window_column_offset(&self) -> usize
The column window’s first column, after the frozen ones, as set.
Sourcepub fn max_column_offset(&self) -> usize
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.
Sourcepub fn shown_columns(&self, width: usize) -> Vec<usize>
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.
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Move the window to row offset (0-based).
Sourcepub fn set_height(&mut self, rows: usize)
pub fn set_height(&mut self, rows: usize)
Change how many rows the window shows (at most MAX_HEIGHT).
Sourcepub fn scroll_by(&mut self, rows: isize)
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.
Sourcepub fn window_offset(&self) -> usize
pub fn window_offset(&self) -> usize
The window’s first row (0-based), as set.
Sourcepub fn window_height(&self) -> usize
pub fn window_height(&self) -> usize
How many rows the window shows.
Sourcepub fn max_offset(&self) -> Option<usize>
pub fn max_offset(&self) -> Option<usize>
The offset of the last full window, when the source knows its length.
Sourcepub fn source_mut(&mut self) -> &mut S
pub fn source_mut(&mut self) -> &mut S
The source, to change. Call resample if the first
rows changed.
Sourcepub fn page(&self) -> Page
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.
Sourcepub fn page_at(&self, width: usize) -> Page
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.
Sourcepub fn column_widths(&self) -> Vec<usize>
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.
Sourcepub fn chrome_lines(&self, console: &Console, width: usize) -> usize
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.
Trait Implementations§
Source§impl<S: VirtualRows> AccessibleText for VirtualTable<S>
impl<S: VirtualRows> AccessibleText for VirtualTable<S>
Source§fn accessible_text(&self, width: usize) -> String
fn accessible_text(&self, width: usize) -> String
width where layout matters.Source§impl<S> Debug for VirtualTable<S>
impl<S> Debug for VirtualTable<S>
Source§impl<S: VirtualRows> Renderable for VirtualTable<S>
impl<S: VirtualRows> Renderable for VirtualTable<S>
Source§fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
The table’s measurement, widened to the position line and footnote:
every line rich_render emits.
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
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>
fn vertical(&self) -> Option<VerticalAlign>
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
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
"\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.