From 3859ebb38decdcd85ba01d0fe7012946c5881dd5 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sun, 25 Aug 2019 10:24:27 +0300 Subject: [PATCH] [F] Fixed compilation errors --- example/main.c | 192 +++++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 95 deletions(-) diff --git a/example/main.c b/example/main.c index 0ba95fd..c8c3d73 100644 --- a/example/main.c +++ b/example/main.c @@ -173,122 +173,124 @@ void custom_border_style_example(void) void colorfull_table(void) { #if defined(FT_HAVE_WCHAR) + { + setlocale(LC_CTYPE, ""); - setlocale(LC_CTYPE, ""); + ft_table_t *table = ft_create_table(); + ft_set_border_style(table, FT_NICE_STYLE); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); - ft_table_t *table = ft_create_table(); - ft_set_border_style(table, FT_NICE_STYLE); - ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); + /* Filling table with data */ + ft_wwrite_ln(table, L"Test", L"Iterations", L"ms/op", L"Ticks", L"Passed"); + ft_wwrite_ln(table, L"n-body", L"1000", L"1.6", L"1,500,000", L"✔"); + ft_add_separator(table); + ft_wwrite_ln(table, L"regex-redux", L"1000", L"0.8", L"8,000,000"); + ft_wwrite_ln(table, L"", L"2500", L"3.9", L"27,000,000", L"✖"); + ft_wwrite_ln(table, L"", L"10000", L"12.5", L"96,800,000"); + ft_add_separator(table); + ft_wwrite_ln(table, L"mandelbrot", L"1000", L"8.1", L"89,000,000"); + ft_wwrite_ln(table, L"", L"2500", L"19.8", L"320,000,000", L"✔"); + ft_wwrite_ln(table, L"", L"10000", L"60.7", L"987,000,000"); + ft_add_separator(table); + ft_set_cell_span(table, 8, 0, 4); + ft_wwrite_ln(table, L"Total result", L"", L"", L"", L"✖"); - /* Filling table with data */ - ft_wwrite_ln(table, L"Test", L"Iterations", L"ms/op", L"Ticks", L"Passed"); - ft_wwrite_ln(table, L"n-body", L"1000", L"1.6", L"1,500,000", L"✔"); - ft_add_separator(table); - ft_wwrite_ln(table, L"regex-redux", L"1000", L"0.8", L"8,000,000"); - ft_wwrite_ln(table, L"", L"2500", L"3.9", L"27,000,000", L"✖"); - ft_wwrite_ln(table, L"", L"10000", L"12.5", L"96,800,000"); - ft_add_separator(table); - ft_wwrite_ln(table, L"mandelbrot", L"1000", L"8.1", L"89,000,000"); - ft_wwrite_ln(table, L"", L"2500", L"19.8", L"320,000,000", L"✔"); - ft_wwrite_ln(table, L"", L"10000", L"60.7", L"987,000,000"); - ft_add_separator(table); - ft_set_cell_span(table, 8, 0, 4); - ft_wwrite_ln(table, L"Total result", L"", L"", L"", L"✖"); + /* Setting text styles */ + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, 8, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_ITALIC); - /* Setting text styles */ - ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, 8, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_ITALIC); + /* Set alignment */ + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); + ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); + ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); + ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, 8, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - /* Set alignment */ - ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_prop(table, 8, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + /* Set colors */ + ft_set_cell_prop(table, 1, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); + ft_set_cell_prop(table, 3, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); + ft_set_cell_prop(table, 6, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); + ft_set_cell_prop(table, 8, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); + ft_set_cell_prop(table, 3, 2, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); + ft_set_cell_prop(table, 4, 3, FT_CPROP_CONT_BG_COLOR, FT_COLOR_LIGHT_RED); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_FG_COLOR, FT_COLOR_LIGHT_BLUE); - /* Set colors */ - ft_set_cell_prop(table, 1, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); - ft_set_cell_prop(table, 3, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); - ft_set_cell_prop(table, 6, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); - ft_set_cell_prop(table, 8, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); - ft_set_cell_prop(table, 3, 2, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); - ft_set_cell_prop(table, 4, 3, FT_CPROP_CONT_BG_COLOR, FT_COLOR_LIGHT_RED); - ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_FG_COLOR, FT_COLOR_LIGHT_BLUE); + /* Move table to the center of the screen */ + ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 1); + ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 10); - /* Move table to the center of the screen */ - ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 1); - ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 10); + const wchar_t *table_wstr = ft_to_wstring(table); + if (table_wstr) { + fwprintf(stderr, L"Table:\n%ls\n\n ", table_wstr); + } else { + fwprintf(stderr, L"Table conversion failed !!!\n "); + } - const wchar_t *table_wstr = ft_to_wstring(table); - if (table_wstr) { - fwprintf(stderr, L"Table:\n%ls\n\n ", table_wstr); - } else { - fwprintf(stderr, L"Table conversion failed !!!\n "); + ft_destroy_table(table); } - - ft_destroy_table(table); #endif #if defined(FT_HAVE_UTF8) + { + ft_table_t *table = ft_create_table(); + ft_set_border_style(table, FT_NICE_STYLE); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); - table = ft_create_table(); - ft_set_border_style(table, FT_NICE_STYLE); - ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); + /* Filling table with data */ + ft_u8write_ln(table, "Тест", "Итерации", "ms/op", "Тики", "Результат"); + ft_u8write_ln(table, "n-body", "1000", "1.6", "1,500,000", "✔"); + ft_add_separator(table); + ft_u8write_ln(table, "regex-redux", "1000", "0.8", "8,000,000"); + ft_u8write_ln(table, "", "2500", "3.9", "27,000,000", "✖"); + ft_u8write_ln(table, "", "10000", "12.5", "96,800,000"); + ft_add_separator(table); + ft_u8write_ln(table, "mandelbrot", "1000", "8.1", "89,000,000"); + ft_u8write_ln(table, "", "2500", "19.8", "320,000,000", "✔"); + ft_u8write_ln(table, "", "10000", "60.7", "987,000,000"); + ft_add_separator(table); + ft_set_cell_span(table, 8, 0, 4); + ft_u8write_ln(table, "Итог", "", "", "", "✖"); - /* Filling table with data */ - ft_u8write_ln(table, "Тест", "Итерации", "ms/op", "Тики", "Результат"); - ft_u8write_ln(table, "n-body", "1000", "1.6", "1,500,000", "✔"); - ft_add_separator(table); - ft_u8write_ln(table, "regex-redux", "1000", "0.8", "8,000,000"); - ft_u8write_ln(table, "", "2500", "3.9", "27,000,000", "✖"); - ft_u8write_ln(table, "", "10000", "12.5", "96,800,000"); - ft_add_separator(table); - ft_u8write_ln(table, "mandelbrot", "1000", "8.1", "89,000,000"); - ft_u8write_ln(table, "", "2500", "19.8", "320,000,000", "✔"); - ft_u8write_ln(table, "", "10000", "60.7", "987,000,000"); - ft_add_separator(table); - ft_set_cell_span(table, 8, 0, 4); - ft_u8write_ln(table, "Итог", "", "", "", "✖"); + /* Setting text styles */ + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, 8, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); + ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_ITALIC); - /* Setting text styles */ - ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, 8, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, FT_ANY_ROW, 0, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_BOLD); - ft_set_cell_prop(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_CPROP_CONT_TEXT_STYLE, FT_TSTYLE_ITALIC); + /* Set alignment */ + ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); + ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); + ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); + ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + ft_set_cell_prop(table, 8, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - /* Set alignment */ - ft_set_cell_prop(table, FT_ANY_ROW, 1, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - ft_set_cell_prop(table, FT_ANY_ROW, 2, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - ft_set_cell_prop(table, FT_ANY_ROW, 3, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_RIGHT); - ft_set_cell_prop(table, FT_ANY_ROW, 4, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); - ft_set_cell_prop(table, 8, 0, FT_CPROP_TEXT_ALIGN, FT_ALIGNED_CENTER); + /* Set colors */ + ft_set_cell_prop(table, 1, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); + ft_set_cell_prop(table, 3, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); + ft_set_cell_prop(table, 6, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); + ft_set_cell_prop(table, 8, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); + ft_set_cell_prop(table, 3, 2, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); + ft_set_cell_prop(table, 4, 3, FT_CPROP_CONT_BG_COLOR, FT_COLOR_LIGHT_RED); + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_FG_COLOR, FT_COLOR_LIGHT_BLUE); - /* Set colors */ - ft_set_cell_prop(table, 1, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); - ft_set_cell_prop(table, 3, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); - ft_set_cell_prop(table, 6, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_GREEN); - ft_set_cell_prop(table, 8, 4, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); - ft_set_cell_prop(table, 3, 2, FT_CPROP_CONT_FG_COLOR, FT_COLOR_RED); - ft_set_cell_prop(table, 4, 3, FT_CPROP_CONT_BG_COLOR, FT_COLOR_LIGHT_RED); - ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_CONT_FG_COLOR, FT_COLOR_LIGHT_BLUE); + /* Move table to the center of the screen */ + ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 1); + ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 10); - /* Move table to the center of the screen */ - ft_set_tbl_prop(table, FT_TPROP_TOP_MARGIN, 1); - ft_set_tbl_prop(table, FT_TPROP_LEFT_MARGIN, 10); + const char *table_str = ft_to_u8string(table); + if (table_str) { + printf("Table:\n%s\n\n ", table_str); + } else { + printf("Table conversion failed !!!\n "); + } - const char *table_str = ft_to_u8string(table); - if (table_wstr) { - printf("Table:\n%s\n\n ", table_str); - } else { - printf("Table conversion failed !!!\n "); + ft_destroy_table(table); } - - ft_destroy_table(table); #endif }