[C] Changed default alignment
This commit is contained in:
parent
54542b9cb6
commit
a8868e7bd9
31
README.md
31
README.md
@ -18,20 +18,31 @@
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```C
|
```C
|
||||||
ft_table_t *table = ft_create_table();
|
#include "fort.h"
|
||||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
int main(void)
|
||||||
ft_write_ln(table, "Rank", "Title", "Year", "Rating");
|
{
|
||||||
|
ft_table_t *table = ft_create_table();;
|
||||||
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
|
ft_write_ln(table, "N", "Planet", "Speed, km/s");
|
||||||
|
|
||||||
ft_write_ln(table, "1", "The Shawshank Redemption", "1994", "9.5");
|
ft_write_ln(table, "1", "Mercury", "47.362");
|
||||||
ft_write_ln(table, "2", "12 Angry Men", "1957", "8.8");
|
ft_write_ln(table, "2", "Venus", "35.02");
|
||||||
ft_write_ln(table, "3", "2001: A Space Odyssey", "1968", "8.5");
|
ft_write_ln(table, "3", "Earth", "29.78");
|
||||||
ft_write_ln(table, "4", "Blade Runner", "1982", "8.1");
|
|
||||||
|
|
||||||
printf("%s\n", ft_to_string(table));
|
printf("%s\n", ft_to_string(table));
|
||||||
ft_destroy_table(table);
|
ft_destroy_table(table);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
```text
|
||||||
|
+---+---------+-------------+
|
||||||
|
| N | Planet | Speed, km/s |
|
||||||
|
+---+---------+-------------+
|
||||||
|
| 1 | Mercury | 47.362 |
|
||||||
|
| 2 | Venus | 35.02 |
|
||||||
|
| 3 | Earth | 29.78 |
|
||||||
|
+---+---------+-------------+
|
||||||
|
```
|
||||||
|
|
||||||
<img src="https://github.com/seleznevae/libfort/blob/master/docs/images/basic_table.png" data-canonical-src="https://github.com/seleznevae/libfort/blob/master/docs/images/basic_table.png" width="500" />
|
<img src="https://github.com/seleznevae/libfort/blob/master/docs/images/basic_table.png" data-canonical-src="https://github.com/seleznevae/libfort/blob/master/docs/images/basic_table.png" width="500" />
|
||||||
|
|
||||||
|
@ -33,8 +33,24 @@ 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_write_ln(table, "N", "Planet", "Speed, km/s");
|
||||||
|
|
||||||
|
ft_write_ln(table, "1", "Mercury", "47.362");
|
||||||
|
ft_write_ln(table, "2", "Venus", "35.02");
|
||||||
|
ft_write_ln(table, "3", "Earth", "29.78");
|
||||||
|
|
||||||
|
printf("%s\n", ft_to_string(table));
|
||||||
|
ft_destroy_table(table);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
base_example();
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
ft_table_t *table = NULL;
|
ft_table_t *table = NULL;
|
||||||
|
@ -674,7 +674,7 @@ 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 */
|
||||||
FT_ALIGNED_RIGHT, /* align */
|
FT_ALIGNED_LEFT, /* 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 */
|
||||||
|
@ -17,7 +17,7 @@ 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 */
|
||||||
FT_ALIGNED_RIGHT, /* align */
|
FT_ALIGNED_LEFT, /* 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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user