summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-04-21 21:02:37 -0700
committerCaleb Bassi <calebjbassi@gmail.com>2018-04-21 21:02:37 -0700
commit8505b9c2404c5cc39c50fb036bc5e234a42eec25 (patch)
tree62fa722f0c1a9df92ff4c87635de27eff6bd4c87
parentba84728600e79981d78d6e47d41bff57b555604f (diff)
Fix column spacing issues1.2.14
-rw-r--r--Gopkg.lock2
-rw-r--r--vendor/github.com/cjbassi/termui/README.md2
-rw-r--r--vendor/github.com/cjbassi/termui/colors.go34
-rw-r--r--vendor/github.com/cjbassi/termui/table.go30
-rw-r--r--widgets/proc.go15
5 files changed, 35 insertions, 48 deletions
diff --git a/Gopkg.lock b/Gopkg.lock
index 2ee7a27..0cc5818 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -17,7 +17,7 @@
branch = "master"
name = "github.com/cjbassi/termui"
packages = ["."]
- revision = "39b79d4cffc860780782f8ca6cca4bbb9d38bbf2"
+ revision = "75525ee19c41f52324024b7a2bf31edcd1428494"
[[projects]]
branch = "master"
diff --git a/vendor/github.com/cjbassi/termui/README.md b/vendor/github.com/cjbassi/termui/README.md
index 8b8e291..6ac814c 100644
--- a/vendor/github.com/cjbassi/termui/README.md
+++ b/vendor/github.com/cjbassi/termui/README.md
@@ -5,7 +5,7 @@ A fork of [termui](https://github.com/gizak/termui) with a lot of code cleanup a
You can see an implementation/example usage of this library [here](https://github.com/cjbassi/gotop).
Some usage improvements include:
-* better event/keypress names
+* better event/key-combo names
* more convenient event handling function
* 256 colors
* better grid system
diff --git a/vendor/github.com/cjbassi/termui/colors.go b/vendor/github.com/cjbassi/termui/colors.go
index 3af2469..7913a67 100644
--- a/vendor/github.com/cjbassi/termui/colors.go
+++ b/vendor/github.com/cjbassi/termui/colors.go
@@ -13,25 +13,6 @@ const (
AttrReverse
)
-// Theme is assigned to the current theme.
-var Theme = DefaultTheme
-
-// DefaultTheme implements a generic set of colors to use by default.
-var DefaultTheme = Colorscheme{
- Fg: 7,
- Bg: -1,
-
- LabelFg: 7,
- LabelBg: -1,
- BorderFg: 6,
- BorderBg: -1,
-
- Sparkline: 4,
- LineGraph: 0,
- TableCursor: 4,
- GaugeColor: 7,
-}
-
// A Colorscheme represents the current look-and-feel of the dashboard.
type Colorscheme struct {
Fg Color
@@ -47,3 +28,18 @@ type Colorscheme struct {
TableCursor Color
GaugeColor Color
}
+
+var Theme = Colorscheme{
+ Fg: 7,
+ Bg: -1,
+
+ LabelFg: 7,
+ LabelBg: -1,
+ BorderFg: 6,
+ BorderBg: -1,
+
+ Sparkline: 4,
+ LineGraph: 0,
+ TableCursor: 4,
+ GaugeColor: 7,
+}
diff --git a/vendor/github.com/cjbassi/termui/table.go b/vendor/github.com/cjbassi/termui/table.go
index 1e962a6..816363a 100644
--- a/vendor/github.com/cjbassi/termui/table.go
+++ b/vendor/github.com/cjbassi/termui/table.go
@@ -8,17 +8,21 @@ import (
// Table tracks all the attributes of a Table instance
type Table struct {
*Block
- Header []string
- Rows [][]string
- ColWidths []int
- CellXPos []int // column position
- Gap int // gap between columns
- Cursor Color
+
+ Header []string
+ Rows [][]string
+
+ ColWidths []int
+ CellXPos []int // column position
+ ColResizer func() // for widgets that inherit a Table and want to overload the ColResize method
+ Gap int // gap between columns
+
+ Cursor Color
+
UniqueCol int // the column used to identify the selected item
SelectedItem string // used to keep the cursor on the correct item if the data changes
SelectedRow int
- TopRow int // used to indicate where in the table we are scrolled at
- ColResizer func() // for widgets that inherit a Table and want to overload the ColResize method
+ TopRow int // used to indicate where in the table we are scrolled at
}
// NewTable returns a new Table instance
@@ -63,9 +67,9 @@ func (self *Table) Buffer() *Buffer {
for i, h := range self.Header {
width := self.ColWidths[i]
if width == 0 {
- break
+ continue
}
- h = MaxString(h, self.X-6)
+ h = MaxString(h, self.X-self.CellXPos[i])
buf.SetString(self.CellXPos[i], 1, h, self.Fg|AttrBold, self.Bg)
}
@@ -89,7 +93,7 @@ func (self *Table) Buffer() *Buffer {
bg = self.Cursor
for _, width := range self.ColWidths {
if width == 0 {
- break
+ continue
}
buf.SetString(1, y, strings.Repeat(" ", self.X), self.Fg, bg)
}
@@ -100,9 +104,9 @@ func (self *Table) Buffer() *Buffer {
// prints each col of the row
for i, width := range self.ColWidths {
if width == 0 {
- break
+ continue
}
- r := MaxString(row[i], self.X-6)
+ r := MaxString(row[i], self.X-self.CellXPos[i])
buf.SetString(self.CellXPos[i], y, r, self.Fg, bg)
}
}
diff --git a/widgets/proc.go b/widgets/proc.go
index d521fcc..a322b88 100644
--- a/widgets/proc.go
+++ b/widgets/proc.go
@@ -8,22 +8,15 @@ import (
"time"
ui "github.com/cjbassi/termui"
- "github.com/mattn/go-runewidth"
psCPU "github.com/shirou/gopsutil/cpu"
psProc "github.com/shirou/gopsutil/process"
)
-var arrowWidth int
-
const (
UP = "▲"
DOWN = "▼"
)
-func init() {
- arrowWidth = runewidth.StringWidth(UP)
-}
-
// Process represents each process.
type Process struct {
PID int32
@@ -137,13 +130,7 @@ func (self *Proc) Sort() {
func (self *Proc) ColResize() {
copy(self.ColWidths, self.DefaultColWidths)
- // calculate gap size based on total width
self.Gap = 3
- if self.X < 50 {
- self.Gap = 1
- } else if self.X < 75 {
- self.Gap = 2
- }
self.CellXPos = []int{
self.Gap,
@@ -163,7 +150,7 @@ func (self *Proc) ColResize() {
self.ColWidths[2] = 0
self.ColWidths[3] = 0
} else if self.X < rowWidth {
- self.CellXPos[2] = self.CellXPos[3] - 1
+ self.CellXPos[2] = self.CellXPos[3]
self.ColWidths[3] = 0
}
}