1use crate::{
2 grid::config::ColoredConfig,
3 grid::records::{ExactRecords, Records, RecordsMut, Resizable},
4 settings::TableOption,
5};
6
7use super::Panel;
8
9/// Header inserts a [`Panel`] at the top.
10/// See [`Panel`].
11#[derive(Debug)]
12pub struct Header<S>(S);
13
14impl<S> Header<S> {
15 /// Creates a new object.
16 pub fn new(text: S) -> Self
17 where
18 S: AsRef<str>,
19 {
20 Self(text)
21 }
22}
23
24impl<S, R, D> TableOption<R, D, ColoredConfig> for Header<S>
25where
26 S: AsRef<str>,
27 R: Records + ExactRecords + Resizable + RecordsMut<String>,
28{
29 fn change(self, records: &mut R, cfg: &mut ColoredConfig, dimension: &mut D) {
30 Panel::horizontal(row:0, self.0.as_ref()).change(records, cfg, dimension);
31 }
32}
33