47 #define LIBFORT_MAJOR_VERSION 0 48 #define LIBFORT_MINOR_VERSION 4 49 #define LIBFORT_REVISION 2 50 #define LIBFORT_VERSION_STR "0.4.2" 64 #if !defined(FT_CONGIG_DISABLE_WCHAR) 68 #if !defined(FT_CONGIG_DISABLE_UTF8) 85 #define FT_MEMORY_ERROR -1 99 #define FT_INTERN_ERROR -3 107 #define FT_GEN_ERROR -4 110 #define FT_IS_SUCCESS(arg) ((arg) >= 0) 111 #define FT_IS_ERROR(arg) ((arg) < 0) 124 #if defined(__clang__) 125 #define FT_CLANG_COMPILER 126 #elif defined(__GNUC__) 127 #define FT_GCC_COMPILER 128 #elif defined(_MSC_VER) 129 #define FT_MICROSOFT_COMPILER 131 #define FT_UNDEFINED_COMPILER 139 #if defined(__cplusplus) 140 #define FT_INLINE inline 142 #define FT_INLINE __inline 151 # define FT_BEGIN_DECLS extern "C" { 152 # define FT_END_DECLS } 154 # define FT_BEGIN_DECLS 155 # define FT_END_DECLS 163 #define FT_STR_2_CAT_(arg1, arg2) \ 165 #define FT_STR_2_CAT(arg1, arg2) \ 166 FT_STR_2_CAT_(arg1, arg2) 171 static FT_INLINE
int ft_check_if_string_helper(
const char *str)
180 static FT_INLINE
int ft_check_if_wstring_helper(
const wchar_t *str)
186 #define FT_NARGS_IMPL_(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,N,...) N 187 #define FT_EXPAND_(x) x 188 #define FT_PP_NARG_(...) \ 189 FT_EXPAND_(FT_NARGS_IMPL_(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) 191 #define FT_CHECK_IF_STR_32(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_31(checker,__VA_ARGS__))) 192 #define FT_CHECK_IF_STR_31(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_30(checker,__VA_ARGS__))) 193 #define FT_CHECK_IF_STR_30(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_29(checker,__VA_ARGS__))) 194 #define FT_CHECK_IF_STR_29(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_28(checker,__VA_ARGS__))) 195 #define FT_CHECK_IF_STR_28(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_27(checker,__VA_ARGS__))) 196 #define FT_CHECK_IF_STR_27(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_26(checker,__VA_ARGS__))) 197 #define FT_CHECK_IF_STR_26(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_25(checker,__VA_ARGS__))) 198 #define FT_CHECK_IF_STR_25(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_24(checker,__VA_ARGS__))) 199 #define FT_CHECK_IF_STR_24(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_23(checker,__VA_ARGS__))) 200 #define FT_CHECK_IF_STR_23(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_22(checker,__VA_ARGS__))) 201 #define FT_CHECK_IF_STR_22(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_21(checker,__VA_ARGS__))) 202 #define FT_CHECK_IF_STR_21(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_20(checker,__VA_ARGS__))) 203 #define FT_CHECK_IF_STR_20(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_19(checker,__VA_ARGS__))) 204 #define FT_CHECK_IF_STR_19(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_18(checker,__VA_ARGS__))) 205 #define FT_CHECK_IF_STR_18(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_17(checker,__VA_ARGS__))) 206 #define FT_CHECK_IF_STR_17(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_16(checker,__VA_ARGS__))) 207 #define FT_CHECK_IF_STR_16(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_15(checker,__VA_ARGS__))) 208 #define FT_CHECK_IF_STR_15(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_14(checker,__VA_ARGS__))) 209 #define FT_CHECK_IF_STR_14(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_13(checker,__VA_ARGS__))) 210 #define FT_CHECK_IF_STR_13(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_12(checker,__VA_ARGS__))) 211 #define FT_CHECK_IF_STR_12(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_11(checker,__VA_ARGS__))) 212 #define FT_CHECK_IF_STR_11(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_10(checker,__VA_ARGS__))) 213 #define FT_CHECK_IF_STR_10(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_9(checker,__VA_ARGS__))) 214 #define FT_CHECK_IF_STR_9(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_8(checker,__VA_ARGS__))) 215 #define FT_CHECK_IF_STR_8(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_7(checker,__VA_ARGS__))) 216 #define FT_CHECK_IF_STR_7(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_6(checker,__VA_ARGS__))) 217 #define FT_CHECK_IF_STR_6(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_5(checker,__VA_ARGS__))) 218 #define FT_CHECK_IF_STR_5(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_4(checker,__VA_ARGS__))) 219 #define FT_CHECK_IF_STR_4(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_3(checker,__VA_ARGS__))) 220 #define FT_CHECK_IF_STR_3(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_2(checker,__VA_ARGS__))) 221 #define FT_CHECK_IF_STR_2(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_1(checker,__VA_ARGS__))) 222 #define FT_CHECK_IF_STR_1(checker,arg) (checker(arg)) 224 #define FT_CHECK_IF_ARGS_ARE_STRINGS__(checker,func, ...) \ 225 FT_EXPAND_(func(checker,__VA_ARGS__)) 226 #define FT_CHECK_IF_ARGS_ARE_STRINGS_(checker,basis, n, ...) \ 227 FT_CHECK_IF_ARGS_ARE_STRINGS__(checker,FT_STR_2_CAT_(basis, n), __VA_ARGS__) 228 #define FT_CHECK_IF_ARGS_ARE_STRINGS(...) \ 229 FT_CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_string_helper,FT_CHECK_IF_STR_,FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__) 232 #define CHECK_IF_ARGS_ARE_WSTRINGS(...) \ 233 FT_CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_wstring_helper,FT_CHECK_IF_STR_,FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__) 245 #if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) 246 #define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) \ 247 __attribute__ ((format (printf, string_index, first_to_check))) 249 #define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) 394 size_t top_left_row,
size_t top_left_col,
395 size_t bottom_right_row,
size_t bottom_right_col);
397 #if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) 459 int ft_printf_impl(
ft_table_t *table,
const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
460 int ft_printf_ln_impl(
ft_table_t *table, const
char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
462 #define ft_printf(table, ...) \ 463 (( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_impl(table, __VA_ARGS__)) 464 #define ft_printf_ln(table, ...) \ 465 (( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_ln_impl(table, __VA_ARGS__)) 496 #define ft_write(table, ...)\ 497 (0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) 514 #define ft_write_ln(table, ...)\ 515 (0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) 689 const char *top_border_ch;
690 const char *separator_ch;
691 const char *bottom_border_ch;
692 const char *side_border_ch;
693 const char *out_intersect_ch;
694 const char *in_intersect_ch;
703 const char *hor_separator_char;
765 #define FT_ANY_COLUMN (UINT_MAX) 766 #define FT_CUR_COLUMN (UINT_MAX - 1) 767 #define FT_ANY_ROW (UINT_MAX) 768 #define FT_CUR_ROW (UINT_MAX - 1) 771 #define FT_MAX_ROW_INDEX (UINT_MAX - 2) 772 #define FT_MAX_COL_INDEX (UINT_MAX - 2) 779 #define FT_CPROP_MIN_WIDTH (0x01U << 0) 780 #define FT_CPROP_TEXT_ALIGN (0x01U << 1) 781 #define FT_CPROP_TOP_PADDING (0x01U << 2) 782 #define FT_CPROP_BOTTOM_PADDING (0x01U << 3) 783 #define FT_CPROP_LEFT_PADDING (0x01U << 4) 784 #define FT_CPROP_RIGHT_PADDING (0x01U << 5) 785 #define FT_CPROP_EMPTY_STR_HEIGHT (0x01U << 6) 786 #define FT_CPROP_ROW_TYPE (0x01U << 7) 787 #define FT_CPROP_CONT_FG_COLOR (0x01U << 8) 788 #define FT_CPROP_CELL_BG_COLOR (0x01U << 9) 789 #define FT_CPROP_CONT_BG_COLOR (0x01U << 10) 790 #define FT_CPROP_CELL_TEXT_STYLE (0x01U << 11) 791 #define FT_CPROP_CONT_TEXT_STYLE (0x01U << 12) 887 #define FT_TPROP_LEFT_MARGIN (0x01U << 0) 888 #define FT_TPROP_TOP_MARGIN (0x01U << 1) 889 #define FT_TPROP_RIGHT_MARGIN (0x01U << 2) 890 #define FT_TPROP_BOTTOM_MARGIN (0x01U << 3) 891 #define FT_TPROP_ADDING_STRATEGY (0x01U << 4) 985 int ft_wprintf(
ft_table_t *table,
const wchar_t *fmt, ...);
986 int ft_wprintf_ln(
ft_table_t *table,
const wchar_t *fmt, ...);
989 #define ft_wwrite(table, ...)\ 990 (0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) 991 #define ft_wwrite_ln(table, ...)\ 992 (0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) 993 int ft_nwwrite(
ft_table_t *table,
size_t n,
const wchar_t *cell_content, ...);
994 int ft_nwwrite_ln(
ft_table_t *table,
size_t n,
const wchar_t *cell_content, ...);
996 int ft_row_wwrite(
ft_table_t *table,
size_t cols,
const wchar_t *row_cells[]);
997 int ft_row_wwrite_ln(
ft_table_t *table,
size_t cols,
const wchar_t *row_cells[]);
999 int ft_table_wwrite(
ft_table_t *table,
size_t rows,
size_t cols,
const wchar_t *table_cells[]);
1000 int ft_table_wwrite_ln(
ft_table_t *table,
size_t rows,
size_t cols,
const wchar_t *table_cells[]);
1002 const wchar_t *ft_to_wstring(
const ft_table_t *table);
1008 #define ft_u8write(table, ...)\ 1009 (ft_u8nwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) 1010 #define ft_u8write_ln(table, ...)\ 1011 (ft_u8nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) 1012 int ft_u8nwrite(
ft_table_t *table,
size_t n,
const void *cell_content, ...);
1013 int ft_u8nwrite_ln(
ft_table_t *table,
size_t n,
const void *cell_content, ...);
1015 int ft_u8printf(
ft_table_t *table,
const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
1016 int ft_u8printf_ln(
ft_table_t *table, const
char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
1018 const
void *ft_to_u8string(const
ft_table_t *table);
int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style)
Definition: fort.c:3551
int ft_erase_range(ft_table_t *table, size_t top_left_row, size_t top_left_col, size_t bottom_right_row, size_t bottom_right_col)
Definition: fort.c:2832
ft_text_alignment
Definition: fort.h:836
int ft_table_write(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[])
Definition: fort.c:3249
ft_table_t * ft_copy_table(ft_table_t *table)
Definition: fort.c:2697
int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value)
Definition: fort.c:3600
size_t ft_cur_row(const ft_table_t *table)
Definition: fort.c:2801
int ft_table_write_ln(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[])
Definition: fort.c:3267
void ft_set_u8strwid_func(int(*u8strwid)(const void *beg, const void *end, size_t *width))
Definition: fort.c:3743
int ft_set_default_border_style(const struct ft_border_style *style)
Definition: fort.c:3545
void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col)
Definition: fort.c:2813
ft_table_t * ft_create_table(void)
Definition: fort.c:2639
ft_text_style
Definition: fort.h:821
void ft_destroy_table(ft_table_t *table)
Definition: fort.c:2671
int ft_add_separator(ft_table_t *table)
Definition: fort.c:3418
int int void ft_set_default_printf_field_separator(char separator)
Definition: fort.c:3027
int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span)
Definition: fort.c:3636
const char * ft_strerror(int error_code)
Definition: fort.c:3617
int ft_printf(ft_table_t *table, const char *fmt,...) __attribute__((format(printf
int ft_set_default_cell_prop(uint32_t property, int value)
Definition: fort.c:3589
int ft_nwrite_ln(ft_table_t *table, size_t count, const char *cell_content,...)
Definition: fort.c:3115
int ft_row_write_ln(ft_table_t *table, size_t cols, const char *row_cells[])
Definition: fort.c:3209
int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value)
Definition: fort.c:3565
size_t ft_cur_col(const ft_table_t *table)
Definition: fort.c:2807
void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void(*f_free)(void *ptr))
Definition: fort.c:3612
int ft_nwrite(ft_table_t *table, size_t count, const char *cell_content,...)
Definition: fort.c:3092
int ft_ln(ft_table_t *table)
Definition: fort.c:2771
const char * ft_to_string(const ft_table_t *table)
Definition: fort.c:3405
int ft_row_write(ft_table_t *table, size_t cols, const char *row_cells[])
Definition: fort.c:3195
int int ft_printf_ln(ft_table_t *table, const char *fmt,...) __attribute__((format(printf
ft_adding_strategy
Definition: fort.h:900
ft_row_type
Definition: fort.h:845
int ft_is_empty(const ft_table_t *table)
Definition: fort.c:2820
int ft_set_default_tbl_prop(uint32_t property, int value)
Definition: fort.c:3595
size_t ft_row_count(const ft_table_t *table)
Definition: fort.c:2826