mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 23:26:45 +08:00
fix panic on row removal
This commit is contained in:
@@ -20,8 +20,11 @@ func NewCompactGrid() *CompactGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cg *CompactGrid) Align() {
|
func (cg *CompactGrid) Align() {
|
||||||
// update row ypos, width recursively
|
|
||||||
y := cg.Y
|
y := cg.Y
|
||||||
|
if cg.Offset >= len(cg.Rows) {
|
||||||
|
cg.Offset = 0
|
||||||
|
}
|
||||||
|
// update row ypos, width recursively
|
||||||
for _, r := range cg.pageRows() {
|
for _, r := range cg.pageRows() {
|
||||||
r.SetY(y)
|
r.SetY(y)
|
||||||
y += r.GetHeight()
|
y += r.GetHeight()
|
||||||
@@ -30,7 +33,7 @@ func (cg *CompactGrid) Align() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cg *CompactGrid) Clear() { cg.Rows = []ui.GridBufferer{} }
|
func (cg *CompactGrid) Clear() { cg.Rows = []ui.GridBufferer{} }
|
||||||
func (cg *CompactGrid) GetHeight() int { return len(cg.Rows) }
|
func (cg *CompactGrid) GetHeight() int { return len(cg.Rows) + header.Height }
|
||||||
func (cg *CompactGrid) SetX(x int) { cg.X = x }
|
func (cg *CompactGrid) SetX(x int) { cg.X = x }
|
||||||
func (cg *CompactGrid) SetY(y int) { cg.Y = y }
|
func (cg *CompactGrid) SetY(y int) { cg.Y = y }
|
||||||
func (cg *CompactGrid) SetWidth(w int) { cg.Width = w }
|
func (cg *CompactGrid) SetWidth(w int) { cg.Width = w }
|
||||||
|
|||||||
Reference in New Issue
Block a user