[C] Renames some entities
This commit is contained in:
parent
0fa22238ef
commit
edaf106ed1
@ -6,10 +6,10 @@
|
|||||||
static FTABLE *create_basic_table()
|
static FTABLE *create_basic_table()
|
||||||
{
|
{
|
||||||
FTABLE *table = ft_create_table();
|
FTABLE *table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, CenterAligned);
|
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, LeftAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
|
FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
|
||||||
|
|
||||||
FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
|
FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
|
||||||
@ -28,10 +28,10 @@ int main(void)
|
|||||||
FTABLE *table = NULL;
|
FTABLE *table = NULL;
|
||||||
|
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, CenterAligned);
|
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, LeftAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_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);
|
||||||
|
|
||||||
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);
|
||||||
@ -45,10 +45,10 @@ int main(void)
|
|||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
|
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, CenterAligned);
|
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, LeftAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
ft_printf_ln(table, "Rank|Title|Year|Rating");
|
ft_printf_ln(table, "Rank|Title|Year|Rating");
|
||||||
|
|
||||||
FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
|
FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
|
||||||
@ -64,10 +64,10 @@ int main(void)
|
|||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
|
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, LeftAligned);
|
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, CenterAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
ft_printf_ln(table, "Commodity|Farm price|Avg. spread");
|
ft_printf_ln(table, "Commodity|Farm price|Avg. spread");
|
||||||
|
|
||||||
const char *row1[] = {"Potatoes", "$1.60", "200.94%"};
|
const char *row1[] = {"Potatoes", "$1.60", "200.94%"};
|
||||||
@ -82,10 +82,10 @@ int main(void)
|
|||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
#if !defined(__cplusplus) && !defined(FT_MICROSOFT_COMPILER)
|
#if !defined(__cplusplus) && !defined(FT_MICROSOFT_COMPILER)
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, LeftAligned);
|
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, CenterAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
ft_printf_ln(table, "No.|Name|Avg. Mark");
|
ft_printf_ln(table, "No.|Name|Avg. Mark");
|
||||||
const char *ctab[2][3] = {
|
const char *ctab[2][3] = {
|
||||||
{"1", "Joe Public", "3.14"},
|
{"1", "Joe Public", "3.14"},
|
||||||
@ -102,10 +102,10 @@ int main(void)
|
|||||||
|
|
||||||
|
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, CenterAligned);
|
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, LeftAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
ft_printf_ln(table, "No.|Name|Avg. Mark");
|
ft_printf_ln(table, "No.|Name|Avg. Mark");
|
||||||
const char **tab[2] = {
|
const char **tab[2] = {
|
||||||
row1,
|
row1,
|
||||||
@ -150,10 +150,10 @@ int main(void)
|
|||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, CenterAligned);
|
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, LeftAligned);
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
FT_NWWRITE_LN(table, L"Ранг", L"Название", L"Год", L"Рейтинг");
|
FT_NWWRITE_LN(table, L"Ранг", L"Название", L"Год", L"Рейтинг");
|
||||||
|
|
||||||
FT_NWWRITE_LN(table, L"1", L"Побег из Шоушенка", L"1994", L"9.5");
|
FT_NWWRITE_LN(table, L"1", L"Побег из Шоушенка", L"1994", L"9.5");
|
||||||
|
119
include/fort.h
119
include/fort.h
@ -302,49 +302,17 @@ FT_EXTERN int ft_add_separator(FTABLE *table);
|
|||||||
FT_EXTERN const char *ft_to_string(const FTABLE *table);
|
FT_EXTERN const char *ft_to_string(const FTABLE *table);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Setting table appearance
|
|
||||||
*/
|
|
||||||
#define FT_ANY_COLUMN (UINT_MAX)
|
|
||||||
#define FT_ANY_ROW (UINT_MAX)
|
|
||||||
|
|
||||||
#define FT_CUR_COLUMN (UINT_MAX - 1)
|
|
||||||
#define FT_CUR_ROW (UINT_MAX - 1)
|
|
||||||
|
|
||||||
#define FT_ROW_UNSPEC (UINT_MAX - 2)
|
|
||||||
#define FT_COLUMN_UNSPEC (UINT_MAX - 2)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cell options
|
|
||||||
*/
|
|
||||||
#define FT_COPT_MIN_WIDTH (0x01U << 0) /**< Minimum width */
|
|
||||||
#define FT_COPT_TEXT_ALIGN (0x01U << 1) /**< Text alignmemnt */
|
|
||||||
#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 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Table options
|
|
||||||
*/
|
|
||||||
#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)
|
|
||||||
|
|
||||||
|
|
||||||
enum TextAlignment {
|
|
||||||
LeftAligned,
|
|
||||||
CenterAligned,
|
|
||||||
RightAligned
|
|
||||||
};
|
|
||||||
|
|
||||||
enum RowType {
|
|
||||||
Common,
|
|
||||||
Header
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct ft_border_chars {
|
struct ft_border_chars {
|
||||||
char top_border_ch;
|
char top_border_ch;
|
||||||
@ -361,20 +329,87 @@ struct ft_border_style {
|
|||||||
char hor_separator_char;
|
char hor_separator_char;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* List of built-in table border styles */
|
/**
|
||||||
|
* Built-in table border styles
|
||||||
|
*/
|
||||||
extern struct ft_border_style *FT_BASIC_STYLE;
|
extern struct ft_border_style *FT_BASIC_STYLE;
|
||||||
extern struct ft_border_style *FT_SIMPLE_STYLE;
|
extern struct ft_border_style *FT_SIMPLE_STYLE;
|
||||||
extern struct ft_border_style *FT_PLAIN_STYLE;
|
extern struct ft_border_style *FT_PLAIN_STYLE;
|
||||||
extern struct ft_border_style *FT_DOT_STYLE;
|
extern struct ft_border_style *FT_DOT_STYLE;
|
||||||
extern struct ft_border_style *FT_EMPTY_STYLE;
|
extern struct ft_border_style *FT_EMPTY_STYLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default border style for all new formatted tables.
|
||||||
|
*
|
||||||
|
* @param style
|
||||||
|
* Pointer to border style
|
||||||
|
* @return
|
||||||
|
* - 0: Success; default border style was changed.
|
||||||
|
* - (-1): !!!!!!!! todo
|
||||||
|
*/
|
||||||
FT_EXTERN int ft_set_default_border_style(struct ft_border_style *style);
|
FT_EXTERN int ft_set_default_border_style(struct ft_border_style *style);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set border style for the table.
|
||||||
|
*
|
||||||
|
* @param table
|
||||||
|
* A pointer to the FTABLE structure
|
||||||
|
* @param style
|
||||||
|
* Pointer to border style
|
||||||
|
* @return
|
||||||
|
* - 0: Success; table border style was changed.
|
||||||
|
* - (-1): !!!!!!!! todo
|
||||||
|
*/
|
||||||
FT_EXTERN int ft_set_border_style(FTABLE *table, struct ft_border_style *style);
|
FT_EXTERN int ft_set_border_style(FTABLE *table, struct ft_border_style *style);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special macros to define cell position (row and column)
|
||||||
|
*/
|
||||||
|
#define FT_ANY_COLUMN (UINT_MAX)
|
||||||
|
#define FT_CUR_COLUMN (UINT_MAX - 1)
|
||||||
|
#define FT_ANY_ROW (UINT_MAX)
|
||||||
|
#define FT_CUR_ROW (UINT_MAX - 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cell options
|
||||||
|
*/
|
||||||
|
#define FT_COPT_MIN_WIDTH (0x01U << 0) /**< Minimum width */
|
||||||
|
#define FT_COPT_TEXT_ALIGN (0x01U << 1) /**< Text alignmemnt */
|
||||||
|
#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 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alignment of cell content
|
||||||
|
*/
|
||||||
|
enum ft_text_alignment {
|
||||||
|
FT_ALIGNED_LEFT,
|
||||||
|
FT_ALIGNED_CENTER,
|
||||||
|
FT_ALIGNED_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of table row
|
||||||
|
*/
|
||||||
|
enum ft_row_type {
|
||||||
|
FT_ROW_COMMON,
|
||||||
|
FT_ROW_HEADER
|
||||||
|
};
|
||||||
|
|
||||||
FT_EXTERN int ft_set_default_cell_option(uint32_t option, int value);
|
FT_EXTERN int ft_set_default_cell_option(uint32_t option, int value);
|
||||||
FT_EXTERN int ft_set_cell_option(FTABLE *table, unsigned row, unsigned col, uint32_t option, int value);
|
FT_EXTERN int ft_set_cell_option(FTABLE *table, unsigned row, unsigned col, uint32_t option, int value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table options
|
||||||
|
*/
|
||||||
|
#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)
|
||||||
|
|
||||||
FT_EXTERN int ft_set_default_tbl_option(uint32_t option, int value);
|
FT_EXTERN int ft_set_default_tbl_option(uint32_t option, int value);
|
||||||
FT_EXTERN int ft_set_tbl_option(FTABLE *table, uint32_t option, int value);
|
FT_EXTERN int ft_set_tbl_option(FTABLE *table, uint32_t option, int value);
|
||||||
|
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
#ifndef LIBFORT_HPP
|
#ifndef LIBFORT_HPP
|
||||||
#define LIBFORT_HPP
|
#define LIBFORT_HPP
|
||||||
|
|
||||||
#include "fort.h"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <exception>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "fort.h"
|
||||||
|
|
||||||
|
|
||||||
namespace fort
|
namespace fort
|
||||||
{
|
{
|
||||||
@ -66,7 +63,7 @@ public:
|
|||||||
FTable &operator<<(const FTableManipulator &arg)
|
FTable &operator<<(const FTableManipulator &arg)
|
||||||
{
|
{
|
||||||
if (arg.value == header.value)
|
if (arg.value == header.value)
|
||||||
ft_set_cell_option(table, FT_CUR_ROW, FT_ANY_ROW, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, FT_CUR_ROW, FT_ANY_ROW, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
else if (arg.value == endl.value)
|
else if (arg.value == endl.value)
|
||||||
ft_ln(table);
|
ft_ln(table);
|
||||||
else if (arg.value == separator.value)
|
else if (arg.value == separator.value)
|
||||||
|
@ -17,14 +17,14 @@ struct fort_cell_options g_default_cell_option = {
|
|||||||
| FT_COPT_EMPTY_STR_HEIGHT,
|
| FT_COPT_EMPTY_STR_HEIGHT,
|
||||||
|
|
||||||
0, /* col_min_width */
|
0, /* col_min_width */
|
||||||
RightAligned, /* align */
|
FT_ALIGNED_RIGHT, /* align */
|
||||||
0, /* cell_padding_top */
|
0, /* cell_padding_top */
|
||||||
0, /* cell_padding_bottom */
|
0, /* cell_padding_bottom */
|
||||||
1, /* cell_padding_left */
|
1, /* cell_padding_left */
|
||||||
1, /* cell_padding_right */
|
1, /* cell_padding_right */
|
||||||
1, /* cell_empty_string_height */
|
1, /* cell_empty_string_height */
|
||||||
|
|
||||||
Common, /* row_type */
|
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_option_value_if_exists_otherwise_default(const struct fort_cell_options *cell_opts, uint32_t option)
|
||||||
@ -59,7 +59,7 @@ static int get_option_value_if_exists_otherwise_default(const struct fort_cell_o
|
|||||||
|
|
||||||
fort_column_options_t g_column_options = {
|
fort_column_options_t g_column_options = {
|
||||||
0, /* col_min_width*/
|
0, /* col_min_width*/
|
||||||
RightAligned, /* align */
|
FT_ALIGNED_RIGHT, /* align */
|
||||||
};
|
};
|
||||||
|
|
||||||
fort_column_options_t create_column_options(void)
|
fort_column_options_t create_column_options(void)
|
||||||
@ -158,7 +158,7 @@ static fort_status_t set_cell_option_impl(fort_cell_options_t *opt, uint32_t opt
|
|||||||
if (OPTION_IS_SET(option, FT_COPT_MIN_WIDTH)) {
|
if (OPTION_IS_SET(option, FT_COPT_MIN_WIDTH)) {
|
||||||
opt->col_min_width = value;
|
opt->col_min_width = value;
|
||||||
} else if (OPTION_IS_SET(option, FT_COPT_TEXT_ALIGN)) {
|
} else if (OPTION_IS_SET(option, FT_COPT_TEXT_ALIGN)) {
|
||||||
opt->align = (enum TextAlignment)value;
|
opt->align = (enum ft_text_alignment)value;
|
||||||
} else if (OPTION_IS_SET(option, FT_COPT_TOP_PADDING)) {
|
} else if (OPTION_IS_SET(option, FT_COPT_TOP_PADDING)) {
|
||||||
opt->cell_padding_top = value;
|
opt->cell_padding_top = value;
|
||||||
} else if (OPTION_IS_SET(option, FT_COPT_BOTTOM_PADDING)) {
|
} else if (OPTION_IS_SET(option, FT_COPT_BOTTOM_PADDING)) {
|
||||||
@ -170,7 +170,7 @@ static fort_status_t set_cell_option_impl(fort_cell_options_t *opt, uint32_t opt
|
|||||||
} else if (OPTION_IS_SET(option, FT_COPT_EMPTY_STR_HEIGHT)) {
|
} else if (OPTION_IS_SET(option, FT_COPT_EMPTY_STR_HEIGHT)) {
|
||||||
opt->cell_empty_string_height = value;
|
opt->cell_empty_string_height = value;
|
||||||
} else if (OPTION_IS_SET(option, FT_COPT_ROW_TYPE)) {
|
} else if (OPTION_IS_SET(option, FT_COPT_ROW_TYPE)) {
|
||||||
opt->row_type = (enum RowType)value;
|
opt->row_type = (enum ft_row_type)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_SUCCESS;
|
return FT_SUCCESS;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
struct fort_column_options
|
struct fort_column_options
|
||||||
{
|
{
|
||||||
int col_min_width;
|
int col_min_width;
|
||||||
enum TextAlignment align;
|
enum ft_text_alignment align;
|
||||||
};
|
};
|
||||||
typedef struct fort_column_options fort_column_options_t;
|
typedef struct fort_column_options fort_column_options_t;
|
||||||
|
|
||||||
@ -30,13 +30,13 @@ struct fort_cell_options
|
|||||||
unsigned cell_col;
|
unsigned cell_col;
|
||||||
uint32_t options;
|
uint32_t options;
|
||||||
int col_min_width;
|
int col_min_width;
|
||||||
enum TextAlignment align;
|
enum ft_text_alignment align;
|
||||||
int cell_padding_top;
|
int cell_padding_top;
|
||||||
int cell_padding_bottom;
|
int cell_padding_bottom;
|
||||||
int cell_padding_left;
|
int cell_padding_left;
|
||||||
int cell_padding_right;
|
int cell_padding_right;
|
||||||
int cell_empty_string_height;
|
int cell_empty_string_height;
|
||||||
enum RowType row_type;
|
enum ft_row_type row_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct fort_cell_options fort_cell_options_t;
|
typedef struct fort_cell_options fort_cell_options_t;
|
||||||
|
30
src/row.c
30
src/row.c
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
struct fort_row {
|
struct fort_row {
|
||||||
vector_t *cells;
|
vector_t *cells;
|
||||||
/*enum RowType type;*/
|
/*enum ft_row_type type;*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ fort_row_t *create_row(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
row->is_header = F_FALSE;
|
row->is_header = F_FALSE;
|
||||||
row->type = Common;
|
row->type = FT_ROW_COMMON;
|
||||||
*/
|
*/
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@ -127,13 +127,13 @@ int print_row_separator(char *buffer, size_t buffer_sz,
|
|||||||
int written = 0;
|
int written = 0;
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
enum RowType lower_row_type = Common;
|
enum ft_row_type lower_row_type = FT_ROW_COMMON;
|
||||||
if (lower_row != NULL) {
|
if (lower_row != NULL) {
|
||||||
lower_row_type = (enum RowType)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_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE);
|
||||||
}
|
}
|
||||||
enum RowType upper_row_type = Common;
|
enum ft_row_type upper_row_type = FT_ROW_COMMON;
|
||||||
if (upper_row != NULL) {
|
if (upper_row != NULL) {
|
||||||
upper_row_type = (enum RowType)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_opt_value_hierarcial(context->table_options, context->row - 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ int print_row_separator(char *buffer, size_t buffer_sz,
|
|||||||
typedef const char (*border_chars_point_t)[BorderItemPosSize];
|
typedef const char (*border_chars_point_t)[BorderItemPosSize];
|
||||||
const char (*border_chars)[BorderItemPosSize] = NULL;
|
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_options->border_style.border_chars;
|
||||||
if (upper_row_type == Header || lower_row_type == Header) {
|
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_options->border_style.header_border_chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,13 +232,13 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
|
|||||||
int written = 0;
|
int written = 0;
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
enum RowType lower_row_type = Common;
|
enum ft_row_type lower_row_type = FT_ROW_COMMON;
|
||||||
if (lower_row != NULL) {
|
if (lower_row != NULL) {
|
||||||
lower_row_type = (enum RowType)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_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE);
|
||||||
}
|
}
|
||||||
enum RowType upper_row_type = Common;
|
enum ft_row_type upper_row_type = FT_ROW_COMMON;
|
||||||
if (upper_row != NULL) {
|
if (upper_row != NULL) {
|
||||||
upper_row_type = (enum RowType)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_opt_value_hierarcial(context->table_options, context->row - 1, FT_ANY_COLUMN, FT_COPT_ROW_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Row separator anatomy
|
/* Row separator anatomy
|
||||||
@ -253,7 +253,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
|
|||||||
typedef const char (*border_chars_point_t)[BorderItemPosSize];
|
typedef const char (*border_chars_point_t)[BorderItemPosSize];
|
||||||
const char (*border_chars)[BorderItemPosSize] = NULL;
|
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_options->border_style.border_chars;
|
||||||
if (upper_row_type == Header || lower_row_type == Header) {
|
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_options->border_style.header_border_chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,8 +473,8 @@ 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];
|
typedef const char (*border_chars_point_t)[BorderItemPosSize];
|
||||||
enum RowType row_type = (enum RowType)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_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE);
|
||||||
const char (*bord_chars)[BorderItemPosSize] = (row_type == Header)
|
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.header_border_chars)
|
||||||
: (border_chars_point_t)(&context->table_options->border_style.border_chars);
|
: (border_chars_point_t)(&context->table_options->border_style.border_chars);
|
||||||
const char *L = &(*bord_chars)[LL_bip];
|
const char *L = &(*bord_chars)[LL_bip];
|
||||||
@ -543,7 +543,7 @@ 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];
|
typedef const char (*border_chars_point_t)[BorderItemPosSize];
|
||||||
enum RowType row_type = (enum RowType)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_opt_value_hierarcial(context->table_options, context->row, FT_ANY_COLUMN, FT_COPT_ROW_TYPE);
|
||||||
const char (*bord_chars)[BorderItemPosSize] = (row_type)
|
const char (*bord_chars)[BorderItemPosSize] = (row_type)
|
||||||
? (border_chars_point_t)(&context->table_options->border_style.header_border_chars)
|
? (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_options->border_style.border_chars);
|
||||||
|
@ -10,10 +10,10 @@ struct fort_row;
|
|||||||
typedef struct fort_row fort_row_t;
|
typedef struct fort_row fort_row_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
enum RowType
|
enum ft_row_type
|
||||||
{
|
{
|
||||||
Common,
|
FT_ROW_COMMON,
|
||||||
Header
|
FT_ROW_HEADER
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -295,15 +295,15 @@ int buffer_printf(string_buffer_t *buffer, size_t buffer_row, char *buf, size_t
|
|||||||
int right = 0;
|
int right = 0;
|
||||||
|
|
||||||
switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) {
|
switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) {
|
||||||
case LeftAligned:
|
case FT_ALIGNED_LEFT:
|
||||||
left = 0;
|
left = 0;
|
||||||
right = (buf_len - 1) - content_width;
|
right = (buf_len - 1) - content_width;
|
||||||
break;
|
break;
|
||||||
case CenterAligned:
|
case FT_ALIGNED_CENTER:
|
||||||
left = ((buf_len - 1) - content_width) / 2;
|
left = ((buf_len - 1) - content_width) / 2;
|
||||||
right = ((buf_len - 1) - content_width) - left;
|
right = ((buf_len - 1) - content_width) - left;
|
||||||
break;
|
break;
|
||||||
case RightAligned:
|
case FT_ALIGNED_RIGHT:
|
||||||
left = (buf_len - 1) - content_width;
|
left = (buf_len - 1) - content_width;
|
||||||
right = 0;
|
right = 0;
|
||||||
break;
|
break;
|
||||||
@ -377,15 +377,15 @@ int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, siz
|
|||||||
int right = 0;
|
int right = 0;
|
||||||
|
|
||||||
switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) {
|
switch (get_cell_opt_value_hierarcial(context->table_options, context->row, context->column, FT_COPT_TEXT_ALIGN)) {
|
||||||
case LeftAligned:
|
case FT_ALIGNED_LEFT:
|
||||||
left = 0;
|
left = 0;
|
||||||
right = (buf_len - 1) - content_width;
|
right = (buf_len - 1) - content_width;
|
||||||
break;
|
break;
|
||||||
case CenterAligned:
|
case FT_ALIGNED_CENTER:
|
||||||
left = ((buf_len - 1) - content_width) / 2;
|
left = ((buf_len - 1) - content_width) / 2;
|
||||||
right = ((buf_len - 1) - content_width) - left;
|
right = ((buf_len - 1) - content_width) - left;
|
||||||
break;
|
break;
|
||||||
case RightAligned:
|
case FT_ALIGNED_RIGHT:
|
||||||
left = (buf_len - 1) - content_width;
|
left = (buf_len - 1) - content_width;
|
||||||
right = 0;
|
right = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -10,7 +10,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||||
@ -40,7 +40,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||||
@ -72,7 +72,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "c", "234", "3.140000", "3") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "c", "234", "3.140000", "3") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "234", "3.140000", "3", "c") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "234", "3.140000", "3", "c") == FT_SUCCESS);
|
||||||
@ -102,7 +102,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"3") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"3") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"234", L"3.140000", L"3", L"c") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"234", L"3.140000", L"3", L"c") == FT_SUCCESS);
|
||||||
@ -132,7 +132,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWRITE_LN(table, "", "", "234", "3.140000") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "", "", "234", "3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "c", "234", "3.140000", "") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "c", "234", "3.140000", "") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "234", "3.140000", "", "") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "234", "3.140000", "", "") == FT_SUCCESS);
|
||||||
@ -162,7 +162,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"234", L"3.140000") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"", L"", L"234", L"3.140000") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"234", L"3.140000", L"", L"") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"234", L"3.140000", L"", L"") == FT_SUCCESS);
|
||||||
@ -192,7 +192,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||||
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||||
@ -222,7 +222,7 @@ void test_table_basic(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||||
@ -260,7 +260,7 @@ void test_wcs_table_boundaries(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
assert_true(FT_NWWRITE_LN(table, L"3", L"12345\x8888\x8888", L"c") == FT_SUCCESS); /* \x8888,\x8888 - occupy 2 columns each */
|
assert_true(FT_NWWRITE_LN(table, L"3", L"12345\x8888\x8888", L"c") == FT_SUCCESS); /* \x8888,\x8888 - occupy 2 columns each */
|
||||||
assert_true(FT_NWWRITE_LN(table, L"c", L"12345678\x500", L"c") == FT_SUCCESS); /* \x500 - occupies 1 column */
|
assert_true(FT_NWWRITE_LN(table, L"c", L"12345678\x500", L"c") == FT_SUCCESS); /* \x500 - occupies 1 column */
|
||||||
assert_true(FT_NWWRITE_LN(table, L"234", L"123456789", L"c") == FT_SUCCESS);
|
assert_true(FT_NWWRITE_LN(table, L"234", L"123456789", L"c") == FT_SUCCESS);
|
||||||
@ -296,7 +296,7 @@ void test_table_write(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
const char *row_0[4] = {"3", "c", "234", "3.140000"};
|
const char *row_0[4] = {"3", "c", "234", "3.140000"};
|
||||||
const char *row_1[4] = {"c", "234", "3.140000", "3"};
|
const char *row_1[4] = {"c", "234", "3.140000", "3"};
|
||||||
const char *row_2[4] = {"234", "3.140000", "3", "c"};
|
const char *row_2[4] = {"234", "3.140000", "3", "c"};
|
||||||
@ -329,7 +329,7 @@ void test_table_write(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
const wchar_t *row_0[4] = {L"3", L"c", L"234", L"3.140000"};
|
const wchar_t *row_0[4] = {L"3", L"c", L"234", L"3.140000"};
|
||||||
const wchar_t *row_1[4] = {L"c", L"234", L"3.140000", L"3"};
|
const wchar_t *row_1[4] = {L"c", L"234", L"3.140000", L"3"};
|
||||||
const wchar_t *row_2[4] = {L"234", L"3.140000", L"3", L"c"};
|
const wchar_t *row_2[4] = {L"234", L"3.140000", L"3", L"c"};
|
||||||
@ -363,7 +363,7 @@ void test_table_write(void)
|
|||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
|
int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
|
||||||
assert_true(n == 4);
|
assert_true(n == 4);
|
||||||
n = ft_printf_ln(table, "%c|%s|%f|%d", 'c', "234", 3.14, 3);
|
n = ft_printf_ln(table, "%c|%s|%f|%d", 'c', "234", 3.14, 3);
|
||||||
|
@ -96,7 +96,7 @@ void test_table_border_style(void)
|
|||||||
table = create_test_int_table(1);
|
table = create_test_int_table(1);
|
||||||
ft_add_separator(table);
|
ft_add_separator(table);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
||||||
|
|
||||||
assert_true(n == 4);
|
assert_true(n == 4);
|
||||||
|
@ -336,12 +336,12 @@ void test_table_cell_options(void)
|
|||||||
int status = FT_SUCCESS;
|
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_MIN_WIDTH, 7);
|
||||||
status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, LeftAligned);
|
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_MIN_WIDTH, 8);
|
||||||
status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_COPT_TEXT_ALIGN, CenterAligned);
|
status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_COPT_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_MIN_WIDTH, 6);
|
||||||
status |= ft_set_cell_option(table, 2, 3, FT_COPT_TEXT_ALIGN, LeftAligned);
|
status |= ft_set_cell_option(table, 2, 3, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
assert_true(status == FT_SUCCESS);
|
assert_true(status == FT_SUCCESS);
|
||||||
|
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ void test_table_cell_options(void)
|
|||||||
|
|
||||||
int status = FT_SUCCESS;
|
int status = FT_SUCCESS;
|
||||||
status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 5);
|
status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 5);
|
||||||
status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, CenterAligned);
|
status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER);
|
||||||
assert_true(status == FT_SUCCESS);
|
assert_true(status == FT_SUCCESS);
|
||||||
|
|
||||||
table = create_test_int_table(0);
|
table = create_test_int_table(0);
|
||||||
@ -401,7 +401,7 @@ void test_table_cell_options(void)
|
|||||||
|
|
||||||
table = ft_create_table();
|
table = ft_create_table();
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
int n = ft_printf_ln(table, "%d|%c|%s|%f", 4, 'c', "234", 3.14);
|
int n = ft_printf_ln(table, "%d|%c|%s|%f", 4, 'c', "234", 3.14);
|
||||||
|
|
||||||
assert_true(n == 4);
|
assert_true(n == 4);
|
||||||
|
@ -38,7 +38,7 @@ int set_test_options_as_default()
|
|||||||
int status = FT_SUCCESS;
|
int status = FT_SUCCESS;
|
||||||
|
|
||||||
status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 0);
|
status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 0);
|
||||||
status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, RightAligned);
|
status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, FT_ALIGNED_RIGHT);
|
||||||
|
|
||||||
status |= ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1);
|
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_TOP_PADDING, 1);
|
||||||
@ -83,7 +83,7 @@ FTABLE *create_test_int_table(int set_test_opts)
|
|||||||
|
|
||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
||||||
int n = FT_NWRITE_LN(table, "3", "4", "55", "67");
|
int n = FT_NWRITE_LN(table, "3", "4", "55", "67");
|
||||||
assert(n == FT_SUCCESS);
|
assert(n == FT_SUCCESS);
|
||||||
@ -113,7 +113,7 @@ FTABLE *create_test_int_wtable(int set_test_opts)
|
|||||||
|
|
||||||
assert_true(table != NULL);
|
assert_true(table != NULL);
|
||||||
|
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
||||||
int n = FT_NWWRITE_LN(table, L"3", L"4", L"55", L"67");
|
int n = FT_NWWRITE_LN(table, L"3", L"4", L"55", L"67");
|
||||||
assert(n == FT_SUCCESS);
|
assert(n == FT_SUCCESS);
|
||||||
|
Loading…
Reference in New Issue
Block a user