Skip to main content

rat_ftable2/
lib.rs

1#![doc = include_str!("../readme.md")]
2
3use crate::_private::NonExhaustive;
4use ratatui_core::layout::Rect;
5use ratatui_core::style::Style;
6
7mod derive;
8pub mod edit;
9pub mod selection;
10mod table;
11mod util;
12mod vec;
13
14pub use rat_ftable::TableSelection;
15pub use rat_ftable::TableStyle;
16pub use table::{Table, TableState};
17pub use vec::{TableVec, TableVecState};
18
19/// Width for the table-layout.
20#[derive(Debug, Default)]
21pub enum LayoutWidth {
22    /// Fixed width. Columns are layout for this size.
23    Length(u16),
24    /// Width is the sum of the columns. If the width is
25    /// larger than the area, horizontal scrolling is used.
26    ///
27    /// Note: Constraint::Fill is useless for this.
28    /// Such columns will assume a width of 10.
29    Columns,
30    /// Fit the columns to the table-area.
31    #[default]
32    Area,
33}
34
35/// Render-context for rendering a table-cell.
36#[derive(Debug)]
37pub struct TableContext<'a> {
38    /// Current row.
39    pub row: usize,
40
41    /// Focus flag is set.
42    pub focus: bool,
43
44    /// Cell is selected.
45    pub selected_cell: bool,
46    /// Row of the cell is selected.
47    pub selected_row: bool,
48    /// Column of the cell is selected.
49    pub selected_column: bool,
50
51    /// Base style
52    pub style: Style,
53    /// Selection style if any.
54    pub select_style: Option<Style>,
55
56    /// Column layout for all columns.
57    /// Only the x-position and width are set,
58    /// y-position and height are 0.
59    pub column_layout: &'a [Rect],
60    /// Spacing after the current cell.
61    /// Will be empty when calling row-rendering.
62    pub space_area: Rect,
63    /// Total area for the current row.
64    pub row_area: Rect,
65
66    /// Construct with `..Default::default()`
67    pub non_exhaustive: NonExhaustive,
68}
69
70/// Eventhandling.
71pub mod event {
72    pub use rat_event::*;
73    pub use rat_ftable::event::{DoubleClickOutcome, TableOutcome};
74}
75
76mod _private {
77    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
78    pub struct NonExhaustive;
79}