aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gizak/termui
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gizak/termui')
-rw-r--r--vendor/github.com/gizak/termui/barchart.go2
-rw-r--r--vendor/github.com/gizak/termui/block.go2
-rw-r--r--vendor/github.com/gizak/termui/block_common.go2
-rw-r--r--vendor/github.com/gizak/termui/block_windows.go2
-rw-r--r--vendor/github.com/gizak/termui/buffer.go6
-rw-r--r--vendor/github.com/gizak/termui/canvas.go2
-rwxr-xr-xvendor/github.com/gizak/termui/config26
-rw-r--r--vendor/github.com/gizak/termui/config.py79
-rw-r--r--vendor/github.com/gizak/termui/doc.go2
-rw-r--r--vendor/github.com/gizak/termui/events.go2
-rw-r--r--vendor/github.com/gizak/termui/gauge.go2
-rw-r--r--vendor/github.com/gizak/termui/glide.lock28
-rw-r--r--vendor/github.com/gizak/termui/glide.yaml1
-rw-r--r--vendor/github.com/gizak/termui/grid.go2
-rw-r--r--vendor/github.com/gizak/termui/helper.go2
-rw-r--r--vendor/github.com/gizak/termui/linechart.go2
-rw-r--r--vendor/github.com/gizak/termui/linechart_others.go2
-rw-r--r--vendor/github.com/gizak/termui/linechart_windows.go2
-rw-r--r--vendor/github.com/gizak/termui/list.go2
-rw-r--r--vendor/github.com/gizak/termui/mbarchart.go2
-rw-r--r--vendor/github.com/gizak/termui/par.go2
-rw-r--r--vendor/github.com/gizak/termui/pos.go2
-rw-r--r--vendor/github.com/gizak/termui/render.go33
-rw-r--r--vendor/github.com/gizak/termui/sparkline.go2
-rw-r--r--vendor/github.com/gizak/termui/table.go170
-rw-r--r--vendor/github.com/gizak/termui/textbuilder.go2
-rw-r--r--vendor/github.com/gizak/termui/theme.go2
-rw-r--r--vendor/github.com/gizak/termui/widget.go2
28 files changed, 327 insertions, 58 deletions
diff --git a/vendor/github.com/gizak/termui/barchart.go b/vendor/github.com/gizak/termui/barchart.go
index 9e2a10689..1102f3416 100644
--- a/vendor/github.com/gizak/termui/barchart.go
+++ b/vendor/github.com/gizak/termui/barchart.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/block.go b/vendor/github.com/gizak/termui/block.go
index 418738c8d..43a4c4039 100644
--- a/vendor/github.com/gizak/termui/block.go
+++ b/vendor/github.com/gizak/termui/block.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/block_common.go b/vendor/github.com/gizak/termui/block_common.go
index 0f972cbbd..aa4a92a7d 100644
--- a/vendor/github.com/gizak/termui/block_common.go
+++ b/vendor/github.com/gizak/termui/block_common.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/block_windows.go b/vendor/github.com/gizak/termui/block_windows.go
index 4dbc017de..50480e55b 100644
--- a/vendor/github.com/gizak/termui/block_windows.go
+++ b/vendor/github.com/gizak/termui/block_windows.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/buffer.go b/vendor/github.com/gizak/termui/buffer.go
index 60e77863a..cbbab6f50 100644
--- a/vendor/github.com/gizak/termui/buffer.go
+++ b/vendor/github.com/gizak/termui/buffer.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
@@ -46,7 +46,7 @@ func (b Buffer) Bounds() image.Rectangle {
y0 = p.Y
}
}
- return image.Rect(x0, y0, x1, y1)
+ return image.Rect(x0, y0, x1+1, y1+1)
}
// SetArea assigns a new rect area to Buffer b.
@@ -56,7 +56,7 @@ func (b *Buffer) SetArea(r image.Rectangle) {
}
// Sync sets drawing area to the buffer's bound
-func (b Buffer) Sync() {
+func (b *Buffer) Sync() {
b.SetArea(b.Bounds())
}
diff --git a/vendor/github.com/gizak/termui/canvas.go b/vendor/github.com/gizak/termui/canvas.go
index 4173780f3..911a6787f 100644
--- a/vendor/github.com/gizak/termui/canvas.go
+++ b/vendor/github.com/gizak/termui/canvas.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/config b/vendor/github.com/gizak/termui/config
deleted file mode 100755
index 18fd6a401..000000000
--- a/vendor/github.com/gizak/termui/config
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env perl6
-
-use v6;
-
-my $copyright = '// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
-// Use of this source code is governed by a MIT license that can
-// be found in the LICENSE file.
-
-';
-
-sub MAIN('update-docstr', Str $srcp) {
- if $srcp.IO.f {
- $_ = $srcp.IO.slurp;
- if m/^ \/\/\s Copyright .+? \n\n/ {
- unless ~$/ eq $copyright {
- s/^ \/\/\s Copyright .+? \n\n /$copyright/;
- spurt $srcp, $_;
- say "[updated] doc string for:"~$srcp;
- }
- } else {
- say "[added] doc string for "~$srcp~" (no match found)";
- $_ = $copyright ~ $_;
- spurt $srcp, $_;
- }
- }
-}
diff --git a/vendor/github.com/gizak/termui/config.py b/vendor/github.com/gizak/termui/config.py
new file mode 100644
index 000000000..9152bf517
--- /dev/null
+++ b/vendor/github.com/gizak/termui/config.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+
+# use v6;
+#
+# my $copyright = '// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+# // Use of this source code is governed by a MIT license that can
+# // be found in the LICENSE file.
+#
+# ';
+#
+# sub MAIN('update-docstr', Str $srcp) {
+# if $srcp.IO.f {
+# $_ = $srcp.IO.slurp;
+# if m/^ \/\/\s Copyright .+? \n\n/ {
+# unless ~$/ eq $copyright {
+# s/^ \/\/\s Copyright .+? \n\n /$copyright/;
+# spurt $srcp, $_;
+# say "[updated] doc string for:"~$srcp;
+# }
+# } else {
+# say "[added] doc string for "~$srcp~" (no match found)";
+# $_ = $copyright ~ $_;
+# spurt $srcp, $_;
+# }
+# }
+# }
+
+import re
+import os
+import io
+
+copyright = """// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
+// Use of this source code is governed by a MIT license that can
+// be found in the LICENSE file.
+
+"""
+
+exclude_dirs = [".git", "_docs"]
+exclude_files = []
+include_dirs = [".", "debug", "extra", "test", "_example"]
+
+
+def is_target(fpath):
+ if os.path.splitext(fpath)[-1] == ".go":
+ return True
+ return False
+
+
+def update_copyright(fpath):
+ print("processing " + fpath)
+ f = io.open(fpath, 'r', encoding='utf-8')
+ fstr = f.read()
+ f.close()
+
+ # remove old
+ m = re.search('^// Copyright .+?\r?\n\r?\n', fstr, re.MULTILINE|re.DOTALL)
+ if m:
+ fstr = fstr[m.end():]
+
+ # add new
+ fstr = copyright + fstr
+ f = io.open(fpath, 'w',encoding='utf-8')
+ f.write(fstr)
+ f.close()
+
+
+def main():
+ for d in include_dirs:
+ files = [
+ os.path.join(d, f) for f in os.listdir(d)
+ if os.path.isfile(os.path.join(d, f))
+ ]
+ for f in files:
+ if is_target(f):
+ update_copyright(f)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/vendor/github.com/gizak/termui/doc.go b/vendor/github.com/gizak/termui/doc.go
index 0d7108d30..fdf7dd079 100644
--- a/vendor/github.com/gizak/termui/doc.go
+++ b/vendor/github.com/gizak/termui/doc.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/events.go b/vendor/github.com/gizak/termui/events.go
index 6627f8942..5ba5263c0 100644
--- a/vendor/github.com/gizak/termui/events.go
+++ b/vendor/github.com/gizak/termui/events.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/gauge.go b/vendor/github.com/gizak/termui/gauge.go
index 01af0ea7c..a143111ea 100644
--- a/vendor/github.com/gizak/termui/gauge.go
+++ b/vendor/github.com/gizak/termui/gauge.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/glide.lock b/vendor/github.com/gizak/termui/glide.lock
index 798e944d3..be5952d46 100644
--- a/vendor/github.com/gizak/termui/glide.lock
+++ b/vendor/github.com/gizak/termui/glide.lock
@@ -1,14 +1,30 @@
-hash: 67a478802ee1d122cf1df063c52458d074864900c96a5cc25dc6be4b7638eb1c
-updated: 2016-04-06T21:16:00.849048757-04:00
+hash: 7a754ba100256404a978b2fc8738aee337beb822458e4b6060399fb89ebd215c
+updated: 2016-11-03T17:39:24.323773674-04:00
imports:
+- name: github.com/maruel/panicparse
+ version: ad661195ed0e88491e0f14be6613304e3b1141d6
+ subpackages:
+ - stack
- name: github.com/mattn/go-runewidth
- version: d6bea18f789704b5f83375793155289da36a3c7f
+ version: 737072b4e32b7a5018b4a7125da8d12de90e8045
- name: github.com/mitchellh/go-wordwrap
version: ad45545899c7b13c020ea92b2072220eefad42b8
- name: github.com/nsf/termbox-go
- version: 362329b0aa6447eadd52edd8d660ec1dff470295
+ version: b6acae516ace002cb8105a89024544a1480655a5
- name: golang.org/x/net
- version: af4fee9d05b66edc24197d189e6118f8ebce8c2b
+ version: 569280fa63be4e201b975e5411e30a92178f0118
subpackages:
- websocket
-devImports: []
+testImports:
+- name: github.com/davecgh/go-spew
+ version: 346938d642f2ec3594ed81d874461961cd0faa76
+ subpackages:
+ - spew
+- name: github.com/pmezard/go-difflib
+ version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
+ subpackages:
+ - difflib
+- name: github.com/stretchr/testify
+ version: 976c720a22c8eb4eb6a0b4348ad85ad12491a506
+ subpackages:
+ - assert
diff --git a/vendor/github.com/gizak/termui/glide.yaml b/vendor/github.com/gizak/termui/glide.yaml
index d8e445254..a6812317f 100644
--- a/vendor/github.com/gizak/termui/glide.yaml
+++ b/vendor/github.com/gizak/termui/glide.yaml
@@ -6,3 +6,4 @@ import:
- package: golang.org/x/net
subpackages:
- websocket
+- package: github.com/maruel/panicparse
diff --git a/vendor/github.com/gizak/termui/grid.go b/vendor/github.com/gizak/termui/grid.go
index 364442e02..679b825b7 100644
--- a/vendor/github.com/gizak/termui/grid.go
+++ b/vendor/github.com/gizak/termui/grid.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/helper.go b/vendor/github.com/gizak/termui/helper.go
index 308f6c1db..5870bac94 100644
--- a/vendor/github.com/gizak/termui/helper.go
+++ b/vendor/github.com/gizak/termui/helper.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/linechart.go b/vendor/github.com/gizak/termui/linechart.go
index 81834efdb..188611496 100644
--- a/vendor/github.com/gizak/termui/linechart.go
+++ b/vendor/github.com/gizak/termui/linechart.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/linechart_others.go b/vendor/github.com/gizak/termui/linechart_others.go
index 7e2e66b3e..fad7a80b1 100644
--- a/vendor/github.com/gizak/termui/linechart_others.go
+++ b/vendor/github.com/gizak/termui/linechart_others.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/linechart_windows.go b/vendor/github.com/gizak/termui/linechart_windows.go
index 1478b5ce3..9c9917ba8 100644
--- a/vendor/github.com/gizak/termui/linechart_windows.go
+++ b/vendor/github.com/gizak/termui/linechart_windows.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/list.go b/vendor/github.com/gizak/termui/list.go
index 0029d2622..492b62d54 100644
--- a/vendor/github.com/gizak/termui/list.go
+++ b/vendor/github.com/gizak/termui/list.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/mbarchart.go b/vendor/github.com/gizak/termui/mbarchart.go
index 6828e6533..fa6d54ca1 100644
--- a/vendor/github.com/gizak/termui/mbarchart.go
+++ b/vendor/github.com/gizak/termui/mbarchart.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/par.go b/vendor/github.com/gizak/termui/par.go
index 78bffd091..14d6b4d34 100644
--- a/vendor/github.com/gizak/termui/par.go
+++ b/vendor/github.com/gizak/termui/par.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/pos.go b/vendor/github.com/gizak/termui/pos.go
index 2046dce5a..a0359af7c 100644
--- a/vendor/github.com/gizak/termui/pos.go
+++ b/vendor/github.com/gizak/termui/pos.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/render.go b/vendor/github.com/gizak/termui/render.go
index 36544f063..be3bf464e 100644
--- a/vendor/github.com/gizak/termui/render.go
+++ b/vendor/github.com/gizak/termui/render.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
@@ -6,9 +6,19 @@ package termui
import (
"image"
+ "io"
"sync"
"time"
+ "fmt"
+
+ "os"
+
+ "runtime/debug"
+
+ "bytes"
+
+ "github.com/maruel/panicparse/stack"
tm "github.com/nsf/termbox-go"
)
@@ -89,7 +99,26 @@ func TermHeight() int {
// Render renders all Bufferer in the given order from left to right,
// right could overlap on left ones.
func render(bs ...Bufferer) {
-
+ defer func() {
+ if e := recover(); e != nil {
+ Close()
+ fmt.Fprintf(os.Stderr, "Captured a panic(value=%v) when rendering Bufferer. Exit termui and clean terminal...\nPrint stack trace:\n\n", e)
+ //debug.PrintStack()
+ gs, err := stack.ParseDump(bytes.NewReader(debug.Stack()), os.Stderr)
+ if err != nil {
+ debug.PrintStack()
+ os.Exit(1)
+ }
+ p := &stack.Palette{}
+ buckets := stack.SortBuckets(stack.Bucketize(gs, stack.AnyValue))
+ srcLen, pkgLen := stack.CalcLengths(buckets, false)
+ for _, bucket := range buckets {
+ io.WriteString(os.Stdout, p.BucketHeader(&bucket, false, len(buckets) > 1))
+ io.WriteString(os.Stdout, p.StackLines(&bucket.Signature, srcLen, pkgLen, false))
+ }
+ os.Exit(1)
+ }
+ }()
for _, b := range bs {
buf := b.Buffer()
diff --git a/vendor/github.com/gizak/termui/sparkline.go b/vendor/github.com/gizak/termui/sparkline.go
index 312ad9563..e127b52e1 100644
--- a/vendor/github.com/gizak/termui/sparkline.go
+++ b/vendor/github.com/gizak/termui/sparkline.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/table.go b/vendor/github.com/gizak/termui/table.go
new file mode 100644
index 000000000..319b89701
--- /dev/null
+++ b/vendor/github.com/gizak/termui/table.go
@@ -0,0 +1,170 @@
+package termui
+
+import "strings"
+
+/*
+ table := termui.NewTable()
+ table.Rows = rows
+ table.FgColor = termui.ColorWhite
+ table.BgColor = termui.ColorDefault
+ table.Height = 7
+ table.Width = 62
+ table.Y = 0
+ table.X = 0
+ table.Border = true
+*/
+
+type Table struct {
+ Block
+ Rows [][]string
+ CellWidth []int
+ FgColor Attribute
+ BgColor Attribute
+ FgColors []Attribute
+ BgColors []Attribute
+ Seperator bool
+ TextAlign Align
+}
+
+func NewTable() *Table {
+ table := &Table{Block: *NewBlock()}
+ table.FgColor = ColorWhite
+ table.BgColor = ColorDefault
+ table.Seperator = true
+ return table
+}
+
+func (table *Table) Analysis() {
+ length := len(table.Rows)
+ if length < 1 {
+ return
+ }
+
+ if len(table.FgColors) == 0 {
+ table.FgColors = make([]Attribute, len(table.Rows))
+ }
+ if len(table.BgColors) == 0 {
+ table.BgColors = make([]Attribute, len(table.Rows))
+ }
+
+ row_width := len(table.Rows[0])
+ cellWidthes := make([]int, row_width)
+
+ for index, row := range table.Rows {
+ for i, str := range row {
+ if cellWidthes[i] < len(str) {
+ cellWidthes[i] = len(str)
+ }
+ }
+
+ if table.FgColors[index] == 0 {
+ table.FgColors[index] = table.FgColor
+ }
+
+ if table.BgColors[index] == 0 {
+ table.BgColors[index] = table.BgColor
+ }
+ }
+
+ table.CellWidth = cellWidthes
+
+ //width_sum := 2
+ //for i, width := range cellWidthes {
+ // width_sum += (width + 2)
+ // for u, row := range table.Rows {
+ // switch table.TextAlign {
+ // case "right":
+ // row[i] = fmt.Sprintf(" %*s ", width, table.Rows[u][i])
+ // case "center":
+ // word_width := len(table.Rows[u][i])
+ // offset := (width - word_width) / 2
+ // row[i] = fmt.Sprintf(" %*s ", width, fmt.Sprintf("%-*s", offset+word_width, table.Rows[u][i]))
+ // default: // left
+ // row[i] = fmt.Sprintf(" %-*s ", width, table.Rows[u][i])
+ // }
+ // }
+ //}
+
+ //if table.Width == 0 {
+ // table.Width = width_sum
+ //}
+}
+
+func (table *Table) SetSize() {
+ length := len(table.Rows)
+ if table.Seperator {
+ table.Height = length*2 + 1
+ } else {
+ table.Height = length + 2
+ }
+ table.Width = 2
+ if length != 0 {
+ for _, cell_width := range table.CellWidth {
+ table.Width += cell_width + 3
+ }
+ }
+}
+
+func (table *Table) CalculatePosition(x int, y int, x_coordinate *int, y_coordibate *int, cell_beginning *int) {
+ if table.Seperator {
+ *y_coordibate = table.innerArea.Min.Y + y*2
+ } else {
+ *y_coordibate = table.innerArea.Min.Y + y
+ }
+ if x == 0 {
+ *cell_beginning = table.innerArea.Min.X
+ } else {
+ *cell_beginning += table.CellWidth[x-1] + 3
+ }
+
+ switch table.TextAlign {
+ case AlignRight:
+ *x_coordinate = *cell_beginning + (table.CellWidth[x] - len(table.Rows[y][x])) + 2
+ case AlignCenter:
+ *x_coordinate = *cell_beginning + (table.CellWidth[x]-len(table.Rows[y][x]))/2 + 2
+ default:
+ *x_coordinate = *cell_beginning + 2
+ }
+}
+
+func (table *Table) Buffer() Buffer {
+ buffer := table.Block.Buffer()
+ table.Analysis()
+
+ pointer_x := table.innerArea.Min.X + 2
+ pointer_y := table.innerArea.Min.Y
+ border_pointer_x := table.innerArea.Min.X
+ for y, row := range table.Rows {
+ for x, cell := range row {
+ table.CalculatePosition(x, y, &pointer_x, &pointer_y, &border_pointer_x)
+ backgraound := DefaultTxBuilder.Build(strings.Repeat(" ", table.CellWidth[x]+3), table.BgColors[y], table.BgColors[y])
+ cells := DefaultTxBuilder.Build(cell, table.FgColors[y], table.BgColors[y])
+
+ for i, back := range backgraound {
+ buffer.Set(border_pointer_x+i, pointer_y, back)
+ }
+
+ coordinate_x := pointer_x
+ for _, printer := range cells {
+ buffer.Set(coordinate_x, pointer_y, printer)
+ coordinate_x += printer.Width()
+ }
+
+ if x != 0 {
+ devidors := DefaultTxBuilder.Build("|", table.FgColors[y], table.BgColors[y])
+ for _, devidor := range devidors {
+ buffer.Set(border_pointer_x, pointer_y, devidor)
+ }
+ }
+ }
+
+ if table.Seperator {
+ border := DefaultTxBuilder.Build(strings.Repeat("─", table.Width-2), table.FgColor, table.BgColor)
+ for i, cell := range border {
+ buffer.Set(i+1, pointer_y+1, cell)
+ }
+ }
+ }
+
+ return buffer
+}
diff --git a/vendor/github.com/gizak/termui/textbuilder.go b/vendor/github.com/gizak/termui/textbuilder.go
index 06a019bed..818a40022 100644
--- a/vendor/github.com/gizak/termui/textbuilder.go
+++ b/vendor/github.com/gizak/termui/textbuilder.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/theme.go b/vendor/github.com/gizak/termui/theme.go
index c3ccda559..9632ae791 100644
--- a/vendor/github.com/gizak/termui/theme.go
+++ b/vendor/github.com/gizak/termui/theme.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
diff --git a/vendor/github.com/gizak/termui/widget.go b/vendor/github.com/gizak/termui/widget.go
index 35cf143a3..f14aa8602 100644
--- a/vendor/github.com/gizak/termui/widget.go
+++ b/vendor/github.com/gizak/termui/widget.go
@@ -1,4 +1,4 @@
-// Copyright 2016 Zack Guo <gizak@icloud.com>. All rights reserved.
+// Copyright 2016 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.