comfy_table/style/column.rs
1/// A Constraint can be added to a [columns](crate::Column).
2///
3/// They allow some control over Column widths as well as the dynamic arrangement process.
4///
5/// All percental boundaries will be ignored, if:
6/// - you aren't using one of ContentArrangement::{Dynamic, DynamicFullWidth}
7/// - the width of the table/terminal cannot be determined.
8#[derive(Copy, Clone, Debug, PartialEq, Eq)]
9pub enum ColumnConstraint {
10 /// This will completely hide a column.
11 Hidden,
12 /// Force the column to be as long as it's content.
13 /// Use with caution! This can easily mess up your table formatting,
14 /// if a column's content is overly long.
15 ContentWidth,
16 /// Enforce a absolute width for a column.
17 Absolute(Width),
18 /// Specify a lower boundary, either fixed or as percentage of the total width.
19 /// A column with this constraint will be at least as wide as specified.
20 /// If the content isn't as long as that boundary, it will be padded.
21 /// If the column has longer content and is allowed to grow, the column may take more space.
22 LowerBoundary(Width),
23 /// Specify a upper boundary, either fixed or as percentage of the total width.
24 /// A column with this constraint will be at most as wide as specified.
25 /// The column may be smaller than that width.
26 UpperBoundary(Width),
27 /// Specify both, an upper and a lower boundary.
28 Boundaries { lower: Width, upper: Width },
29}
30
31#[derive(Copy, Clone, Debug, PartialEq, Eq)]
32pub enum Width {
33 /// A fixed amount of characters.
34 Fixed(u16),
35 /// A width equivalent to a certain percentage of the available width.
36 /// Values above 100 will be automatically reduced to 100.
37 ///
38 /// **Warning:** This option will be ignored if:
39 /// - you aren't using one of ContentArrangement::{Dynamic, DynamicFullWidth}
40 /// - the width of the table/terminal cannot be determined.
41 Percentage(u16),
42}