Skip to content

Commit

Permalink
Merge pull request #97 from alexander-beedie/ascii-condensed-preset
Browse files Browse the repository at this point in the history
New preset "ASCII_FULL_CONDENSED"
  • Loading branch information
Nukesor authored Dec 30, 2022
2 parents 2c018c3 + b735bf8 commit b4204fb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
15 changes: 13 additions & 2 deletions src/style/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
/// ```
pub const ASCII_FULL: &str = "||--+==+|-+||++++++";

/// Default style without any borders.
/// Just like ASCII_FULL, but without dividers between rows.
///
/// ```text
/// +-------+-------+
/// | Hello | there |
/// +===============+
/// | a | b |
/// | c | d |
/// +-------+-------+
pub const ASCII_FULL_CONDENSED: &str = "||--+==+| ++++++";

/// Just like ASCII_FULL, but without any borders.
///
/// ```text
/// Hello | there
Expand Down Expand Up @@ -84,7 +95,7 @@ pub const ASCII_MARKDOWN: &str = "|| |-||| ";
/// ```
pub const UTF8_FULL: &str = "││──╞═╪╡┆╌┼├┤┬┴┌┐└┘";

/// Default UTF8 style, but without spacing between rows.
/// Default UTF8 style, but without dividers between rows.
///
/// ```text
/// ┌───────┬───────┐
Expand Down
4 changes: 2 additions & 2 deletions src/utils/arrangement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn arrange_content(table: &Table) -> Vec<ColumnDisplayInfo> {
table_width
} else {
disabled::arrange(table, &mut infos, visible_columns, &max_content_widths);
return infos.into_iter().map(|(_, info)| info).collect();
return infos.into_values().collect();
};

match &table.arrangement {
Expand All @@ -54,7 +54,7 @@ pub fn arrange_content(table: &Table) -> Vec<ColumnDisplayInfo> {
}
}

infos.into_iter().map(|(_, info)| info).collect()
infos.into_values().collect()
}

#[cfg(test)]
Expand Down
18 changes: 17 additions & 1 deletion tests/all/presets_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ fn test_ascii_full() {
assert_eq!("\n".to_string() + &table.to_string(), expected);
}

#[test]
fn test_ascii_full_condensed() {
let mut table = get_preset_table();
table.load_preset(ASCII_FULL_CONDENSED);
println!("{table}");
let expected = "
+-------+-------+
| Hello | there |
+===============+
| a | b |
| c | d |
+-------+-------+";
println!("{expected}");
assert_eq!("\n".to_string() + &table.trim_fmt(), expected);
}

#[test]
fn test_ascii_no_borders() {
let mut table = get_preset_table();
Expand Down Expand Up @@ -127,7 +143,7 @@ fn test_utf8_full() {
}

#[test]
fn test_utf8_condensed() {
fn test_utf8_full_condensed() {
let mut table = get_preset_table();
table.load_preset(UTF8_FULL_CONDENSED);
println!("{table}");
Expand Down

0 comments on commit b4204fb

Please sign in to comment.