Fix statusbar not showing (Close #98)
This commit is contained in:
parent
93d631ef67
commit
95b6665026
43
main.go
43
main.go
@ -58,6 +58,7 @@ var (
|
|||||||
temp *w.Temp
|
temp *w.Temp
|
||||||
help *w.HelpMenu
|
help *w.HelpMenu
|
||||||
grid *ui.Grid
|
grid *ui.Grid
|
||||||
|
bar *w.StatusBar
|
||||||
)
|
)
|
||||||
|
|
||||||
func cliArguments() error {
|
func cliArguments() error {
|
||||||
@ -154,50 +155,37 @@ func getCustomColorscheme(name string) (colorschemes.Colorscheme, error) {
|
|||||||
func setupGrid() {
|
func setupGrid() {
|
||||||
grid = ui.NewGrid()
|
grid = ui.NewGrid()
|
||||||
|
|
||||||
var barRow interface{}
|
|
||||||
if minimalMode {
|
if minimalMode {
|
||||||
rowHeight := 1.0 / 2
|
|
||||||
if statusbar {
|
|
||||||
rowHeight = 50.0 / 101
|
|
||||||
barRow = ui.NewRow(1.0/101, w.NewStatusBar())
|
|
||||||
}
|
|
||||||
grid.Set(
|
grid.Set(
|
||||||
ui.NewRow(rowHeight, cpu),
|
ui.NewRow(1.0/2, cpu),
|
||||||
ui.NewRow(rowHeight,
|
ui.NewRow(1.0/2,
|
||||||
ui.NewCol(1.0/2, mem),
|
ui.NewCol(1.0/2, mem),
|
||||||
ui.NewCol(1.0/2, proc),
|
ui.NewCol(1.0/2, proc),
|
||||||
),
|
),
|
||||||
barRow,
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
rowHeight := 1.0 / 3
|
|
||||||
if statusbar {
|
|
||||||
rowHeight = 50.0 / 151
|
|
||||||
barRow = ui.NewRow(1.0/151, w.NewStatusBar())
|
|
||||||
}
|
|
||||||
var cpuRow ui.GridItem
|
var cpuRow ui.GridItem
|
||||||
if battery {
|
if battery {
|
||||||
cpuRow = ui.NewRow(rowHeight,
|
cpuRow = ui.NewRow(1.0/3,
|
||||||
ui.NewCol(2.0/3, cpu),
|
ui.NewCol(2.0/3, cpu),
|
||||||
ui.NewCol(1.0/3, batt),
|
ui.NewCol(1.0/3, batt),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
cpuRow = ui.NewRow(rowHeight, cpu)
|
cpuRow = ui.NewRow(1.0/3, cpu)
|
||||||
}
|
}
|
||||||
grid.Set(
|
grid.Set(
|
||||||
cpuRow,
|
cpuRow,
|
||||||
ui.NewRow(rowHeight,
|
ui.NewRow(1.0/3,
|
||||||
ui.NewCol(1.0/3,
|
ui.NewCol(1.0/3,
|
||||||
ui.NewRow(1.0/2, disk),
|
ui.NewRow(1.0/2, disk),
|
||||||
ui.NewRow(1.0/2, temp),
|
ui.NewRow(1.0/2, temp),
|
||||||
),
|
),
|
||||||
ui.NewCol(2.0/3, mem),
|
ui.NewCol(2.0/3, mem),
|
||||||
),
|
),
|
||||||
ui.NewRow(rowHeight,
|
ui.NewRow(1.0/3,
|
||||||
ui.NewCol(1.0/2, net),
|
ui.NewCol(1.0/2, net),
|
||||||
ui.NewCol(1.0/2, proc),
|
ui.NewCol(1.0/2, proc),
|
||||||
),
|
),
|
||||||
barRow,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,6 +260,9 @@ func initWidgets() {
|
|||||||
disk = w.NewDisk(&renderLock)
|
disk = w.NewDisk(&renderLock)
|
||||||
temp = w.NewTemp(&renderLock, fahrenheit)
|
temp = w.NewTemp(&renderLock, fahrenheit)
|
||||||
}
|
}
|
||||||
|
if statusbar {
|
||||||
|
bar = w.NewStatusBar()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func render(drawable ...ui.Drawable) {
|
func render(drawable ...ui.Drawable) {
|
||||||
@ -307,8 +298,13 @@ func eventLoop() {
|
|||||||
helpVisible = !helpVisible
|
helpVisible = !helpVisible
|
||||||
case "<Resize>":
|
case "<Resize>":
|
||||||
payload := e.Payload.(ui.Resize)
|
payload := e.Payload.(ui.Resize)
|
||||||
|
if statusbar {
|
||||||
|
grid.SetRect(0, 0, payload.Width, payload.Height-1)
|
||||||
|
} else {
|
||||||
grid.SetRect(0, 0, payload.Width, payload.Height)
|
grid.SetRect(0, 0, payload.Width, payload.Height)
|
||||||
|
}
|
||||||
help.Resize(payload.Width, payload.Height)
|
help.Resize(payload.Width, payload.Height)
|
||||||
|
bar.SetRect(0, payload.Height-1, payload.Width, payload.Height)
|
||||||
ui.Clear()
|
ui.Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,6 +337,7 @@ func eventLoop() {
|
|||||||
}
|
}
|
||||||
case "<Resize>":
|
case "<Resize>":
|
||||||
render(grid)
|
render(grid)
|
||||||
|
render(bar)
|
||||||
case "<MouseLeft>":
|
case "<MouseLeft>":
|
||||||
payload := e.Payload.(ui.Mouse)
|
payload := e.Payload.(ui.Mouse)
|
||||||
proc.Click(payload.X, payload.Y)
|
proc.Click(payload.X, payload.Y)
|
||||||
@ -441,10 +438,18 @@ func main() {
|
|||||||
setupGrid()
|
setupGrid()
|
||||||
|
|
||||||
termWidth, termHeight := ui.TerminalDimensions()
|
termWidth, termHeight := ui.TerminalDimensions()
|
||||||
|
if statusbar {
|
||||||
|
grid.SetRect(0, 0, termWidth, termHeight-1)
|
||||||
|
} else {
|
||||||
grid.SetRect(0, 0, termWidth, termHeight)
|
grid.SetRect(0, 0, termWidth, termHeight)
|
||||||
|
}
|
||||||
help.Resize(termWidth, termHeight)
|
help.Resize(termWidth, termHeight)
|
||||||
|
|
||||||
ui.Render(grid)
|
ui.Render(grid)
|
||||||
|
if statusbar {
|
||||||
|
bar.SetRect(0, termHeight-1, termWidth, termHeight)
|
||||||
|
ui.Render(bar)
|
||||||
|
}
|
||||||
|
|
||||||
eventLoop()
|
eventLoop()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user