aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gizak
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-02-16 20:21:11 +0800
committerFelix Lange <fjl@twurst.com>2017-02-16 20:44:09 +0800
commit2c4455b12aca82ccd29c05c1750c25430867e545 (patch)
tree0beb8c96c7bf6a5a82434ed79218e822927434c3 /vendor/github.com/gizak
parentc8695fae359aa327da9203a57ffaf4f2d47d4370 (diff)
downloaddexon-2c4455b12aca82ccd29c05c1750c25430867e545.tar
dexon-2c4455b12aca82ccd29c05c1750c25430867e545.tar.gz
dexon-2c4455b12aca82ccd29c05c1750c25430867e545.tar.bz2
dexon-2c4455b12aca82ccd29c05c1750c25430867e545.tar.lz
dexon-2c4455b12aca82ccd29c05c1750c25430867e545.tar.xz
dexon-2c4455b12aca82ccd29c05c1750c25430867e545.tar.zst
dexon-2c4455b12aca82ccd29c05c1750c25430867e545.zip
vendor: update dependencies with github.com/kardianos/govendor
Diffstat (limited to 'vendor/github.com/gizak')
-rw-r--r--vendor/github.com/gizak/termui/.gitignore26
-rw-r--r--vendor/github.com/gizak/termui/.travis.yml6
-rw-r--r--vendor/github.com/gizak/termui/README.md1
-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.go2
-rw-r--r--vendor/github.com/gizak/termui/canvas.go2
-rw-r--r--vendor/github.com/gizak/termui/config.py27
-rw-r--r--vendor/github.com/gizak/termui/doc.go2
-rw-r--r--vendor/github.com/gizak/termui/events.go5
-rw-r--r--vendor/github.com/gizak/termui/gauge.go2
-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.go4
-rw-r--r--vendor/github.com/gizak/termui/sparkline.go2
-rw-r--r--vendor/github.com/gizak/termui/table.go163
-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, 117 insertions, 157 deletions
diff --git a/vendor/github.com/gizak/termui/.gitignore b/vendor/github.com/gizak/termui/.gitignore
deleted file mode 100644
index 8b156b020..000000000
--- a/vendor/github.com/gizak/termui/.gitignore
+++ /dev/null
@@ -1,26 +0,0 @@
-# Compiled Object files, Static and Dynamic libs (Shared Objects)
-*.o
-*.a
-*.so
-
-# Folders
-_obj
-_test
-
-# Architecture specific extensions/prefixes
-*.[568vq]
-[568vq].out
-
-*.cgo1.go
-*.cgo2.c
-_cgo_defun.c
-_cgo_gotypes.go
-_cgo_export.*
-
-_testmain.go
-
-*.exe
-*.test
-*.prof
-.DS_Store
-/vendor
diff --git a/vendor/github.com/gizak/termui/.travis.yml b/vendor/github.com/gizak/termui/.travis.yml
deleted file mode 100644
index 206e88740..000000000
--- a/vendor/github.com/gizak/termui/.travis.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-language: go
-
-go:
- - tip
-
-script: go test -v ./ \ No newline at end of file
diff --git a/vendor/github.com/gizak/termui/README.md b/vendor/github.com/gizak/termui/README.md
index 4f3d4a419..d5f3d9a8f 100644
--- a/vendor/github.com/gizak/termui/README.md
+++ b/vendor/github.com/gizak/termui/README.md
@@ -131,6 +131,7 @@ Click image to see the corresponding demo codes.
[<img src="./_example/barchart.png" alt="barchart" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_example/barchart.go)
[<img src="./_example/mbarchart.png" alt="barchart" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_example/mbarchart.go)
[<img src="./_example/sparklines.png" alt="sparklines" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_example/sparklines.go)
+[<img src="./_example/table.png" alt="table" type="image/png" width="45%">](https://github.com/gizak/termui/blob/master/_example/table.go)
## GoDoc
diff --git a/vendor/github.com/gizak/termui/barchart.go b/vendor/github.com/gizak/termui/barchart.go
index 1102f3416..6560c8b14 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 43a4c4039..3e8571bc2 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 aa4a92a7d..6438bf217 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 50480e55b..a4fba77d7 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 cbbab6f50..9e3a97345 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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/canvas.go b/vendor/github.com/gizak/termui/canvas.go
index 911a6787f..6d2513ebd 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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.py b/vendor/github.com/gizak/termui/config.py
index 9152bf517..30fadcf86 100644
--- a/vendor/github.com/gizak/termui/config.py
+++ b/vendor/github.com/gizak/termui/config.py
@@ -1,35 +1,10 @@
#!/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.
+copyright = """// Copyright 2017 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/doc.go b/vendor/github.com/gizak/termui/doc.go
index fdf7dd079..13924eb1f 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 5ba5263c0..16d9bd9cc 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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.
@@ -221,6 +221,7 @@ func findMatch(mux map[string]func(Event), path string) string {
return pattern
}
+
// Remove all existing defined Handlers from the map
func (es *EvtStream) ResetHandlers() {
for Path, _ := range es.Handlers {
@@ -309,7 +310,7 @@ func NewTimerCh(du time.Duration) chan Event {
return t
}
-var DefualtHandler = func(e Event) {
+var DefaultHandler = func(e Event) {
}
var usrEvtCh = make(chan Event)
diff --git a/vendor/github.com/gizak/termui/gauge.go b/vendor/github.com/gizak/termui/gauge.go
index a143111ea..9f6ce3a70 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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/grid.go b/vendor/github.com/gizak/termui/grid.go
index 679b825b7..a95023225 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 5870bac94..18a677043 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 188611496..f7eea28bb 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 fad7a80b1..14897ea0f 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 9c9917ba8..994d3e590 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 492b62d54..ea6635ecc 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 fa6d54ca1..0f91e9713 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 14d6b4d34..29b6d462f 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 a0359af7c..c7d647f31 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 be3bf464e..b9d37d938 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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.
@@ -51,7 +51,7 @@ func Init() error {
DefaultEvtStream.Merge("timer", NewTimerCh(time.Second))
DefaultEvtStream.Merge("custom", usrEvtCh)
- DefaultEvtStream.Handle("/", DefualtHandler)
+ DefaultEvtStream.Handle("/", DefaultHandler)
DefaultEvtStream.Handle("/sys/wnd/resize", func(e Event) {
w := e.Data.(EvtWnd)
Body.Width = w.Width
diff --git a/vendor/github.com/gizak/termui/sparkline.go b/vendor/github.com/gizak/termui/sparkline.go
index e127b52e1..d906e49df 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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
index 319b89701..e3d1bbf30 100644
--- a/vendor/github.com/gizak/termui/table.go
+++ b/vendor/github.com/gizak/termui/table.go
@@ -1,10 +1,32 @@
+// Copyright 2017 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.
+
package termui
import "strings"
-/*
+/* Table is like:
+
+┌Awesome Table ────────────────────────────────────────────────┐
+│ Col0 | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 |
+│──────────────────────────────────────────────────────────────│
+│ Some Item #1 | AAA | 123 | CCCCC | EEEEE | GGGGG | IIIII |
+│──────────────────────────────────────────────────────────────│
+│ Some Item #2 | BBB | 456 | DDDDD | FFFFF | HHHHH | JJJJJ |
+└──────────────────────────────────────────────────────────────┘
+
+Datapoints are a two dimensional array of strings: [][]string
+
+Example:
+ data := [][]string{
+ {"Col0", "Col1", "Col3", "Col4", "Col5", "Col6"},
+ {"Some Item #1", "AAA", "123", "CCCCC", "EEEEE", "GGGGG", "IIIII"},
+ {"Some Item #2", "BBB", "456", "DDDDD", "FFFFF", "HHHHH", "JJJJJ"},
+ }
+
table := termui.NewTable()
- table.Rows = rows
+ table.Rows = data // type [][]string
table.FgColor = termui.ColorWhite
table.BgColor = termui.ColorDefault
table.Height = 7
@@ -14,6 +36,7 @@ import "strings"
table.Border = true
*/
+// Table tracks all the attributes of a Table instance
type Table struct {
Block
Rows [][]string
@@ -22,22 +45,34 @@ type Table struct {
BgColor Attribute
FgColors []Attribute
BgColors []Attribute
- Seperator bool
+ Separator bool
TextAlign Align
}
+// NewTable returns a new Table instance
func NewTable() *Table {
table := &Table{Block: *NewBlock()}
table.FgColor = ColorWhite
table.BgColor = ColorDefault
- table.Seperator = true
+ table.Separator = true
return table
}
-func (table *Table) Analysis() {
+// CellsWidth calculates the width of a cell array and returns an int
+func cellsWidth(cells []Cell) int {
+ width := 0
+ for _, c := range cells {
+ width += c.Width()
+ }
+ return width
+}
+
+// Analysis generates and returns an array of []Cell that represent all columns in the Table
+func (table *Table) Analysis() [][]Cell {
+ var rowCells [][]Cell
length := len(table.Rows)
if length < 1 {
- return
+ return rowCells
}
if len(table.FgColors) == 0 {
@@ -47,121 +82,101 @@ func (table *Table) Analysis() {
table.BgColors = make([]Attribute, len(table.Rows))
}
- row_width := len(table.Rows[0])
- cellWidthes := make([]int, row_width)
+ cellWidths := make([]int, len(table.Rows[0]))
- for index, row := range table.Rows {
- for i, str := range row {
- if cellWidthes[i] < len(str) {
- cellWidthes[i] = len(str)
- }
+ for y, row := range table.Rows {
+ if table.FgColors[y] == 0 {
+ table.FgColors[y] = table.FgColor
}
-
- if table.FgColors[index] == 0 {
- table.FgColors[index] = table.FgColor
+ if table.BgColors[y] == 0 {
+ table.BgColors[y] = table.BgColor
}
-
- if table.BgColors[index] == 0 {
- table.BgColors[index] = table.BgColor
+ for x, str := range row {
+ cells := DefaultTxBuilder.Build(str, table.FgColors[y], table.BgColors[y])
+ cw := cellsWidth(cells)
+ if cellWidths[x] < cw {
+ cellWidths[x] = cw
+ }
+ rowCells = append(rowCells, cells)
}
}
-
- 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
- //}
+ table.CellWidth = cellWidths
+ return rowCells
}
+// SetSize calculates the table size and sets the internal value
func (table *Table) SetSize() {
length := len(table.Rows)
- if table.Seperator {
+ if table.Separator {
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
+ for _, cellWidth := range table.CellWidth {
+ table.Width += cellWidth + 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
+// CalculatePosition ...
+func (table *Table) CalculatePosition(x int, y int, coordinateX *int, coordinateY *int, cellStart *int) {
+ if table.Separator {
+ *coordinateY = table.innerArea.Min.Y + y*2
} else {
- *y_coordibate = table.innerArea.Min.Y + y
+ *coordinateY = table.innerArea.Min.Y + y
}
if x == 0 {
- *cell_beginning = table.innerArea.Min.X
+ *cellStart = table.innerArea.Min.X
} else {
- *cell_beginning += table.CellWidth[x-1] + 3
+ *cellStart += table.CellWidth[x-1] + 3
}
switch table.TextAlign {
case AlignRight:
- *x_coordinate = *cell_beginning + (table.CellWidth[x] - len(table.Rows[y][x])) + 2
+ *coordinateX = *cellStart + (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
+ *coordinateX = *cellStart + (table.CellWidth[x]-len(table.Rows[y][x]))/2 + 2
default:
- *x_coordinate = *cell_beginning + 2
+ *coordinateX = *cellStart + 2
}
}
+// Buffer ...
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
+ rowCells := table.Analysis()
+ pointerX := table.innerArea.Min.X + 2
+ pointerY := table.innerArea.Min.Y
+ borderPointerX := 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)
+ for x := range row {
+ table.CalculatePosition(x, y, &pointerX, &pointerY, &borderPointerX)
+ background := DefaultTxBuilder.Build(strings.Repeat(" ", table.CellWidth[x]+3), table.BgColors[y], table.BgColors[y])
+ cells := rowCells[y*len(row)+x]
+ for i, back := range background {
+ buffer.Set(borderPointerX+i, pointerY, back)
}
- coordinate_x := pointer_x
+ coordinateX := pointerX
for _, printer := range cells {
- buffer.Set(coordinate_x, pointer_y, printer)
- coordinate_x += printer.Width()
+ buffer.Set(coordinateX, pointerY, printer)
+ coordinateX += 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)
+ dividors := DefaultTxBuilder.Build("|", table.FgColors[y], table.BgColors[y])
+ for _, dividor := range dividors {
+ buffer.Set(borderPointerX, pointerY, dividor)
}
}
}
- if table.Seperator {
+ if table.Separator {
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)
+ buffer.Set(i+1, pointerY+1, cell)
}
}
}
diff --git a/vendor/github.com/gizak/termui/textbuilder.go b/vendor/github.com/gizak/termui/textbuilder.go
index 818a40022..12e2055b5 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 9632ae791..21fb3bfb7 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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 f14aa8602..80276bf1f 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 <zack.y.guo@gmail.com>. All rights reserved.
+// Copyright 2017 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.