From a87e060b7cbf461dc94fc5a0d21515a1174a0cb4 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Tue, 1 Jan 2019 12:59:35 +0300 Subject: [PATCH] [A] Added new empty style --- docs/index.md | 256 ++++++++++++----------- example/main.c | 18 +- lib/fort.c | 30 ++- lib/fort.h | 1 + src/fort_impl.c | 2 + src/properties.c | 27 ++- src/properties.h | 1 + tests/bb_tests/test_table_border_style.c | 18 ++ 8 files changed, 226 insertions(+), 127 deletions(-) diff --git a/docs/index.md b/docs/index.md index c4ce68b..725569e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -111,126 +111,142 @@ These pages contain the API documentation of **libfort** - simple library to cre List of libfort builtin border styles: ~~~~~~~~~~~~~~~~~~~~~ - - - - FT_BASIC_STYLE FT_BASIC2_STYLE - - +------+--------------------------+------+--------+ +------+--------------------------+------+--------+ - | Rank | Title | Year | Rating | | Rank | Title | Year | Rating | - +------+--------------------------+------+--------+ +------+--------------------------+------+--------+ - | 1 | The Shawshank Redemption | 1994 | 9.5 | | 1 | The Shawshank Redemption | 1994 | 9.5 | - | 2 | 12 Angry Men | 1957 | 8.8 | +------+--------------------------+------+--------+ - | 3 | It's a Wonderful Life | 1946 | 8.6 | | 2 | 12 Angry Men | 1957 | 8.8 | - +------+--------------------------+------+--------+ +------+--------------------------+------+--------+ - | 4 | 2001: A Space Odyssey | 1968 | 8.5 | | 3 | It's a Wonderful Life | 1946 | 8.6 | - | 5 | Blade Runner | 1982 | 8.1 | +------+--------------------------+------+--------+ - +------+--------------------------+------+--------+ | 4 | 2001: A Space Odyssey | 1968 | 8.5 | - +------+--------------------------+------+--------+ - | 5 | Blade Runner | 1982 | 8.1 | - +------+--------------------------+------+--------+ - - - - - FT_SIMPLE_STYLE FT_PLAIN_STYLE - - ------------------------------------------------- - Rank Title Year Rating Rank Title Year Rating - ------ -------------------------- ------ -------- ------------------------------------------------- - 1 The Shawshank Redemption 1994 9.5 1 The Shawshank Redemption 1994 9.5 - 2 12 Angry Men 1957 8.8 2 12 Angry Men 1957 8.8 - 3 It's a Wonderful Life 1946 8.6 3 It's a Wonderful Life 1946 8.6 - ------ -------------------------- ------ -------- ------------------------------------------------- - 4 2001: A Space Odyssey 1968 8.5 4 2001: A Space Odyssey 1968 8.5 - 5 Blade Runner 1982 8.1 5 Blade Runner 1982 8.1 - - - - - - FT_DOT_STYLE FT_EMPTY_STYLE - - ................................................... - : Rank : Title : Year : Rating : Rank Title Year Rating - :......:..........................:......:........: 1 The Shawshank Redemption 1994 9.5 - : 1 : The Shawshank Redemption : 1994 : 9.5 : 2 12 Angry Men 1957 8.8 - : 2 : 12 Angry Men : 1957 : 8.8 : 3 It's a Wonderful Life 1946 8.6 - : 3 : It's a Wonderful Life : 1946 : 8.6 : - :......:..........................:......:........: 4 2001: A Space Odyssey 1968 8.5 - : 4 : 2001: A Space Odyssey : 1968 : 8.5 : 5 Blade Runner 1982 8.1 - : 5 : Blade Runner : 1982 : 8.1 : - :......:..........................:......:........: - - - - - FT_SOLID_STYLE FT_SOLID_ROUND_STYLE - - ┌──────┬──────────────────────────┬──────┬────────┐ ╭──────┬──────────────────────────┬──────┬────────╮ - │ Rank │ Title │ Year │ Rating │ │ Rank │ Title │ Year │ Rating │ - ├──────┼──────────────────────────┼──────┼────────┤ ├──────┼──────────────────────────┼──────┼────────┤ - │ 1 │ The Shawshank Redemption │ 1994 │ 9.5 │ │ 1 │ The Shawshank Redemption │ 1994 │ 9.5 │ - │ 2 │ 12 Angry Men │ 1957 │ 8.8 │ │ 2 │ 12 Angry Men │ 1957 │ 8.8 │ - │ 3 │ It's a Wonderful Life │ 1946 │ 8.6 │ │ 3 │ It's a Wonderful Life │ 1946 │ 8.6 │ - ├──────┼──────────────────────────┼──────┼────────┤ ├──────┼──────────────────────────┼──────┼────────┤ - │ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 │ │ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 │ - │ 5 │ Blade Runner │ 1982 │ 8.1 │ │ 5 │ Blade Runner │ 1982 │ 8.1 │ - └──────┴──────────────────────────┴──────┴────────╯ ╰──────┴──────────────────────────┴──────┴────────╯ - - - - - FT_NICE_STYLE FT_DOUBLE_STYLE - - ╔══════╦══════════════════════════╦══════╦════════╗ ╔══════╦══════════════════════════╦══════╦════════╗ - ║ Rank ║ Title ║ Year ║ Rating ║ ║ Rank ║ Title ║ Year ║ Rating ║ - ╠══════╬══════════════════════════╬══════╬════════╣ ╠══════╬══════════════════════════╬══════╬════════╣ - ║ 1 ║ The Shawshank Redemption ║ 1994 ║ 9.5 ║ ║ 1 ║ The Shawshank Redemption ║ 1994 ║ 9.5 ║ - ║ 2 ║ 12 Angry Men ║ 1957 ║ 8.8 ║ ║ 2 ║ 12 Angry Men ║ 1957 ║ 8.8 ║ - ║ 3 ║ It's a Wonderful Life ║ 1946 ║ 8.6 ║ ║ 3 ║ It's a Wonderful Life ║ 1946 ║ 8.6 ║ - ╟──────╫──────────────────────────╫──────╫────────╢ ╠══════╬══════════════════════════╬══════╬════════╣ - ║ 4 ║ 2001: A Space Odyssey ║ 1968 ║ 8.5 ║ ║ 4 ║ 2001: A Space Odyssey ║ 1968 ║ 8.5 ║ - ║ 5 ║ Blade Runner ║ 1982 ║ 8.1 ║ ║ 5 ║ Blade Runner ║ 1982 ║ 8.1 ║ - ╚══════╩══════════════════════════╩══════╩════════╝ ╚══════╩══════════════════════════╩══════╩════════╝ - - - - - FT_DOUBLE2_STYLE FT_BOLD_STYLE - - ╔══════╤══════════════════════════╤══════╤════════╗ ┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━┓ - ║ Rank │ Title │ Year │ Rating ║ ┃ Rank ┃ Title ┃ Year ┃ Rating ┃ - ╠══════╪══════════════════════════╪══════╪════════╣ ┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━┫ - ║ 1 │ The Shawshank Redemption │ 1994 │ 9.5 ║ ┃ 1 ┃ The Shawshank Redemption ┃ 1994 ┃ 9.5 ┃ - ╟──────┼──────────────────────────┼──────┼────────╢ ┃ 2 ┃ 12 Angry Men ┃ 1957 ┃ 8.8 ┃ - ║ 2 │ 12 Angry Men │ 1957 │ 8.8 ║ ┃ 3 ┃ It's a Wonderful Life ┃ 1946 ┃ 8.6 ┃ - ╟──────┼──────────────────────────┼──────┼────────╢ ┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━┫ - ║ 3 │ It's a Wonderful Life │ 1946 │ 8.6 ║ ┃ 4 ┃ 2001: A Space Odyssey ┃ 1968 ┃ 8.5 ┃ - ╠══════╪══════════════════════════╪══════╪════════╣ ┃ 5 ┃ Blade Runner ┃ 1982 ┃ 8.1 ┃ - ║ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 ║ ┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━┻━━━━━━━━┛ - ╟──────┼──────────────────────────┼──────┼────────╢ - ║ 5 │ Blade Runner │ 1982 │ 8.1 ║ - ╚══════╧══════════════════════════╧══════╧════════╝ - - - - - FT_BOLD2_STYLE FT_FRAME_STYLE - - ┏━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━┓ ▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜ - ┃ Rank │ Title │ Year │ Rating ┃ ▌ Rank ┃ Title ┃ Year ┃ Rating ▐ - ┣━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━┿━━━━━━━━┫ ▌━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━▐ - ┃ 1 │ The Shawshank Redemption │ 1994 │ 9.5 ┃ ▌ 1 ┃ The Shawshank Redemption ┃ 1994 ┃ 9.5 ▐ - ┠──────┼──────────────────────────┼──────┼────────┨ ▌ 2 ┃ 12 Angry Men ┃ 1957 ┃ 8.8 ▐ - ┃ 2 │ 12 Angry Men │ 1957 │ 8.8 ┃ ▌ 3 ┃ It's a Wonderful Life ┃ 1946 ┃ 8.6 ▐ - ┠──────┼──────────────────────────┼──────┼────────┨ ▌━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━▐ - ┃ 3 │ It's a Wonderful Life │ 1946 │ 8.6 ┃ ▌ 4 ┃ 2001: A Space Odyssey ┃ 1968 ┃ 8.5 ▐ - ┣━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━┿━━━━━━━━┫ ▌ 5 ┃ Blade Runner ┃ 1982 ┃ 8.1 ▐ - ┃ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 ┃ ▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟ - ┠──────┼──────────────────────────┼──────┼────────┨ - ┃ 5 │ Blade Runner │ 1982 │ 8.1 ┃ - ┗━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━┛ + + + + FT_BASIC_STYLE FT_BASIC2_STYLE + + +------+--------------------------+------+--------+ +------+--------------------------+------+--------+ + | Rank | Title | Year | Rating | | Rank | Title | Year | Rating | + +------+--------------------------+------+--------+ +------+--------------------------+------+--------+ + | 1 | The Shawshank Redemption | 1994 | 9.5 | | 1 | The Shawshank Redemption | 1994 | 9.5 | + | 2 | 12 Angry Men | 1957 | 8.8 | +------+--------------------------+------+--------+ + | 3 | It's a Wonderful Life | 1946 | 8.6 | | 2 | 12 Angry Men | 1957 | 8.8 | + +------+--------------------------+------+--------+ +------+--------------------------+------+--------+ + | 4 | 2001: A Space Odyssey | 1968 | 8.5 | | 3 | It's a Wonderful Life | 1946 | 8.6 | + | 5 | Blade Runner | 1982 | 8.1 | +------+--------------------------+------+--------+ + +------+--------------------------+------+--------+ | 4 | 2001: A Space Odyssey | 1968 | 8.5 | + +------+--------------------------+------+--------+ + | 5 | Blade Runner | 1982 | 8.1 | + +------+--------------------------+------+--------+ + + + + + FT_SIMPLE_STYLE FT_PLAIN_STYLE + + ------------------------------------------------- + Rank Title Year Rating Rank Title Year Rating + ------ -------------------------- ------ -------- ------------------------------------------------- + 1 The Shawshank Redemption 1994 9.5 1 The Shawshank Redemption 1994 9.5 + 2 12 Angry Men 1957 8.8 2 12 Angry Men 1957 8.8 + 3 It's a Wonderful Life 1946 8.6 3 It's a Wonderful Life 1946 8.6 + ------ -------------------------- ------ -------- ------------------------------------------------- + 4 2001: A Space Odyssey 1968 8.5 4 2001: A Space Odyssey 1968 8.5 + 5 Blade Runner 1982 8.1 5 Blade Runner 1982 8.1 + + + + + + FT_DOT_STYLE FT_EMPTY_STYLE + + ................................................... Rank Title Year Rating + : Rank : Title : Year : Rating : 1 The Shawshank Redemption 1994 9.5 + :......:..........................:......:........: 2 12 Angry Men 1957 8.8 + : 1 : The Shawshank Redemption : 1994 : 9.5 : 3 It's a Wonderful Life 1946 8.6 + : 2 : 12 Angry Men : 1957 : 8.8 : + : 3 : It's a Wonderful Life : 1946 : 8.6 : 4 2001: A Space Odyssey 1968 8.5 + :......:..........................:......:........: 5 Blade Runner 1982 8.1 + : 4 : 2001: A Space Odyssey : 1968 : 8.5 : + : 5 : Blade Runner : 1982 : 8.1 : + :......:..........................:......:........: + + + + + FT_EMPTY2_STYLE FT_SOLID_STYLE + + ┌──────┬──────────────────────────┬──────┬────────┐ + Rank Title Year Rating │ Rank │ Title │ Year │ Rating │ + 1 The Shawshank Redemption 1994 9.5 ├──────┼──────────────────────────┼──────┼────────┤ + 2 12 Angry Men 1957 8.8 │ 1 │ The Shawshank Redemption │ 1994 │ 9.5 │ + 3 It's a Wonderful Life 1946 8.6 │ 2 │ 12 Angry Men │ 1957 │ 8.8 │ + │ 3 │ It's a Wonderful Life │ 1946 │ 8.6 │ + 4 2001: A Space Odyssey 1968 8.5 ├──────┼──────────────────────────┼──────┼────────┤ + 5 Blade Runner 1982 8.1 │ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 │ + │ 5 │ Blade Runner │ 1982 │ 8.1 │ + └──────┴──────────────────────────┴──────┴────────╯ + + + + + FT_SOLID_ROUND_STYLE FT_NICE_STYLE + + ╭──────┬──────────────────────────┬──────┬────────╮ ╔══════╦══════════════════════════╦══════╦════════╗ + │ Rank │ Title │ Year │ Rating │ ║ Rank ║ Title ║ Year ║ Rating ║ + ├──────┼──────────────────────────┼──────┼────────┤ ╠══════╬══════════════════════════╬══════╬════════╣ + │ 1 │ The Shawshank Redemption │ 1994 │ 9.5 │ ║ 1 ║ The Shawshank Redemption ║ 1994 ║ 9.5 ║ + │ 2 │ 12 Angry Men │ 1957 │ 8.8 │ ║ 2 ║ 12 Angry Men ║ 1957 ║ 8.8 ║ + │ 3 │ It's a Wonderful Life │ 1946 │ 8.6 │ ║ 3 ║ It's a Wonderful Life ║ 1946 ║ 8.6 ║ + ├──────┼──────────────────────────┼──────┼────────┤ ╟──────╫──────────────────────────╫──────╫────────╢ + │ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 │ ║ 4 ║ 2001: A Space Odyssey ║ 1968 ║ 8.5 ║ + │ 5 │ Blade Runner │ 1982 │ 8.1 │ ║ 5 ║ Blade Runner ║ 1982 ║ 8.1 ║ + ╰──────┴──────────────────────────┴──────┴────────╯ ╚══════╩══════════════════════════╩══════╩════════╝ + + + + + FT_DOUBLE_STYLE FT_DOUBLE2_STYLE + + ╔══════╦══════════════════════════╦══════╦════════╗ ╔══════╤══════════════════════════╤══════╤════════╗ + ║ Rank ║ Title ║ Year ║ Rating ║ ║ Rank │ Title │ Year │ Rating ║ + ╠══════╬══════════════════════════╬══════╬════════╣ ╠══════╪══════════════════════════╪══════╪════════╣ + ║ 1 ║ The Shawshank Redemption ║ 1994 ║ 9.5 ║ ║ 1 │ The Shawshank Redemption │ 1994 │ 9.5 ║ + ║ 2 ║ 12 Angry Men ║ 1957 ║ 8.8 ║ ╟──────┼──────────────────────────┼──────┼────────╢ + ║ 3 ║ It's a Wonderful Life ║ 1946 ║ 8.6 ║ ║ 2 │ 12 Angry Men │ 1957 │ 8.8 ║ + ╠══════╬══════════════════════════╬══════╬════════╣ ╟──────┼──────────────────────────┼──────┼────────╢ + ║ 4 ║ 2001: A Space Odyssey ║ 1968 ║ 8.5 ║ ║ 3 │ It's a Wonderful Life │ 1946 │ 8.6 ║ + ║ 5 ║ Blade Runner ║ 1982 ║ 8.1 ║ ╠══════╪══════════════════════════╪══════╪════════╣ + ╚══════╩══════════════════════════╩══════╩════════╝ ║ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 ║ + ╟──────┼──────────────────────────┼──────┼────────╢ + ║ 5 │ Blade Runner │ 1982 │ 8.1 ║ + ╚══════╧══════════════════════════╧══════╧════════╝ + + + + + FT_BOLD_STYLE FT_BOLD2_STYLE + + ┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━┓ ┏━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━┓ + ┃ Rank ┃ Title ┃ Year ┃ Rating ┃ ┃ Rank │ Title │ Year │ Rating ┃ + ┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━┫ ┣━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━┿━━━━━━━━┫ + ┃ 1 ┃ The Shawshank Redemption ┃ 1994 ┃ 9.5 ┃ ┃ 1 │ The Shawshank Redemption │ 1994 │ 9.5 ┃ + ┃ 2 ┃ 12 Angry Men ┃ 1957 ┃ 8.8 ┃ ┠──────┼──────────────────────────┼──────┼────────┨ + ┃ 3 ┃ It's a Wonderful Life ┃ 1946 ┃ 8.6 ┃ ┃ 2 │ 12 Angry Men │ 1957 │ 8.8 ┃ + ┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━┫ ┠──────┼──────────────────────────┼──────┼────────┨ + ┃ 4 ┃ 2001: A Space Odyssey ┃ 1968 ┃ 8.5 ┃ ┃ 3 │ It's a Wonderful Life │ 1946 │ 8.6 ┃ + ┃ 5 ┃ Blade Runner ┃ 1982 ┃ 8.1 ┃ ┣━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━┿━━━━━━━━┫ + ┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━┻━━━━━━━━┛ ┃ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 ┃ + ┠──────┼──────────────────────────┼──────┼────────┨ + ┃ 5 │ Blade Runner │ 1982 │ 8.1 ┃ + ┗━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━┛ + + + + + FT_FRAME_STYLE + + ▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜ + ▌ Rank ┃ Title ┃ Year ┃ Rating ▐ + ▌━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━▐ + ▌ 1 ┃ The Shawshank Redemption ┃ 1994 ┃ 9.5 ▐ + ▌ 2 ┃ 12 Angry Men ┃ 1957 ┃ 8.8 ▐ + ▌ 3 ┃ It's a Wonderful Life ┃ 1946 ┃ 8.6 ▐ + ▌━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━▐ + ▌ 4 ┃ 2001: A Space Odyssey ┃ 1968 ┃ 8.5 ▐ + ▌ 5 ┃ Blade Runner ┃ 1982 ┃ 8.1 ▐ + ▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟ ~~~~~~~~~~~~~~~~~~~~~ diff --git a/example/main.c b/example/main.c index f3a719d..d0eb77c 100644 --- a/example/main.c +++ b/example/main.c @@ -251,6 +251,7 @@ void print_different_border_styles() FT_PLAIN_STYLE, FT_DOT_STYLE, FT_EMPTY_STYLE, + FT_EMPTY2_STYLE, FT_SOLID_STYLE, FT_SOLID_ROUND_STYLE, FT_NICE_STYLE, @@ -269,6 +270,7 @@ void print_different_border_styles() L"FT_PLAIN_STYLE", L"FT_DOT_STYLE", L"FT_EMPTY_STYLE", + L"FT_EMPTY2_STYLE", L"FT_SOLID_STYLE", L"FT_SOLID_ROUND_STYLE", L"FT_NICE_STYLE", @@ -281,13 +283,14 @@ void print_different_border_styles() for (size_t i = 0; i < sizeof(styles)/sizeof(styles[0]); i += 2) { ft_table_t *table_tmp_1 = create_basic_wtable(styles[i]); - ft_table_t *table_tmp_2 = create_basic_wtable(styles[i + 1]); - ft_wprintf(table, L" %ls \n\n%ls", style_names[i], ft_to_wstring(table_tmp_1)); - ft_wprintf_ln(table, L" %ls \n\n%ls", style_names[i + 1], ft_to_wstring(table_tmp_2)); - ft_destroy_table(table_tmp_1); - ft_destroy_table(table_tmp_2); + + if (i + 1 < sizeof(styles)/sizeof(styles[0])) { + ft_table_t *table_tmp_2 = create_basic_wtable(styles[i + 1]); + ft_wprintf_ln(table, L" %ls \n\n%ls", style_names[i + 1], ft_to_wstring(table_tmp_2)); + ft_destroy_table(table_tmp_2); + } } fwprintf(stderr, L"Table:\n%ls\n ", ft_to_wstring(table)); ft_destroy_table(table); @@ -403,6 +406,11 @@ int main(void) printf("Table:\n%s\n", ft_to_string(table)); ft_destroy_table(table); + ft_set_default_border_style(FT_EMPTY2_STYLE); + table = create_basic_table(); + printf("Table:\n%s\n", ft_to_string(table)); + ft_destroy_table(table); + ft_set_default_border_style(FT_SOLID_STYLE); table = create_basic_table(); printf("Table:\n%s\n", ft_to_string(table)); diff --git a/lib/fort.c b/lib/fort.c index 4c628f4..46b7909 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -545,6 +545,7 @@ extern struct fort_border_style FORT_SIMPLE_STYLE; extern struct fort_border_style FORT_PLAIN_STYLE; extern struct fort_border_style FORT_DOT_STYLE; extern struct fort_border_style FORT_EMPTY_STYLE; +extern struct fort_border_style FORT_EMPTY2_STYLE; extern struct fort_border_style FORT_SOLID_STYLE; extern struct fort_border_style FORT_SOLID_ROUND_STYLE; extern struct fort_border_style FORT_NICE_STYLE; @@ -1964,6 +1965,7 @@ struct ft_border_style *const FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT struct ft_border_style *const FT_PLAIN_STYLE = (struct ft_border_style *) &FORT_PLAIN_STYLE; struct ft_border_style *const FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYLE; struct ft_border_style *const FT_EMPTY_STYLE = (struct ft_border_style *) &FORT_EMPTY_STYLE; +struct ft_border_style *const FT_EMPTY2_STYLE = (struct ft_border_style *) &FORT_EMPTY2_STYLE; struct ft_border_style *const FT_SOLID_STYLE = (struct ft_border_style *) &FORT_SOLID_STYLE; struct ft_border_style *const FT_SOLID_ROUND_STYLE = (struct ft_border_style *) &FORT_SOLID_ROUND_STYLE; struct ft_border_style *const FT_NICE_STYLE = (struct ft_border_style *) &FORT_NICE_STYLE; @@ -1983,6 +1985,7 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons || (const struct fort_border_style *)style == &FORT_DOT_STYLE || (const struct fort_border_style *)style == &FORT_PLAIN_STYLE || (const struct fort_border_style *)style == &FORT_EMPTY_STYLE + || (const struct fort_border_style *)style == &FORT_EMPTY2_STYLE || (const struct fort_border_style *)style == &FORT_SOLID_STYLE || (const struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE || (const struct fort_border_style *)style == &FORT_NICE_STYLE @@ -3087,6 +3090,31 @@ fort_status_t set_default_cell_property(uint32_t property, int value) } #define EMPTY_STYLE { \ + /* border_chars */ \ + { \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + }, \ + /* header_border_chars */ \ + { \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + }, \ + /* separator_chars */ \ + { \ + "\0", " ", "\0 ", "\0", \ + "\0", "\0", \ + }, \ +} + + +#define EMPTY2_STYLE { \ /* border_chars */ \ { \ " ", " ", " ", " ", \ @@ -3110,7 +3138,6 @@ fort_status_t set_default_cell_property(uint32_t property, int value) }, \ } - #define SOLID_STYLE { \ /* border_chars */ \ { \ @@ -3314,6 +3341,7 @@ struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE; struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE; struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE; +struct fort_border_style FORT_EMPTY2_STYLE = EMPTY2_STYLE; struct fort_border_style FORT_SOLID_STYLE = SOLID_STYLE; struct fort_border_style FORT_SOLID_ROUND_STYLE = SOLID_ROUND_STYLE; struct fort_border_style FORT_NICE_STYLE = NICE_STYLE; diff --git a/lib/fort.h b/lib/fort.h index a172482..fd970a6 100644 --- a/lib/fort.h +++ b/lib/fort.h @@ -611,6 +611,7 @@ extern struct ft_border_style *const FT_SIMPLE_STYLE; extern struct ft_border_style *const FT_PLAIN_STYLE; extern struct ft_border_style *const FT_DOT_STYLE; extern struct ft_border_style *const FT_EMPTY_STYLE; +extern struct ft_border_style *const FT_EMPTY2_STYLE; extern struct ft_border_style *const FT_SOLID_STYLE; extern struct ft_border_style *const FT_SOLID_ROUND_STYLE; extern struct ft_border_style *const FT_NICE_STYLE; diff --git a/src/fort_impl.c b/src/fort_impl.c index 1d14244..8e372c5 100644 --- a/src/fort_impl.c +++ b/src/fort_impl.c @@ -809,6 +809,7 @@ struct ft_border_style *const FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT struct ft_border_style *const FT_PLAIN_STYLE = (struct ft_border_style *) &FORT_PLAIN_STYLE; struct ft_border_style *const FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYLE; struct ft_border_style *const FT_EMPTY_STYLE = (struct ft_border_style *) &FORT_EMPTY_STYLE; +struct ft_border_style *const FT_EMPTY2_STYLE = (struct ft_border_style *) &FORT_EMPTY2_STYLE; struct ft_border_style *const FT_SOLID_STYLE = (struct ft_border_style *) &FORT_SOLID_STYLE; struct ft_border_style *const FT_SOLID_ROUND_STYLE = (struct ft_border_style *) &FORT_SOLID_ROUND_STYLE; struct ft_border_style *const FT_NICE_STYLE = (struct ft_border_style *) &FORT_NICE_STYLE; @@ -828,6 +829,7 @@ static void set_border_props_for_props(fort_table_properties_t *properties, cons || (const struct fort_border_style *)style == &FORT_DOT_STYLE || (const struct fort_border_style *)style == &FORT_PLAIN_STYLE || (const struct fort_border_style *)style == &FORT_EMPTY_STYLE + || (const struct fort_border_style *)style == &FORT_EMPTY2_STYLE || (const struct fort_border_style *)style == &FORT_SOLID_STYLE || (const struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE || (const struct fort_border_style *)style == &FORT_NICE_STYLE diff --git a/src/properties.c b/src/properties.c index da82769..e704e84 100644 --- a/src/properties.c +++ b/src/properties.c @@ -638,6 +638,31 @@ fort_status_t set_default_cell_property(uint32_t property, int value) } #define EMPTY_STYLE { \ + /* border_chars */ \ + { \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + }, \ + /* header_border_chars */ \ + { \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + }, \ + /* separator_chars */ \ + { \ + "\0", " ", "\0 ", "\0", \ + "\0", "\0", \ + }, \ +} + + +#define EMPTY2_STYLE { \ /* border_chars */ \ { \ " ", " ", " ", " ", \ @@ -661,7 +686,6 @@ fort_status_t set_default_cell_property(uint32_t property, int value) }, \ } - #define SOLID_STYLE { \ /* border_chars */ \ { \ @@ -865,6 +889,7 @@ struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE; struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE; struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE; +struct fort_border_style FORT_EMPTY2_STYLE = EMPTY2_STYLE; struct fort_border_style FORT_SOLID_STYLE = SOLID_STYLE; struct fort_border_style FORT_SOLID_ROUND_STYLE = SOLID_ROUND_STYLE; struct fort_border_style FORT_NICE_STYLE = NICE_STYLE; diff --git a/src/properties.h b/src/properties.h index 4bc7db3..453bbdb 100644 --- a/src/properties.h +++ b/src/properties.h @@ -160,6 +160,7 @@ extern struct fort_border_style FORT_SIMPLE_STYLE; extern struct fort_border_style FORT_PLAIN_STYLE; extern struct fort_border_style FORT_DOT_STYLE; extern struct fort_border_style FORT_EMPTY_STYLE; +extern struct fort_border_style FORT_EMPTY2_STYLE; extern struct fort_border_style FORT_SOLID_STYLE; extern struct fort_border_style FORT_SOLID_ROUND_STYLE; extern struct fort_border_style FORT_NICE_STYLE; diff --git a/tests/bb_tests/test_table_border_style.c b/tests/bb_tests/test_table_border_style.c index 6612136..6dd4a49 100644 --- a/tests/bb_tests/test_table_border_style.c +++ b/tests/bb_tests/test_table_border_style.c @@ -354,6 +354,24 @@ void test_table_builtin_border_styles(void) table_str = ft_to_string(table); assert_true(table_str != NULL); + table_str_etalon = + " Rank Title Year Rating \n" + " 1 The Shawshank Redemption 1994 9.5 \n" + " 2 12 Angry Men 1957 8.8 \n" + " 3 It's a Wonderful Life 1946 8.6 \n" + " \n" + " 4 2001: A Space Odyssey 1968 8.5 \n" + " 5 Blade Runner 1982 8.1 \n"; + assert_str_equal(table_str, table_str_etalon); + ft_destroy_table(table); + + /* *************************************************************** */ + + ft_set_default_border_style(FT_EMPTY2_STYLE); + table = create_basic_table(); + table_str = ft_to_string(table); + assert_true(table_str != NULL); + table_str_etalon = " \n" " Rank Title Year Rating \n"