mirror of https://github.com/mum4k/termdash.git
commit
df8734811c
|
@ -92,6 +92,37 @@ func TestBorder(t *testing.T) {
|
|||
return ft
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "draws double border around the canvas",
|
||||
canvas: image.Rect(0, 0, 4, 4),
|
||||
border: image.Rect(0, 0, 4, 4),
|
||||
opts: []BorderOption{
|
||||
BorderLineStyle(LineStyleDouble),
|
||||
},
|
||||
want: func(size image.Point) *faketerm.Terminal {
|
||||
ft := faketerm.MustNew(size)
|
||||
c := testcanvas.MustNew(ft.Area())
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{0, 0}, lineStyleChars[LineStyleDouble][topLeftCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 1}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 2}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{0, 3}, lineStyleChars[LineStyleDouble][bottomLeftCorner])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{1, 0}, lineStyleChars[LineStyleDouble][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{1, 3}, lineStyleChars[LineStyleDouble][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{2, 0}, lineStyleChars[LineStyleDouble][hLine])
|
||||
testcanvas.MustSetCell(c, image.Point{2, 3}, lineStyleChars[LineStyleDouble][hLine])
|
||||
|
||||
testcanvas.MustSetCell(c, image.Point{3, 0}, lineStyleChars[LineStyleDouble][topRightCorner])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 1}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 2}, lineStyleChars[LineStyleDouble][vLine])
|
||||
testcanvas.MustSetCell(c, image.Point{3, 3}, lineStyleChars[LineStyleDouble][bottomRightCorner])
|
||||
|
||||
testcanvas.MustApply(c, ft)
|
||||
return ft
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "draws border in the canvas",
|
||||
canvas: image.Rect(0, 0, 4, 4),
|
||||
|
|
|
@ -39,6 +39,19 @@ var lineStyleChars = map[LineStyle]map[linePart]rune{
|
|||
vAndRight: '├',
|
||||
vAndH: '┼',
|
||||
},
|
||||
LineStyleDouble: {
|
||||
hLine: '═',
|
||||
vLine: '║',
|
||||
topLeftCorner: '╔',
|
||||
topRightCorner: '╗',
|
||||
bottomLeftCorner: '╚',
|
||||
bottomRightCorner: '╝',
|
||||
hAndUp: '╩',
|
||||
hAndDown: '╦',
|
||||
vAndLeft: '╣',
|
||||
vAndRight: '╠',
|
||||
vAndH: '╬',
|
||||
},
|
||||
}
|
||||
|
||||
// init verifies that all line parts are half-width runes (occupy only one
|
||||
|
@ -75,13 +88,15 @@ func (ls LineStyle) String() string {
|
|||
|
||||
// lineStyleNames maps LineStyle values to human readable names.
|
||||
var lineStyleNames = map[LineStyle]string{
|
||||
LineStyleLight: "LineStyleLight",
|
||||
LineStyleLight: "LineStyleLight",
|
||||
LineStyleDouble: "LineStyleDouble",
|
||||
}
|
||||
|
||||
// Supported line styles.
|
||||
const (
|
||||
LineStyleNone LineStyle = iota
|
||||
LineStyleLight
|
||||
LineStyleDouble
|
||||
)
|
||||
|
||||
// linePart identifies individual line parts.
|
||||
|
|
Loading…
Reference in New Issue