mirror of https://github.com/mum4k/termdash.git
commit
df8734811c
|
@ -92,6 +92,37 @@ func TestBorder(t *testing.T) {
|
||||||
return ft
|
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",
|
desc: "draws border in the canvas",
|
||||||
canvas: image.Rect(0, 0, 4, 4),
|
canvas: image.Rect(0, 0, 4, 4),
|
||||||
|
|
|
@ -39,6 +39,19 @@ var lineStyleChars = map[LineStyle]map[linePart]rune{
|
||||||
vAndRight: '├',
|
vAndRight: '├',
|
||||||
vAndH: '┼',
|
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
|
// 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.
|
// lineStyleNames maps LineStyle values to human readable names.
|
||||||
var lineStyleNames = map[LineStyle]string{
|
var lineStyleNames = map[LineStyle]string{
|
||||||
LineStyleLight: "LineStyleLight",
|
LineStyleLight: "LineStyleLight",
|
||||||
|
LineStyleDouble: "LineStyleDouble",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supported line styles.
|
// Supported line styles.
|
||||||
const (
|
const (
|
||||||
LineStyleNone LineStyle = iota
|
LineStyleNone LineStyle = iota
|
||||||
LineStyleLight
|
LineStyleLight
|
||||||
|
LineStyleDouble
|
||||||
)
|
)
|
||||||
|
|
||||||
// linePart identifies individual line parts.
|
// linePart identifies individual line parts.
|
||||||
|
|
Loading…
Reference in New Issue