Skip to content

Commit

Permalink
profile: update color from yellow to black
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Oct 11, 2023
1 parent db1e34e commit 8db3748
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,19 @@ func (p *profiler) fastCounter() {
p.printTime <- last
}

func colorize1(msg string, color int) string {
return fmt.Sprintf("%s%dm%s%s", COLOR_SEQ, color, msg, RESET_SEQ)
}

func printLines(lines []string, colorful bool) {
if colorful {
fmt.Print("\033[2J\033[1;1H") // clear screen
fmt.Printf("\033[92m%s\n\033[0m", lines[0])
fmt.Printf("\033[97m%s\n\033[0m", lines[1])
fmt.Printf("\033[94m%s\n\033[0m", lines[2])
fmt.Print(CLEAR_SCREEM)
fmt.Println(colorize1(lines[0], GREEN))
fmt.Println(colorize1(lines[1], YELLOW))
fmt.Println(colorize1(lines[2], BLUE))
if len(lines) > 3 {
for _, l := range lines[3:] {
fmt.Printf("\033[93m%s\n\033[0m", l)
fmt.Println(colorize1(l, BLACK))
}
}
} else {
Expand Down
1 change: 1 addition & 0 deletions cmd/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const (
COLOR_SEQ = "\033[1;" // %dm
COLOR_DARK_SEQ = "\033[0;" // %dm
UNDERLINE_SEQ = "\033[4m"
CLEAR_SCREEM = "\033[2J\033[1;1H"
// BOLD_SEQ = "\033[1m"
)

Expand Down

0 comments on commit 8db3748

Please sign in to comment.