// This file is part of beagles.
//
// Copyright © 2020 Chris Palmer <chris@red-oxide.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"github.com/gdamore/tcell"
tui "gitlab.com/tslocum/cview"
)
func newSeparator(theme *themeType, isVertical bool) *tui.Box {
line := tui.NewBox()
color := theme.BackgroundColor
if theme.Separator != "" {
color = theme.Separator
}
line.SetBackgroundColor(tcell.GetColor(color))
style := tcell.StyleDefault.Foreground(tcell.GetColor(color))
line.SetDrawFunc(func(screen tcell.Screen, x, y, w, h int) (int, int, int, int) {
if isVertical {
fh := y + h
for pos := y; pos < fh; pos++ {
screen.SetContent(x, pos, tui.BoxDrawingsHeavyVertical, nil, style)
}
} else {
fw := x + w
for pos := x; pos < fw; pos++ {
screen.SetContent(pos, y, tui.BoxDrawingsHeavyHorizontal, nil, style)
}
}
return 0, 0, 0, 0
})
return line
}