mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add y pos scrolling to expanded view
This commit is contained in:
parent
8327406069
commit
12fa716825
@ -18,6 +18,7 @@ type Expanded struct {
|
||||
Cpu *Cpu
|
||||
Mem *Mem
|
||||
IO *IO
|
||||
X, Y int
|
||||
Width int
|
||||
}
|
||||
|
||||
@ -35,14 +36,25 @@ func NewExpanded(id string) *Expanded {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Expanded) SetWidth(w int) {
|
||||
e.Width = w
|
||||
func (e *Expanded) Up() {
|
||||
if e.Y < 0 {
|
||||
e.Y++
|
||||
e.Align()
|
||||
ui.Render(e)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Expanded) SetMeta(k, v string) {
|
||||
e.Info.Set(k, v)
|
||||
func (e *Expanded) Down() {
|
||||
if e.Y > (ui.TermHeight() - e.GetHeight()) {
|
||||
e.Y--
|
||||
e.Align()
|
||||
ui.Render(e)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Expanded) SetWidth(w int) { e.Width = w }
|
||||
func (e *Expanded) SetMeta(k, v string) { e.Info.Set(k, v) }
|
||||
|
||||
func (e *Expanded) SetMetrics(m metrics.Metrics) {
|
||||
e.Cpu.Update(m.CPUUtil)
|
||||
e.Net.Update(m.NetRx, m.NetTx)
|
||||
@ -50,12 +62,28 @@ func (e *Expanded) SetMetrics(m metrics.Metrics) {
|
||||
e.IO.Update(m.IOBytesRead, m.IOBytesWrite)
|
||||
}
|
||||
|
||||
// Return total column height
|
||||
func (e *Expanded) GetHeight() (h int) {
|
||||
h += e.Info.Height
|
||||
h += e.Net.Height
|
||||
h += e.Cpu.Height
|
||||
h += e.Mem.Height
|
||||
h += e.IO.Height
|
||||
return h
|
||||
}
|
||||
|
||||
func (e *Expanded) Align() {
|
||||
y := 0
|
||||
// reset offset if needed
|
||||
if e.GetHeight() <= ui.TermHeight() {
|
||||
e.Y = 0
|
||||
}
|
||||
|
||||
y := e.Y
|
||||
for _, i := range e.all() {
|
||||
i.SetY(y)
|
||||
y += i.GetHeight()
|
||||
}
|
||||
|
||||
if e.Width > colWidth[0] {
|
||||
colWidth[1] = e.Width - (colWidth[0] + 1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user