Skip to main content

comfy_table/style/
mod.rs

1#[cfg(all(feature = "tty", not(feature = "reexport_crossterm")))]
2mod attribute;
3mod cell;
4#[cfg(all(feature = "tty", not(feature = "reexport_crossterm")))]
5mod color;
6mod column;
7/// This module provides styling presets for tables.\
8/// Every preset has an example preview.
9pub mod presets;
10mod table;
11mod table_style;
12
13pub use cell::CellAlignment;
14pub use column::{ColumnConstraint, Width};
15#[cfg(feature = "tty")]
16pub use styling_enums::{Attribute, Color};
17#[cfg(feature = "tty")]
18pub(crate) use styling_enums::{map_attribute, map_color};
19pub use table::ContentArrangement;
20pub use table_style::{ContentLineStyle, LineStyle, TableStyle};
21
22/// Convenience module to have cleaner and "identical" conditional re-exports for style enums.
23#[cfg(all(feature = "tty", not(feature = "reexport_crossterm")))]
24mod styling_enums {
25    pub use super::{attribute::*, color::*};
26}
27
28/// Re-export the crossterm type directly instead of using the internal mirrored types.
29/// This result in possible ABI incompatibilities when using comfy_table and crossterm in the same
30/// project with different versions, but may also be very convenient for developers.
31#[cfg(all(feature = "tty", feature = "reexport_crossterm"))]
32mod styling_enums {
33    /// Attributes used for styling cell content. Reexport of crossterm's
34    /// [Attributes](crossterm::style::Attribute) enum.
35    pub use crossterm::style::Attribute;
36    /// Colors used for styling cell content. Reexport of crossterm's
37    /// [Color](crossterm::style::Color) enum.
38    pub use crossterm::style::Color;
39
40    /// Convenience function to have the same mapping code for reexported types.
41    #[inline]
42    pub(crate) fn map_attribute(attribute: Attribute) -> Attribute {
43        attribute
44    }
45
46    /// Convenience function to have the same mapping code for reexported types.
47    #[inline]
48    pub(crate) fn map_color(color: Color) -> Color {
49        color
50    }
51}