dovecot-2.0: doveadm: Use actual terminal width for table format...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jun 12 03:54:56 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/2f3ce92f53ff
changeset: 11534:2f3ce92f53ff
user: Timo Sirainen <tss at iki.fi>
date: Sat Jun 12 01:54:53 2010 +0100
description:
doveadm: Use actual terminal width for table formatter if possible.
diffstat:
src/doveadm/doveadm-print-table.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diffs (35 lines):
diff -r f35949b56863 -r 2f3ce92f53ff src/doveadm/doveadm-print-table.c
--- a/src/doveadm/doveadm-print-table.c Sat Jun 12 01:49:06 2010 +0100
+++ b/src/doveadm/doveadm-print-table.c Sat Jun 12 01:54:53 2010 +0100
@@ -5,8 +5,11 @@
#include "doveadm-print-private.h"
#include <stdio.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
#define DEFAULT_COLUMNS 80
+#define MIN_COLUMNS 30
#define MAX_BUFFER_LINES 100
struct doveadm_print_table_header {
@@ -164,6 +167,7 @@
static void doveadm_print_table_init(void)
{
pool_t pool;
+ struct ttysize ts;
pool = pool_alloconly_create("doveadm print table", 1024);
ctx = p_new(pool, struct doveadm_print_table_context, 1);
@@ -171,6 +175,11 @@
p_array_init(&ctx->headers, pool, 16);
i_array_init(&ctx->buffered_values, 64);
ctx->columns = DEFAULT_COLUMNS;
+
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ts) == 0) {
+ ctx->columns = ts.ts_cols < MIN_COLUMNS ?
+ MIN_COLUMNS : ts.ts_cols;
+ }
}
static void doveadm_print_table_deinit(void)
More information about the dovecot-cvs
mailing list