pub struct Context { /* private fields */ }Expand description
What a widget is told when it measures and renders: the width to fill, the tab stop spacing, and the box characters.
A context holds no colour or terminal fact. Styles are resolved before layout, and escape sequences are written after it.
It is Clone but not Copy, so a later release can add a field without
breaking a caller that copies it. A widget takes &Context.
The at_* and using_* methods return a changed clone, so a container
derives the context of a child from its own: context.at_width(column).
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(width: u16) -> Self
pub fn new(width: u16) -> Self
A context width cells wide, with tab stops every TAB_WIDTH
cells and Unicode box characters.
Sourcepub fn unbounded() -> Self
pub fn unbounded() -> Self
A context with no width limit, so a widget takes its natural width.
width reports u16::MAX, so layout arithmetic needs
no special case, and is_unbounded tells a
caller that the width is no limit and not a real one. Every method that
returns a changed clone keeps the flag, including
at_width.
Sourcepub fn at_tab_width(&self, tab_width: NonZeroU16) -> Self
pub fn at_tab_width(&self, tab_width: NonZeroU16) -> Self
This context with tab stops every tab_width cells.
Sourcepub fn using_box_chars(&self, box_chars: BoxChars) -> Self
pub fn using_box_chars(&self, box_chars: BoxChars) -> Self
This context with box_chars for borders.
Sourcepub fn is_unbounded(&self) -> bool
pub fn is_unbounded(&self) -> bool
Sourcepub fn tab_width(&self) -> NonZeroU16
pub fn tab_width(&self) -> NonZeroU16
The spacing of tab stops, in cells.