From ece19c8bcbc5fbac659589f6eda1af8523d34d21 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sat, 3 Nov 2018 23:50:30 +0300 Subject: [PATCH] [C] Renames options to properties --- CMakeLists.txt | 6 +- README.md | 15 +- amalgamate.py | 4 +- example/main.c | 58 +- example/main.cpp | 20 +- lib/fort.c | 496 +++++++++--------- lib/fort.h | 78 +-- lib/fort.hpp | 108 ++-- src/cell.c | 26 +- src/fort_impl.c | 76 +-- src/fort_utils.h | 10 +- src/{options.c => properties.c} | 214 ++++---- src/{options.h => properties.h} | 60 +-- src/row.c | 72 +-- src/row.h | 2 +- src/string_buffer.c | 6 +- src/table.c | 20 +- src/table.h | 2 +- tests/bb_tests/test_memory_errors.c | 4 +- tests/bb_tests/test_table_basic.c | 98 ++-- tests/bb_tests/test_table_border_style.c | 20 +- ...able_options.c => test_table_properties.c} | 134 ++--- tests/bb_tests_cpp/test_table_basic.cpp | 18 +- tests/main_test.c | 4 +- tests/test_utils.c | 36 +- tests/tests.h | 8 +- tests/wb_tests/test_table_geometry.c | 4 +- 27 files changed, 798 insertions(+), 801 deletions(-) rename src/{options.c => properties.c} (70%) rename src/{options.h => properties.h} (64%) rename tests/bb_tests/{test_table_options.c => test_table_properties.c} (80%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd07107..6e49a5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ set(FORT_DEV_SOURCES src/fort_impl.c src/vector.c src/string_buffer.c - src/options.c + src/properties.c src/cell.c src/row.c src/table.c @@ -96,7 +96,7 @@ set(TEST_SOURCES_DEV tests/wb_tests/test_table_geometry.c tests/bb_tests/test_table_basic.c tests/bb_tests/test_table_border_style.c - tests/bb_tests/test_table_options.c + tests/bb_tests/test_table_properties.c tests/bb_tests/test_memory_errors.c tests/test_utils.c) add_executable(${PROJECT_NAME}_test_dev @@ -110,7 +110,7 @@ set(TEST_SOURCES tests/main_test.c tests/bb_tests/test_table_basic.c tests/bb_tests/test_table_border_style.c - tests/bb_tests/test_table_options.c + tests/bb_tests/test_table_properties.c tests/bb_tests/test_memory_errors.c tests/test_utils.c) add_executable(${PROJECT_NAME}_test diff --git a/README.md b/README.md index 82e548f..27fcdc1 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ **Features:** - Easy to integrate (only 2 files) -- Customization of appearance (various border styles and row/column/cell options for indentation, alignment, padding) +- Customization of appearance (various border styles and row/column/cell properties for indentation, alignment, padding) - A number of functions to fill the table (add content by adding separate cells, rows or use _printf_ like functions) - Support of multiple lines in cells - Support of wide characters @@ -56,7 +56,7 @@ See [wiki](https://github.com/seleznevae/libfort/wiki) of the project. The common libfort usage pattern: - create a table (`_ft_create_table_`); - fill it with data (`_ft_write_ln_`, `_fr_ptrintf_ln_`, `_ft_row_write_`, ...); -- modify basic table appearance (`_ft_set_cell_option_`, `ft_set_border_style` ...) +- modify basic table appearance (`_ft_set_cell_prop_`, `ft_set_border_style` ...) - convert table to string representation (`_ft_to_string_`); - destroy the table (`_ft_destroy_table_`) @@ -73,7 +73,8 @@ int main(void) { ft_table_t *table = ft_create_table(); /* Set "header" type for the first row */ - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); + ft_write_ln(table, "N", "Driver", "Time", "Avg Speed"); ft_write_ln(table, "1", "Ricciardo", "1:25.945", "222.128"); @@ -126,7 +127,7 @@ int main(void) ft_set_border_style(table, FT_DOUBLE2_STYLE); /* Set "header" type for the first row */ - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Movie title", "Director", "Year", "Rating"); ft_write_ln(table, "The Shawshank Redemption", "Frank Darabont", "1994", "9.5"); @@ -134,8 +135,8 @@ int main(void) ft_write_ln(table, "2001: A Space Odyssey", "Stanley Kubrick", "1968", "8.5"); /* Set center alignment for the 1st and 3rd columns */ - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 3, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); printf("%s\n", ft_to_string(table)); ft_destroy_table(table); @@ -189,7 +190,7 @@ int main(void) { ft_table_t *table = ft_create_table(); /* Set "header" type for the first row */ - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "N", "Planet", "Speed, km/s", "Temperature, K"); /* Fill row with printf like function */ diff --git a/amalgamate.py b/amalgamate.py index 1cd9260..552052f 100644 --- a/amalgamate.py +++ b/amalgamate.py @@ -95,7 +95,7 @@ def main(): "vector.h", "wcwidth.h", "string_buffer.h", - "options.h", + "properties.h", "cell.h", "row.h", "table.h" @@ -106,4 +106,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/example/main.c b/example/main.c index 3ba495f..0b90d69 100644 --- a/example/main.c +++ b/example/main.c @@ -6,10 +6,10 @@ static ft_table_t *create_basic_table(void) { ft_table_t *table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Rank", "Title", "Year", "Rating"); ft_write_ln(table, "1", "The Shawshank Redemption", "1994", "9.5"); @@ -36,7 +36,7 @@ void print_char_str(const char *str) void base_example(void) { ft_table_t *table = ft_create_table(); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "N", "Driver", "Time", "Avg Speed"); ft_write_ln(table, "1", "Ricciardo", "1:25.945", "222.128"); @@ -54,7 +54,7 @@ void complex_layout_example(void) ft_set_border_style(table, FT_DOUBLE2_STYLE); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Sed", "Aenean", "Text"); ft_write_ln(table, "Duis", "Aliquam", @@ -65,21 +65,21 @@ void complex_layout_example(void) "quam pellentesque."); ft_write_ln(table, "Summary", "", "Sed tempor est eget odio varius dignissim."); - ft_set_cell_option(table, 0, 2, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, 3, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, 0, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, 3, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); ft_set_cell_span(table, 3, 0, 2); printf("%s\n", ft_to_string(table)); ft_destroy_table(table); } -void different_cell_options_example(void) +void different_cell_properties_example(void) { ft_table_t *table = ft_create_table(); /* Change border style */ ft_set_border_style(table, FT_DOUBLE2_STYLE); /* Set "header" type for the first row */ - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Movie title", "Director", "Year", "Rating"); ft_write_ln(table, "The Shawshank Redemption", "Frank Darabont", "1994", "9.5"); @@ -87,8 +87,8 @@ void different_cell_options_example(void) ft_write_ln(table, "2001: A Space Odyssey", "Stanley Kubrick", "1968", "8.5"); /* Set center alignment for the 1st and 3rd columns */ - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 3, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); printf("%s\n", ft_to_string(table)); ft_destroy_table(table); @@ -98,7 +98,7 @@ void fill_table_with_data_example(void) { ft_table_t *table = ft_create_table(); /* Set "header" type for the first row */ - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "N", "Planet", "Speed, km/s", "Temperature, K"); /* Fill row with printf like function */ @@ -118,7 +118,7 @@ void fill_table_with_data_example(void) int main(void) { base_example(); - different_cell_options_example(); + different_cell_properties_example(); fill_table_with_data_example(); complex_layout_example(); @@ -127,10 +127,10 @@ int main(void) ft_table_t *table = NULL; table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_printf_ln(table, "%d|%s|%5.2f km/s", 1, "Mercury", 47.362); ft_printf_ln(table, "%d|%s|%5.2f km/s", 1, "Mercury", 47.362); @@ -144,10 +144,10 @@ int main(void) /*-------------------------------------------------------------*/ table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Rank", "Title", "Year", "Rating"); ft_write_ln(table, "1", "The Shawshank Redemption", "1994", "9.5"); @@ -163,10 +163,10 @@ int main(void) /*-------------------------------------------------------------*/ table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_printf_ln(table, "Commodity|Farm price|Avg. spread"); const char *row1[] = {"Potatoes", "$1.60", "200.94%"}; @@ -180,10 +180,10 @@ int main(void) /*-------------------------------------------------------------*/ table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_printf_ln(table, "No.|Name|Avg. Mark"); const char *ctab[2][3] = { {"1", "Joe Public", "3.14"}, @@ -260,7 +260,7 @@ int main(void) /* Debug */ ft_set_default_border_style(FT_SOLID_STYLE); table = create_basic_table(); - ft_set_cell_option(table, FT_CUR_ROW, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, FT_CUR_ROW, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Summary", "", "", "8.7"); ft_set_cell_span(table, 6, 0, 3); ft_set_cell_span(table, 0, 0, 3); @@ -275,10 +275,10 @@ int main(void) ft_set_default_border_style(FT_BASIC_STYLE); table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_wwrite_ln(table, L"Ранг", L"Название", L"Год", L"Рейтинг"); ft_wwrite_ln(table, L"1", L"Побег из Шоушенка", L"1994", L"9.5"); diff --git a/example/main.cpp b/example/main.cpp index 92dba67..d249c65 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -38,7 +38,7 @@ void base_example(void) std::cout << table.to_string() << std::endl; } -void different_cell_options_example(void) +void different_cell_properties_example(void) { fort::Table table; /* Change border style */ @@ -87,7 +87,7 @@ void fill_table_with_data_example(void) int main() { base_example(); - different_cell_options_example(); + different_cell_properties_example(); fill_table_with_data_example(); { @@ -103,11 +103,11 @@ int main() << "5" << "Blade Runner" << "1982" << "8.1" << fort::endr << fort::endr; - using fort::CellOption; - using fort::TableOption; - table.set_option(0, 0, 20); - table.set_option(0, 0, fort::TextAlign::Left); - table.set_option(2, FT_ANY_COLUMN, fort::RowType::Header); + using fort::CellProperty; + using fort::TableProperty; + table.set_property(0, 0, 20); + table.set_property(0, 0, fort::TextAlign::Left); + table.set_property(2, FT_ANY_COLUMN, fort::RowType::Header); std::cout << table.to_string() << std::endl; } @@ -124,14 +124,14 @@ int main() table.write_ln("4", "2001: A Space Odyssey", "1968", "8.5"); table.write_ln("5", "Blade Runner", "1982", "8.1"); - using fort::CellOption; - using fort::TableOption; + using fort::CellProperty; + using fort::TableProperty; table.set_cell_min_width(0, 0, 20); table.set_cell_text_align(0, 0, fort::TextAlign::Left); table.set_cell_row_type(2, FT_ANY_COLUMN, fort::RowType::Header); - table.set_option(4); + table.set_property(4); table.set_border_style(FT_SOLID_STYLE); std::cout << table.to_string(); diff --git a/lib/fort.c b/lib/fort.c index e54e2d9..3c2447b 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -117,8 +117,8 @@ enum F_BOOL { -struct fort_table_options; -struct fort_column_options; +struct fort_table_properties; +struct fort_column_properties; struct fort_row; struct vector; struct fort_cell; @@ -127,14 +127,14 @@ struct separator { int enabled; }; -typedef struct fort_table_options fort_table_options_t; +typedef struct fort_table_properties fort_table_properties_t; struct fort_context { - fort_table_options_t *table_options; + fort_table_properties_t *table_properties; size_t row; size_t column; }; typedef struct fort_context context_t; -typedef struct fort_column_options fort_column_options_t; +typedef struct fort_column_properties fort_column_properties_t; typedef struct vector vector_t; typedef struct fort_cell fort_cell_t; typedef struct string_buffer string_buffer_t; @@ -354,24 +354,24 @@ int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, siz /******************************************************** - Begin of file "options.h" + Begin of file "properties.h" ********************************************************/ -#ifndef OPTIONS_H -#define OPTIONS_H +#ifndef PROPERTIES_H +#define PROPERTIES_H /* #include "fort_utils.h" */ /* Commented by amalgamation script */ #include #include -#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option)) -#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option)) -#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option)) +#define PROP_IS_SET(ft_props, property) ((ft_props) & (property)) +#define PROP_SET(ft_props, property) ((ft_props) |=(property)) +#define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)property)) -struct fort_cell_options { +struct fort_cell_props { size_t cell_row; size_t cell_col; - uint32_t options; + uint32_t properties; unsigned int col_min_width; enum ft_text_alignment align; unsigned int cell_padding_top; @@ -382,29 +382,29 @@ struct fort_cell_options { enum ft_row_type row_type; }; -typedef struct fort_cell_options fort_cell_options_t; -typedef vector_t fort_cell_opt_container_t; +typedef struct fort_cell_props fort_cell_props_t; +typedef vector_t fort_cell_prop_container_t; FT_INTERNAL -fort_cell_opt_container_t *create_cell_opt_container(void); +fort_cell_prop_container_t *create_cell_prop_container(void); FT_INTERNAL -void destroy_cell_opt_container(fort_cell_opt_container_t *cont); +void destroy_cell_prop_container(fort_cell_prop_container_t *cont); FT_INTERNAL -const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col); +const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col); FT_INTERNAL -fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col); +fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col); FT_INTERNAL -fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value); +fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value); FT_INTERNAL -int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option); +int get_cell_property_value_hierarcial(const fort_table_properties_t *properties, size_t row, size_t column, uint32_t property); FT_INTERNAL -fort_status_t set_default_cell_option(uint32_t option, int value); +fort_status_t set_default_cell_property(uint32_t property, int value); /***************************************************************************** * TABLE BORDER @@ -501,44 +501,44 @@ extern struct fort_border_style FORT_BOLD2_STYLE; extern struct fort_border_style FORT_FRAME_STYLE; -struct fort_entire_table_options { +struct fort_entire_table_properties { unsigned int left_margin; unsigned int top_margin; unsigned int right_margin; unsigned int bottom_margin; }; -typedef struct fort_entire_table_options fort_entire_table_options_t; -extern fort_entire_table_options_t g_entire_table_options; +typedef struct fort_entire_table_properties fort_entire_table_properties_t; +extern fort_entire_table_properties_t g_entire_table_properties; FT_INTERNAL -fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value); +fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value); FT_INTERNAL -fort_status_t set_default_entire_table_option(uint32_t option, int value); +fort_status_t set_default_entire_table_property(uint32_t property, int value); -struct fort_table_options { +struct fort_table_properties { struct fort_border_style border_style; - fort_cell_opt_container_t *cell_options; - fort_entire_table_options_t entire_table_options; + fort_cell_prop_container_t *cell_properties; + fort_entire_table_properties_t entire_table_properties; }; -extern fort_table_options_t g_table_options; +extern fort_table_properties_t g_table_properties; FT_INTERNAL -size_t max_border_elem_strlen(struct fort_table_options *); +size_t max_border_elem_strlen(struct fort_table_properties *); FT_INTERNAL -fort_table_options_t *create_table_options(void); +fort_table_properties_t *create_table_properties(void); FT_INTERNAL -void destroy_table_options(fort_table_options_t *options); +void destroy_table_properties(fort_table_properties_t *properties); FT_INTERNAL -fort_table_options_t *copy_table_options(const fort_table_options_t *option); +fort_table_properties_t *copy_table_properties(const fort_table_properties_t *property); -#endif /* OPTIONS_H */ +#endif /* PROPERTIES_H */ /******************************************************** - End of file "options.h" + End of file "properties.h" ********************************************************/ @@ -606,7 +606,7 @@ string_buffer_t *cell_get_string_buffer(fort_cell_t *cell); /* #include "fort_utils.h" */ /* Commented by amalgamation script */ #include "fort.h" #include -/* #include "options.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ #ifdef FT_HAVE_WCHAR #include #endif @@ -699,7 +699,7 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t struct ft_table { vector_t *rows; - fort_table_options_t *options; + fort_table_properties_t *properties; string_buffer_t *conv_buffer; size_t cur_row; size_t cur_col; @@ -746,26 +746,26 @@ fort_status_t table_geometry(const ft_table_t *table, size_t *height, size_t *wi /******************************************************** - Begin of file "options.c" + Begin of file "properties.c" ********************************************************/ #include -/* #include "options.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ /* #include "fort_utils.h" */ /* Commented by amalgamation script */ /* #include "vector.h" */ /* Commented by amalgamation script */ /***************************************************************************** - * COLUMN OPTIONS + * COLUMN PROPERTIES * ***************************************************************************/ -struct fort_cell_options g_default_cell_option = { +struct fort_cell_props g_default_cell_properties = { FT_ANY_ROW, /* cell_row */ FT_ANY_COLUMN, /* cell_col */ - /* options */ - FT_COPT_MIN_WIDTH | FT_COPT_TEXT_ALIGN | FT_COPT_TOP_PADDING - | FT_COPT_BOTTOM_PADDING | FT_COPT_LEFT_PADDING | FT_COPT_RIGHT_PADDING - | FT_COPT_EMPTY_STR_HEIGHT, + /* properties */ + FT_CPROP_MIN_WIDTH | FT_CPROP_TEXT_ALIGN | FT_CPROP_TOP_PADDING + | FT_CPROP_BOTTOM_PADDING | FT_CPROP_LEFT_PADDING | FT_CPROP_RIGHT_PADDING + | FT_CPROP_EMPTY_STR_HEIGHT, 0, /* col_min_width */ FT_ALIGNED_LEFT, /* align */ @@ -778,28 +778,28 @@ struct fort_cell_options g_default_cell_option = { FT_ROW_COMMON, /* row_type */ }; -static int get_option_value_if_exists_otherwise_default(const struct fort_cell_options *cell_opts, uint32_t option) +static int get_prop_value_if_exists_otherwise_default(const struct fort_cell_props *cell_opts, uint32_t property) { - if (cell_opts == NULL || !OPTION_IS_SET(cell_opts->options, option)) { - cell_opts = &g_default_cell_option; + if (cell_opts == NULL || !PROP_IS_SET(cell_opts->properties, property)) { + cell_opts = &g_default_cell_properties; } - switch (option) { - case FT_COPT_MIN_WIDTH: + switch (property) { + case FT_CPROP_MIN_WIDTH: return cell_opts->col_min_width; - case FT_COPT_TEXT_ALIGN: + case FT_CPROP_TEXT_ALIGN: return cell_opts->align; - case FT_COPT_TOP_PADDING: + case FT_CPROP_TOP_PADDING: return cell_opts->cell_padding_top; - case FT_COPT_BOTTOM_PADDING: + case FT_CPROP_BOTTOM_PADDING: return cell_opts->cell_padding_bottom; - case FT_COPT_LEFT_PADDING: + case FT_CPROP_LEFT_PADDING: return cell_opts->cell_padding_left; - case FT_COPT_RIGHT_PADDING: + case FT_CPROP_RIGHT_PADDING: return cell_opts->cell_padding_right; - case FT_COPT_EMPTY_STR_HEIGHT: + case FT_CPROP_EMPTY_STR_HEIGHT: return cell_opts->cell_empty_string_height; - case FT_COPT_ROW_TYPE: + case FT_CPROP_ROW_TYPE: return cell_opts->row_type; default: /* todo: implement later */ @@ -808,17 +808,16 @@ static int get_option_value_if_exists_otherwise_default(const struct fort_cell_o } -//#define DEFAULT_CELL_OPTION {FT_ROW_UNSPEC, FT_COLUMN_UNSPEC, 0, 0, 0} FT_INTERNAL -fort_cell_opt_container_t *create_cell_opt_container(void) +fort_cell_prop_container_t *create_cell_prop_container(void) { - fort_cell_opt_container_t *ret = create_vector(sizeof(fort_cell_options_t), DEFAULT_VECTOR_CAPACITY); + fort_cell_prop_container_t *ret = create_vector(sizeof(fort_cell_props_t), DEFAULT_VECTOR_CAPACITY); return ret; } FT_INTERNAL -void destroy_cell_opt_container(fort_cell_opt_container_t *cont) +void destroy_cell_prop_container(fort_cell_prop_container_t *cont) { if (cont) destroy_vector(cont); @@ -826,13 +825,13 @@ void destroy_cell_opt_container(fort_cell_opt_container_t *cont) FT_INTERNAL -const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col) +const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col) { assert(cont); size_t sz = vector_size(cont); size_t i = 0; for (i = 0; i < sz; ++i) { - const fort_cell_options_t *opt = (const fort_cell_options_t *)vector_at_c(cont, i); + const fort_cell_props_t *opt = (const fort_cell_props_t *)vector_at_c(cont, i); if (opt->cell_row == row && opt->cell_col == col) return opt; } @@ -841,28 +840,27 @@ const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, FT_INTERNAL -fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col) +fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col) { assert(cont); size_t sz = vector_size(cont); size_t i = 0; for (i = 0; i < sz; ++i) { - fort_cell_options_t *opt = (fort_cell_options_t *)vector_at(cont, i); + fort_cell_props_t *opt = (fort_cell_props_t *)vector_at(cont, i); if (opt->cell_row == row && opt->cell_col == col) return opt; } -// fort_cell_options_t opt = g_default_cell_option;// DEFAULT_CELL_OPTION; - fort_cell_options_t opt; + fort_cell_props_t opt; if (row == FT_ANY_ROW && col == FT_ANY_COLUMN) - memcpy(&opt, &g_default_cell_option, sizeof(fort_cell_options_t)); + memcpy(&opt, &g_default_cell_properties, sizeof(fort_cell_props_t)); else - memset(&opt, 0, sizeof(fort_cell_options_t)); + memset(&opt, 0, sizeof(fort_cell_props_t)); opt.cell_row = row; opt.cell_col = col; if (FT_IS_SUCCESS(vector_push(cont, &opt))) { - return (fort_cell_options_t *)vector_at(cont, sz); + return (fort_cell_props_t *)vector_at(cont, sz); } return NULL; @@ -870,15 +868,15 @@ fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_contain FT_INTERNAL -int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option) +int get_cell_property_value_hierarcial(const fort_table_properties_t *propertiess, size_t row, size_t column, uint32_t property) { - assert(options); + assert(propertiess); - const fort_cell_options_t *opt = NULL; - if (options->cell_options != NULL) { + const fort_cell_props_t *opt = NULL; + if (propertiess->cell_properties != NULL) { while (1) { - opt = cget_cell_opt(options->cell_options, row, column); - if (opt != NULL && OPTION_IS_SET(opt->options, option)) + opt = cget_cell_prop(propertiess->cell_properties, row, column); + if (opt != NULL && PROP_IS_SET(opt->properties, property)) break; if (row != FT_ANY_ROW) { row = FT_ANY_ROW; @@ -894,36 +892,36 @@ int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t ro } } - return get_option_value_if_exists_otherwise_default(opt, option); + return get_prop_value_if_exists_otherwise_default(opt, property); } -static fort_status_t set_cell_option_impl(fort_cell_options_t *opt, uint32_t option, int value) +static fort_status_t set_cell_property_impl(fort_cell_props_t *opt, uint32_t property, int value) { assert(opt); - OPTION_SET(opt->options, option); - if (OPTION_IS_SET(option, FT_COPT_MIN_WIDTH)) { + PROP_SET(opt->properties, property); + if (PROP_IS_SET(property, FT_CPROP_MIN_WIDTH)) { CHECK_NOT_NEGATIVE(value); opt->col_min_width = value; - } else if (OPTION_IS_SET(option, FT_COPT_TEXT_ALIGN)) { + } else if (PROP_IS_SET(property, FT_CPROP_TEXT_ALIGN)) { opt->align = (enum ft_text_alignment)value; - } else if (OPTION_IS_SET(option, FT_COPT_TOP_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_TOP_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_top = value; - } else if (OPTION_IS_SET(option, FT_COPT_BOTTOM_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_BOTTOM_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_bottom = value; - } else if (OPTION_IS_SET(option, FT_COPT_LEFT_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_LEFT_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_left = value; - } else if (OPTION_IS_SET(option, FT_COPT_RIGHT_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_RIGHT_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_right = value; - } else if (OPTION_IS_SET(option, FT_COPT_EMPTY_STR_HEIGHT)) { + } else if (PROP_IS_SET(property, FT_CPROP_EMPTY_STR_HEIGHT)) { CHECK_NOT_NEGATIVE(value); opt->cell_empty_string_height = value; - } else if (OPTION_IS_SET(option, FT_COPT_ROW_TYPE)) { + } else if (PROP_IS_SET(property, FT_CPROP_ROW_TYPE)) { opt->row_type = (enum ft_row_type)value; } @@ -935,18 +933,18 @@ fort_fail: FT_INTERNAL -fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value) +fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value) { - fort_cell_options_t *opt = get_cell_opt_and_create_if_not_exists(cont, row, col); + fort_cell_props_t *opt = get_cell_prop_and_create_if_not_exists(cont, row, col); if (opt == NULL) return FT_ERROR; - return set_cell_option_impl(opt, option, value); + return set_cell_property_impl(opt, property, value); /* - OPTION_SET(opt->options, option); - if (OPTION_IS_SET(option, FT_COPT_MIN_WIDTH)) { + PROP_SET(opt->propertiess, property); + if (PROP_IS_SET(property, FT_CPROP_MIN_WIDTH)) { opt->col_min_width = value; - } else if (OPTION_IS_SET(option, FT_COPT_TEXT_ALIGN)) { + } else if (PROP_IS_SET(property, FT_CPROP_TEXT_ALIGN)) { opt->align = value; } @@ -956,13 +954,13 @@ fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_ FT_INTERNAL -fort_status_t set_default_cell_option(uint32_t option, int value) +fort_status_t set_default_cell_property(uint32_t property, int value) { - return set_cell_option_impl(&g_default_cell_option, option, value); + return set_cell_property_impl(&g_default_cell_properties, property, value); } /***************************************************************************** - * OPTIONS + * PROPERTIESS * ***************************************************************************/ @@ -1286,25 +1284,25 @@ struct fort_border_style FORT_FRAME_STYLE = FRAME_STYLE; -fort_entire_table_options_t g_entire_table_options = { +fort_entire_table_properties_t g_entire_table_properties = { 0, /* left_margin */ 0, /* top_margin */ 0, /* right_margin */ 0, /* bottom_margin */ }; -static fort_status_t set_entire_table_option_internal(fort_entire_table_options_t *options, uint32_t option, int value) +static fort_status_t set_entire_table_property_internal(fort_entire_table_properties_t *properties, uint32_t property, int value) { - assert(options); + assert(properties); CHECK_NOT_NEGATIVE(value); - if (OPTION_IS_SET(option, FT_TOPT_LEFT_MARGIN)) { - options->left_margin = value; - } else if (OPTION_IS_SET(option, FT_TOPT_TOP_MARGIN)) { - options->top_margin = value; - } else if (OPTION_IS_SET(option, FT_TOPT_RIGHT_MARGIN)) { - options->right_margin = value; - } else if (OPTION_IS_SET(option, FT_TOPT_BOTTOM_MARGIN)) { - options->bottom_margin = value; + if (PROP_IS_SET(property, FT_TPROP_LEFT_MARGIN)) { + properties->left_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_TOP_MARGIN)) { + properties->top_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_RIGHT_MARGIN)) { + properties->right_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_BOTTOM_MARGIN)) { + properties->bottom_margin = value; } else { return FT_EINVAL; } @@ -1316,48 +1314,48 @@ fort_fail: FT_INTERNAL -fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value) +fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value) { - assert(table_options); - return set_entire_table_option_internal(&table_options->entire_table_options, option, value); + assert(table_properties); + return set_entire_table_property_internal(&table_properties->entire_table_properties, property, value); } FT_INTERNAL -fort_status_t set_default_entire_table_option(uint32_t option, int value) +fort_status_t set_default_entire_table_property(uint32_t property, int value) { - return set_entire_table_option_internal(&g_entire_table_options, option, value); + return set_entire_table_property_internal(&g_entire_table_properties, property, value); } FT_INTERNAL -size_t max_border_elem_strlen(struct fort_table_options *options) +size_t max_border_elem_strlen(struct fort_table_properties *properties) { - assert(options); + assert(properties); size_t result = 1; int i = 0; for (i = 0; i < BorderItemPosSize; ++i) { - result = MAX(result, strlen(options->border_style.border_chars[i])); + result = MAX(result, strlen(properties->border_style.border_chars[i])); } i = 0; for (i = 0; i < BorderItemPosSize; ++i) { - result = MAX(result, strlen(options->border_style.header_border_chars[i])); + result = MAX(result, strlen(properties->border_style.header_border_chars[i])); } i = 0; for (i = 0; i < SepratorItemPosSize; ++i) { - result = MAX(result, strlen(options->border_style.separator_chars[i])); + result = MAX(result, strlen(properties->border_style.separator_chars[i])); } return result; } -fort_table_options_t g_table_options = { +fort_table_properties_t g_table_properties = { /* border_style */ BASIC_STYLE, - NULL, /* cell_options */ - /* entire_table_options */ + NULL, /* cell_properties */ + /* entire_table_properties */ { 0, /* left_margin */ 0, /* top_margin */ @@ -1368,46 +1366,46 @@ fort_table_options_t g_table_options = { FT_INTERNAL -fort_table_options_t *create_table_options(void) +fort_table_properties_t *create_table_properties(void) { - fort_table_options_t *options = (fort_table_options_t *)F_CALLOC(sizeof(fort_table_options_t), 1); - if (options == NULL) { + fort_table_properties_t *properties = (fort_table_properties_t *)F_CALLOC(sizeof(fort_table_properties_t), 1); + if (properties == NULL) { return NULL; } - memcpy(options, &g_table_options, sizeof(fort_table_options_t)); - options->cell_options = create_cell_opt_container(); - if (options->cell_options == NULL) { - destroy_table_options(options); + memcpy(properties, &g_table_properties, sizeof(fort_table_properties_t)); + properties->cell_properties = create_cell_prop_container(); + if (properties->cell_properties == NULL) { + destroy_table_properties(properties); return NULL; } - memcpy(&options->entire_table_options, &g_entire_table_options, sizeof(fort_entire_table_options_t)); - return options; + memcpy(&properties->entire_table_properties, &g_entire_table_properties, sizeof(fort_entire_table_properties_t)); + return properties; } FT_INTERNAL -void destroy_table_options(fort_table_options_t *options) +void destroy_table_properties(fort_table_properties_t *properties) { - if (options == NULL) + if (properties == NULL) return; - if (options->cell_options != NULL) { - destroy_cell_opt_container(options->cell_options); + if (properties->cell_properties != NULL) { + destroy_cell_prop_container(properties->cell_properties); } - F_FREE(options); + F_FREE(properties); } static -fort_cell_opt_container_t *copy_cell_options(fort_cell_opt_container_t *cont) +fort_cell_prop_container_t *copy_cell_properties(fort_cell_prop_container_t *cont) { - fort_cell_opt_container_t *result = create_cell_opt_container(); + fort_cell_prop_container_t *result = create_cell_prop_container(); if (result == NULL) return NULL; size_t sz = vector_size(cont); for (size_t i = 0; i < sz; ++i) { - fort_cell_options_t *opt = (fort_cell_options_t *)vector_at(cont, i); + fort_cell_props_t *opt = (fort_cell_props_t *)vector_at(cont, i); if (FT_IS_ERROR(vector_push(result, opt))) { - destroy_cell_opt_container(result); + destroy_cell_prop_container(result); return NULL; } } @@ -1415,22 +1413,22 @@ fort_cell_opt_container_t *copy_cell_options(fort_cell_opt_container_t *cont) } FT_INTERNAL -fort_table_options_t *copy_table_options(const fort_table_options_t *option) +fort_table_properties_t *copy_table_properties(const fort_table_properties_t *properties) { - fort_table_options_t *new_opt = create_table_options(); + fort_table_properties_t *new_opt = create_table_properties(); if (new_opt == NULL) return NULL; - destroy_vector(new_opt->cell_options); - new_opt->cell_options = copy_cell_options(option->cell_options); + destroy_vector(new_opt->cell_properties); + new_opt->cell_properties = copy_cell_properties(properties->cell_properties); if (new_opt == NULL) { - destroy_table_options(new_opt); + destroy_table_properties(new_opt); return NULL; } - memcpy(&new_opt->border_style, &option->border_style, sizeof(struct fort_border_style)); - memcpy(&new_opt->entire_table_options, - &option->entire_table_options, sizeof(fort_entire_table_options_t)); + memcpy(&new_opt->border_style, &properties->border_style, sizeof(struct fort_border_style)); + memcpy(&new_opt->entire_table_properties, + &properties->entire_table_properties, sizeof(fort_entire_table_properties_t)); return new_opt; } @@ -1439,7 +1437,7 @@ fort_table_options_t *copy_table_options(const fort_table_options_t *option) /******************************************************** - End of file "options.c" + End of file "properties.c" ********************************************************/ @@ -1595,7 +1593,7 @@ fort_status_t table_rows_and_cols_geometry(const ft_table_t *table, int combined_cells_found = 0; context_t context; - context.table_options = (table->options ? table->options : &g_table_options); + context.table_properties = (table->properties ? table->properties : &g_table_properties); size_t col = 0; for (col = 0; col < cols; ++col) { col_width_arr[col] = 0; @@ -1661,9 +1659,9 @@ fort_status_t table_rows_and_cols_geometry(const ft_table_t *table, * paddings but be min width of the cell content without padding */ /* - if (table->options) { + if (table->properties) { for (size_t i = 0; i < cols; ++i) { - col_width_arr[i] = MAX((int)col_width_arr[i], fort_options_column_width(table->options, i)); + col_width_arr[i] = MAX((int)col_width_arr[i], fort_props_column_width(table->properties, i)); } } */ @@ -1710,16 +1708,16 @@ fort_status_t table_geometry(const ft_table_t *table, size_t *height, size_t *wi F_FREE(col_width_arr); F_FREE(row_height_arr); - if (table->options) { - *height += table->options->entire_table_options.top_margin; - *height += table->options->entire_table_options.bottom_margin; - *width += table->options->entire_table_options.left_margin; - *width += table->options->entire_table_options.right_margin; + if (table->properties) { + *height += table->properties->entire_table_properties.top_margin; + *height += table->properties->entire_table_properties.bottom_margin; + *width += table->properties->entire_table_properties.left_margin; + *width += table->properties->entire_table_properties.right_margin; } /* Take into account that border elements can be more than one byte long */ - fort_table_options_t *table_options = table->options ? table->options : &g_table_options; - size_t max_border_elem_len = max_border_elem_strlen(table_options); + fort_table_properties_t *table_properties = table->properties ? table->properties : &g_table_properties; + size_t max_border_elem_len = max_border_elem_strlen(table_properties); *width *= max_border_elem_len; return FT_SUCCESS; @@ -1776,7 +1774,7 @@ SOFTWARE. /* #include "string_buffer.h" */ /* Commented by amalgamation script */ /* #include "table.h" */ /* Commented by amalgamation script */ /* #include "row.h" */ /* Commented by amalgamation script */ -/* #include "options.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ ft_table_t *ft_create_table(void) @@ -1796,7 +1794,7 @@ ft_table_t *ft_create_table(void) F_FREE(result); return NULL; } - result->options = NULL; + result->properties = NULL; result->conv_buffer = NULL; result->cur_row = 0; result->cur_col = 0; @@ -1825,7 +1823,7 @@ void ft_destroy_table(ft_table_t *table) } destroy_vector(table->separators); } - destroy_table_options(table->options); + destroy_table_properties(table->properties); destroy_string_buffer(table->conv_buffer); F_FREE(table); } @@ -1862,8 +1860,8 @@ ft_table_t *ft_copy_table(ft_table_t *table) } - result->options = copy_table_options(table->options); - if (result->options == NULL) { + result->properties = copy_table_properties(table->properties); + if (result->properties == NULL) { ft_destroy_table(result); return NULL; } @@ -2360,14 +2358,14 @@ const char *ft_to_string(const ft_table_t *table) int tmp = 0; size_t i = 0; context_t context; - context.table_options = (table->options ? table->options : &g_table_options); + context.table_properties = (table->properties ? table->properties : &g_table_properties); fort_row_t *prev_row = NULL; fort_row_t *cur_row = NULL; separator_t *cur_sep = NULL; size_t sep_size = vector_size(table->separators); /* Print top margin */ - for (i = 0; i < context.table_options->entire_table_options.top_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -2386,7 +2384,7 @@ const char *ft_to_string(const ft_table_t *table) CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context)); /* Print bottom margin */ - for (i = 0; i < context.table_options->entire_table_options.bottom_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -2465,14 +2463,14 @@ const wchar_t *ft_to_wstring(const ft_table_t *table) int tmp = 0; size_t i = 0; context_t context; - context.table_options = (table->options ? table->options : &g_table_options); + context.table_properties = (table->properties ? table->properties : &g_table_properties); fort_row_t *prev_row = NULL; fort_row_t *cur_row = NULL; separator_t *cur_sep = NULL; size_t sep_size = vector_size(table->separators); /* Print top margin */ - for (i = 0; i < context.table_options->entire_table_options.top_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -2491,7 +2489,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table) CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context)); /* Print bottom margin */ - for (i = 0; i < context.table_options->entire_table_options.bottom_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -2582,7 +2580,7 @@ struct ft_border_style *FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME -static void set_border_options_for_options(fort_table_options_t *options, const struct ft_border_style *style) +static void set_border_props_for_props(fort_table_properties_t *properties, const struct ft_border_style *style) { if ((struct fort_border_style *)style == &FORT_BASIC_STYLE || (struct fort_border_style *)style == &FORT_BASIC2_STYLE @@ -2597,16 +2595,16 @@ static void set_border_options_for_options(fort_table_options_t *options, const || (struct fort_border_style *)style == &FORT_BOLD_STYLE || (struct fort_border_style *)style == &FORT_BOLD2_STYLE || (struct fort_border_style *)style == &FORT_FRAME_STYLE) { - memcpy(&(options->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style)); + memcpy(&(properties->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style)); return; } const struct ft_border_chars *border_chs = &(style->border_chs); const struct ft_border_chars *header_border_chs = &(style->header_border_chs); -#define BOR_CHARS options->border_style.border_chars -#define H_BOR_CHARS options->border_style.header_border_chars -#define SEP_CHARS options->border_style.separator_chars +#define BOR_CHARS properties->border_style.border_chars +#define H_BOR_CHARS properties->border_style.header_border_chars +#define SEP_CHARS properties->border_style.separator_chars /* BOR_CHARS[TL_bip] = BOR_CHARS[TT_bip] = BOR_CHARS[TV_bip] = BOR_CHARS[TR_bip] = border_chs->top_border_ch; @@ -2671,36 +2669,36 @@ static void set_border_options_for_options(fort_table_options_t *options, const int ft_set_default_border_style(const struct ft_border_style *style) { - set_border_options_for_options(&g_table_options, style); + set_border_props_for_props(&g_table_properties, style); return FT_SUCCESS; } int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style) { assert(table); - if (table->options == NULL) { - table->options = create_table_options(); - if (table->options == NULL) + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) return FT_MEMORY_ERROR; } - set_border_options_for_options(table->options, style); + set_border_props_for_props(table->properties, style); return FT_SUCCESS; } -int ft_set_cell_option(ft_table_t *table, size_t row, size_t col, uint32_t option, int value) +int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value) { assert(table); - if (table->options == NULL) { - table->options = create_table_options(); - if (table->options == NULL) + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) return FT_MEMORY_ERROR; } - if (table->options->cell_options == NULL) { - table->options->cell_options = create_cell_opt_container(); - if (table->options->cell_options == NULL) { + if (table->properties->cell_properties == NULL) { + table->properties->cell_properties = create_cell_prop_container(); + if (table->properties->cell_properties == NULL) { return FT_ERROR; } } @@ -2710,30 +2708,30 @@ int ft_set_cell_option(ft_table_t *table, size_t row, size_t col, uint32_t optio if (row == FT_CUR_COLUMN) col = table->cur_col; - return set_cell_option(table->options->cell_options, row, col, option, value); + return set_cell_property(table->properties->cell_properties, row, col, property, value); } -int ft_set_default_cell_option(uint32_t option, int value) +int ft_set_default_cell_prop(uint32_t property, int value) { - return set_default_cell_option(option, value); + return set_default_cell_property(property, value); } -int ft_set_default_tbl_option(uint32_t option, int value) +int ft_set_default_tbl_prop(uint32_t property, int value) { - return set_default_entire_table_option(option, value); + return set_default_entire_table_property(property, value); } -int ft_set_tbl_option(ft_table_t *table, uint32_t option, int value) +int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value) { assert(table); - if (table->options == NULL) { - table->options = create_table_options(); - if (table->options == NULL) + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) return FT_MEMORY_ERROR; } - return set_entire_table_option(table->options, option, value); + return set_entire_table_property(table->properties, property, value); } void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)) @@ -3013,7 +3011,7 @@ void vector_clear(vector_t *vector) ********************************************************/ /* #include "string_buffer.h" */ /* Commented by amalgamation script */ -/* #include "options.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ /* #include "wcwidth.h" */ /* Commented by amalgamation script */ #include #include @@ -3377,7 +3375,7 @@ int buffer_printf(string_buffer_t *buffer, size_t buffer_row, char *buf, size_t size_t left = 0; size_t right = 0; - switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) { + switch (get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TEXT_ALIGN)) { case FT_ALIGNED_LEFT: left = 0; right = (buf_len - 1) - content_width; @@ -3465,7 +3463,7 @@ int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, siz size_t left = 0; size_t right = 0; - switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) { + switch (get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TEXT_ALIGN)) { case FT_ALIGNED_LEFT: left = 0; right = (buf_len - 1) - content_width; @@ -4106,11 +4104,11 @@ int print_row_separator(char *buffer, size_t buffer_sz, enum ft_row_type lower_row_type = FT_ROW_COMMON; if (lower_row != NULL) { - lower_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + lower_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } enum ft_row_type upper_row_type = FT_ROW_COMMON; if (upper_row != NULL) { - upper_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row - 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + upper_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row - 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } /* Row separator anatomy @@ -4130,20 +4128,20 @@ int print_row_separator(char *buffer, size_t buffer_sz, typedef const char *(*border_chars_point_t)[BorderItemPosSize]; const char *(*border_chars)[BorderItemPosSize] = NULL; - border_chars = (border_chars_point_t)&context->table_options->border_style.border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.border_chars; if (upper_row_type == FT_ROW_HEADER || lower_row_type == FT_ROW_HEADER) { - border_chars = (border_chars_point_t)&context->table_options->border_style.header_border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.header_border_chars; } if (sep && sep->enabled) { - L = &(context->table_options->border_style.separator_chars[LH_sip]); - I = &(context->table_options->border_style.separator_chars[IH_sip]); - IV = &(context->table_options->border_style.separator_chars[II_sip]); - R = &(context->table_options->border_style.separator_chars[RH_sip]); + L = &(context->table_properties->border_style.separator_chars[LH_sip]); + I = &(context->table_properties->border_style.separator_chars[IH_sip]); + IV = &(context->table_properties->border_style.separator_chars[II_sip]); + R = &(context->table_properties->border_style.separator_chars[RH_sip]); - IT = &(context->table_options->border_style.separator_chars[II_sip]); - IB = &(context->table_options->border_style.separator_chars[II_sip]); - II = &(context->table_options->border_style.separator_chars[IH_sip]); + IT = &(context->table_properties->border_style.separator_chars[II_sip]); + IB = &(context->table_properties->border_style.separator_chars[II_sip]); + II = &(context->table_properties->border_style.separator_chars[IH_sip]); } else { switch (separatorPos) { case TopSeparator: @@ -4199,7 +4197,7 @@ int print_row_separator(char *buffer, size_t buffer_sz, } /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); for (i = 0; i < cols; ++i) { if (i == 0) { @@ -4221,7 +4219,7 @@ int print_row_separator(char *buffer, size_t buffer_sz, CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, "\n")); @@ -4281,11 +4279,11 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, enum ft_row_type lower_row_type = FT_ROW_COMMON; if (lower_row != NULL) { - lower_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + lower_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } enum ft_row_type upper_row_type = FT_ROW_COMMON; if (upper_row != NULL) { - upper_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row - 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + upper_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row - 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } /* Row separator anatomy @@ -4305,20 +4303,20 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, typedef const char *(*border_chars_point_t)[BorderItemPosSize]; const char *(*border_chars)[BorderItemPosSize] = NULL; - border_chars = (border_chars_point_t)&context->table_options->border_style.border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.border_chars; if (upper_row_type == FT_ROW_HEADER || lower_row_type == FT_ROW_HEADER) { - border_chars = (border_chars_point_t)&context->table_options->border_style.header_border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.header_border_chars; } if (sep && sep->enabled) { - L = &(context->table_options->border_style.separator_chars[LH_sip]); - I = &(context->table_options->border_style.separator_chars[IH_sip]); - IV = &(context->table_options->border_style.separator_chars[II_sip]); - R = &(context->table_options->border_style.separator_chars[RH_sip]); + L = &(context->table_properties->border_style.separator_chars[LH_sip]); + I = &(context->table_properties->border_style.separator_chars[IH_sip]); + IV = &(context->table_properties->border_style.separator_chars[II_sip]); + R = &(context->table_properties->border_style.separator_chars[RH_sip]); - IT = &(context->table_options->border_style.separator_chars[II_sip]); - IB = &(context->table_options->border_style.separator_chars[II_sip]); - II = &(context->table_options->border_style.separator_chars[IH_sip]); + IT = &(context->table_properties->border_style.separator_chars[II_sip]); + IB = &(context->table_properties->border_style.separator_chars[II_sip]); + II = &(context->table_properties->border_style.separator_chars[IH_sip]); } else { switch (separatorPos) { case TopSeparator: @@ -4374,7 +4372,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, } /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); for (i = 0; i < cols; ++i) { if (i == 0) { @@ -4396,7 +4394,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, "\n")); @@ -4780,10 +4778,10 @@ int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col */ typedef const char *(*border_chars_point_t)[BorderItemPosSize]; - enum ft_row_type row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + enum ft_row_type row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); const char *(*bord_chars)[BorderItemPosSize] = (row_type == FT_ROW_HEADER) - ? (border_chars_point_t)(&context->table_options->border_style.header_border_chars) - : (border_chars_point_t)(&context->table_options->border_style.border_chars); + ? (border_chars_point_t)(&context->table_properties->border_style.header_border_chars) + : (border_chars_point_t)(&context->table_properties->border_style.border_chars); const char **L = &(*bord_chars)[LL_bip]; const char **IV = &(*bord_chars)[IV_bip]; const char **R = &(*bord_chars)[RR_bip]; @@ -4794,7 +4792,7 @@ int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col size_t i = 0; for (i = 0; i < row_height; ++i) { /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); /* Print left table boundary */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *L)); @@ -4831,7 +4829,7 @@ int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); /* Print new line character */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, new_line_char)); @@ -4870,10 +4868,10 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t */ typedef const char *(*border_chars_point_t)[BorderItemPosSize]; - enum ft_row_type row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + enum ft_row_type row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); const char *(*bord_chars)[BorderItemPosSize] = (row_type == FT_ROW_HEADER) - ? (border_chars_point_t)(&context->table_options->border_style.header_border_chars) - : (border_chars_point_t)(&context->table_options->border_style.border_chars); + ? (border_chars_point_t)(&context->table_properties->border_style.header_border_chars) + : (border_chars_point_t)(&context->table_properties->border_style.border_chars); const char **L = &(*bord_chars)[LL_bip]; const char **IV = &(*bord_chars)[IV_bip]; const char **R = &(*bord_chars)[RR_bip]; @@ -4884,7 +4882,7 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t size_t i = 0; for (i = 0; i < row_height; ++i) { /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); /* Print left table boundary */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *L)); @@ -4921,7 +4919,7 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); /* Print new line character */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, new_line_char)); @@ -5180,7 +5178,7 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n) ********************************************************/ /* #include "cell.h" */ /* Commented by amalgamation script */ -/* #include "options.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ /* #include "string_buffer.h" */ /* Commented by amalgamation script */ #include @@ -5254,13 +5252,13 @@ size_t hint_width_cell(const fort_cell_t *cell, const context_t *context) assert(cell); assert(context); - size_t cell_padding_left = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_LEFT_PADDING); - size_t cell_padding_right = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_RIGHT_PADDING); + size_t cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + size_t cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); size_t result = cell_padding_left + cell_padding_right; if (cell->str_buffer && cell->str_buffer->str.data) { result += buffer_text_width(cell->str_buffer); } - result = MAX(result, (size_t)get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_MIN_WIDTH)); + result = MAX(result, (size_t)get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_MIN_WIDTH)); return result; } @@ -5269,9 +5267,9 @@ size_t hint_height_cell(const fort_cell_t *cell, const context_t *context) { assert(cell); assert(context); - size_t cell_padding_top = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TOP_PADDING); - size_t cell_padding_bottom = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_BOTTOM_PADDING); - size_t cell_empty_string_height = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_EMPTY_STR_HEIGHT); + size_t cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + size_t cell_padding_bottom = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_BOTTOM_PADDING); + size_t cell_empty_string_height = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_EMPTY_STR_HEIGHT); size_t result = cell_padding_top + cell_padding_bottom; if (cell->str_buffer && cell->str_buffer->str.data) { size_t text_height = buffer_text_height(cell->str_buffer); @@ -5296,9 +5294,9 @@ int cell_printf(fort_cell_t *cell, size_t row, char *buf, size_t buf_len, const return -1; } - unsigned int cell_padding_top = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TOP_PADDING); - unsigned int cell_padding_left = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_LEFT_PADDING); - unsigned int cell_padding_right = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_RIGHT_PADDING); + unsigned int cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + unsigned int cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + unsigned int cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); if (row >= hint_height_cell(cell, context) || row < cell_padding_top @@ -5342,9 +5340,9 @@ int cell_wprintf(fort_cell_t *cell, size_t row, wchar_t *buf, size_t buf_len, co return -1; } - unsigned int cell_padding_top = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TOP_PADDING); - unsigned int cell_padding_left = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_LEFT_PADDING); - unsigned int cell_padding_right = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_RIGHT_PADDING); + unsigned int cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + unsigned int cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + unsigned int cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); if (row >= hint_height_cell(cell, context) || row < cell_padding_top diff --git a/lib/fort.h b/lib/fort.h index df09c6e..7a93662 100644 --- a/lib/fort.h +++ b/lib/fort.h @@ -672,17 +672,17 @@ int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style); /** - * @name Cell options identifiers. + * @name Cell properties identifiers. * @{ */ -#define FT_COPT_MIN_WIDTH (0x01U << 0) /**< Minimum width */ -#define FT_COPT_TEXT_ALIGN (0x01U << 1) /**< Text alignment */ -#define FT_COPT_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */ -#define FT_COPT_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */ -#define FT_COPT_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */ -#define FT_COPT_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */ -#define FT_COPT_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */ -#define FT_COPT_ROW_TYPE (0x01U << 7) /**< Row type */ +#define FT_CPROP_MIN_WIDTH (0x01U << 0) /**< Minimum width */ +#define FT_CPROP_TEXT_ALIGN (0x01U << 1) /**< Text alignment */ +#define FT_CPROP_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */ +#define FT_CPROP_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */ +#define FT_CPROP_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */ +#define FT_CPROP_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */ +#define FT_CPROP_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */ +#define FT_CPROP_ROW_TYPE (0x01U << 7) /**< Row type */ /** @} */ @@ -705,20 +705,20 @@ enum ft_row_type { }; /** - * Set default cell option for all new formatted tables. + * Set default cell property for all new formatted tables. * - * @param option - * Cell option identifier. + * @param property + * Cell property identifier. * @param value - * Cell option value. + * Cell property value. * @return - * - 0: Success; default cell option was changed. + * - 0: Success; default cell property was changed. * - (<0): In case of error */ -int ft_set_default_cell_option(uint32_t option, int value); +int ft_set_default_cell_prop(uint32_t property, int value); /** - * Set option for the specified cell of the table. + * Set property for the specified cell of the table. * * @param table * A pointer to the ft_table_t structure. @@ -726,56 +726,56 @@ int ft_set_default_cell_option(uint32_t option, int value); * Cell row. * @param col * Cell column. - * @param option - * Cell option identifier. + * @param property + * Cell property identifier. * @param value - * Cell option value. + * Cell property value. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ -int ft_set_cell_option(ft_table_t *table, size_t row, size_t col, uint32_t option, int value); +int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value); /** - * @name Table options identifiers. + * @name Table properties identifiers. * @{ */ -#define FT_TOPT_LEFT_MARGIN (0x01U << 0) -#define FT_TOPT_TOP_MARGIN (0x01U << 1) -#define FT_TOPT_RIGHT_MARGIN (0x01U << 2) -#define FT_TOPT_BOTTOM_MARGIN (0x01U << 3) +#define FT_TPROP_LEFT_MARGIN (0x01U << 0) +#define FT_TPROP_TOP_MARGIN (0x01U << 1) +#define FT_TPROP_RIGHT_MARGIN (0x01U << 2) +#define FT_TPROP_BOTTOM_MARGIN (0x01U << 3) /** @} */ /** - * Set default table option. + * Set default table property. * - * @param option - * Table option identifier. + * @param property + * Table property identifier. * @param value - * Table option value. + * Table property value. * @return - * - 0: Success; default table option was changed. + * - 0: Success; default table property was changed. * - (<0): In case of error */ -int ft_set_default_tbl_option(uint32_t option, int value); +int ft_set_default_tbl_prop(uint32_t property, int value); /** - * Set table option. + * Set table property. * * @param table * A pointer to the ft_table_t structure. - * @param option - * Table option identifier. + * @param property + * Table property identifier. * @param value - * Table option value. + * Table property value. * @return - * - 0: Success; default table option was changed. + * - 0: Success; default table property was changed. * - (<0): In case of error */ -int ft_set_tbl_option(ft_table_t *table, uint32_t option, int value); +int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value); /** @@ -790,7 +790,7 @@ int ft_set_tbl_option(ft_table_t *table, uint32_t option, int value); * @param hor_span * Column span. * @return - * - 0: Success; default table option was changed. + * - 0: Success; cell span was changed. * - (<0): In case of error */ int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span); diff --git a/lib/fort.hpp b/lib/fort.hpp index b5c773b..201f6a2 100644 --- a/lib/fort.hpp +++ b/lib/fort.hpp @@ -42,7 +42,7 @@ SOFTWARE. namespace fort { -enum class CellOption { +enum class CellProperty { MinWidth, TextAlign, TopPadding, @@ -53,7 +53,7 @@ enum class CellOption { RowType }; -enum class TableOption { +enum class TableProperty { LeftMargin, TopMargin, RightMargin, @@ -241,7 +241,7 @@ public: Table &operator<<(const TableManipulator &arg) { if (arg.value == header.value) - ft_set_cell_option(table, FT_CUR_ROW, FT_ANY_ROW, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, FT_CUR_ROW, FT_ANY_ROW, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); else if (arg.value == endr.value) ft_ln(table); else if (arg.value == separator.value) @@ -402,12 +402,12 @@ public: * @param value * Value of the min width. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_min_width(size_t row, size_t col, unsigned value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_MIN_WIDTH, value)); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_MIN_WIDTH, value)); } /** @@ -420,12 +420,12 @@ public: * @param value * Value of the text alignment. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_text_align(size_t row, size_t col, enum TextAlign value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_TEXT_ALIGN, static_cast(value))); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_TEXT_ALIGN, static_cast(value))); } /** @@ -438,12 +438,12 @@ public: * @param value * Value of the top padding. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_top_padding(size_t row, size_t col, unsigned value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_TOP_PADDING, value)); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_TOP_PADDING, value)); } /** @@ -456,12 +456,12 @@ public: * @param value * Value of the bottom padding. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_bottom_padding(size_t row, size_t col, unsigned value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_BOTTOM_PADDING, value)); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_BOTTOM_PADDING, value)); } /** @@ -474,12 +474,12 @@ public: * @param value * Value of the left padding. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_left_padding(size_t row, size_t col, unsigned value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_LEFT_PADDING, value)); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_LEFT_PADDING, value)); } /** @@ -492,12 +492,12 @@ public: * @param value * Value of the left padding. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_right_padding(size_t row, size_t col, unsigned value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_RIGHT_PADDING, value)); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_RIGHT_PADDING, value)); } /** @@ -510,12 +510,12 @@ public: * @param value * Value of the empty string height. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_empty_str_height(size_t row, size_t col, unsigned value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_EMPTY_STR_HEIGHT, value)); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_EMPTY_STR_HEIGHT, value)); } /** @@ -528,25 +528,25 @@ public: * @param value * Value of the row type. * @return - * - 0: Success; cell option was changed. + * - 0: Success; cell property was changed. * - (<0): In case of error */ bool set_cell_row_type(size_t row, size_t col, enum RowType value) { - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_ROW_TYPE, static_cast(value))); + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_ROW_TYPE, static_cast(value))); } - template - bool set_option(size_t row, size_t col, unsigned value); + template + bool set_property(size_t row, size_t col, unsigned value); - template - bool set_option(size_t row, size_t col, enum TextAlign align); + template + bool set_property(size_t row, size_t col, enum TextAlign align); - template - bool set_option(size_t row, size_t col, enum RowType rowType); + template + bool set_property(size_t row, size_t col, enum RowType rowType); - template - bool set_option(unsigned value); + template + bool set_property(unsigned value); /** * Set border style for the table. @@ -646,49 +646,49 @@ bool set_default_border_style(struct ft_border_style *style) /* - * Declare specializations for set_option functions + * Declare specializations for set_property functions */ -#define DECLARE_SPECS_FOR_CELL_OPTIONS_X \ - SET_CELL_OPTION_SPEC(CellOption::MinWidth, FT_COPT_MIN_WIDTH, unsigned) \ - SET_CELL_OPTION_SPEC(CellOption::TextAlign, FT_COPT_TEXT_ALIGN, TextAlign) \ - SET_CELL_OPTION_SPEC(CellOption::TopPadding, FT_COPT_TOP_PADDING, unsigned) \ - SET_CELL_OPTION_SPEC(CellOption::BottomPadding, FT_COPT_BOTTOM_PADDING, unsigned) \ - SET_CELL_OPTION_SPEC(CellOption::LeftPadding, FT_COPT_LEFT_PADDING, unsigned) \ - SET_CELL_OPTION_SPEC(CellOption::RightPading, FT_COPT_RIGHT_PADDING, unsigned) \ - SET_CELL_OPTION_SPEC(CellOption::EmptyStrHeight, FT_COPT_EMPTY_STR_HEIGHT, unsigned) \ - SET_CELL_OPTION_SPEC(CellOption::RowType, FT_COPT_ROW_TYPE, RowType) +#define DECLARE_SPECS_FOR_CELL_PROPS_X \ + SET_CELL_PROP_SPEC(CellProperty::MinWidth, FT_CPROP_MIN_WIDTH, unsigned) \ + SET_CELL_PROP_SPEC(CellProperty::TextAlign, FT_CPROP_TEXT_ALIGN, TextAlign) \ + SET_CELL_PROP_SPEC(CellProperty::TopPadding, FT_CPROP_TOP_PADDING, unsigned) \ + SET_CELL_PROP_SPEC(CellProperty::BottomPadding, FT_CPROP_BOTTOM_PADDING, unsigned) \ + SET_CELL_PROP_SPEC(CellProperty::LeftPadding, FT_CPROP_LEFT_PADDING, unsigned) \ + SET_CELL_PROP_SPEC(CellProperty::RightPading, FT_CPROP_RIGHT_PADDING, unsigned) \ + SET_CELL_PROP_SPEC(CellProperty::EmptyStrHeight, FT_CPROP_EMPTY_STR_HEIGHT, unsigned) \ + SET_CELL_PROP_SPEC(CellProperty::RowType, FT_CPROP_ROW_TYPE, RowType) -#define SET_CELL_OPTION_SPEC(CELL_OPTION, C_OPTION, VALUE_TYPE) \ +#define SET_CELL_PROP_SPEC(CELL_OPTION, C_OPTION, VALUE_TYPE) \ template <> \ -bool Table::set_option(size_t row, size_t col, VALUE_TYPE value) \ +bool Table::set_property(size_t row, size_t col, VALUE_TYPE value) \ { \ - return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, C_OPTION, static_cast(value))); \ + return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, C_OPTION, static_cast(value))); \ } -DECLARE_SPECS_FOR_CELL_OPTIONS_X +DECLARE_SPECS_FOR_CELL_PROPS_X -#undef SET_TABLE_OPTION_SPEC -#undef DECLARE_SPECS_FOR_CELL_OPTIONS_X +#undef SET_TABLE_PROP_SPEC +#undef DECLARE_SPECS_FOR_PROPS_X -#define DECLARE_SPECS_FOR_TABLE_OPTIONS_X \ - SET_TABLE_OPTION_SPEC(TableOption::LeftMargin, FT_TOPT_LEFT_MARGIN) \ - SET_TABLE_OPTION_SPEC(TableOption::TopMargin, FT_TOPT_TOP_MARGIN) \ - SET_TABLE_OPTION_SPEC(TableOption::RightMargin, FT_TOPT_RIGHT_MARGIN) \ - SET_TABLE_OPTION_SPEC(TableOption::BottomMargin, FT_TOPT_BOTTOM_MARGIN) +#define DECLARE_SPECS_FOR_TABLE_PROPS_X \ + SET_TABLE_PROP_SPEC(TableProperty::LeftMargin, FT_TPROP_LEFT_MARGIN) \ + SET_TABLE_PROP_SPEC(TableProperty::TopMargin, FT_TPROP_TOP_MARGIN) \ + SET_TABLE_PROP_SPEC(TableProperty::RightMargin, FT_TPROP_RIGHT_MARGIN) \ + SET_TABLE_PROP_SPEC(TableProperty::BottomMargin, FT_TPROP_BOTTOM_MARGIN) -#define SET_TABLE_OPTION_SPEC(TABLE_OPTION, TBL_OPTION) \ +#define SET_TABLE_PROP_SPEC(TABLE_OPTION, TBL_OPTION) \ template <> \ -bool Table::set_option(unsigned value) \ +bool Table::set_property(unsigned value) \ { \ - return FT_IS_SUCCESS(ft_set_tbl_option(table, TBL_OPTION, static_cast(value))); \ + return FT_IS_SUCCESS(ft_set_tbl_prop(table, TBL_OPTION, static_cast(value))); \ } -DECLARE_SPECS_FOR_TABLE_OPTIONS_X +DECLARE_SPECS_FOR_TABLE_PROPS_X -#undef SET_TABLE_OPTION_SPEC -#undef DECLARE_SPECS_FOR_TABLE_OPTIONS_X +#undef SET_TABLE_PROP_SPEC +#undef DECLARE_SPECS_FOR_TABLE_PROPS_X diff --git a/src/cell.c b/src/cell.c index 901b7b0..9477630 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1,5 +1,5 @@ #include "cell.h" -#include "options.h" +#include "properties.h" #include "string_buffer.h" #include @@ -73,13 +73,13 @@ size_t hint_width_cell(const fort_cell_t *cell, const context_t *context) assert(cell); assert(context); - size_t cell_padding_left = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_LEFT_PADDING); - size_t cell_padding_right = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_RIGHT_PADDING); + size_t cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + size_t cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); size_t result = cell_padding_left + cell_padding_right; if (cell->str_buffer && cell->str_buffer->str.data) { result += buffer_text_width(cell->str_buffer); } - result = MAX(result, (size_t)get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_MIN_WIDTH)); + result = MAX(result, (size_t)get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_MIN_WIDTH)); return result; } @@ -88,9 +88,9 @@ size_t hint_height_cell(const fort_cell_t *cell, const context_t *context) { assert(cell); assert(context); - size_t cell_padding_top = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TOP_PADDING); - size_t cell_padding_bottom = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_BOTTOM_PADDING); - size_t cell_empty_string_height = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_EMPTY_STR_HEIGHT); + size_t cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + size_t cell_padding_bottom = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_BOTTOM_PADDING); + size_t cell_empty_string_height = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_EMPTY_STR_HEIGHT); size_t result = cell_padding_top + cell_padding_bottom; if (cell->str_buffer && cell->str_buffer->str.data) { size_t text_height = buffer_text_height(cell->str_buffer); @@ -115,9 +115,9 @@ int cell_printf(fort_cell_t *cell, size_t row, char *buf, size_t buf_len, const return -1; } - unsigned int cell_padding_top = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TOP_PADDING); - unsigned int cell_padding_left = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_LEFT_PADDING); - unsigned int cell_padding_right = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_RIGHT_PADDING); + unsigned int cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + unsigned int cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + unsigned int cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); if (row >= hint_height_cell(cell, context) || row < cell_padding_top @@ -161,9 +161,9 @@ int cell_wprintf(fort_cell_t *cell, size_t row, wchar_t *buf, size_t buf_len, co return -1; } - unsigned int cell_padding_top = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TOP_PADDING); - unsigned int cell_padding_left = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_LEFT_PADDING); - unsigned int cell_padding_right = get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_RIGHT_PADDING); + unsigned int cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + unsigned int cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + unsigned int cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); if (row >= hint_height_cell(cell, context) || row < cell_padding_top diff --git a/src/fort_impl.c b/src/fort_impl.c index 5f2e40d..de92dff 100644 --- a/src/fort_impl.c +++ b/src/fort_impl.c @@ -38,7 +38,7 @@ SOFTWARE. #include "string_buffer.h" #include "table.h" #include "row.h" -#include "options.h" +#include "properties.h" ft_table_t *ft_create_table(void) @@ -58,7 +58,7 @@ ft_table_t *ft_create_table(void) F_FREE(result); return NULL; } - result->options = NULL; + result->properties = NULL; result->conv_buffer = NULL; result->cur_row = 0; result->cur_col = 0; @@ -87,7 +87,7 @@ void ft_destroy_table(ft_table_t *table) } destroy_vector(table->separators); } - destroy_table_options(table->options); + destroy_table_properties(table->properties); destroy_string_buffer(table->conv_buffer); F_FREE(table); } @@ -124,8 +124,8 @@ ft_table_t *ft_copy_table(ft_table_t *table) } - result->options = copy_table_options(table->options); - if (result->options == NULL) { + result->properties = copy_table_properties(table->properties); + if (result->properties == NULL) { ft_destroy_table(result); return NULL; } @@ -622,14 +622,14 @@ const char *ft_to_string(const ft_table_t *table) int tmp = 0; size_t i = 0; context_t context; - context.table_options = (table->options ? table->options : &g_table_options); + context.table_properties = (table->properties ? table->properties : &g_table_properties); fort_row_t *prev_row = NULL; fort_row_t *cur_row = NULL; separator_t *cur_sep = NULL; size_t sep_size = vector_size(table->separators); /* Print top margin */ - for (i = 0; i < context.table_options->entire_table_options.top_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -648,7 +648,7 @@ const char *ft_to_string(const ft_table_t *table) CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context)); /* Print bottom margin */ - for (i = 0; i < context.table_options->entire_table_options.bottom_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -727,14 +727,14 @@ const wchar_t *ft_to_wstring(const ft_table_t *table) int tmp = 0; size_t i = 0; context_t context; - context.table_options = (table->options ? table->options : &g_table_options); + context.table_properties = (table->properties ? table->properties : &g_table_properties); fort_row_t *prev_row = NULL; fort_row_t *cur_row = NULL; separator_t *cur_sep = NULL; size_t sep_size = vector_size(table->separators); /* Print top margin */ - for (i = 0; i < context.table_options->entire_table_options.top_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -753,7 +753,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table) CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context)); /* Print bottom margin */ - for (i = 0; i < context.table_options->entire_table_options.bottom_margin; ++i) { + for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) { CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); } @@ -844,7 +844,7 @@ struct ft_border_style *FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME -static void set_border_options_for_options(fort_table_options_t *options, const struct ft_border_style *style) +static void set_border_props_for_props(fort_table_properties_t *properties, const struct ft_border_style *style) { if ((struct fort_border_style *)style == &FORT_BASIC_STYLE || (struct fort_border_style *)style == &FORT_BASIC2_STYLE @@ -859,16 +859,16 @@ static void set_border_options_for_options(fort_table_options_t *options, const || (struct fort_border_style *)style == &FORT_BOLD_STYLE || (struct fort_border_style *)style == &FORT_BOLD2_STYLE || (struct fort_border_style *)style == &FORT_FRAME_STYLE) { - memcpy(&(options->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style)); + memcpy(&(properties->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style)); return; } const struct ft_border_chars *border_chs = &(style->border_chs); const struct ft_border_chars *header_border_chs = &(style->header_border_chs); -#define BOR_CHARS options->border_style.border_chars -#define H_BOR_CHARS options->border_style.header_border_chars -#define SEP_CHARS options->border_style.separator_chars +#define BOR_CHARS properties->border_style.border_chars +#define H_BOR_CHARS properties->border_style.header_border_chars +#define SEP_CHARS properties->border_style.separator_chars /* BOR_CHARS[TL_bip] = BOR_CHARS[TT_bip] = BOR_CHARS[TV_bip] = BOR_CHARS[TR_bip] = border_chs->top_border_ch; @@ -933,36 +933,36 @@ static void set_border_options_for_options(fort_table_options_t *options, const int ft_set_default_border_style(const struct ft_border_style *style) { - set_border_options_for_options(&g_table_options, style); + set_border_props_for_props(&g_table_properties, style); return FT_SUCCESS; } int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style) { assert(table); - if (table->options == NULL) { - table->options = create_table_options(); - if (table->options == NULL) + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) return FT_MEMORY_ERROR; } - set_border_options_for_options(table->options, style); + set_border_props_for_props(table->properties, style); return FT_SUCCESS; } -int ft_set_cell_option(ft_table_t *table, size_t row, size_t col, uint32_t option, int value) +int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value) { assert(table); - if (table->options == NULL) { - table->options = create_table_options(); - if (table->options == NULL) + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) return FT_MEMORY_ERROR; } - if (table->options->cell_options == NULL) { - table->options->cell_options = create_cell_opt_container(); - if (table->options->cell_options == NULL) { + if (table->properties->cell_properties == NULL) { + table->properties->cell_properties = create_cell_prop_container(); + if (table->properties->cell_properties == NULL) { return FT_ERROR; } } @@ -972,30 +972,30 @@ int ft_set_cell_option(ft_table_t *table, size_t row, size_t col, uint32_t optio if (row == FT_CUR_COLUMN) col = table->cur_col; - return set_cell_option(table->options->cell_options, row, col, option, value); + return set_cell_property(table->properties->cell_properties, row, col, property, value); } -int ft_set_default_cell_option(uint32_t option, int value) +int ft_set_default_cell_prop(uint32_t property, int value) { - return set_default_cell_option(option, value); + return set_default_cell_property(property, value); } -int ft_set_default_tbl_option(uint32_t option, int value) +int ft_set_default_tbl_prop(uint32_t property, int value) { - return set_default_entire_table_option(option, value); + return set_default_entire_table_property(property, value); } -int ft_set_tbl_option(ft_table_t *table, uint32_t option, int value) +int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value) { assert(table); - if (table->options == NULL) { - table->options = create_table_options(); - if (table->options == NULL) + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) return FT_MEMORY_ERROR; } - return set_entire_table_option(table->options, option, value); + return set_entire_table_property(table->properties, property, value); } void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)) diff --git a/src/fort_utils.h b/src/fort_utils.h index e6baf7b..f2bd320 100644 --- a/src/fort_utils.h +++ b/src/fort_utils.h @@ -80,8 +80,8 @@ enum F_BOOL { -struct fort_table_options; -struct fort_column_options; +struct fort_table_properties; +struct fort_column_properties; struct fort_row; struct vector; struct fort_cell; @@ -90,14 +90,14 @@ struct separator { int enabled; }; -typedef struct fort_table_options fort_table_options_t; +typedef struct fort_table_properties fort_table_properties_t; struct fort_context { - fort_table_options_t *table_options; + fort_table_properties_t *table_properties; size_t row; size_t column; }; typedef struct fort_context context_t; -typedef struct fort_column_options fort_column_options_t; +typedef struct fort_column_properties fort_column_properties_t; typedef struct vector vector_t; typedef struct fort_cell fort_cell_t; typedef struct string_buffer string_buffer_t; diff --git a/src/options.c b/src/properties.c similarity index 70% rename from src/options.c rename to src/properties.c index 22ca878..c0bb607 100644 --- a/src/options.c +++ b/src/properties.c @@ -1,20 +1,20 @@ #include -#include "options.h" +#include "properties.h" #include "fort_utils.h" #include "vector.h" /***************************************************************************** - * COLUMN OPTIONS + * COLUMN PROPERTIES * ***************************************************************************/ -struct fort_cell_options g_default_cell_option = { +struct fort_cell_props g_default_cell_properties = { FT_ANY_ROW, /* cell_row */ FT_ANY_COLUMN, /* cell_col */ - /* options */ - FT_COPT_MIN_WIDTH | FT_COPT_TEXT_ALIGN | FT_COPT_TOP_PADDING - | FT_COPT_BOTTOM_PADDING | FT_COPT_LEFT_PADDING | FT_COPT_RIGHT_PADDING - | FT_COPT_EMPTY_STR_HEIGHT, + /* properties */ + FT_CPROP_MIN_WIDTH | FT_CPROP_TEXT_ALIGN | FT_CPROP_TOP_PADDING + | FT_CPROP_BOTTOM_PADDING | FT_CPROP_LEFT_PADDING | FT_CPROP_RIGHT_PADDING + | FT_CPROP_EMPTY_STR_HEIGHT, 0, /* col_min_width */ FT_ALIGNED_LEFT, /* align */ @@ -27,28 +27,28 @@ struct fort_cell_options g_default_cell_option = { FT_ROW_COMMON, /* row_type */ }; -static int get_option_value_if_exists_otherwise_default(const struct fort_cell_options *cell_opts, uint32_t option) +static int get_prop_value_if_exists_otherwise_default(const struct fort_cell_props *cell_opts, uint32_t property) { - if (cell_opts == NULL || !OPTION_IS_SET(cell_opts->options, option)) { - cell_opts = &g_default_cell_option; + if (cell_opts == NULL || !PROP_IS_SET(cell_opts->properties, property)) { + cell_opts = &g_default_cell_properties; } - switch (option) { - case FT_COPT_MIN_WIDTH: + switch (property) { + case FT_CPROP_MIN_WIDTH: return cell_opts->col_min_width; - case FT_COPT_TEXT_ALIGN: + case FT_CPROP_TEXT_ALIGN: return cell_opts->align; - case FT_COPT_TOP_PADDING: + case FT_CPROP_TOP_PADDING: return cell_opts->cell_padding_top; - case FT_COPT_BOTTOM_PADDING: + case FT_CPROP_BOTTOM_PADDING: return cell_opts->cell_padding_bottom; - case FT_COPT_LEFT_PADDING: + case FT_CPROP_LEFT_PADDING: return cell_opts->cell_padding_left; - case FT_COPT_RIGHT_PADDING: + case FT_CPROP_RIGHT_PADDING: return cell_opts->cell_padding_right; - case FT_COPT_EMPTY_STR_HEIGHT: + case FT_CPROP_EMPTY_STR_HEIGHT: return cell_opts->cell_empty_string_height; - case FT_COPT_ROW_TYPE: + case FT_CPROP_ROW_TYPE: return cell_opts->row_type; default: /* todo: implement later */ @@ -57,17 +57,16 @@ static int get_option_value_if_exists_otherwise_default(const struct fort_cell_o } -//#define DEFAULT_CELL_OPTION {FT_ROW_UNSPEC, FT_COLUMN_UNSPEC, 0, 0, 0} FT_INTERNAL -fort_cell_opt_container_t *create_cell_opt_container(void) +fort_cell_prop_container_t *create_cell_prop_container(void) { - fort_cell_opt_container_t *ret = create_vector(sizeof(fort_cell_options_t), DEFAULT_VECTOR_CAPACITY); + fort_cell_prop_container_t *ret = create_vector(sizeof(fort_cell_props_t), DEFAULT_VECTOR_CAPACITY); return ret; } FT_INTERNAL -void destroy_cell_opt_container(fort_cell_opt_container_t *cont) +void destroy_cell_prop_container(fort_cell_prop_container_t *cont) { if (cont) destroy_vector(cont); @@ -75,13 +74,13 @@ void destroy_cell_opt_container(fort_cell_opt_container_t *cont) FT_INTERNAL -const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col) +const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col) { assert(cont); size_t sz = vector_size(cont); size_t i = 0; for (i = 0; i < sz; ++i) { - const fort_cell_options_t *opt = (const fort_cell_options_t *)vector_at_c(cont, i); + const fort_cell_props_t *opt = (const fort_cell_props_t *)vector_at_c(cont, i); if (opt->cell_row == row && opt->cell_col == col) return opt; } @@ -90,28 +89,27 @@ const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, FT_INTERNAL -fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col) +fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col) { assert(cont); size_t sz = vector_size(cont); size_t i = 0; for (i = 0; i < sz; ++i) { - fort_cell_options_t *opt = (fort_cell_options_t *)vector_at(cont, i); + fort_cell_props_t *opt = (fort_cell_props_t *)vector_at(cont, i); if (opt->cell_row == row && opt->cell_col == col) return opt; } -// fort_cell_options_t opt = g_default_cell_option;// DEFAULT_CELL_OPTION; - fort_cell_options_t opt; + fort_cell_props_t opt; if (row == FT_ANY_ROW && col == FT_ANY_COLUMN) - memcpy(&opt, &g_default_cell_option, sizeof(fort_cell_options_t)); + memcpy(&opt, &g_default_cell_properties, sizeof(fort_cell_props_t)); else - memset(&opt, 0, sizeof(fort_cell_options_t)); + memset(&opt, 0, sizeof(fort_cell_props_t)); opt.cell_row = row; opt.cell_col = col; if (FT_IS_SUCCESS(vector_push(cont, &opt))) { - return (fort_cell_options_t *)vector_at(cont, sz); + return (fort_cell_props_t *)vector_at(cont, sz); } return NULL; @@ -119,15 +117,15 @@ fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_contain FT_INTERNAL -int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option) +int get_cell_property_value_hierarcial(const fort_table_properties_t *propertiess, size_t row, size_t column, uint32_t property) { - assert(options); + assert(propertiess); - const fort_cell_options_t *opt = NULL; - if (options->cell_options != NULL) { + const fort_cell_props_t *opt = NULL; + if (propertiess->cell_properties != NULL) { while (1) { - opt = cget_cell_opt(options->cell_options, row, column); - if (opt != NULL && OPTION_IS_SET(opt->options, option)) + opt = cget_cell_prop(propertiess->cell_properties, row, column); + if (opt != NULL && PROP_IS_SET(opt->properties, property)) break; if (row != FT_ANY_ROW) { row = FT_ANY_ROW; @@ -143,36 +141,36 @@ int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t ro } } - return get_option_value_if_exists_otherwise_default(opt, option); + return get_prop_value_if_exists_otherwise_default(opt, property); } -static fort_status_t set_cell_option_impl(fort_cell_options_t *opt, uint32_t option, int value) +static fort_status_t set_cell_property_impl(fort_cell_props_t *opt, uint32_t property, int value) { assert(opt); - OPTION_SET(opt->options, option); - if (OPTION_IS_SET(option, FT_COPT_MIN_WIDTH)) { + PROP_SET(opt->properties, property); + if (PROP_IS_SET(property, FT_CPROP_MIN_WIDTH)) { CHECK_NOT_NEGATIVE(value); opt->col_min_width = value; - } else if (OPTION_IS_SET(option, FT_COPT_TEXT_ALIGN)) { + } else if (PROP_IS_SET(property, FT_CPROP_TEXT_ALIGN)) { opt->align = (enum ft_text_alignment)value; - } else if (OPTION_IS_SET(option, FT_COPT_TOP_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_TOP_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_top = value; - } else if (OPTION_IS_SET(option, FT_COPT_BOTTOM_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_BOTTOM_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_bottom = value; - } else if (OPTION_IS_SET(option, FT_COPT_LEFT_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_LEFT_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_left = value; - } else if (OPTION_IS_SET(option, FT_COPT_RIGHT_PADDING)) { + } else if (PROP_IS_SET(property, FT_CPROP_RIGHT_PADDING)) { CHECK_NOT_NEGATIVE(value); opt->cell_padding_right = value; - } else if (OPTION_IS_SET(option, FT_COPT_EMPTY_STR_HEIGHT)) { + } else if (PROP_IS_SET(property, FT_CPROP_EMPTY_STR_HEIGHT)) { CHECK_NOT_NEGATIVE(value); opt->cell_empty_string_height = value; - } else if (OPTION_IS_SET(option, FT_COPT_ROW_TYPE)) { + } else if (PROP_IS_SET(property, FT_CPROP_ROW_TYPE)) { opt->row_type = (enum ft_row_type)value; } @@ -184,18 +182,18 @@ fort_fail: FT_INTERNAL -fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value) +fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value) { - fort_cell_options_t *opt = get_cell_opt_and_create_if_not_exists(cont, row, col); + fort_cell_props_t *opt = get_cell_prop_and_create_if_not_exists(cont, row, col); if (opt == NULL) return FT_ERROR; - return set_cell_option_impl(opt, option, value); + return set_cell_property_impl(opt, property, value); /* - OPTION_SET(opt->options, option); - if (OPTION_IS_SET(option, FT_COPT_MIN_WIDTH)) { + PROP_SET(opt->propertiess, property); + if (PROP_IS_SET(property, FT_CPROP_MIN_WIDTH)) { opt->col_min_width = value; - } else if (OPTION_IS_SET(option, FT_COPT_TEXT_ALIGN)) { + } else if (PROP_IS_SET(property, FT_CPROP_TEXT_ALIGN)) { opt->align = value; } @@ -205,13 +203,13 @@ fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_ FT_INTERNAL -fort_status_t set_default_cell_option(uint32_t option, int value) +fort_status_t set_default_cell_property(uint32_t property, int value) { - return set_cell_option_impl(&g_default_cell_option, option, value); + return set_cell_property_impl(&g_default_cell_properties, property, value); } /***************************************************************************** - * OPTIONS + * PROPERTIESS * ***************************************************************************/ @@ -535,25 +533,25 @@ struct fort_border_style FORT_FRAME_STYLE = FRAME_STYLE; -fort_entire_table_options_t g_entire_table_options = { +fort_entire_table_properties_t g_entire_table_properties = { 0, /* left_margin */ 0, /* top_margin */ 0, /* right_margin */ 0, /* bottom_margin */ }; -static fort_status_t set_entire_table_option_internal(fort_entire_table_options_t *options, uint32_t option, int value) +static fort_status_t set_entire_table_property_internal(fort_entire_table_properties_t *properties, uint32_t property, int value) { - assert(options); + assert(properties); CHECK_NOT_NEGATIVE(value); - if (OPTION_IS_SET(option, FT_TOPT_LEFT_MARGIN)) { - options->left_margin = value; - } else if (OPTION_IS_SET(option, FT_TOPT_TOP_MARGIN)) { - options->top_margin = value; - } else if (OPTION_IS_SET(option, FT_TOPT_RIGHT_MARGIN)) { - options->right_margin = value; - } else if (OPTION_IS_SET(option, FT_TOPT_BOTTOM_MARGIN)) { - options->bottom_margin = value; + if (PROP_IS_SET(property, FT_TPROP_LEFT_MARGIN)) { + properties->left_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_TOP_MARGIN)) { + properties->top_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_RIGHT_MARGIN)) { + properties->right_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_BOTTOM_MARGIN)) { + properties->bottom_margin = value; } else { return FT_EINVAL; } @@ -565,48 +563,48 @@ fort_fail: FT_INTERNAL -fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value) +fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value) { - assert(table_options); - return set_entire_table_option_internal(&table_options->entire_table_options, option, value); + assert(table_properties); + return set_entire_table_property_internal(&table_properties->entire_table_properties, property, value); } FT_INTERNAL -fort_status_t set_default_entire_table_option(uint32_t option, int value) +fort_status_t set_default_entire_table_property(uint32_t property, int value) { - return set_entire_table_option_internal(&g_entire_table_options, option, value); + return set_entire_table_property_internal(&g_entire_table_properties, property, value); } FT_INTERNAL -size_t max_border_elem_strlen(struct fort_table_options *options) +size_t max_border_elem_strlen(struct fort_table_properties *properties) { - assert(options); + assert(properties); size_t result = 1; int i = 0; for (i = 0; i < BorderItemPosSize; ++i) { - result = MAX(result, strlen(options->border_style.border_chars[i])); + result = MAX(result, strlen(properties->border_style.border_chars[i])); } i = 0; for (i = 0; i < BorderItemPosSize; ++i) { - result = MAX(result, strlen(options->border_style.header_border_chars[i])); + result = MAX(result, strlen(properties->border_style.header_border_chars[i])); } i = 0; for (i = 0; i < SepratorItemPosSize; ++i) { - result = MAX(result, strlen(options->border_style.separator_chars[i])); + result = MAX(result, strlen(properties->border_style.separator_chars[i])); } return result; } -fort_table_options_t g_table_options = { +fort_table_properties_t g_table_properties = { /* border_style */ BASIC_STYLE, - NULL, /* cell_options */ - /* entire_table_options */ + NULL, /* cell_properties */ + /* entire_table_properties */ { 0, /* left_margin */ 0, /* top_margin */ @@ -617,46 +615,46 @@ fort_table_options_t g_table_options = { FT_INTERNAL -fort_table_options_t *create_table_options(void) +fort_table_properties_t *create_table_properties(void) { - fort_table_options_t *options = (fort_table_options_t *)F_CALLOC(sizeof(fort_table_options_t), 1); - if (options == NULL) { + fort_table_properties_t *properties = (fort_table_properties_t *)F_CALLOC(sizeof(fort_table_properties_t), 1); + if (properties == NULL) { return NULL; } - memcpy(options, &g_table_options, sizeof(fort_table_options_t)); - options->cell_options = create_cell_opt_container(); - if (options->cell_options == NULL) { - destroy_table_options(options); + memcpy(properties, &g_table_properties, sizeof(fort_table_properties_t)); + properties->cell_properties = create_cell_prop_container(); + if (properties->cell_properties == NULL) { + destroy_table_properties(properties); return NULL; } - memcpy(&options->entire_table_options, &g_entire_table_options, sizeof(fort_entire_table_options_t)); - return options; + memcpy(&properties->entire_table_properties, &g_entire_table_properties, sizeof(fort_entire_table_properties_t)); + return properties; } FT_INTERNAL -void destroy_table_options(fort_table_options_t *options) +void destroy_table_properties(fort_table_properties_t *properties) { - if (options == NULL) + if (properties == NULL) return; - if (options->cell_options != NULL) { - destroy_cell_opt_container(options->cell_options); + if (properties->cell_properties != NULL) { + destroy_cell_prop_container(properties->cell_properties); } - F_FREE(options); + F_FREE(properties); } static -fort_cell_opt_container_t *copy_cell_options(fort_cell_opt_container_t *cont) +fort_cell_prop_container_t *copy_cell_properties(fort_cell_prop_container_t *cont) { - fort_cell_opt_container_t *result = create_cell_opt_container(); + fort_cell_prop_container_t *result = create_cell_prop_container(); if (result == NULL) return NULL; size_t sz = vector_size(cont); for (size_t i = 0; i < sz; ++i) { - fort_cell_options_t *opt = (fort_cell_options_t *)vector_at(cont, i); + fort_cell_props_t *opt = (fort_cell_props_t *)vector_at(cont, i); if (FT_IS_ERROR(vector_push(result, opt))) { - destroy_cell_opt_container(result); + destroy_cell_prop_container(result); return NULL; } } @@ -664,22 +662,22 @@ fort_cell_opt_container_t *copy_cell_options(fort_cell_opt_container_t *cont) } FT_INTERNAL -fort_table_options_t *copy_table_options(const fort_table_options_t *option) +fort_table_properties_t *copy_table_properties(const fort_table_properties_t *properties) { - fort_table_options_t *new_opt = create_table_options(); + fort_table_properties_t *new_opt = create_table_properties(); if (new_opt == NULL) return NULL; - destroy_vector(new_opt->cell_options); - new_opt->cell_options = copy_cell_options(option->cell_options); + destroy_vector(new_opt->cell_properties); + new_opt->cell_properties = copy_cell_properties(properties->cell_properties); if (new_opt == NULL) { - destroy_table_options(new_opt); + destroy_table_properties(new_opt); return NULL; } - memcpy(&new_opt->border_style, &option->border_style, sizeof(struct fort_border_style)); - memcpy(&new_opt->entire_table_options, - &option->entire_table_options, sizeof(fort_entire_table_options_t)); + memcpy(&new_opt->border_style, &properties->border_style, sizeof(struct fort_border_style)); + memcpy(&new_opt->entire_table_properties, + &properties->entire_table_properties, sizeof(fort_entire_table_properties_t)); return new_opt; } diff --git a/src/options.h b/src/properties.h similarity index 64% rename from src/options.h rename to src/properties.h index 615b27c..0aa6881 100644 --- a/src/options.h +++ b/src/properties.h @@ -1,18 +1,18 @@ -#ifndef OPTIONS_H -#define OPTIONS_H +#ifndef PROPERTIES_H +#define PROPERTIES_H #include "fort_utils.h" #include #include -#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option)) -#define OPTION_SET(ft_opts, option) ((ft_opts) |=(option)) -#define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option)) +#define PROP_IS_SET(ft_props, property) ((ft_props) & (property)) +#define PROP_SET(ft_props, property) ((ft_props) |=(property)) +#define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)property)) -struct fort_cell_options { +struct fort_cell_props { size_t cell_row; size_t cell_col; - uint32_t options; + uint32_t properties; unsigned int col_min_width; enum ft_text_alignment align; unsigned int cell_padding_top; @@ -23,29 +23,29 @@ struct fort_cell_options { enum ft_row_type row_type; }; -typedef struct fort_cell_options fort_cell_options_t; -typedef vector_t fort_cell_opt_container_t; +typedef struct fort_cell_props fort_cell_props_t; +typedef vector_t fort_cell_prop_container_t; FT_INTERNAL -fort_cell_opt_container_t *create_cell_opt_container(void); +fort_cell_prop_container_t *create_cell_prop_container(void); FT_INTERNAL -void destroy_cell_opt_container(fort_cell_opt_container_t *cont); +void destroy_cell_prop_container(fort_cell_prop_container_t *cont); FT_INTERNAL -const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col); +const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col); FT_INTERNAL -fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col); +fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col); FT_INTERNAL -fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value); +fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value); FT_INTERNAL -int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option); +int get_cell_property_value_hierarcial(const fort_table_properties_t *properties, size_t row, size_t column, uint32_t property); FT_INTERNAL -fort_status_t set_default_cell_option(uint32_t option, int value); +fort_status_t set_default_cell_property(uint32_t property, int value); /***************************************************************************** * TABLE BORDER @@ -142,38 +142,38 @@ extern struct fort_border_style FORT_BOLD2_STYLE; extern struct fort_border_style FORT_FRAME_STYLE; -struct fort_entire_table_options { +struct fort_entire_table_properties { unsigned int left_margin; unsigned int top_margin; unsigned int right_margin; unsigned int bottom_margin; }; -typedef struct fort_entire_table_options fort_entire_table_options_t; -extern fort_entire_table_options_t g_entire_table_options; +typedef struct fort_entire_table_properties fort_entire_table_properties_t; +extern fort_entire_table_properties_t g_entire_table_properties; FT_INTERNAL -fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value); +fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value); FT_INTERNAL -fort_status_t set_default_entire_table_option(uint32_t option, int value); +fort_status_t set_default_entire_table_property(uint32_t property, int value); -struct fort_table_options { +struct fort_table_properties { struct fort_border_style border_style; - fort_cell_opt_container_t *cell_options; - fort_entire_table_options_t entire_table_options; + fort_cell_prop_container_t *cell_properties; + fort_entire_table_properties_t entire_table_properties; }; -extern fort_table_options_t g_table_options; +extern fort_table_properties_t g_table_properties; FT_INTERNAL -size_t max_border_elem_strlen(struct fort_table_options *); +size_t max_border_elem_strlen(struct fort_table_properties *); FT_INTERNAL -fort_table_options_t *create_table_options(void); +fort_table_properties_t *create_table_properties(void); FT_INTERNAL -void destroy_table_options(fort_table_options_t *options); +void destroy_table_properties(fort_table_properties_t *properties); FT_INTERNAL -fort_table_options_t *copy_table_options(const fort_table_options_t *option); +fort_table_properties_t *copy_table_properties(const fort_table_properties_t *property); -#endif /* OPTIONS_H */ +#endif /* PROPERTIES_H */ diff --git a/src/row.c b/src/row.c index 90190a3..5236fba 100644 --- a/src/row.c +++ b/src/row.c @@ -271,11 +271,11 @@ int print_row_separator(char *buffer, size_t buffer_sz, enum ft_row_type lower_row_type = FT_ROW_COMMON; if (lower_row != NULL) { - lower_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + lower_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } enum ft_row_type upper_row_type = FT_ROW_COMMON; if (upper_row != NULL) { - upper_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row - 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + upper_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row - 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } /* Row separator anatomy @@ -295,20 +295,20 @@ int print_row_separator(char *buffer, size_t buffer_sz, typedef const char *(*border_chars_point_t)[BorderItemPosSize]; const char *(*border_chars)[BorderItemPosSize] = NULL; - border_chars = (border_chars_point_t)&context->table_options->border_style.border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.border_chars; if (upper_row_type == FT_ROW_HEADER || lower_row_type == FT_ROW_HEADER) { - border_chars = (border_chars_point_t)&context->table_options->border_style.header_border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.header_border_chars; } if (sep && sep->enabled) { - L = &(context->table_options->border_style.separator_chars[LH_sip]); - I = &(context->table_options->border_style.separator_chars[IH_sip]); - IV = &(context->table_options->border_style.separator_chars[II_sip]); - R = &(context->table_options->border_style.separator_chars[RH_sip]); + L = &(context->table_properties->border_style.separator_chars[LH_sip]); + I = &(context->table_properties->border_style.separator_chars[IH_sip]); + IV = &(context->table_properties->border_style.separator_chars[II_sip]); + R = &(context->table_properties->border_style.separator_chars[RH_sip]); - IT = &(context->table_options->border_style.separator_chars[II_sip]); - IB = &(context->table_options->border_style.separator_chars[II_sip]); - II = &(context->table_options->border_style.separator_chars[IH_sip]); + IT = &(context->table_properties->border_style.separator_chars[II_sip]); + IB = &(context->table_properties->border_style.separator_chars[II_sip]); + II = &(context->table_properties->border_style.separator_chars[IH_sip]); } else { switch (separatorPos) { case TopSeparator: @@ -364,7 +364,7 @@ int print_row_separator(char *buffer, size_t buffer_sz, } /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); for (i = 0; i < cols; ++i) { if (i == 0) { @@ -386,7 +386,7 @@ int print_row_separator(char *buffer, size_t buffer_sz, CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, "\n")); @@ -446,11 +446,11 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, enum ft_row_type lower_row_type = FT_ROW_COMMON; if (lower_row != NULL) { - lower_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + lower_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } enum ft_row_type upper_row_type = FT_ROW_COMMON; if (upper_row != NULL) { - upper_row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row - 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + upper_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row - 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); } /* Row separator anatomy @@ -470,20 +470,20 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, typedef const char *(*border_chars_point_t)[BorderItemPosSize]; const char *(*border_chars)[BorderItemPosSize] = NULL; - border_chars = (border_chars_point_t)&context->table_options->border_style.border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.border_chars; if (upper_row_type == FT_ROW_HEADER || lower_row_type == FT_ROW_HEADER) { - border_chars = (border_chars_point_t)&context->table_options->border_style.header_border_chars; + border_chars = (border_chars_point_t)&context->table_properties->border_style.header_border_chars; } if (sep && sep->enabled) { - L = &(context->table_options->border_style.separator_chars[LH_sip]); - I = &(context->table_options->border_style.separator_chars[IH_sip]); - IV = &(context->table_options->border_style.separator_chars[II_sip]); - R = &(context->table_options->border_style.separator_chars[RH_sip]); + L = &(context->table_properties->border_style.separator_chars[LH_sip]); + I = &(context->table_properties->border_style.separator_chars[IH_sip]); + IV = &(context->table_properties->border_style.separator_chars[II_sip]); + R = &(context->table_properties->border_style.separator_chars[RH_sip]); - IT = &(context->table_options->border_style.separator_chars[II_sip]); - IB = &(context->table_options->border_style.separator_chars[II_sip]); - II = &(context->table_options->border_style.separator_chars[IH_sip]); + IT = &(context->table_properties->border_style.separator_chars[II_sip]); + IB = &(context->table_properties->border_style.separator_chars[II_sip]); + II = &(context->table_properties->border_style.separator_chars[IH_sip]); } else { switch (separatorPos) { case TopSeparator: @@ -539,7 +539,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, } /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); for (i = 0; i < cols; ++i) { if (i == 0) { @@ -561,7 +561,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, "\n")); @@ -945,10 +945,10 @@ int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col */ typedef const char *(*border_chars_point_t)[BorderItemPosSize]; - enum ft_row_type row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + enum ft_row_type row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); const char *(*bord_chars)[BorderItemPosSize] = (row_type == FT_ROW_HEADER) - ? (border_chars_point_t)(&context->table_options->border_style.header_border_chars) - : (border_chars_point_t)(&context->table_options->border_style.border_chars); + ? (border_chars_point_t)(&context->table_properties->border_style.header_border_chars) + : (border_chars_point_t)(&context->table_properties->border_style.border_chars); const char **L = &(*bord_chars)[LL_bip]; const char **IV = &(*bord_chars)[IV_bip]; const char **R = &(*bord_chars)[RR_bip]; @@ -959,7 +959,7 @@ int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col size_t i = 0; for (i = 0; i < row_height; ++i) { /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); /* Print left table boundary */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *L)); @@ -996,7 +996,7 @@ int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); /* Print new line character */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, new_line_char)); @@ -1035,10 +1035,10 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t */ typedef const char *(*border_chars_point_t)[BorderItemPosSize]; - enum ft_row_type row_type = (enum ft_row_type)get_cell_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE); + enum ft_row_type row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); const char *(*bord_chars)[BorderItemPosSize] = (row_type == FT_ROW_HEADER) - ? (border_chars_point_t)(&context->table_options->border_style.header_border_chars) - : (border_chars_point_t)(&context->table_options->border_style.border_chars); + ? (border_chars_point_t)(&context->table_properties->border_style.header_border_chars) + : (border_chars_point_t)(&context->table_properties->border_style.border_chars); const char **L = &(*bord_chars)[LL_bip]; const char **IV = &(*bord_chars)[IV_bip]; const char **R = &(*bord_chars)[RR_bip]; @@ -1049,7 +1049,7 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t size_t i = 0; for (i = 0; i < row_height; ++i) { /* Print left margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.left_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); /* Print left table boundary */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *L)); @@ -1086,7 +1086,7 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *R)); /* Print right margin */ - CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_options->entire_table_options.right_margin, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); /* Print new line character */ CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, new_line_char)); diff --git a/src/row.h b/src/row.h index 614bd1e..ee96bdc 100644 --- a/src/row.h +++ b/src/row.h @@ -4,7 +4,7 @@ #include "fort_utils.h" #include "fort.h" #include -#include "options.h" +#include "properties.h" #ifdef FT_HAVE_WCHAR #include #endif diff --git a/src/string_buffer.c b/src/string_buffer.c index f729426..48ec131 100644 --- a/src/string_buffer.c +++ b/src/string_buffer.c @@ -1,5 +1,5 @@ #include "string_buffer.h" -#include "options.h" +#include "properties.h" #include "wcwidth.h" #include #include @@ -363,7 +363,7 @@ int buffer_printf(string_buffer_t *buffer, size_t buffer_row, char *buf, size_t size_t left = 0; size_t right = 0; - switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) { + switch (get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TEXT_ALIGN)) { case FT_ALIGNED_LEFT: left = 0; right = (buf_len - 1) - content_width; @@ -451,7 +451,7 @@ int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, siz size_t left = 0; size_t right = 0; - switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) { + switch (get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TEXT_ALIGN)) { case FT_ALIGNED_LEFT: left = 0; right = (buf_len - 1) - content_width; diff --git a/src/table.c b/src/table.c index 6d1831f..9d7040e 100644 --- a/src/table.c +++ b/src/table.c @@ -146,7 +146,7 @@ fort_status_t table_rows_and_cols_geometry(const ft_table_t *table, int combined_cells_found = 0; context_t context; - context.table_options = (table->options ? table->options : &g_table_options); + context.table_properties = (table->properties ? table->properties : &g_table_properties); size_t col = 0; for (col = 0; col < cols; ++col) { col_width_arr[col] = 0; @@ -212,9 +212,9 @@ fort_status_t table_rows_and_cols_geometry(const ft_table_t *table, * paddings but be min width of the cell content without padding */ /* - if (table->options) { + if (table->properties) { for (size_t i = 0; i < cols; ++i) { - col_width_arr[i] = MAX((int)col_width_arr[i], fort_options_column_width(table->options, i)); + col_width_arr[i] = MAX((int)col_width_arr[i], fort_props_column_width(table->properties, i)); } } */ @@ -261,16 +261,16 @@ fort_status_t table_geometry(const ft_table_t *table, size_t *height, size_t *wi F_FREE(col_width_arr); F_FREE(row_height_arr); - if (table->options) { - *height += table->options->entire_table_options.top_margin; - *height += table->options->entire_table_options.bottom_margin; - *width += table->options->entire_table_options.left_margin; - *width += table->options->entire_table_options.right_margin; + if (table->properties) { + *height += table->properties->entire_table_properties.top_margin; + *height += table->properties->entire_table_properties.bottom_margin; + *width += table->properties->entire_table_properties.left_margin; + *width += table->properties->entire_table_properties.right_margin; } /* Take into account that border elements can be more than one byte long */ - fort_table_options_t *table_options = table->options ? table->options : &g_table_options; - size_t max_border_elem_len = max_border_elem_strlen(table_options); + fort_table_properties_t *table_properties = table->properties ? table->properties : &g_table_properties; + size_t max_border_elem_len = max_border_elem_strlen(table_properties); *width *= max_border_elem_len; return FT_SUCCESS; diff --git a/src/table.h b/src/table.h index 9adca0b..5c1ebfa 100644 --- a/src/table.h +++ b/src/table.h @@ -5,7 +5,7 @@ struct ft_table { vector_t *rows; - fort_table_options_t *options; + fort_table_properties_t *properties; string_buffer_t *conv_buffer; size_t cur_row; size_t cur_col; diff --git a/tests/bb_tests/test_memory_errors.c b/tests/bb_tests/test_memory_errors.c index b7a9089..c32d14a 100644 --- a/tests/bb_tests/test_memory_errors.c +++ b/tests/bb_tests/test_memory_errors.c @@ -35,11 +35,11 @@ static int create_simple_table_and_show(void) goto exit; } /* - if (set_test_options_for_table(table) != FT_SUCCESS) + if (set_test_props_for_table(table) != FT_SUCCESS) return 2; */ - if (ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER) != FT_SUCCESS) { + if (ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER) != FT_SUCCESS) { result = 3; goto exit; } diff --git a/tests/bb_tests/test_table_basic.c b/tests/bb_tests/test_table_basic.c index c965d3f..c3d0540 100644 --- a/tests/bb_tests/test_table_basic.c +++ b/tests/bb_tests/test_table_basic.c @@ -9,9 +9,9 @@ void test_table_basic(void) WHEN("All columns are equal and not empty") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS); assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS); assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS); @@ -40,9 +40,9 @@ void test_table_basic(void) WHEN("All columns are equal and not empty (wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_wwrite_ln(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS); @@ -71,9 +71,9 @@ void test_table_basic(void) WHEN("All columns are not equal and not empty") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS); assert_true(ft_write_ln(table, "c", "234", "3.140000", "3") == FT_SUCCESS); assert_true(ft_write_ln(table, "234", "3.140000", "3", "c") == FT_SUCCESS); @@ -102,9 +102,9 @@ void test_table_basic(void) WHEN("All columns are not equal and not empty (wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_wwrite_ln(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"c", L"234", L"3.140000", L"3") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"234", L"3.140000", L"3", L"c") == FT_SUCCESS); @@ -133,9 +133,9 @@ void test_table_basic(void) WHEN("All columns are not equal and some cells are empty") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_write_ln(table, "", "", "234", "3.140000") == FT_SUCCESS); assert_true(ft_write_ln(table, "c", "234", "3.140000", "") == FT_SUCCESS); assert_true(ft_write_ln(table, "234", "3.140000", "", "") == FT_SUCCESS); @@ -164,9 +164,9 @@ void test_table_basic(void) WHEN("All columns are not equal and some cells are empty (wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_wwrite_ln(table, L"", L"", L"234", L"3.140000") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"c", L"234", L"3.140000", L"") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"234", L"3.140000", L"", L"") == FT_SUCCESS); @@ -195,9 +195,9 @@ void test_table_basic(void) WHEN("All cells are empty") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_write_ln(table, "", "", "", "") == FT_SUCCESS); assert_true(ft_write_ln(table, "", "", "", "") == FT_SUCCESS); assert_true(ft_write_ln(table, "", "", "", "") == FT_SUCCESS); @@ -226,9 +226,9 @@ void test_table_basic(void) WHEN("All cells are empty (wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_wwrite_ln(table, L"", L"", L"", L"") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"", L"", L"", L"") == FT_SUCCESS); assert_true(ft_wwrite_ln(table, L"", L"", L"", L"") == FT_SUCCESS); @@ -265,9 +265,9 @@ void test_wcs_table_boundaries(void) WHEN("All columns are not equal and not empty (wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_wwrite_ln(table, L"3", L"12345\x8888\x8888", L"c") == FT_SUCCESS); /* \x8888,\x8888 - occupy 2 columns each */ assert_true(ft_wwrite_ln(table, L"c", L"12345678\x500", L"c") == FT_SUCCESS); /* \x500 - occupies 1 column */ assert_true(ft_wwrite_ln(table, L"234", L"123456789", L"c") == FT_SUCCESS); @@ -302,9 +302,9 @@ void test_table_write(void) SCENARIO("Test write functions") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(FT_IS_SUCCESS(ft_write(table, "3"))); assert_true(FT_IS_SUCCESS(ft_write(table, "c"))); assert_true(FT_IS_SUCCESS(ft_write(table, "234"))); @@ -350,9 +350,9 @@ void test_table_write(void) SCENARIO("Test wwrite functions(wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(FT_IS_SUCCESS(ft_wwrite(table, L"3"))); assert_true(FT_IS_SUCCESS(ft_wwrite(table, L"c"))); assert_true(FT_IS_SUCCESS(ft_wwrite(table, L"234"))); @@ -398,9 +398,9 @@ void test_table_write(void) SCENARIO("Test nwrite functions") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_nwrite(table, 4, "3", "c", "234", "3.140000") == FT_SUCCESS); ft_ln(table); assert_true(ft_nwrite_ln(table, 4, "c", "235", "3.150000", "5") == FT_SUCCESS); @@ -434,9 +434,9 @@ void test_table_write(void) SCENARIO("Test nwwrite functions(wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(ft_nwwrite(table, 4, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS); ft_ln(table); assert_true(ft_nwwrite_ln(table, 4, L"c", L"235", L"3.150000", L"5") == FT_SUCCESS); @@ -471,9 +471,9 @@ void test_table_write(void) SCENARIO("Test row_write functions") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); const char *row_0[4] = {"3", "c", "234", "3.140000"}; const char *row_1[4] = {"c", "235", "3.150000", "5"}; const char *row_2[4] = {"234", "3.140000", "3", "c"}; @@ -512,9 +512,9 @@ void test_table_write(void) SCENARIO("Test row_write functions(wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); const wchar_t *row_0[4] = {L"3", L"c", L"234", L"3.140000"}; const wchar_t *row_1[4] = {L"c", L"235", L"3.150000", L"5"}; const wchar_t *row_2[4] = {L"234", L"3.140000", L"3", L"c"}; @@ -553,9 +553,9 @@ void test_table_write(void) SCENARIO("Test table_write functions") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); const char *table_cont[3][4] = { {"3", "c", "234", "3.140000"}, {"c", "234", "3.140000", "3"}, @@ -587,9 +587,9 @@ void test_table_write(void) SCENARIO("Test table_write functions(wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); const wchar_t *table_cont[3][4] = { {L"3", L"c", L"234", L"3.140000"}, {L"c", L"234", L"3.140000", L"3"}, @@ -621,9 +621,9 @@ void test_table_write(void) SCENARIO("Test printf functions") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14); assert_true(n == 4); n = ft_printf(table, "%c|%s|%f|%d", 'c', "235", 3.15, 5); @@ -661,9 +661,9 @@ void test_table_write(void) SCENARIO("Test printf functions(wide strings)") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_wprintf_ln(table, L"%d|%c|%ls|%f", 3, 'c', L"234", 3.14); assert_true(n == 4); n = ft_wprintf(table, L"%c|%ls|%f|%d", 'c', L"235", 3.15, 5); @@ -701,9 +701,9 @@ void test_table_write(void) SCENARIO("Test printf functions with strings with separators inside them") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14); assert_true(n == 4); n = ft_printf(table, "%c", 'c'); @@ -742,9 +742,9 @@ void test_table_write(void) SCENARIO("Test printf functions with strings with separators inside them") { table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_wprintf_ln(table, L"%d|%c|%ls|%f", 3, 'c', L"234", 3.14); assert_true(n == 4); n = ft_wprintf(table, L"%c", 'c'); @@ -791,16 +791,16 @@ void test_table_copy(void) table = ft_create_table(); assert_true(table != NULL); - assert_true(ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_BOTTOM_PADDING, 1) == FT_SUCCESS); - assert_true(ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_TOP_PADDING, 1) == FT_SUCCESS); - assert_true(ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_LEFT_PADDING, 2) == FT_SUCCESS); - assert_true(ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 2) == FT_SUCCESS); + assert_true(ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_BOTTOM_PADDING, 1) == FT_SUCCESS); + assert_true(ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_TOP_PADDING, 1) == FT_SUCCESS); + assert_true(ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_LEFT_PADDING, 2) == FT_SUCCESS); + assert_true(ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_RIGHT_PADDING, 2) == FT_SUCCESS); ft_set_border_style(table, FT_DOUBLE2_STYLE); /* Set "header" type for the first row */ - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Movie title", "Director", "Year", "Rating"); ft_write_ln(table, "The Shawshank Redemption", "Frank Darabont", "1994", "9.5"); @@ -810,8 +810,8 @@ void test_table_copy(void) ft_write_ln(table, "2001: A Space Odyssey", "Stanley Kubrick", "1968", "8.5"); /* Set center alignment for the 1st and 3rd columns */ - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 3, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); ft_table_t *table_copy = ft_copy_table(table); diff --git a/tests/bb_tests/test_table_border_style.c b/tests/bb_tests/test_table_border_style.c index d17bff4..e962ab5 100644 --- a/tests/bb_tests/test_table_border_style.c +++ b/tests/bb_tests/test_table_border_style.c @@ -9,7 +9,7 @@ void test_table_border_style(void) { ft_table_t *table = NULL; - set_test_options_as_default(); + set_test_properties_as_default(); WHEN("Changing cell separators") { @@ -74,11 +74,11 @@ void test_table_border_style(void) ft_set_default_border_style(&brdr_style); - ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 0); - ft_set_default_cell_option(FT_COPT_TOP_PADDING, 0); - ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1); - ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1); - ft_set_default_cell_option(FT_COPT_EMPTY_STR_HEIGHT, 0); + ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_EMPTY_STR_HEIGHT, 0); table = create_test_int_table(0); @@ -100,7 +100,7 @@ void test_table_border_style(void) table = create_test_int_table(1); ft_add_separator(table); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67); assert_true(n == 4); @@ -134,10 +134,10 @@ void test_table_border_style(void) static ft_table_t *create_basic_table(void) { ft_table_t *table = ft_create_table(); - ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); ft_write_ln(table, "Rank", "Title", "Year", "Rating"); ft_write_ln(table, "1", "The Shawshank Redemption", "1994", "9.5"); diff --git a/tests/bb_tests/test_table_options.c b/tests/bb_tests/test_table_properties.c similarity index 80% rename from tests/bb_tests/test_table_options.c rename to tests/bb_tests/test_table_properties.c index 38759db..2018b7c 100644 --- a/tests/bb_tests/test_table_options.c +++ b/tests/bb_tests/test_table_properties.c @@ -3,17 +3,17 @@ #include #include #include -#include "options.h" +#include "properties.h" #include "vector.h" -void test_table_tbl_options(void) +void test_table_tbl_properties(void) { ft_table_t *table = NULL; - WHEN("Test setting entire table options") { - set_test_options_as_default(); + WHEN("Test setting entire table properties") { + set_test_properties_as_default(); table = create_test_int_table(0); @@ -35,11 +35,11 @@ void test_table_tbl_options(void) "+---+---+----+----+\n"; assert_str_equal(table_str, table_str_etalon); - /* Now set table options */ - ft_set_tbl_option(table, FT_TOPT_TOP_MARGIN, 3); - ft_set_tbl_option(table, FT_TOPT_BOTTOM_MARGIN, 4); - ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1); - ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2); + /* Now set table properties */ + ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 3); + ft_set_tbl_prop(table, FT_TPROP_BOTTOM_MARGIN, 4); + ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 1); + ft_set_tbl_prop(table, FT_TPROP_RIGHT_MARGIN, 2); table_str = ft_to_string(table); assert_true(table_str != NULL); table_str_etalon = @@ -72,8 +72,8 @@ void test_table_tbl_options(void) #ifdef FT_HAVE_WCHAR - WHEN("Test setting entire table options(wide strings case)") { - set_test_options_as_default(); + WHEN("Test setting entire table properties(wide strings case)") { + set_test_properties_as_default(); table = create_test_int_wtable(0); @@ -95,11 +95,11 @@ void test_table_tbl_options(void) L"+---+---+----+----+\n"; assert_wcs_equal(table_str, table_str_etalon); - /* Now set table options */ - ft_set_tbl_option(table, FT_TOPT_TOP_MARGIN, 3); - ft_set_tbl_option(table, FT_TOPT_BOTTOM_MARGIN, 4); - ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1); - ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2); + /* Now set table properties */ + ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 3); + ft_set_tbl_prop(table, FT_TPROP_BOTTOM_MARGIN, 4); + ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 1); + ft_set_tbl_prop(table, FT_TPROP_RIGHT_MARGIN, 2); table_str = ft_to_wstring(table); assert_true(table_str != NULL); table_str_etalon = @@ -132,18 +132,18 @@ void test_table_tbl_options(void) -void test_table_cell_options(void) +void test_table_cell_properties(void) { ft_table_t *table = NULL; WHEN("All paddings = 1") { - set_test_options_as_default(); + set_test_properties_as_default(); - ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1); - ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1); - ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1); - ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 1); table = create_test_int_table(0); @@ -171,10 +171,10 @@ void test_table_cell_options(void) WHEN("Top and bottom padding = 0") { - ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 0); - ft_set_default_cell_option(FT_COPT_TOP_PADDING, 0); - ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1); - ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 1); table = create_test_int_table(0); @@ -194,10 +194,10 @@ void test_table_cell_options(void) WHEN("Left and right padding = 0") { - ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1); - ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1); - ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 0); - ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 0); table = create_test_int_table(0); @@ -223,10 +223,10 @@ void test_table_cell_options(void) WHEN("All paddings = 0") { - ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 0); - ft_set_default_cell_option(FT_COPT_TOP_PADDING, 0); - ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 0); - ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 0); + ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 0); table = create_test_int_table(0); @@ -246,11 +246,11 @@ void test_table_cell_options(void) WHEN("Empty string has 0 heigt") { - ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1); - ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1); - ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1); - ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1); - ft_set_default_cell_option(FT_COPT_EMPTY_STR_HEIGHT, 0); + ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 1); + ft_set_default_cell_prop(FT_CPROP_EMPTY_STR_HEIGHT, 0); table = create_test_int_table(0); int n = ft_printf_ln(table, "|||"); @@ -280,15 +280,15 @@ void test_table_cell_options(void) } - WHEN("Setting options for a particular table") { + WHEN("Setting properties for a particular table") { table = create_test_int_table(0); - set_test_options_for_table(table); + set_test_props_for_table(table); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_BOTTOM_PADDING, 0); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_TOP_PADDING, 0); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_LEFT_PADDING, 0); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_BOTTOM_PADDING, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_TOP_PADDING, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_LEFT_PADDING, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_RIGHT_PADDING, 0); const char *table_str = ft_to_string(table); assert_true(table_str != NULL); @@ -303,11 +303,11 @@ void test_table_cell_options(void) assert_str_equal(table_str, table_str_etalon); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_BOTTOM_PADDING, 1); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_TOP_PADDING, 1); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_LEFT_PADDING, 0); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 0); - ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_EMPTY_STR_HEIGHT, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_BOTTOM_PADDING, 1); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_TOP_PADDING, 1); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_LEFT_PADDING, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_RIGHT_PADDING, 0); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_EMPTY_STR_HEIGHT, 0); table_str = ft_to_string(table); assert_true(table_str != NULL); @@ -333,18 +333,18 @@ void test_table_cell_options(void) WHEN("Set table width and column alignment") { - set_test_options_as_default(); + set_test_properties_as_default(); table = create_test_int_table(0); int status = FT_SUCCESS; - status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_MIN_WIDTH, 7); - status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); - status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_COPT_MIN_WIDTH, 8); - status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + status |= ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_MIN_WIDTH, 7); + status |= ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); + status |= ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_MIN_WIDTH, 8); + status |= ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - status |= ft_set_cell_option(table, 2, 3, FT_COPT_MIN_WIDTH, 6); - status |= ft_set_cell_option(table, 2, 3, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT); + status |= ft_set_cell_prop(table, 2, 3, FT_CPROP_MIN_WIDTH, 6); + status |= ft_set_cell_prop(table, 2, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_LEFT); assert_true(status == FT_SUCCESS); @@ -370,11 +370,11 @@ void test_table_cell_options(void) WHEN("Set table width and column alignment as default") { - set_test_options_as_default(); + set_test_properties_as_default(); int status = FT_SUCCESS; - status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 5); - status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER); + status |= ft_set_default_cell_prop(FT_CPROP_MIN_WIDTH, 5); + status |= ft_set_default_cell_prop(FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); assert_true(status == FT_SUCCESS); table = create_test_int_table(0); @@ -400,11 +400,11 @@ void test_table_cell_options(void) } WHEN("Multiline cell") { - set_test_options_as_default(); + set_test_properties_as_default(); table = ft_create_table(); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_printf_ln(table, "%d|%c|%s|%f", 4, 'c', "234", 3.14); assert_true(n == 4); @@ -436,7 +436,7 @@ void test_table_cell_options(void) WHEN("Cells with spans") { - set_test_options_as_default(); + set_test_properties_as_default(); table = ft_create_table(); int n = ft_set_cell_span(table, 0, 0, 5); @@ -444,9 +444,9 @@ void test_table_cell_options(void) n = ft_set_cell_span(table, 1, 1, 3); assert_true(n == FT_SUCCESS); - n = ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + n = ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(n == FT_SUCCESS); - n = ft_set_cell_option(table, 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + n = ft_set_cell_prop(table, 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(n == FT_SUCCESS); n = ft_write_ln(table, "111", "2222", "33333", "444444", "55555555"); @@ -494,7 +494,7 @@ void test_table_cell_options(void) } WHEN("Cells with spans in common and header cells") { - set_test_options_as_default(); + set_test_properties_as_default(); table = ft_create_table(); ft_set_border_style(table, FT_DOUBLE2_STYLE); @@ -506,7 +506,7 @@ void test_table_cell_options(void) n = ft_set_cell_span(table, 1, 1, 3); assert_true(n == FT_SUCCESS); - n = ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + n = ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); assert_true(n == FT_SUCCESS); n = ft_write_ln(table, "111", "2222", "33333", "444444", "55555555"); diff --git a/tests/bb_tests_cpp/test_table_basic.cpp b/tests/bb_tests_cpp/test_table_basic.cpp index d546cac..8a44521 100644 --- a/tests/bb_tests_cpp/test_table_basic.cpp +++ b/tests/bb_tests_cpp/test_table_basic.cpp @@ -3,7 +3,7 @@ #define assert_string_equal(str1, str2) assert_str_equal(str1.c_str(), str2.c_str()) -bool set_test_options_for_table(fort::Table *table) +bool set_test_props_for_table(fort::Table *table) { assert_true(table->set_cell_bottom_padding(FT_ANY_ROW, FT_ANY_COLUMN, 1)); assert_true(table->set_cell_top_padding(FT_ANY_ROW, FT_ANY_COLUMN, 1)); @@ -36,7 +36,7 @@ void test_cpp_table_basic(void) { WHEN("All columns are equal and not empty.") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header << "3" << "c" << "234" << "3.140000" << fort::endr @@ -63,7 +63,7 @@ void test_cpp_table_basic(void) WHEN("Checking basic constructors and assignmets.") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header << "3" << "c" << "234" << "3.140000" << fort::endr @@ -98,7 +98,7 @@ void test_cpp_table_basic(void) WHEN("All columns are not equal and not empty") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header << "3" << "c" << "234" << "3.140000" << fort::endr @@ -125,7 +125,7 @@ void test_cpp_table_basic(void) WHEN("All columns are not equal and some cells are empty") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header << "" << "" << "234" << "3.140000" << fort::endr @@ -152,7 +152,7 @@ void test_cpp_table_basic(void) WHEN("All cells are empty") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header << "" << "" << "" << "" << fort::endr @@ -183,7 +183,7 @@ void test_cpp_table_write(void) { SCENARIO("Test write functions") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header; assert_true(table.write("3")); assert_true(table.write("c")); @@ -225,7 +225,7 @@ void test_cpp_table_write(void) SCENARIO("Test n write functions") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header; assert_true(table.write("3", "c", "234", "3.140000")); table << fort::endr; @@ -257,7 +257,7 @@ void test_cpp_table_write(void) SCENARIO("Test row_write functions") { fort::Table table; - assert_true(set_test_options_for_table(&table)); + assert_true(set_test_props_for_table(&table)); table << fort::header; const char *row_0[4] = {"3", "c", "234", "3.140000"}; diff --git a/tests/main_test.c b/tests/main_test.c index 5408f08..ef822a8 100644 --- a/tests/main_test.c +++ b/tests/main_test.c @@ -22,8 +22,8 @@ struct test_case bb_test_suit [] = { {"test_table_write", test_table_write}, {"test_table_border_style", test_table_border_style}, {"test_table_builtin_border_styles", test_table_builtin_border_styles}, - {"test_table_cell_options", test_table_cell_options}, - {"test_table_tbl_options", test_table_tbl_options}, + {"test_table_cell_properties", test_table_cell_properties}, + {"test_table_tbl_properties", test_table_tbl_properties}, {"test_memory_errors", test_memory_errors}, }; diff --git a/tests/test_utils.c b/tests/test_utils.c index d39c0b6..46ecf3c 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -1,15 +1,15 @@ #include "tests.h" #include "fort.h" -int set_test_options_for_table(struct ft_table *table) +int set_test_props_for_table(struct ft_table *table) { assert(table); int status = FT_SUCCESS; - status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_BOTTOM_PADDING, 1); - status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_TOP_PADDING, 1); - status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_LEFT_PADDING, 1); - status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 1); - status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_EMPTY_STR_HEIGHT, 1); + status |= ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_BOTTOM_PADDING, 1); + status |= ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_TOP_PADDING, 1); + status |= ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_LEFT_PADDING, 1); + status |= ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_RIGHT_PADDING, 1); + status |= ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_EMPTY_STR_HEIGHT, 1); assert_true(status == FT_SUCCESS); @@ -33,18 +33,18 @@ int set_test_options_for_table(struct ft_table *table) return ft_set_border_style(table, &brdr_style); } -int set_test_options_as_default(void) +int set_test_properties_as_default(void) { int status = FT_SUCCESS; - status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 0); - status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, FT_ALIGNED_RIGHT); + status |= ft_set_default_cell_prop(FT_CPROP_MIN_WIDTH, 0); + status |= ft_set_default_cell_prop(FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - status |= ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1); - status |= ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1); - status |= ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1); - status |= ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1); - status |= ft_set_default_cell_option(FT_COPT_EMPTY_STR_HEIGHT, 1); + status |= ft_set_default_cell_prop(FT_CPROP_BOTTOM_PADDING, 1); + status |= ft_set_default_cell_prop(FT_CPROP_TOP_PADDING, 1); + status |= ft_set_default_cell_prop(FT_CPROP_LEFT_PADDING, 1); + status |= ft_set_default_cell_prop(FT_CPROP_RIGHT_PADDING, 1); + status |= ft_set_default_cell_prop(FT_CPROP_EMPTY_STR_HEIGHT, 1); assert_true(status == FT_SUCCESS); @@ -78,12 +78,12 @@ struct ft_table *create_test_int_table(int set_test_opts) table = ft_create_table(); assert_true(table != NULL); if (set_test_opts) { - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); } assert_true(table != NULL); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_write_ln(table, "3", "4", "55", "67"); assert(n == FT_SUCCESS); @@ -108,12 +108,12 @@ struct ft_table *create_test_int_wtable(int set_test_opts) table = ft_create_table(); assert_true(table != NULL); if (set_test_opts) { - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); } assert_true(table != NULL); - ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); int n = ft_wwrite_ln(table, L"3", L"4", L"55", L"67"); assert(n == FT_SUCCESS); diff --git a/tests/tests.h b/tests/tests.h index ebf28e5..8d3a317 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -32,8 +32,8 @@ void test_wcs_table_boundaries(void); void test_table_write(void); void test_table_border_style(void); void test_table_builtin_border_styles(void); -void test_table_cell_options(void); -void test_table_tbl_options(void); +void test_table_cell_properties(void); +void test_table_tbl_properties(void); void test_memory_errors(void); struct test_case { @@ -73,8 +73,8 @@ struct ft_table; extern "C" { #endif -int set_test_options_for_table(struct ft_table *table); -int set_test_options_as_default(void); +int set_test_props_for_table(struct ft_table *table); +int set_test_properties_as_default(void); struct ft_table *create_test_int_table(int set_test_opts); struct ft_table *create_test_int_wtable(int set_test_opts); void run_test_suit(const char *test_suit_name, int n_tests, struct test_case test_suit[]); diff --git a/tests/wb_tests/test_table_geometry.c b/tests/wb_tests/test_table_geometry.c index ad43d5a..3d30046 100644 --- a/tests/wb_tests/test_table_geometry.c +++ b/tests/wb_tests/test_table_geometry.c @@ -5,7 +5,7 @@ void test_table_sizes(void) { ft_table_t *table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); size_t rows = 0; @@ -54,7 +54,7 @@ void test_table_geometry(void) { ft_table_t *table = ft_create_table(); assert_true(table != NULL); - assert_true(set_test_options_for_table(table) == FT_SUCCESS); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); size_t height = 0; size_t width = 0;