diff --git a/_example/tabs.go b/_example/tabs.go index 2283005..3d5d00e 100644 --- a/_example/tabs.go +++ b/_example/tabs.go @@ -69,11 +69,13 @@ func main() { termui.Handle("/sys/kbd/j", func(termui.Event) { tabpane.SetActiveLeft() + termui.Clear() termui.Render(header, tabpane) }) termui.Handle("/sys/kbd/k", func(termui.Event) { tabpane.SetActiveRight() + termui.Clear() termui.Render(header, tabpane) }) diff --git a/buffer.go b/buffer.go index 60e7786..4b91392 100644 --- a/buffer.go +++ b/buffer.go @@ -46,7 +46,7 @@ func (b Buffer) Bounds() image.Rectangle { y0 = p.Y } } - return image.Rect(x0, y0, x1, y1) + return image.Rect(x0, y0, x1+1, y1+1) } // SetArea assigns a new rect area to Buffer b. @@ -56,7 +56,7 @@ func (b *Buffer) SetArea(r image.Rectangle) { } // Sync sets drawing area to the buffer's bound -func (b Buffer) Sync() { +func (b *Buffer) Sync() { b.SetArea(b.Bounds()) } diff --git a/extra/tabpane.go b/extra/tabpane.go index a0df474..7469199 100644 --- a/extra/tabpane.go +++ b/extra/tabpane.go @@ -122,8 +122,8 @@ type point struct { X int Y int Ch rune - Bg Attribute Fg Attribute + Bg Attribute } func buf2pt(b Buffer) []point { @@ -179,7 +179,8 @@ func (tp *Tabpane) Buffer() Buffer { tp.Width = tp.posTabText[len(tp.Tabs)] + 2 } buf := tp.Block.Buffer() - ps := buf2pt(buf) + ps := []point{} + tp.align() if tp.InnerHeight() <= 0 || tp.InnerWidth() <= 0 { return NewBuffer() @@ -249,7 +250,6 @@ func (tp *Tabpane) Buffer() Buffer { //draw tab content below the Tabpane if i == tp.activeTabIndex { blockPoints := buf2pt(tab.Buffer()) - panic(len(blockPoints)) for i := 0; i < len(blockPoints); i++ { blockPoints[i].Y += tp.Height + tp.Y } @@ -260,6 +260,6 @@ func (tp *Tabpane) Buffer() Buffer { for _, v := range ps { buf.Set(v.X, v.Y, NewCell(v.Ch, v.Fg, v.Bg)) } - + buf.Sync() return buf }