summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2013-11-22 14:06:44 +0100
committerKarel Zak2014-03-11 11:35:12 +0100
commit735822963753884202a3a020121c9289752b8306 (patch)
treef7a983eb5116a398add7f78c3ff0a0e5db4880a4 /lib
parentlib/tt: add TT_FL_MAX to fill screen (diff)
downloadkernel-qcow2-util-linux-735822963753884202a3a020121c9289752b8306.tar.gz
kernel-qcow2-util-linux-735822963753884202a3a020121c9289752b8306.tar.xz
kernel-qcow2-util-linux-735822963753884202a3a020121c9289752b8306.zip
lib/tt: add reduce term width functionality
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/tt.c b/lib/tt.c
index b5beb7ad7..3cca4817f 100644
--- a/lib/tt.c
+++ b/lib/tt.c
@@ -239,6 +239,17 @@ void tt_set_stream(struct tt *tb, FILE *out)
tb->out = out;
}
+/*
+ * Reduce terminal size, the final table size will be
+ * termwidth - termreduce.
+ */
+void tt_set_termreduce(struct tt *tb, size_t re)
+{
+ if (!tb)
+ return;
+ tb->termreduce = re;
+}
+
size_t tb_get_nlines(struct tt *tb)
{
struct list_head *p;
@@ -943,6 +954,8 @@ int tt_print_table(struct tt *tb)
tb->termwidth = get_terminal_width();
if (tb->termwidth <= 0)
tb->termwidth = 80;
+
+ tb->termwidth -= tb->termreduce;
}
line_sz = tb->termwidth;