From 43a81d5f7009fe164e7027cef81193eb8c71a391 Mon Sep 17 00:00:00 2001 From: Alok Kumar Singh Date: Tue, 14 May 2019 22:05:09 +0530 Subject: [PATCH] Option to disable white spaces in row start --- table.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/table.go b/table.go index 3cf0996..5b7e9b8 100644 --- a/table.go +++ b/table.go @@ -72,6 +72,7 @@ type Table struct { newLine string rowLine bool autoMergeCells bool + trimRowStart bool hdrLine bool borders Border colSize int @@ -225,6 +226,11 @@ func (t *Table) SetAlignment(align int) { t.align = align } +// SetTrimRowStart is used to disable whitespaces in row start +func (t *Table) SetTrimRowStart(allow bool) { + t.trimRowStart = allow +} + func (t *Table) SetColumnAlignment(keys []int) { for _, v := range keys { switch v { @@ -654,9 +660,11 @@ func (t *Table) printRow(columns [][]string, rowIdx int) { for y := 0; y < total; y++ { // Check if border is set - fmt.Fprint(t.out, ConditionString((!t.borders.Left && y == 0), SPACE, t.pColumn)) + if !t.trimRowStart { + fmt.Fprint(t.out, ConditionString((!t.borders.Left && y == 0), SPACE, t.pColumn)) + fmt.Fprintf(t.out, SPACE) + } - fmt.Fprintf(t.out, SPACE) str := columns[y][x] // Embedding escape sequence with column value