comfy_table/utils/arrangement/
disabled.rs

1use super::constraint;
2use super::helper::*;
3use super::{ColumnDisplayInfo, DisplayInfos};
4use crate::Table;
5
6/// Dynamic arrangement is disabled.
7/// Apply all non-relative constraints, and set the width of all remaining columns to the
8/// respective max content width.
9pub fn arrange(
10    table: &Table,
11    infos: &mut DisplayInfos,
12    visible_columns: usize,
13    max_content_widths: &[u16],
14) {
15    for column in table.columns.iter() {
16        if infos.contains_key(&column.index) {
17            continue;
18        }
19
20        let mut width = max_content_widths[column.index];
21
22        // Reduce the width, if a column has longer content than the specified MaxWidth constraint.
23        if let Some(max_width) = constraint::max(table, &column.constraint, visible_columns) {
24            if max_width < width {
25                width = absolute_width_with_padding(column, max_width);
26            }
27        }
28
29        let info = ColumnDisplayInfo::new(column, width);
30        infos.insert(column.index, info);
31    }
32}