]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: add scols_column_add_width()
authorKarel Zak <kzak@redhat.com>
Fri, 30 Sep 2016 09:01:41 +0000 (11:01 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 30 Sep 2016 09:01:41 +0000 (11:01 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/docs/libsmartcols-sections.txt
libsmartcols/src/column.c
libsmartcols/src/libsmartcols.h.in
libsmartcols/src/libsmartcols.sym

index 0c6d23d4690206d1170744a22e410481912ccd25..ee696642a63a5d81a4b604cc78d49e02deff9faf 100644 (file)
@@ -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
index 6f74f76fbfb0898c46f4b5d2c30ce2f4421fe6be..1d32879603652683651ece19ba3595ef600f3729 100644 (file)
@@ -396,6 +396,25 @@ const char *scols_column_get_safechars(const struct libscols_column *cl)
        return cl->safechars;
 }
 
+/**
+ * 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
index d7f1da6b1cdd30ac0126c2b9016a3ff1ddc1da18..4a00fed1bd4100c2c84ce5e8ba5f1aeed3f489a4 100644 (file)
@@ -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);
 
index 930a4f47d0704c1298463740dbd859edb0ba66af..2bf2b4ee4d237fd3e7a8b7869a4dab0e675c924e 100644 (file)
@@ -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;