Bring tabpane back
Fix https://github.com/gizak/termui/issues/101 Fix https://github.com/gizak/termui/issues/94 Fix https://github.com/gizak/termui/issue Fix Buffer.Sync() can not actually take affect Fix Buffer.Bounds() cutting corner
This commit is contained in:
parent
c8b6d85d42
commit
7cbb70e87e
@ -69,11 +69,13 @@ func main() {
|
|||||||
|
|
||||||
termui.Handle("/sys/kbd/j", func(termui.Event) {
|
termui.Handle("/sys/kbd/j", func(termui.Event) {
|
||||||
tabpane.SetActiveLeft()
|
tabpane.SetActiveLeft()
|
||||||
|
termui.Clear()
|
||||||
termui.Render(header, tabpane)
|
termui.Render(header, tabpane)
|
||||||
})
|
})
|
||||||
|
|
||||||
termui.Handle("/sys/kbd/k", func(termui.Event) {
|
termui.Handle("/sys/kbd/k", func(termui.Event) {
|
||||||
tabpane.SetActiveRight()
|
tabpane.SetActiveRight()
|
||||||
|
termui.Clear()
|
||||||
termui.Render(header, tabpane)
|
termui.Render(header, tabpane)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func (b Buffer) Bounds() image.Rectangle {
|
|||||||
y0 = p.Y
|
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.
|
// 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
|
// Sync sets drawing area to the buffer's bound
|
||||||
func (b Buffer) Sync() {
|
func (b *Buffer) Sync() {
|
||||||
b.SetArea(b.Bounds())
|
b.SetArea(b.Bounds())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ type point struct {
|
|||||||
X int
|
X int
|
||||||
Y int
|
Y int
|
||||||
Ch rune
|
Ch rune
|
||||||
Bg Attribute
|
|
||||||
Fg Attribute
|
Fg Attribute
|
||||||
|
Bg Attribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func buf2pt(b Buffer) []point {
|
func buf2pt(b Buffer) []point {
|
||||||
@ -179,7 +179,8 @@ func (tp *Tabpane) Buffer() Buffer {
|
|||||||
tp.Width = tp.posTabText[len(tp.Tabs)] + 2
|
tp.Width = tp.posTabText[len(tp.Tabs)] + 2
|
||||||
}
|
}
|
||||||
buf := tp.Block.Buffer()
|
buf := tp.Block.Buffer()
|
||||||
ps := buf2pt(buf)
|
ps := []point{}
|
||||||
|
|
||||||
tp.align()
|
tp.align()
|
||||||
if tp.InnerHeight() <= 0 || tp.InnerWidth() <= 0 {
|
if tp.InnerHeight() <= 0 || tp.InnerWidth() <= 0 {
|
||||||
return NewBuffer()
|
return NewBuffer()
|
||||||
@ -249,7 +250,6 @@ func (tp *Tabpane) Buffer() Buffer {
|
|||||||
//draw tab content below the Tabpane
|
//draw tab content below the Tabpane
|
||||||
if i == tp.activeTabIndex {
|
if i == tp.activeTabIndex {
|
||||||
blockPoints := buf2pt(tab.Buffer())
|
blockPoints := buf2pt(tab.Buffer())
|
||||||
panic(len(blockPoints))
|
|
||||||
for i := 0; i < len(blockPoints); i++ {
|
for i := 0; i < len(blockPoints); i++ {
|
||||||
blockPoints[i].Y += tp.Height + tp.Y
|
blockPoints[i].Y += tp.Height + tp.Y
|
||||||
}
|
}
|
||||||
@ -260,6 +260,6 @@ func (tp *Tabpane) Buffer() Buffer {
|
|||||||
for _, v := range ps {
|
for _, v := range ps {
|
||||||
buf.Set(v.X, v.Y, NewCell(v.Ch, v.Fg, v.Bg))
|
buf.Set(v.X, v.Y, NewCell(v.Ch, v.Fg, v.Bg))
|
||||||
}
|
}
|
||||||
|
buf.Sync()
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user