|
@@ -13,7 +13,12 @@ type BoxStyle struct {
|
|
middle_right string
|
|
middle_right string
|
|
}
|
|
}
|
|
|
|
|
|
-var boxes = [4]BoxStyle{
|
|
|
|
|
|
+// FUTURE:
|
|
|
|
+// Once we detect CP437 or Unicode, set BOXES to point to
|
|
|
|
+// BOXES_CP437 or BOXES_UNICODE. That'll save us from having
|
|
|
|
+// to if Unicode when building boxes. ;)
|
|
|
|
+
|
|
|
|
+var BOXES = [4]BoxStyle{
|
|
/*
|
|
/*
|
|
┌──┐
|
|
┌──┐
|
|
│ │
|
|
│ │
|
|
@@ -43,7 +48,7 @@ var boxes = [4]BoxStyle{
|
|
*/
|
|
*/
|
|
BoxStyle{"\xd6", "\xb7", "\xc4", "\xba", "\xd3", "\xbd", "\xc7", "\xb6"}}
|
|
BoxStyle{"\xd6", "\xb7", "\xc4", "\xba", "\xd3", "\xbd", "\xc7", "\xb6"}}
|
|
|
|
|
|
-var unicode_boxes = []BoxStyle{
|
|
|
|
|
|
+var BOXES_UNICODE = []BoxStyle{
|
|
BoxStyle{"\u250c", "\u2510", "\u2500", "\u2502", "\u2514", "\u2518", "\u251c", "\u2524"},
|
|
BoxStyle{"\u250c", "\u2510", "\u2500", "\u2502", "\u2514", "\u2518", "\u251c", "\u2524"},
|
|
BoxStyle{"\u2554", "\u2557", "\u2550", "\u2551", "\u255a", "\u255d", "\u2560", "\u2563"},
|
|
BoxStyle{"\u2554", "\u2557", "\u2550", "\u2551", "\u255a", "\u255d", "\u2560", "\u2563"},
|
|
BoxStyle{"\u2553", "\u2556", "\u2500", "\u2551", "\u2559", "\u255c", "\u255f", "\u2562"},
|
|
BoxStyle{"\u2553", "\u2556", "\u2500", "\u2551", "\u2559", "\u255c", "\u255f", "\u2562"},
|
|
@@ -58,9 +63,9 @@ type Box struct {
|
|
func (b *Box) Top() string {
|
|
func (b *Box) Top() string {
|
|
var style *BoxStyle
|
|
var style *BoxStyle
|
|
if Unicode {
|
|
if Unicode {
|
|
- style = &unicode_boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES_UNICODE[b.Style]
|
|
} else {
|
|
} else {
|
|
- style = &boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES[b.Style]
|
|
}
|
|
}
|
|
return style.top_left + strings.Repeat(style.top, b.Width) + style.top_right
|
|
return style.top_left + strings.Repeat(style.top, b.Width) + style.top_right
|
|
}
|
|
}
|
|
@@ -68,9 +73,9 @@ func (b *Box) Top() string {
|
|
func (b *Box) Row(text string) string {
|
|
func (b *Box) Row(text string) string {
|
|
var style *BoxStyle
|
|
var style *BoxStyle
|
|
if Unicode {
|
|
if Unicode {
|
|
- style = &unicode_boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES_UNICODE[b.Style]
|
|
} else {
|
|
} else {
|
|
- style = &boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES[b.Style]
|
|
}
|
|
}
|
|
return style.side + text + style.side
|
|
return style.side + text + style.side
|
|
}
|
|
}
|
|
@@ -78,9 +83,9 @@ func (b *Box) Row(text string) string {
|
|
func (b *Box) Middle() string {
|
|
func (b *Box) Middle() string {
|
|
var style *BoxStyle
|
|
var style *BoxStyle
|
|
if Unicode {
|
|
if Unicode {
|
|
- style = &unicode_boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES_UNICODE[b.Style]
|
|
} else {
|
|
} else {
|
|
- style = &boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES[b.Style]
|
|
}
|
|
}
|
|
return style.middle_left + strings.Repeat(style.top, b.Width) + style.middle_right
|
|
return style.middle_left + strings.Repeat(style.top, b.Width) + style.middle_right
|
|
}
|
|
}
|
|
@@ -88,9 +93,9 @@ func (b *Box) Middle() string {
|
|
func (b *Box) Bottom() string {
|
|
func (b *Box) Bottom() string {
|
|
var style *BoxStyle
|
|
var style *BoxStyle
|
|
if Unicode {
|
|
if Unicode {
|
|
- style = &unicode_boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES_UNICODE[b.Style]
|
|
} else {
|
|
} else {
|
|
- style = &boxes[b.Style]
|
|
|
|
|
|
+ style = &BOXES[b.Style]
|
|
}
|
|
}
|
|
return style.bottom_left + strings.Repeat(style.top, b.Width) + style.bottom_right
|
|
return style.bottom_left + strings.Repeat(style.top, b.Width) + style.bottom_right
|
|
}
|
|
}
|