func (e *Editor) compositeRecursively(v *view.Tree) { if leaf := v.Leaf(); leaf != nil { buf := v.Leaf().UIBuf() e.uiBuf.Blit(v.Rect, 0, 0, &buf) return } if left := v.Left(); left != nil { e.compositeRecursively(left) right := v.Right() e.compositeRecursively(right) splitter := right.Rect splitter.X -= 1 splitter.Width = 1 uiBuf := e.uiBuf uiBuf.Fill(splitter, termbox.Cell{ Fg: termbox.AttrReverse, Bg: termbox.AttrReverse, Ch: '│', }) uiBuf.Set(splitter.X, splitter.Y+splitter.Height-1, termbox.Cell{ Fg: termbox.AttrReverse, Bg: termbox.AttrReverse, Ch: '┴', }) } else { e.compositeRecursively(v.Top()) e.compositeRecursively(v.Bottom()) } }
func (e *Editor) fixEdges(v *view.Tree) { var x, y int var cell *termbox.Cell if leaf := v.Leaf(); leaf != nil { y = v.Y + v.Height - 1 x = v.X - 1 cell = e.uiBuf.Get(x, y) if cell != nil { switch cell.Ch { case '│': cell.Ch = '├' case '┤': cell.Ch = '┼' } } x = v.X + v.Width cell = e.uiBuf.Get(x, y) if cell != nil { switch cell.Ch { case '│': cell.Ch = '┤' case '├': cell.Ch = '┼' } } return } if left := v.Left(); left != nil { right := v.Right() x = right.X - 1 y = right.Y - 1 cell = e.uiBuf.Get(x, y) if cell != nil { switch cell.Ch { case '─': cell.Ch = '┬' case '┴': cell.Ch = '┼' } } e.fixEdges(left) e.fixEdges(right) } else { e.fixEdges(v.Top()) e.fixEdges(v.Bottom()) } }