mirror of
https://github.com/cjbassi/gotop.git
synced 2025-05-03 22:17:15 +08:00
Fix column sizing after terminal shrinks
This commit is contained in:
parent
4da1e467d2
commit
5135d62cbe
@ -34,13 +34,14 @@ type Process struct {
|
|||||||
|
|
||||||
type Proc struct {
|
type Proc struct {
|
||||||
*ui.Table
|
*ui.Table
|
||||||
cpuCount int
|
cpuCount int
|
||||||
interval time.Duration
|
interval time.Duration
|
||||||
sortMethod string
|
sortMethod string
|
||||||
groupedProcs []Process
|
groupedProcs []Process
|
||||||
ungroupedProcs []Process
|
ungroupedProcs []Process
|
||||||
group bool
|
group bool
|
||||||
KeyPressed chan bool
|
KeyPressed chan bool
|
||||||
|
DefaultColWidths []int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProc(keyPressed chan bool) *Proc {
|
func NewProc(keyPressed chan bool) *Proc {
|
||||||
@ -53,9 +54,10 @@ func NewProc(keyPressed chan bool) *Proc {
|
|||||||
group: true,
|
group: true,
|
||||||
KeyPressed: keyPressed,
|
KeyPressed: keyPressed,
|
||||||
}
|
}
|
||||||
self.ColResizer = self.ColResize
|
|
||||||
self.Label = "Process List"
|
self.Label = "Process List"
|
||||||
self.ColWidths = []int{5, 10, 4, 4}
|
self.ColResizer = self.ColResize
|
||||||
|
self.DefaultColWidths = []int{5, 10, 4, 4}
|
||||||
|
self.ColWidths = make([]int, 4)
|
||||||
|
|
||||||
self.UniqueCol = 0
|
self.UniqueCol = 0
|
||||||
if self.group {
|
if self.group {
|
||||||
@ -133,6 +135,8 @@ func (self *Proc) Sort() {
|
|||||||
|
|
||||||
// ColResize overrides the default ColResize in the termui table.
|
// ColResize overrides the default ColResize in the termui table.
|
||||||
func (self *Proc) ColResize() {
|
func (self *Proc) ColResize() {
|
||||||
|
copy(self.ColWidths, self.DefaultColWidths)
|
||||||
|
|
||||||
// calculate gap size based on total width
|
// calculate gap size based on total width
|
||||||
self.Gap = 3
|
self.Gap = 3
|
||||||
if self.X < 50 {
|
if self.X < 50 {
|
||||||
@ -159,7 +163,7 @@ func (self *Proc) ColResize() {
|
|||||||
self.ColWidths[2] = 0
|
self.ColWidths[2] = 0
|
||||||
self.ColWidths[3] = 0
|
self.ColWidths[3] = 0
|
||||||
} else if self.X < rowWidth {
|
} else if self.X < rowWidth {
|
||||||
self.CellXPos[2] = self.CellXPos[3]
|
self.CellXPos[2] = self.CellXPos[3] - 1
|
||||||
self.ColWidths[3] = 0
|
self.ColWidths[3] = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user