summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/table_print.c
diff options
context:
space:
mode:
authorKarel Zak2017-01-09 13:28:24 +0100
committerKarel Zak2017-01-09 13:28:24 +0100
commit6ffbd28359104c75015c260b84c804fb893b8620 (patch)
tree1e2a45a83ec2d73c178ec3b2fbf026314dce2e5e /libsmartcols/src/table_print.c
parentMerge branch 'ignatenko/libsmartcols-dead' of https://github.com/ignatenkobra... (diff)
downloadkernel-qcow2-util-linux-6ffbd28359104c75015c260b84c804fb893b8620.tar.gz
kernel-qcow2-util-linux-6ffbd28359104c75015c260b84c804fb893b8620.tar.xz
kernel-qcow2-util-linux-6ffbd28359104c75015c260b84c804fb893b8620.zip
libsmartcols: add scols_cell_get_alignment()
Just to hide that we use cell flags (bitwise operations) to define cell content alignment. The patch also more explicitly specifies the flags in the header file. The alignment is evaluated in the order: right, center, left. The default is left. Note that SCOLS_CELL_FL_* are used for for table title only. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/table_print.c')
-rw-r--r--libsmartcols/src/table_print.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c
index 65f261245..afcbc1647 100644
--- a/libsmartcols/src/table_print.c
+++ b/libsmartcols/src/table_print.c
@@ -782,14 +782,19 @@ static int print_title(struct libscols_table *tb)
goto done;
}
- if (tb->title.flags & SCOLS_CELL_FL_LEFT)
- align = MBS_ALIGN_LEFT;
- else if (tb->title.flags & SCOLS_CELL_FL_RIGHT)
+ switch (scols_cell_get_alignment(&tb->title)) {
+ case SCOLS_CELL_FL_RIGHT:
align = MBS_ALIGN_RIGHT;
- else if (tb->title.flags & SCOLS_CELL_FL_CENTER)
+ break;
+ case SCOLS_CELL_FL_CENTER:
align = MBS_ALIGN_CENTER;
- else
- align = MBS_ALIGN_LEFT; /* default */
+ break;
+ case SCOLS_CELL_FL_LEFT:
+ default:
+ align = MBS_ALIGN_LEFT;
+ break;
+
+ }
/* copy from buf to title and align to width with title_padding */
rc = mbsalign_with_padding(buf, title, titlesz,