@@ -2,8 +2,6 @@ package iavl
22
33import (
44 "fmt"
5- "os"
6- "strings"
75)
86
97// PrintTree prints the whole tree in an indented form.
@@ -66,64 +64,3 @@ func maxInt8(a, b int8) int8 {
6664 }
6765 return b
6866}
69-
70- // Colors: ------------------------------------------------
71-
72- const (
73- ANSIReset = "\x1b [0m"
74- ANSIBright = "\x1b [1m"
75-
76- ANSIFgGreen = "\x1b [32m"
77- ANSIFgBlue = "\x1b [34m"
78- ANSIFgCyan = "\x1b [36m"
79- )
80-
81- // color the string s with color 'color'
82- // unless s is already colored
83- func treat (s string , color string ) string {
84- if len (s ) > 2 && s [:2 ] == "\x1b [" {
85- return s
86- }
87- return color + s + ANSIReset
88- }
89-
90- func treatAll (color string , args ... interface {}) string {
91- parts := make ([]string , 0 , len (args ))
92- for _ , arg := range args {
93- parts = append (parts , treat (fmt .Sprintf ("%v" , arg ), color ))
94- }
95- return strings .Join (parts , "" )
96- }
97-
98- func Green (args ... interface {}) string {
99- return treatAll (ANSIFgGreen , args ... )
100- }
101-
102- func Blue (args ... interface {}) string {
103- return treatAll (ANSIFgBlue , args ... )
104- }
105-
106- func Cyan (args ... interface {}) string {
107- return treatAll (ANSIFgCyan , args ... )
108- }
109-
110- // ColoredBytes takes in the byte that you would like to show as a string and byte
111- // and will display them in a human readable format.
112- // If the environment variable TENDERMINT_IAVL_COLORS_ON is set to a non-empty string then different colors will be used for bytes and strings.
113- func ColoredBytes (data []byte , textColor , bytesColor func (... interface {}) string ) string {
114- colors := os .Getenv ("TENDERMINT_IAVL_COLORS_ON" )
115- if colors == "" {
116- for _ , b := range data {
117- return string (b )
118- }
119- }
120- s := ""
121- for _ , b := range data {
122- if 0x21 <= b && b < 0x7F {
123- s += textColor (string (b ))
124- } else {
125- s += bytesColor (fmt .Sprintf ("%02X" , b ))
126- }
127- }
128- return s
129- }
0 commit comments