add static width for specific columns

This commit is contained in:
Bradley Cicenas
2017-03-12 09:58:56 +00:00
parent 77c3d00e67
commit 2134110224
3 changed files with 33 additions and 15 deletions

View File

@@ -9,10 +9,29 @@ import (
const colSpacing = 1
// Calculate per-column width, given total width and number of items
func calcWidth(width, items int) int {
spacing := colSpacing * items
return (width - statusWidth - spacing) / items
// per-column width. 0 == auto width
var colWidths = []int{
3, // status
0, // name
0, // cid
0, // cpu
0, // memory
0, // net
0, // io
4, // pids
}
// Calculate per-column width, given total width
func calcWidth(width int) int {
spacing := colSpacing * len(colWidths)
var staticCols int
for _, w := range colWidths {
width -= w
if w == 0 {
staticCols += 1
}
}
return (width - spacing) / staticCols
}
func centerParText(p *ui.Par) {