aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2016-09-30 11:01:41 +0200
committerKarel Zak <kzak@redhat.com>2016-09-30 11:01:41 +0200
commit82053f5e3d4cedcbe6fc61ee1e5e39d0db8a0f8f (patch)
tree94fbb13c94b81fd71cdb489f15e04aaa9abe8cfc
parent9abc8232404a20c61f02c2b16f864ddec18e42e8 (diff)
downloadutil-linux-82053f5e3d4cedcbe6fc61ee1e5e39d0db8a0f8f.tar.gz
libsmartcols: add scols_column_add_width()
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libsmartcols/docs/libsmartcols-sections.txt1
-rw-r--r--libsmartcols/src/column.c19
-rw-r--r--libsmartcols/src/libsmartcols.h.in2
-rw-r--r--libsmartcols/src/libsmartcols.sym1
4 files changed, 23 insertions, 0 deletions
diff --git a/libsmartcols/docs/libsmartcols-sections.txt b/libsmartcols/docs/libsmartcols-sections.txt
index 0c6d23d469..ee696642a6 100644
--- a/libsmartcols/docs/libsmartcols-sections.txt
+++ b/libsmartcols/docs/libsmartcols-sections.txt
@@ -24,6 +24,7 @@ scols_column_get_header
scols_column_get_safechars
scols_column_get_table
scols_column_get_whint
+scols_column_get_width
scols_column_is_customwrap
scols_column_is_hidden
scols_column_is_noextremes
diff --git a/libsmartcols/src/column.c b/libsmartcols/src/column.c
index 6f74f76fbf..1d32879603 100644
--- a/libsmartcols/src/column.c
+++ b/libsmartcols/src/column.c
@@ -397,6 +397,25 @@ const char *scols_column_get_safechars(const struct libscols_column *cl)
}
/**
+ * scols_column_get_width:
+ * @cl: a pointer to a struct libscols_column instance
+ *
+ * Important note: the column width is unknown until library starts printing
+ * (width is calculated before printing). The function is usable for example in
+ * nextchunk() callback specified by scols_column_set_wrapfunc().
+ *
+ * See also scols_column_get_whint(), it returns wanted size (!= final size).
+ *
+ * Returns: column width
+ *
+ * Since: 2.29
+ */
+size_t scols_column_get_width(const struct libscols_column *cl)
+{
+ return cl->width;
+}
+
+/**
* scols_column_is_hidden:
* @cl: a pointer to a struct libscols_column instance
*
diff --git a/libsmartcols/src/libsmartcols.h.in b/libsmartcols/src/libsmartcols.h.in
index d7f1da6b1c..4a00fed1bd 100644
--- a/libsmartcols/src/libsmartcols.h.in
+++ b/libsmartcols/src/libsmartcols.h.in
@@ -147,6 +147,8 @@ 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_customwrap(const struct libscols_column *cl);
+extern size_t scols_column_get_width(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);
diff --git a/libsmartcols/src/libsmartcols.sym b/libsmartcols/src/libsmartcols.sym
index 930a4f47d0..2bf2b4ee4d 100644
--- a/libsmartcols/src/libsmartcols.sym
+++ b/libsmartcols/src/libsmartcols.sym
@@ -140,6 +140,7 @@ SMARTCOLS_2.29 {
global:
scols_column_get_safechars;
scols_column_get_table;
+ scols_column_get_width;
scols_column_is_customwrap;
scols_column_set_safechars;
scols_column_set_wrapfunc;