|
@@ -29,192 +29,6 @@ g00r00 Line 7 : User's handle/alias
|
|
|
1 Line 11: Current node number
|
|
|
*/
|
|
|
|
|
|
-func Color(arg ...int) string {
|
|
|
- var result string = "\x1b["
|
|
|
- for i := range arg {
|
|
|
- result += fmt.Sprintf("%d;", arg[i])
|
|
|
- }
|
|
|
- result = result[:len(result)-1]
|
|
|
- result += "m"
|
|
|
- return result
|
|
|
-}
|
|
|
-
|
|
|
-func ColorText(color string) string {
|
|
|
- // split on spaces, uppercase, match first 3 letter
|
|
|
- var result []int
|
|
|
- var bg bool
|
|
|
-
|
|
|
- result = append(result, 0)
|
|
|
-
|
|
|
- parts := strings.Fields(strings.ToUpper(color))
|
|
|
- for _, part := range parts {
|
|
|
- switch part {
|
|
|
- case "BLACK", "BLA":
|
|
|
- if bg {
|
|
|
- result = append(result, 40)
|
|
|
- } else {
|
|
|
- result = append(result, 30)
|
|
|
- }
|
|
|
-
|
|
|
- case "RED":
|
|
|
- if bg {
|
|
|
- result = append(result, 41)
|
|
|
- } else {
|
|
|
- result = append(result, 31)
|
|
|
- }
|
|
|
-
|
|
|
- case "GREEN", "GRE":
|
|
|
- if bg {
|
|
|
- result = append(result, 42)
|
|
|
- } else {
|
|
|
- result = append(result, 32)
|
|
|
- }
|
|
|
-
|
|
|
- case "BROWN", "BRO":
|
|
|
- if bg {
|
|
|
- result = append(result, 43)
|
|
|
- } else {
|
|
|
- result = append(result, 33)
|
|
|
- }
|
|
|
-
|
|
|
- case "YELLOW", "YEL":
|
|
|
- if bg {
|
|
|
- result = append(result, 43)
|
|
|
- } else {
|
|
|
- result = append(result, 33)
|
|
|
- }
|
|
|
-
|
|
|
- case "BLUE", "BLU":
|
|
|
- if bg {
|
|
|
- result = append(result, 44)
|
|
|
- } else {
|
|
|
- result = append(result, 34)
|
|
|
- }
|
|
|
-
|
|
|
- case "MAGENTA", "MAG":
|
|
|
- if bg {
|
|
|
- result = append(result, 45)
|
|
|
- } else {
|
|
|
- result = append(result, 35)
|
|
|
- }
|
|
|
-
|
|
|
- case "CYAN", "CYA":
|
|
|
- if bg {
|
|
|
- result = append(result, 46)
|
|
|
- } else {
|
|
|
- result = append(result, 36)
|
|
|
- }
|
|
|
-
|
|
|
- case "WHITE", "WHI":
|
|
|
- if bg {
|
|
|
- result = append(result, 47)
|
|
|
- } else {
|
|
|
- result = append(result, 37)
|
|
|
- }
|
|
|
-
|
|
|
- case "BOLD", "BOL", "BRIGHT", "BRI":
|
|
|
- result = append(result, 1)
|
|
|
-
|
|
|
- case "ON":
|
|
|
- bg = true
|
|
|
-
|
|
|
- case "BLINK", "BLI":
|
|
|
- result = append(result, 5)
|
|
|
-
|
|
|
- case "INVERT", "INVERSE", "INV":
|
|
|
- result = append(result, 7)
|
|
|
- default:
|
|
|
- fmt.Println("ColorText Unknown:", part)
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- // fmt.Println("ColorText:", result)
|
|
|
- return Color(result...)
|
|
|
-}
|
|
|
-
|
|
|
-type BoxStyle struct {
|
|
|
- top_left string
|
|
|
- top_right string
|
|
|
- top string
|
|
|
- side string
|
|
|
- bottom_left string
|
|
|
- bottom_right string
|
|
|
- middle_left string
|
|
|
- middle_right string
|
|
|
-}
|
|
|
-
|
|
|
-var boxes = [4]BoxStyle{
|
|
|
- /*
|
|
|
- ┌──┐
|
|
|
- │ │
|
|
|
- ├──┤
|
|
|
- └──┘
|
|
|
- */
|
|
|
- BoxStyle{"\xda", "\xbf", "\xc4", "\xb3", "\xc0", "\xd9", "\xc3", "\xb4"},
|
|
|
- /*
|
|
|
- ╔══╗
|
|
|
- ║ ║
|
|
|
- ╠══╣
|
|
|
- ╚══╝
|
|
|
- */
|
|
|
- BoxStyle{"\xc9", "\xbb", "\xcd", "\xba", "\xc8", "\xbc", "\xcc", "\xb9"},
|
|
|
- /*
|
|
|
- ╒══╕
|
|
|
- │ │
|
|
|
- ╞══╡
|
|
|
- ╘══╛
|
|
|
- */
|
|
|
- BoxStyle{"\xd6", "\xb8", "\xcd", "\xb3", "\xd4", "\xbe", "\xc6", "\xb5"},
|
|
|
- /*
|
|
|
- ╓──╖
|
|
|
- ║ ║
|
|
|
- ╟──╢
|
|
|
- ╙──╜
|
|
|
- */
|
|
|
- BoxStyle{"\xd6", "\xb7", "\xc4", "\xba", "\xd3", "\xbd", "\xc7", "\xb6"}}
|
|
|
-
|
|
|
-var unicode_boxes = []BoxStyle{
|
|
|
- BoxStyle{"\u250c", "\u2510", "\u2500", "\u2502", "\u2514", "\u2518", "\u251c", "\u2524"},
|
|
|
- BoxStyle{"\u2554", "\u2557", "\u2550", "\u2551", "\u255a", "\u255d", "\u2560", "\u2563"},
|
|
|
- BoxStyle{"\u2553", "\u2556", "\u2500", "\u2551", "\u2559", "\u255c", "\u255f", "\u2562"},
|
|
|
- BoxStyle{"\u2552", "\u2555", "\u2550", "\u2502", "\u2558", "\u255b", "\u255e", "\u2561"},
|
|
|
-}
|
|
|
-
|
|
|
-type Box struct {
|
|
|
- Width int
|
|
|
- Style int
|
|
|
-}
|
|
|
-
|
|
|
-func (b *Box) Top() string {
|
|
|
- var style *BoxStyle
|
|
|
- if Unicode {
|
|
|
- style = &unicode_boxes[b.Style]
|
|
|
- } else {
|
|
|
- style = &boxes[b.Style]
|
|
|
- }
|
|
|
- return style.top_left + strings.Repeat(style.top, b.Width) + style.top_right
|
|
|
-}
|
|
|
-
|
|
|
-func (b *Box) Middle(text string) string {
|
|
|
- var style *BoxStyle
|
|
|
- if Unicode {
|
|
|
- style = &unicode_boxes[b.Style]
|
|
|
- } else {
|
|
|
- style = &boxes[b.Style]
|
|
|
- }
|
|
|
- return style.side + text + style.side
|
|
|
-}
|
|
|
-
|
|
|
-func (b *Box) Bottom() string {
|
|
|
- var style *BoxStyle
|
|
|
- if Unicode {
|
|
|
- style = &unicode_boxes[b.Style]
|
|
|
- } else {
|
|
|
- style = &boxes[b.Style]
|
|
|
- }
|
|
|
- return style.bottom_left + strings.Repeat(style.top, b.Width) + style.bottom_right
|
|
|
-}
|
|
|
-
|
|
|
var Reset string = Color(0)
|
|
|
var READFD int
|
|
|
var WRITEFD int
|