diff options
author | Karel Zak | 2016-01-22 16:51:59 +0100 |
---|---|---|
committer | Karel Zak | 2016-01-22 16:51:59 +0100 |
commit | 57867795aa7dead56a7339a13f08ea1f3a5de615 (patch) | |
tree | a1b1f247bcb0c70cc135efd98c43c28b0b0234f5 /libsmartcols/src/symbols.c | |
parent | libsmartcols: add title to the test application (diff) | |
download | kernel-qcow2-util-linux-57867795aa7dead56a7339a13f08ea1f3a5de615.tar.gz kernel-qcow2-util-linux-57867795aa7dead56a7339a13f08ea1f3a5de615.tar.xz kernel-qcow2-util-linux-57867795aa7dead56a7339a13f08ea1f3a5de615.zip |
libsmartcols: support multibyte titles, rename wrap to padding
- let's support multibyte table titles
- use lib/mbalign.c to align the title
- rename title_wrap to title_padding (we already use "wrap" on another
places for another things)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/symbols.c')
-rw-r--r-- | libsmartcols/src/symbols.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libsmartcols/src/symbols.c b/libsmartcols/src/symbols.c index dfe2ba7b6..cdf06ab66 100644 --- a/libsmartcols/src/symbols.c +++ b/libsmartcols/src/symbols.c @@ -62,7 +62,7 @@ void scols_unref_symbols(struct libscols_symbols *sy) free(sy->branch); free(sy->vert); free(sy->right); - free(sy->title_wrap); + free(sy->title_padding); free(sy); } } @@ -143,13 +143,16 @@ int scols_symbols_set_right(struct libscols_symbols *sb, const char *str) } /** - * scols_symbols_set_title_wrap: + * scols_symbols_set_title_padding: * @sb: a pointer to a struct libscols_symbols instance * @str: a string which will represent the symbols which wraps title output * + * The current implemetation uses only the first byte from the padding string. + * A multibyte chars are not supported yet. + * * Returns: 0, a negative value in case of an error. */ -int scols_symbols_set_title_wrap(struct libscols_symbols *sb, const char *str) +int scols_symbols_set_title_padding(struct libscols_symbols *sb, const char *str) { char *p = NULL; @@ -162,8 +165,8 @@ int scols_symbols_set_title_wrap(struct libscols_symbols *sb, const char *str) if (!p) return -ENOMEM; } - free(sb->title_wrap); - sb->title_wrap = p; + free(sb->title_padding); + sb->title_padding = p; return 0; } @@ -192,7 +195,7 @@ struct libscols_symbols *scols_copy_symbols(const struct libscols_symbols *sb) if (!rc) rc = scols_symbols_set_right(ret, sb->right); if (!rc) - rc = scols_symbols_set_title_wrap(ret, sb->title_wrap); + rc = scols_symbols_set_title_padding(ret, sb->title_padding); if (!rc) return ret; |