[A] Added new border styles
This commit is contained in:
56
src/fort.c
56
src/fort.c
@@ -72,7 +72,7 @@ FTABLE * ft_create_table(void)
|
||||
}
|
||||
|
||||
|
||||
void ft_destroy_table(FTABLE *FORT_RESTRICT table)
|
||||
void ft_destroy_table(FTABLE *FT_RESTRICT table)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
@@ -98,7 +98,7 @@ void ft_destroy_table(FTABLE *FORT_RESTRICT table)
|
||||
F_FREE(table);
|
||||
}
|
||||
|
||||
void ft_ln(FTABLE *FORT_RESTRICT table)
|
||||
void ft_ln(FTABLE *FT_RESTRICT table)
|
||||
{
|
||||
assert(table);
|
||||
table->cur_col = 0;
|
||||
@@ -106,7 +106,7 @@ void ft_ln(FTABLE *FORT_RESTRICT table)
|
||||
}
|
||||
|
||||
|
||||
static int ft_row_printf_impl(FTABLE *FORT_RESTRICT table, size_t row, const char* FORT_RESTRICT fmt, va_list *va)
|
||||
static int ft_row_printf_impl(FTABLE *FT_RESTRICT table, size_t row, const char* FT_RESTRICT fmt, va_list *va)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
@@ -151,7 +151,7 @@ clear:
|
||||
}
|
||||
|
||||
|
||||
#if defined(FORT_CLANG_COMPILER) || defined(FORT_GCC_COMPILER)
|
||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
|
||||
#define FT_PRINTF ft_printf
|
||||
#define FT_PRINTF_LN ft_printf_ln
|
||||
#else
|
||||
@@ -161,7 +161,7 @@ clear:
|
||||
|
||||
|
||||
|
||||
int FT_PRINTF(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...)
|
||||
int FT_PRINTF(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...)
|
||||
{
|
||||
assert(table);
|
||||
va_list va;
|
||||
@@ -171,7 +171,7 @@ int FT_PRINTF(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...)
|
||||
return result;
|
||||
}
|
||||
|
||||
int FT_PRINTF_LN(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...)
|
||||
int FT_PRINTF_LN(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...)
|
||||
{
|
||||
assert(table);
|
||||
va_list va;
|
||||
@@ -190,7 +190,7 @@ int FT_PRINTF_LN(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...
|
||||
#undef FT_HDR_PRINTF_LN
|
||||
|
||||
|
||||
int ft_write(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content)
|
||||
int ft_write(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content)
|
||||
{
|
||||
assert(table);
|
||||
string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table);
|
||||
@@ -204,7 +204,7 @@ int ft_write(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content
|
||||
return status;
|
||||
}
|
||||
|
||||
int ft_write_ln(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content)
|
||||
int ft_write_ln(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content)
|
||||
{
|
||||
assert(table);
|
||||
int status = ft_write(table, cell_content);
|
||||
@@ -214,7 +214,7 @@ int ft_write_ln(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_cont
|
||||
return status;
|
||||
}
|
||||
|
||||
int ft_wwrite(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_content)
|
||||
int ft_wwrite(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content)
|
||||
{
|
||||
assert(table);
|
||||
string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table);
|
||||
@@ -228,7 +228,7 @@ int ft_wwrite(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_con
|
||||
return status;
|
||||
}
|
||||
|
||||
int ft_wwrite_ln(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_content)
|
||||
int ft_wwrite_ln(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content)
|
||||
{
|
||||
assert(table);
|
||||
int status = ft_wwrite(table, cell_content);
|
||||
@@ -239,7 +239,7 @@ int ft_wwrite_ln(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_
|
||||
}
|
||||
|
||||
|
||||
int ft_nwrite(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT cell_content, ...)
|
||||
int ft_nwrite(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...)
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -260,7 +260,7 @@ int ft_nwrite(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT c
|
||||
return status;
|
||||
}
|
||||
|
||||
int ft_nwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT cell_content, ...)
|
||||
int ft_nwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...)
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -286,7 +286,7 @@ int ft_nwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRIC
|
||||
}
|
||||
|
||||
|
||||
int ft_nwwrite(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRICT cell_content, ...)
|
||||
int ft_nwwrite(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...)
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -307,7 +307,7 @@ int ft_nwwrite(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRI
|
||||
return status;
|
||||
}
|
||||
|
||||
int ft_nwwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRICT cell_content, ...)
|
||||
int ft_nwwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...)
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -333,7 +333,7 @@ int ft_nwwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RES
|
||||
}
|
||||
|
||||
|
||||
FORT_EXTERN int ft_row_write(FTABLE *FORT_RESTRICT table, size_t cols, const char* FORT_RESTRICT cells[])
|
||||
FT_EXTERN int ft_row_write(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT cells[])
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -347,7 +347,7 @@ FORT_EXTERN int ft_row_write(FTABLE *FORT_RESTRICT table, size_t cols, const cha
|
||||
return F_SUCCESS;
|
||||
}
|
||||
|
||||
FORT_EXTERN int ft_row_write_ln(FTABLE *FORT_RESTRICT table, size_t cols, const char* FORT_RESTRICT cells[])
|
||||
FT_EXTERN int ft_row_write_ln(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT cells[])
|
||||
{
|
||||
assert(table);
|
||||
int status = ft_row_write(table, cols, cells);
|
||||
@@ -360,7 +360,7 @@ FORT_EXTERN int ft_row_write_ln(FTABLE *FORT_RESTRICT table, size_t cols, const
|
||||
|
||||
|
||||
|
||||
int ft_s_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* FORT_RESTRICT table_cells[rows][cols])
|
||||
int ft_s_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols])
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -376,7 +376,7 @@ int ft_s_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, cons
|
||||
return F_SUCCESS;
|
||||
}
|
||||
|
||||
int ft_s_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* FORT_RESTRICT table_cells[rows][cols])
|
||||
int ft_s_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols])
|
||||
{
|
||||
assert(table);
|
||||
int status = ft_s_table_write(table, rows, cols, table_cells);
|
||||
@@ -387,7 +387,7 @@ int ft_s_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, c
|
||||
}
|
||||
|
||||
|
||||
int ft_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* * FORT_RESTRICT table_cells[rows])
|
||||
int ft_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows])
|
||||
{
|
||||
size_t i = 0;
|
||||
assert(table);
|
||||
@@ -403,7 +403,7 @@ int ft_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const
|
||||
return F_SUCCESS;
|
||||
}
|
||||
|
||||
int ft_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* * FORT_RESTRICT table_cells[rows])
|
||||
int ft_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows])
|
||||
{
|
||||
assert(table);
|
||||
int status = ft_table_write(table, rows, cols, table_cells);
|
||||
@@ -427,7 +427,7 @@ int ft_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, con
|
||||
|
||||
|
||||
|
||||
const char* ft_to_string(const FTABLE *FORT_RESTRICT table)
|
||||
const char* ft_to_string(const FTABLE *FT_RESTRICT table)
|
||||
{
|
||||
#define CHECK_RESULT_AND_MOVE_DEV(statement) \
|
||||
k = statement; \
|
||||
@@ -521,7 +521,7 @@ clear:
|
||||
}
|
||||
|
||||
|
||||
const wchar_t* ft_to_wstring(const FTABLE *FORT_RESTRICT table)
|
||||
const wchar_t* ft_to_wstring(const FTABLE *FT_RESTRICT table)
|
||||
{
|
||||
#define CHECK_RESULT_AND_MOVE_DEV(statement) \
|
||||
k = statement; \
|
||||
@@ -668,7 +668,9 @@ int ft_add_separator(FTABLE *table)
|
||||
|
||||
struct ft_border_style * FT_BASIC_STYLE = (struct ft_border_style *)&FORT_BASIC_STYLE;
|
||||
struct ft_border_style * FT_SIMPLE_STYLE = (struct ft_border_style *)&FORT_SIMPLE_STYLE;
|
||||
struct ft_border_style * FT_PLAIN_STYLE = (struct ft_border_style *)&FORT_PLAIN_STYLE;
|
||||
struct ft_border_style * FT_DOT_STYLE = (struct ft_border_style *)&FORT_DOT_STYLE;
|
||||
struct ft_border_style * FT_EMPTY_STYLE = (struct ft_border_style *)&FORT_EMPTY_STYLE;
|
||||
|
||||
|
||||
|
||||
@@ -676,7 +678,9 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
|
||||
{
|
||||
if ((struct fort_border_style *)style == &FORT_BASIC_STYLE
|
||||
|| (struct fort_border_style *)style == &FORT_SIMPLE_STYLE
|
||||
|| (struct fort_border_style *)style == &FORT_DOT_STYLE)
|
||||
|| (struct fort_border_style *)style == &FORT_DOT_STYLE
|
||||
|| (struct fort_border_style *)style == &FORT_PLAIN_STYLE
|
||||
|| (struct fort_border_style *)style == &FORT_EMPTY_STYLE)
|
||||
{
|
||||
memcpy(&(options->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style));
|
||||
return;
|
||||
@@ -687,6 +691,7 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
|
||||
|
||||
#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
|
||||
|
||||
/*
|
||||
BOR_CHARS[TL_bip] = BOR_CHARS[TT_bip] = BOR_CHARS[TV_bip] = BOR_CHARS[TR_bip] = border_chs->top_border_ch;
|
||||
@@ -729,8 +734,13 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
|
||||
H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0';
|
||||
}
|
||||
|
||||
SEP_CHARS[LH_sip] = SEP_CHARS[RH_sip] = SEP_CHARS[II_sip] = header_border_chs->out_intersect_ch;
|
||||
SEP_CHARS[IH_sip] = style->hor_separator_char;
|
||||
|
||||
|
||||
#undef BOR_CHARS
|
||||
#undef H_BOR_CHARS
|
||||
#undef SEP_CHARS
|
||||
}
|
||||
|
||||
|
||||
|
@@ -13,8 +13,9 @@ struct fort_cell_options g_default_cell_option =
|
||||
FT_ANY_COLUMN, /* cell_col */
|
||||
|
||||
/* options */
|
||||
FT_OPT_MIN_WIDTH | FT_OPT_TEXT_ALIGN | FT_OPT_TOP_PADDING | FT_OPT_BOTTOM_PADDING
|
||||
| FT_OPT_LEFT_PADDING | FT_OPT_RIGHT_PADDING | FT_OPT_EMPTY_STR_HEIGHT ,
|
||||
FT_OPT_MIN_WIDTH | FT_OPT_TEXT_ALIGN | FT_OPT_TOP_PADDING
|
||||
| FT_OPT_BOTTOM_PADDING | FT_OPT_LEFT_PADDING | FT_OPT_RIGHT_PADDING
|
||||
| FT_OPT_EMPTY_STR_HEIGHT ,
|
||||
|
||||
0, /* col_min_width */
|
||||
RightAligned, /* align */
|
||||
@@ -224,7 +225,7 @@ fort_status_t set_default_cell_option(uint32_t option, int value)
|
||||
}, \
|
||||
/* separator_chars */ \
|
||||
{ \
|
||||
'+', '=', '+', '+', \
|
||||
'+', '-', '+', '+', \
|
||||
}, \
|
||||
}
|
||||
|
||||
@@ -245,7 +246,28 @@ fort_status_t set_default_cell_option(uint32_t option, int value)
|
||||
}, \
|
||||
/* separator_chars */ \
|
||||
{ \
|
||||
' ', '=', ' ', ' ', \
|
||||
' ', '-', ' ', ' ', \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define PLAIN_STYLE { \
|
||||
/* border_chars */ \
|
||||
{ \
|
||||
' ', ' ', ' ', ' ', \
|
||||
' ', ' ', ' ', \
|
||||
'\0', '\0', '\0', '\0', \
|
||||
' ', ' ', ' ', ' ' \
|
||||
}, \
|
||||
/* header_border_chars */ \
|
||||
{ \
|
||||
' ', '-', '-', ' ', \
|
||||
' ', ' ', ' ', \
|
||||
' ', '-', '-', ' ', \
|
||||
' ', '-', '-', ' ' \
|
||||
}, \
|
||||
/* separator_chars */ \
|
||||
{ \
|
||||
' ', '-', '-', ' ', \
|
||||
}, \
|
||||
}
|
||||
|
||||
@@ -266,13 +288,36 @@ fort_status_t set_default_cell_option(uint32_t option, int value)
|
||||
}, \
|
||||
/* separator_chars */ \
|
||||
{ \
|
||||
'+', '=', '+', '+', \
|
||||
':', '.', ':', ':', \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define EMPTY_STYLE { \
|
||||
/* border_chars */ \
|
||||
{ \
|
||||
' ', ' ', ' ', ' ', \
|
||||
' ', ' ', ' ', \
|
||||
'\0', '\0', '\0', '\0', \
|
||||
' ', ' ', ' ', ' ' \
|
||||
}, \
|
||||
/* header_border_chars */ \
|
||||
{ \
|
||||
' ', ' ', ' ', ' ', \
|
||||
' ', ' ', ' ', \
|
||||
'\0', '\0', '\0', '\0', \
|
||||
' ', ' ', ' ', ' ' \
|
||||
}, \
|
||||
/* separator_chars */ \
|
||||
{ \
|
||||
' ', ' ', ' ', ' ', \
|
||||
}, \
|
||||
}
|
||||
|
||||
struct fort_border_style FORT_BASIC_STYLE = BASIC_STYLE;
|
||||
struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE;
|
||||
struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE;
|
||||
struct fort_border_style FORT_DOT_STYLE = DOT_STYLE;
|
||||
struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE;
|
||||
|
||||
|
||||
|
||||
|
@@ -147,7 +147,10 @@ struct fort_border_style
|
||||
};
|
||||
extern struct fort_border_style FORT_BASIC_STYLE;
|
||||
extern struct fort_border_style FORT_SIMPLE_STYLE;
|
||||
extern struct fort_border_style FORT_PLAIN_STYLE;
|
||||
extern struct fort_border_style FORT_DOT_STYLE;
|
||||
extern struct fort_border_style FORT_EMPTY_STYLE;
|
||||
|
||||
|
||||
|
||||
struct fort_table_options
|
||||
|
@@ -403,7 +403,7 @@ clear:
|
||||
|
||||
|
||||
|
||||
fort_row_t* create_row_from_fmt_string(const char* FORT_RESTRICT fmt, va_list *va_args)
|
||||
fort_row_t* create_row_from_fmt_string(const char* FT_RESTRICT fmt, va_list *va_args)
|
||||
{
|
||||
string_buffer_t *buffer = create_string_buffer(DEFAULT_STR_BUF_SIZE, CharBuf);
|
||||
if (buffer == NULL)
|
||||
|
@@ -20,7 +20,7 @@ enum RowType
|
||||
fort_row_t * create_row();
|
||||
void destroy_row(fort_row_t *row);
|
||||
fort_row_t * create_row_from_string(const char *str);
|
||||
fort_row_t* create_row_from_fmt_string(const char* FORT_RESTRICT fmt, va_list *va_args);
|
||||
fort_row_t* create_row_from_fmt_string(const char* FT_RESTRICT fmt, va_list *va_args);
|
||||
|
||||
|
||||
int columns_in_row(const fort_row_t *row);
|
||||
@@ -48,7 +48,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
|
||||
|
||||
|
||||
fort_row_t* create_row_from_string(const char *str);
|
||||
fort_row_t* create_row_from_fmt_string(const char* FORT_RESTRICT fmt, va_list *va_args);
|
||||
fort_row_t* create_row_from_fmt_string(const char* FT_RESTRICT fmt, va_list *va_args);
|
||||
|
||||
int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
|
||||
size_t row_height, const context_t *context);
|
||||
|
@@ -54,7 +54,7 @@ fort_row_t *get_row_and_create_if_not_exists(fort_table_t *table, size_t row)
|
||||
|
||||
|
||||
|
||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FORT_RESTRICT table)
|
||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FT_RESTRICT table)
|
||||
{
|
||||
assert(table);
|
||||
|
||||
|
@@ -16,7 +16,7 @@ struct fort_table
|
||||
vector_t *separators;
|
||||
};
|
||||
|
||||
static FORT_INLINE
|
||||
static FT_INLINE
|
||||
separator_t *create_separator(int enabled)
|
||||
{
|
||||
separator_t *res = F_CALLOC(1, sizeof(separator_t));
|
||||
@@ -26,7 +26,7 @@ separator_t *create_separator(int enabled)
|
||||
return res;
|
||||
}
|
||||
|
||||
static FORT_INLINE
|
||||
static FT_INLINE
|
||||
void destroy_separator(separator_t *sep)
|
||||
{
|
||||
F_FREE(sep);
|
||||
@@ -40,7 +40,7 @@ fort_row_t *get_row(fort_table_t *table, size_t row);
|
||||
const fort_row_t *get_row_c(const fort_table_t *table, size_t row);
|
||||
fort_row_t *get_row_and_create_if_not_exists(fort_table_t *table, size_t row);
|
||||
|
||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FORT_RESTRICT table);
|
||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FT_RESTRICT table);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user