pub struct DetectOptions { /* private fields */ }Expand description
How the width of a stream is decided, and every default it applies.
A width takes the first of these that applies:
- an explicit
width, which is exact; - the window of the stream;
COLUMNS, when it holds a number from 1 to 65535;- the fallback.
The column buffer and the minimum apply only to the window and COLUMNS.
The width that results is at least 1.
Each default has an override and a way to turn it off:
- An explicit width bypasses detection.
- A column buffer of 0 reserves nothing.
- A minimum of 0 sets no floor.
- A fallback of
Noneleaves the width undecided.
The column buffer reads no variable until
column_buffer_envs names some.
Implementations§
Source§impl DetectOptions
impl DetectOptions
Sourcepub const fn new() -> Self
pub const fn new() -> Self
The defaults: no explicit width, a column buffer of
DEFAULT_COLUMN_BUFFER read from no variable, a minimum of
DEFAULT_MINIMUM_WIDTH, and a fallback of DEFAULT_FALLBACK_WIDTH.
Sourcepub const fn width(self, cells: u16) -> Self
pub const fn width(self, cells: u16) -> Self
Use exactly cells, with no detection, buffer, or minimum. 0 counts
as 1.
Sourcepub const fn column_buffer(self, cells: u16) -> Self
pub const fn column_buffer(self, cells: u16) -> Self
Reserve cells from a detected width. 0 reserves nothing. This
replaces whatever the variables of
column_buffer_envs hold.
Sourcepub const fn column_buffer_envs(self, names: &'static [&'static str]) -> Self
pub const fn column_buffer_envs(self, names: &'static [&'static str]) -> Self
Read the column buffer from the first of names that holds a number.
An empty list reads no variable, which is the default.
Sourcepub const fn minimum_width(self, cells: u16) -> Self
pub const fn minimum_width(self, cells: u16) -> Self
Never shrink a detected width below cells, unless the window is
narrower. 0 sets no floor.
Sourcepub const fn fallback_width(self, cells: Option<u16>) -> Self
pub const fn fallback_width(self, cells: Option<u16>) -> Self
Use cells when the stream gives no width and COLUMNS is unset,
empty, zero, or not a number from 1 to 65535.
None leaves the width undecided, and 0 counts as 1.