diff options
author | Karel Zak | 2017-04-03 14:43:13 +0200 |
---|---|---|
committer | Karel Zak | 2017-05-02 12:18:00 +0200 |
commit | c728e00012abe988d085f60d0325deb1654eaa07 (patch) | |
tree | 20594ea6a63a9779648f854447c12fd1f3994742 /text-utils/column.c | |
parent | column: add support for trees (diff) | |
download | kernel-qcow2-util-linux-c728e00012abe988d085f60d0325deb1654eaa07.tar.gz kernel-qcow2-util-linux-c728e00012abe988d085f60d0325deb1654eaa07.tar.xz kernel-qcow2-util-linux-c728e00012abe988d085f60d0325deb1654eaa07.zip |
column: use NOEXTREMES for the last column
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r-- | text-utils/column.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/text-utils/column.c b/text-utils/column.c index d618978f4..3b582ca1d 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -230,6 +230,24 @@ static struct libscols_column *string_to_column(struct column_control *ctl, cons return scols_table_get_column(ctl->tab, colnum); } +static struct libscols_column *get_last_visible_column(struct column_control *ctl) +{ + struct libscols_iter *itr; + struct libscols_column *cl, *last = NULL; + + itr = scols_new_iter(SCOLS_ITER_FORWARD); + if (!itr) + err_oom(); + + while (scols_table_next_column(ctl->tab, itr, &cl) == 0) { + if (scols_column_get_flags(cl) & SCOLS_FL_HIDDEN) + continue; + last = cl; + } + + scols_free_iter(itr); + return last; +} static int column_set_flag(struct libscols_column *cl, int fl) { @@ -344,6 +362,12 @@ static void modify_table(struct column_control *ctl) apply_columnflag_from_list(ctl, ctl->tab_colhide, SCOLS_FL_HIDDEN , _("failed to parse --table-hide list")); + if (!ctl->tab_colnoextrem) { + struct libscols_column *cl = get_last_visible_column(ctl); + if (cl) + column_set_flag(cl, SCOLS_FL_NOEXTREMES); + } + if (ctl->tree) create_tree(ctl); |