diff options
author | Karel Zak | 2016-09-26 11:20:07 +0200 |
---|---|---|
committer | Karel Zak | 2016-09-26 11:20:07 +0200 |
commit | 949ea05f1af647834db24b9172ac006488d2e4f4 (patch) | |
tree | 0e735393ebe57f1f53cab8da3288b96fcc756f27 /libsmartcols/src/libsmartcols.h.in | |
parent | libsmartcols: (docs) add missing functions (diff) | |
download | kernel-qcow2-util-linux-949ea05f1af647834db24b9172ac006488d2e4f4.tar.gz kernel-qcow2-util-linux-949ea05f1af647834db24b9172ac006488d2e4f4.tar.xz kernel-qcow2-util-linux-949ea05f1af647834db24b9172ac006488d2e4f4.zip |
libsmartcols: support custom wrap and remove SCOLS_FL_WRAPNL
This new API provides full control on multi-line cells, you can wrap
text by new lines (build-in support) or by another way (after words,
commas, etc.) Changes:
* new scols_column_set_wrapfunc() sets pointers to two callback functions
1/ chunksize() - returns largest data chunk size; used when we
calculate columns width
2/ nextchunk() - terminate the current chunk and returns pointer to
the next; used when we print data
* remove SCOLS_FL_WRAPNL and add new functions scols_wrapnl_chunksize()
and scols_wrapnl_nextchunk() to provide build-in functionality to
wrap cells on \n
* remove scols_column_is_wrapnl() add scols_column_is_customwrap()
(returns true if custom wrap functions are defined)
* add scols_column_set_safechars() and scols_column_get_safechars() to
allow to control output encoding, safe chars are not encoded by \xFOO
* modify "fromfile" test code to use build-in scols_wrapnl_* callbacks
for "wrapnl" tests
* add new function scols_column_get_table()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/libsmartcols.h.in')
-rw-r--r-- | libsmartcols/src/libsmartcols.h.in | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libsmartcols/src/libsmartcols.h.in b/libsmartcols/src/libsmartcols.h.in index 22cab64a1..d6ae91f60 100644 --- a/libsmartcols/src/libsmartcols.h.in +++ b/libsmartcols/src/libsmartcols.h.in @@ -84,8 +84,7 @@ enum { SCOLS_FL_STRICTWIDTH = (1 << 3), /* don't reduce width if column is empty */ SCOLS_FL_NOEXTREMES = (1 << 4), /* ignore extreme fields when count column width*/ SCOLS_FL_HIDDEN = (1 << 5), /* maintain data, but don't print */ - SCOLS_FL_WRAP = (1 << 6), /* wrap long lines to multi-line cells */ - SCOLS_FL_WRAPNL = (1 << 7) /* wrap based on '\n' char */ + SCOLS_FL_WRAP = (1 << 6) /* wrap long lines to multi-line cells */ }; /* @@ -146,7 +145,10 @@ extern int scols_column_is_strict_width(const struct libscols_column *cl); extern int scols_column_is_hidden(const struct libscols_column *cl); extern int scols_column_is_noextremes(const struct libscols_column *cl); extern int scols_column_is_wrap(const struct libscols_column *cl); -extern int scols_column_is_wrapnl(const struct libscols_column *cl); +extern int scols_column_is_customwrap(const struct libscols_column *cl); + +extern int scols_column_set_safechars(struct libscols_column *cl, const char *safe); +extern const char *scols_column_get_safechars(const struct libscols_column *cl); extern int scols_column_set_flags(struct libscols_column *cl, int flags); extern int scols_column_get_flags(const struct libscols_column *cl); @@ -159,12 +161,23 @@ extern double scols_column_get_whint(const struct libscols_column *cl); extern struct libscols_cell *scols_column_get_header(struct libscols_column *cl); extern int scols_column_set_color(struct libscols_column *cl, const char *color); extern const char *scols_column_get_color(const struct libscols_column *cl); +extern struct libscols_table *scols_column_get_table(struct libscols_column *cl); extern int scols_column_set_cmpfunc(struct libscols_column *cl, int (*cmp)(struct libscols_cell *a, struct libscols_cell *b, void *), void *data); +extern int scols_column_set_wrapfunc(struct libscols_column *cl, + size_t (*wrap_chunksize)(const struct libscols_column *, + const char *, void *), + char * (*wrap_nextchunk)(const struct libscols_column *, + char *, void *), + void *data); + +extern char *scols_wrapnl_nextchunk(const struct libscols_column *cl, char *data, void *userdata); +extern size_t scols_wrapnl_chunksize(const struct libscols_column *cl, const char *data, void *userdata); + /* line.c */ extern struct libscols_line *scols_new_line(void); extern void scols_ref_line(struct libscols_line *ln); |