| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 2 | cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::{maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max()., minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().}, |
| 3 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once()., |
| 4 | }; |
| 5 | |
| 6 | use concat_stringrust-analyzer cargo concat-string 1.0.1 crate/::concat_stringrust-analyzer cargo concat-string 1.0.1 concat_string!; |
| 7 | use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{ |
| 8 | Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#, |
| 9 | layoutrust-analyzer cargo ratatui-core 0.1.2 layout/::{Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#, Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#, Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#, Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#}, |
| 10 | symbolsrust-analyzer cargo ratatui-core 0.1.2 symbols/::linerust-analyzer cargo ratatui-core 0.1.2 symbols/line/, |
| 11 | textrust-analyzer cargo ratatui-core 0.1.2 text/::{Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#, Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#, Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#}, |
| 12 | widgetsrust-analyzer cargo ratatui 0.30.2 widgets/::{Blockrust-analyzer cargo ratatui-widgets 0.3.2 block/Block#, Cellrust-analyzer cargo ratatui-widgets 0.3.2 table/cell/Cell#, Paddingrust-analyzer cargo ratatui-widgets 0.3.2 block/padding/Padding#, Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#, Tablerust-analyzer cargo ratatui-widgets 0.3.2 table/Table#}, |
| 13 | }; |
| 14 | |
| 15 | use superrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/::{ |
| 16 | CalculateColumnWidthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/CalculateColumnWidths#, ColumnHeaderrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnHeader#, ColumnWidthBoundsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnWidthBounds#, DataTablerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#, DataTableColumnrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/DataTableColumn#, DataToCellrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/data_type/DataToCell#, |
| 17 | SortTyperust-analyzer cargo bottom 0.14.9 canvas/components/data_table/sortable/SortType#, |
| 18 | }; |
| 19 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 20 | apprust-analyzer cargo bottom 0.14.9 app/::layout_managerrust-analyzer cargo bottom 0.14.9 app/layout_manager/::BottomWidgetrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#, |
| 21 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::{ |
| 22 | Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 23 | componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::scroll_barrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/::{ScrollBarArgsrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/ScrollBarArgs#, draw_scroll_barrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/draw_scroll_bar().}, |
| 24 | drawing_utilsrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/::widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block()., |
| 25 | }, |
| 26 | constantsrust-analyzer cargo bottom 0.14.9 constants/::TABLE_GAP_HEIGHT_LIMITrust-analyzer cargo bottom 0.14.9 constants/TABLE_GAP_HEIGHT_LIMIT., |
| 27 | optionsrust-analyzer cargo bottom 0.14.9 options/::configrust-analyzer cargo bottom 0.14.9 options/config/::flagsrust-analyzer cargo bottom 0.14.9 options/config/flags/::TableGaprust-analyzer cargo bottom 0.14.9 options/config/flags/TableGap#, |
| 28 | utilsrust-analyzer cargo bottom 0.14.9 utils/::stringsrust-analyzer cargo bottom 0.14.9 utils/strings/::truncate_to_textrust-analyzer cargo bottom 0.14.9 utils/strings/truncate_to_text()., |
| 29 | }; |
| 30 | |
| 31 | pub enum SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState# { |
| 32 | NotSelectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#NotSelected#, |
| 33 | Selectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Selected#, |
| 34 | Expandedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Expanded#, |
| 35 | } |
| 36 | |
| 37 | impl SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState# { |
| 38 | pub fn newrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[SelectionState]new().(is_expanded: bool, is_on_widget: bool) -> Selfrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[SelectionState] { |
| 39 | if is_expanded { |
| 40 | SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::Expandedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Expanded# |
| 41 | } else if is_on_widget { |
| 42 | SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::Selectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Selected# |
| 43 | } else { |
| 44 | SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::NotSelectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#NotSelected# |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /// A [`DrawInfo`] is information required on each draw call. |
| 50 | pub struct DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo# { |
| 51 | pub locrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#loc.: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, |
| 52 | pub force_redrawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#force_redraw.: bool, |
| 53 | pub recalculate_column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#recalculate_column_widths.: bool, |
| 54 | pub selection_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#selection_state.: SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#, |
| 55 | } |
| 56 | |
| 57 | impl DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo# { |
| 58 | pub fn is_on_widgetrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_on_widget().(&self) -> bool { |
| 59 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.selection_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#selection_state., SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::NotSelectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#NotSelected#) |
| 60 | } |
| 61 | |
| 62 | pub fn is_expandedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_expanded().(&self) -> bool { |
| 63 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self.selection_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#selection_state., SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::Expandedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Expanded#) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl<DataType, H, S, C> DataTablerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#<DataType, H, S, C> |
| 68 | where |
| 69 | DataType: DataToCellrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/data_type/DataToCell#<H>, |
| 70 | H: ColumnHeaderrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnHeader#, |
| 71 | S: SortTyperust-analyzer cargo bottom 0.14.9 canvas/components/data_table/sortable/SortType#, |
| 72 | C: DataTableColumnrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/DataTableColumn#<H>, |
| 73 | { |
| 74 | fn blockrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]block().<'a>(&self, draw_info: &'a DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#, data_len: usize) -> Blockrust-analyzer cargo ratatui-widgets 0.3.2 block/Block#<'a> { |
| 75 | let is_selected = match draw_info.selection_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#selection_state. { |
| 76 | SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::NotSelectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#NotSelected# => false, |
| 77 | SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::Selectedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Selected# | SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::Expandedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#Expanded# => true, |
| 78 | }; |
| 79 | |
| 80 | let border_style = if is_selected { |
| 81 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..highlighted_border_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#highlighted_border_style. |
| 82 | } else { |
| 83 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..border_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#border_style. |
| 84 | }; |
| 85 | |
| 86 | let mut block = widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block().( |
| 87 | self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..is_basicrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#is_basic., |
| 88 | is_selected, |
| 89 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..border_typerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#border_type., |
| 90 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..general_widget_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#general_widget_style., |
| 91 | ) |
| 92 | .border_stylerust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]border_style().(border_style); |
| 93 | |
| 94 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((left_title, right_title)) = self.generate_titlerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]generate_title().(draw_info, data_len) { |
| 95 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..is_basicrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#is_basic. { |
| 96 | block = block.title_toprust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]title_top().(left_title); |
| 97 | } |
| 98 | |
| 99 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(right_title) = right_title { |
| 100 | block = block.title_toprust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]title_top().(right_title); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | block |
| 105 | } |
| 106 | |
| 107 | /// Generates a title, given the available space. |
| 108 | fn generate_titlerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]generate_title().( |
| 109 | &self, draw_info: &'_ DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#, total_items: usize, |
| 110 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#<'static>, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#<'static>>)> { |
| 111 | self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..titlerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#title..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|title| { |
| 112 | let current_index = self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..current_indexrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#current_index..saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_add().(1); |
| 113 | let draw_loc = draw_info.locrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#loc.; |
| 114 | let title_style = self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..title_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#title_style.; |
| 115 | |
| 116 | let title = if self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..show_table_scroll_positionrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#show_table_scroll_position. { |
| 117 | let pos = current_index.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 118 | let tot = total_items.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 119 | let title_string = concat_stringrust-analyzer cargo concat-string 1.0.1 concat_string!!(title, "(", pos, " of ", tot, ") "); |
| 120 | |
| 121 | if title_string.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() { |
| 122 | title_string |
| 123 | } else { |
| 124 | title.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 125 | } |
| 126 | } else { |
| 127 | title.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 128 | }; |
| 129 | |
| 130 | let left_title = Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#::fromrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`][`From<Span<'a>>`]from().(Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::styledrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]styled().(title, title_style)).left_alignedrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`]left_aligned().(); |
| 131 | |
| 132 | let right_title = if draw_info.is_expandedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_expanded().() { |
| 133 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#::fromrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`][`From<&'a str>`]from().(" Esc to go back ").right_alignedrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`]right_aligned().()) |
| 134 | } else { |
| 135 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 136 | }; |
| 137 | |
| 138 | (left_title, right_title) |
| 139 | }) |
| 140 | } |
| 141 | |
| 142 | pub fn drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]draw().( |
| 143 | &mut self, f: &mut Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#<'_>, draw_info: &DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#, widget: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut BottomWidgetrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#>, |
| 144 | painter: &Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 145 | ) { |
| 146 | let draw_loc = draw_info.locrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#loc.; |
| 147 | let margined_draw_loc = Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#::defaultrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout][Default]default().() |
| 148 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().([Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Percentagerust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Percentage#(100)]) |
| 149 | .directionrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]direction().(Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#::Horizontalrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#Horizontal#) |
| 150 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(draw_loc)[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 151 | |
| 152 | let mut block = self.blockrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]block().(draw_info, self.datarust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#data..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 153 | |
| 154 | let horizontal_padding = if self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..is_basicrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#is_basic. && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().draw_info.is_on_widgetrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_on_widget().() { |
| 155 | 1 |
| 156 | } else { |
| 157 | 0 |
| 158 | }; |
| 159 | let right_padding = horizontal_padding rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().u16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`From<bool>`]from().(self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..show_table_scroll_barrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#show_table_scroll_bar.); |
| 160 | block = block.paddingrust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]padding().(Paddingrust-analyzer cargo ratatui-widgets 0.3.2 block/padding/Padding#::newrust-analyzer cargo ratatui-widgets 0.3.2 block/padding/impl#[Padding]new().(horizontal_padding, right_padding, 0, 0)); |
| 161 | |
| 162 | let (inner_width, inner_height) = { |
| 163 | let inner_rect = block.innerrust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]inner().(margined_draw_loc); |
| 164 | self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..inner_rectrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#inner_rect. = inner_rect; |
| 165 | (inner_rect.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., inner_rect.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.) |
| 166 | }; |
| 167 | |
| 168 | if inner_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 || inner_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 { |
| 169 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().(block, margined_draw_loc); |
| 170 | } else { |
| 171 | // Calculate widths |
| 172 | if draw_info.recalculate_column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#recalculate_column_widths. { |
| 173 | let col_widths = DataType::column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/data_type/DataToCell#column_widths().(&self.datarust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#data., &self.columnsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#columns.); |
| 174 | |
| 175 | self.columnsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#columns. |
| 176 | .iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() |
| 177 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&col_widths) |
| 178 | .for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#for_each().(|(column, &width)| { |
| 179 | let header_len = column.header_lenrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/DataTableColumn#header_len().() as u16; |
| 180 | if let ColumnWidthBoundsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnWidthBounds#::Softrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnWidthBounds#Soft# { |
| 181 | desiredrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnWidthBounds#Soft#desired., |
| 182 | max_percentagerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/ColumnWidthBounds#Soft#max_percentage.: _, |
| 183 | } = &mut column.bounds_mutrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/DataTableColumn#bounds_mut().() |
| 184 | { |
| 185 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().desired = maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(header_len, width); |
| 186 | } |
| 187 | }); |
| 188 | |
| 189 | self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..calculated_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#calculated_widths. = self |
| 190 | .columnsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#columns. |
| 191 | .calculate_column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/impl#[`[C]`][`CalculateColumnWidths<H>`]calculate_column_widths().(inner_width, self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..left_to_rightrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#left_to_right.); |
| 192 | |
| 193 | // Update draw loc in widget map |
| 194 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget) = widget { |
| 195 | widget.top_left_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#top_left_corner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.)); |
| 196 | widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = |
| 197 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.)); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | let show_header = inner_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().1; |
| 202 | let header_height = u16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`From<bool>`]from().(show_header); |
| 203 | let table_gap_setting = self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..table_gaprust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#table_gap.; |
| 204 | let table_gap = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().show_header || draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().TABLE_GAP_HEIGHT_LIMITrust-analyzer cargo bottom 0.14.9 constants/TABLE_GAP_HEIGHT_LIMIT. { |
| 205 | 0 |
| 206 | } else { |
| 207 | table_gap_setting.heightrust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[TableGap]height().() |
| 208 | }; |
| 209 | |
| 210 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.datarust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#data..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() || !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.first_drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#first_draw. { |
| 211 | if self.first_drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#first_draw. { |
| 212 | // TODO: Doing it this way is fine, but it could be done better (e.g. showing |
| 213 | // custom no results/entries message) |
| 214 | self.first_drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#first_draw. = false; |
| 215 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first_index) = self.first_indexrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#first_index. { |
| 216 | self.set_positionrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/impl#[`DataTable<DataType, H, S, C>`]set_position().(first_index); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | let num_rows: usize = inner_height |
| 221 | .saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]saturating_sub().(table_gap rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().header_height) |
| 222 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 223 | |
| 224 | let columns = &self.columnsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#columns.; |
| 225 | let rows = { |
| 226 | self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state. |
| 227 | .get_start_positionrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/impl#[DataTableState]get_start_position().(num_rows, draw_info.force_redrawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#force_redraw.); |
| 228 | let start = self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..display_start_indexrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#display_start_index.; |
| 229 | let end = minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(self.datarust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#data..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().num_rows); |
| 230 | self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state. |
| 231 | .table_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#table_state. |
| 232 | .selectrust-analyzer cargo ratatui-widgets 0.3.2 table/state/impl#[TableState]select().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..current_indexrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#current_index..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(start))); |
| 233 | |
| 234 | self.datarust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#data.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|data_row| { |
| 235 | let row = Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]new().( |
| 236 | columns |
| 237 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 238 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..calculated_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#calculated_widths.) |
| 239 | .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|(column, &width)| { |
| 240 | data_row.to_cell_textrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/data_type/DataToCell#to_cell_text().(column.innerrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/DataTableColumn#inner().(), width).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|content| { |
| 241 | let content = truncate_to_textrust-analyzer cargo bottom 0.14.9 utils/strings/truncate_to_text().(&content, width.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().()); |
| 242 | |
| 243 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(style) = |
| 244 | data_row.style_cellrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/data_type/DataToCell#style_cell().(column.innerrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/column/DataTableColumn#inner().(), painter) |
| 245 | { |
| 246 | Cellrust-analyzer cargo ratatui-widgets 0.3.2 table/cell/Cell#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/cell/impl#[`Cell<'a>`]new().(content).stylerust-analyzer cargo ratatui-widgets 0.3.2 table/cell/impl#[`Cell<'a>`]style().(style) |
| 247 | } else { |
| 248 | Cellrust-analyzer cargo ratatui-widgets 0.3.2 table/cell/Cell#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/cell/impl#[`Cell<'a>`]new().(content) |
| 249 | } |
| 250 | }) |
| 251 | }), |
| 252 | ); |
| 253 | |
| 254 | data_row.style_rowrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/data_type/DataToCell#style_row().(row, painter) |
| 255 | }) |
| 256 | }; |
| 257 | |
| 258 | let headers = self |
| 259 | .sort_typerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#sort_type. |
| 260 | .build_headerrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/sortable/SortType#build_header().(columns, &self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..calculated_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#calculated_widths.) |
| 261 | .stylerust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]style().(self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..header_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#header_style.) |
| 262 | .bottom_marginrust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]bottom_margin().(table_gap); |
| 263 | |
| 264 | let widget = { |
| 265 | let highlight_style = if draw_info.is_on_widgetrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_on_widget().() |
| 266 | || self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..show_current_entry_when_unfocusedrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#show_current_entry_when_unfocused. |
| 267 | { |
| 268 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..highlighted_text_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#highlighted_text_style. |
| 269 | } else { |
| 270 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..text_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#text_style. |
| 271 | }; |
| 272 | let mut table = Tablerust-analyzer cargo ratatui-widgets 0.3.2 table/Table#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]new().( |
| 273 | rows, |
| 274 | self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..calculated_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#calculated_widths..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|nzu| nzu.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().()), |
| 275 | ) |
| 276 | .blockrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]block().(block) |
| 277 | .row_highlight_stylerust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]row_highlight_style().(highlight_style) |
| 278 | .stylerust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]style().(self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..text_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#text_style.); |
| 279 | |
| 280 | if show_header { |
| 281 | table = table.headerrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]header().(headers); |
| 282 | } |
| 283 | |
| 284 | table |
| 285 | }; |
| 286 | |
| 287 | let table_state = &mut self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..table_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#table_state.; |
| 288 | f.render_stateful_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_stateful_widget().(widget, margined_draw_loc, table_state); |
| 289 | |
| 290 | if self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..show_table_scroll_barrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#show_table_scroll_bar. { |
| 291 | let scrollbar_area = Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect# { |
| 292 | xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x.: self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..inner_rectrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#inner_rect..xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..inner_rectrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#inner_rect..widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., |
| 293 | yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.: self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..inner_rectrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#inner_rect..yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().header_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().table_gap, |
| 294 | widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width.: 1, |
| 295 | heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.: num_rows as u16, |
| 296 | }; |
| 297 | |
| 298 | draw_scroll_barrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/draw_scroll_bar().( |
| 299 | f, |
| 300 | scrollbar_area, |
| 301 | ScrollBarArgsrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/ScrollBarArgs# { |
| 302 | content_lengthrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/ScrollBarArgs#content_length.: self.datarust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#data..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), |
| 303 | viewport_lengthrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/ScrollBarArgs#viewport_length.: num_rows, |
| 304 | positionrust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/ScrollBarArgs#position.: self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..current_indexrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#current_index., |
| 305 | stylerust-analyzer cargo bottom 0.14.9 canvas/components/scroll_bar/ScrollBarArgs#style.: self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..text_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#text_style., |
| 306 | }, |
| 307 | ); |
| 308 | } |
| 309 | |
| 310 | if table_gap rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().0 && table_gap_setting rust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[TableGap][`PartialEq<Self>`]eq().==rust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[TableGap][`PartialEq<Self>`]eq(). rust-analyzer cargo bottom 0.14.9 options/config/flags/impl#[TableGap][`PartialEq<Self>`]eq().TableGaprust-analyzer cargo bottom 0.14.9 options/config/flags/TableGap#::Linerust-analyzer cargo bottom 0.14.9 options/config/flags/TableGap#Line# && show_header { |
| 311 | let y = self.staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..inner_rectrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#inner_rect..yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().header_height; |
| 312 | let buf = f.buffer_mutrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]buffer_mut().(); |
| 313 | let border_style = if draw_info.is_on_widgetrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_on_widget().() { |
| 314 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..highlighted_border_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#highlighted_border_style. |
| 315 | } else { |
| 316 | self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..border_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#border_style. |
| 317 | }; |
| 318 | |
| 319 | for x in (draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().1)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().1) { |
| 320 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cell) = buf.cell_mutrust-analyzer cargo ratatui-core 0.1.2 buffer/buffer/impl#[Buffer]cell_mut().((x, y)) { |
| 321 | cell.set_symbolrust-analyzer cargo ratatui-core 0.1.2 buffer/cell/impl#[Cell]set_symbol().(linerust-analyzer cargo ratatui-core 0.1.2 symbols/line/::NORMALrust-analyzer cargo ratatui-core 0.1.2 symbols/line/NORMAL..horizontalrust-analyzer cargo ratatui-core 0.1.2 symbols/line/Set#horizontal.); |
| 322 | cell.set_stylerust-analyzer cargo ratatui-core 0.1.2 buffer/cell/impl#[Cell]set_style().(border_style); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.propsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#props..is_basicrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/props/DataTableProps#is_basic. || draw_info.is_on_widgetrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[DrawInfo]is_on_widget().() { |
| 327 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cell) = buf.cell_mutrust-analyzer cargo ratatui-core 0.1.2 buffer/buffer/impl#[Buffer]cell_mut().((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x., y)) { |
| 328 | cell.set_symbolrust-analyzer cargo ratatui-core 0.1.2 buffer/cell/impl#[Cell]set_symbol().(linerust-analyzer cargo ratatui-core 0.1.2 symbols/line/::NORMALrust-analyzer cargo ratatui-core 0.1.2 symbols/line/NORMAL..vertical_rightrust-analyzer cargo ratatui-core 0.1.2 symbols/line/Set#vertical_right.); |
| 329 | cell.set_stylerust-analyzer cargo ratatui-core 0.1.2 buffer/cell/impl#[Cell]set_style().(border_style); |
| 330 | } |
| 331 | |
| 332 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cell) = buf.cell_mutrust-analyzer cargo ratatui-core 0.1.2 buffer/buffer/impl#[Buffer]cell_mut().((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().1, y)) { |
| 333 | cell.set_symbolrust-analyzer cargo ratatui-core 0.1.2 buffer/cell/impl#[Cell]set_symbol().(linerust-analyzer cargo ratatui-core 0.1.2 symbols/line/::NORMALrust-analyzer cargo ratatui-core 0.1.2 symbols/line/NORMAL..vertical_leftrust-analyzer cargo ratatui-core 0.1.2 symbols/line/Set#vertical_left.); |
| 334 | cell.set_stylerust-analyzer cargo ratatui-core 0.1.2 buffer/cell/impl#[Cell]set_style().(border_style); |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | } else { |
| 339 | let table = Tablerust-analyzer cargo ratatui-widgets 0.3.2 table/Table#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]new().( |
| 340 | oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(Rowrust-analyzer cargo ratatui-widgets 0.3.2 table/row/Row#::newrust-analyzer cargo ratatui-widgets 0.3.2 table/row/impl#[`Row<'a>`]new().(Textrust-analyzer cargo ratatui-core 0.1.2 text/text/Text#::rawrust-analyzer cargo ratatui-core 0.1.2 text/text/impl#[`Text<'a>`]raw().("No data"))), |
| 341 | [Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Percentagerust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Percentage#(100)], |
| 342 | ) |
| 343 | .blockrust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]block().(block) |
| 344 | .stylerust-analyzer cargo ratatui-widgets 0.3.2 table/impl#[`Table<'a>`]style().(self.stylingrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#styling..text_stylerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/styling/DataTableStyling#text_style.); |
| 345 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().(table, margined_draw_loc); |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | } |