redrawrows on resize

This commit is contained in:
Bradley Cicenas 2017-02-18 00:59:13 +00:00
parent 24b92384ac
commit 8d9e6fd273
2 changed files with 14 additions and 14 deletions

16
grid.go
View File

@ -90,9 +90,9 @@ func (g *Grid) redrawRows() {
ui.Render(ui.Body) ui.Render(ui.Body)
// dump aligned widget positions and sizes // dump aligned widget positions and sizes
for i, w := range ui.Body.Rows[1].Cols { //for i, w := range ui.Body.Rows[1].Cols {
log.Infof("w%v: x=%v y=%v w=%v h=%v", i, w.X, w.Y, w.Width, w.Height) //log.Infof("w%v: x=%v y=%v w=%v h=%v", i, w.X, w.Y, w.Width, w.Height)
} //}
} }
@ -105,8 +105,10 @@ func resizeIndicator() {
continue continue
} }
wDiff := r.Cols[0].Width - (toWidth + xShift) wDiff := r.Cols[0].Width - (toWidth + xShift)
r.Cols[0].SetX(xShift) // set indicator width // set indicator x, width
r.Cols[0].SetWidth(toWidth) // set indicator width r.Cols[0].SetX(xShift)
r.Cols[0].SetWidth(toWidth)
// shift remainder of columns left by wDiff // shift remainder of columns left by wDiff
for _, c := range r.Cols[1:] { for _, c := range r.Cols[1:] {
c.SetX(c.X - wDiff) c.SetX(c.X - wDiff)
@ -217,10 +219,8 @@ func Display(g *Grid) bool {
ui.Handle("/sys/wnd/resize", func(e ui.Event) { ui.Handle("/sys/wnd/resize", func(e ui.Event) {
ui.Body.Width = ui.TermWidth() ui.Body.Width = ui.TermWidth()
ui.Body.Align()
ui.Clear()
ui.Render(ui.Body)
log.Infof("resize: width=%v", ui.Body.Width) log.Infof("resize: width=%v", ui.Body.Width)
g.redrawRows()
}) })
ui.Loop() ui.Loop()

View File

@ -8,8 +8,8 @@ import (
) )
const ( const (
mark = '\u25C9' mark = string('\u25C9')
pause = '\u25AE' vBar = string('\u25AE')
) )
type ContainerWidgets interface { type ContainerWidgets interface {
@ -70,16 +70,16 @@ func (w *Compact) UnHighlight() {
func (w *Compact) SetStatus(val string) { func (w *Compact) SetStatus(val string) {
switch val { switch val {
case "running": case "running":
w.Status.Text = string(mark) w.Status.Text = mark
w.Status.TextFgColor = ui.ColorGreen w.Status.TextFgColor = ui.ColorGreen
case "exited": case "exited":
w.Status.Text = string(mark) w.Status.Text = mark
w.Status.TextFgColor = ui.ColorRed w.Status.TextFgColor = ui.ColorRed
case "paused": case "paused":
w.Status.Text = fmt.Sprintf("%s%s", string(pause), string(pause)) w.Status.Text = fmt.Sprintf("%s%s", vBar, vBar)
w.Status.TextFgColor = ui.ColorDefault w.Status.TextFgColor = ui.ColorDefault
default: default:
w.Status.Text = string(mark) w.Status.Text = mark
w.Status.TextFgColor = ui.ColorRed w.Status.TextFgColor = ui.ColorRed
} }
} }