Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New preset "ASCII_FULL_CONDENSED" #97

Merged
merged 2 commits into from Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/style/presets.rs
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
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
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