Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move helper as it does not work on windows
  • Loading branch information
vilmibm committed Aug 25, 2020
commit e97bcb9b606a136f4303c17cfd497842ef5e42f2
14 changes: 9 additions & 5 deletions pkg/cmd/repo/garden/garden.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func isQuit(b []byte) bool {

func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
cellIx := 0
grassCell := &Cell{utils.RGB(0, 200, 0, ","), "You're standing on a patch of grass in a field of wildflowers."}
grassCell := &Cell{RGB(0, 200, 0, ","), "You're standing on a patch of grass in a field of wildflowers."}
garden := [][]*Cell{}
streamIx := rand.Intn(geo.Width - 1)
if streamIx == geo.Width/2 {
Expand All @@ -265,14 +265,14 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
for x := 0; x < geo.Width; x++ {
if (y > 0 && (x == 0 || x == geo.Width-1)) || y == geo.Height-1 {
garden[y] = append(garden[y], &Cell{
Char: utils.RGB(0, 150, 0, "^"),
Char: RGB(0, 150, 0, "^"),
StatusLine: "You're standing under a tall, leafy tree.",
})
continue
}
if x == streamIx {
garden[y] = append(garden[y], &Cell{
Char: utils.RGB(tint, tint, 255, "#"),
Char: RGB(tint, tint, 255, "#"),
StatusLine: "You're standing in a shallow stream. It's refreshing.",
})
tint += 15
Expand All @@ -290,13 +290,13 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
}
if y == 0 && (x < geo.Width/2 || x > geo.Width/2) {
garden[y] = append(garden[y], &Cell{
Char: utils.RGB(0, 200, 0, ","),
Char: RGB(0, 200, 0, ","),
StatusLine: "You're standing by a wildflower garden. There is a light breeze.",
})
continue
} else if y == 0 && x == geo.Width/2 {
garden[y] = append(garden[y], &Cell{
Char: utils.RGB(139, 69, 19, "+"),
Char: RGB(139, 69, 19, "+"),
StatusLine: fmt.Sprintf("You're standing in front of a weather-beaten sign that says %s.", ghrepo.FullName(geo.Repository)),
})
continue
Expand Down Expand Up @@ -401,3 +401,7 @@ func clear(io *iostreams.IOStreams) {
cmd.Stdout = io.Out
_ = cmd.Run()
}

func RGB(r, g, b int, x string) string {
return fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, x)
}
5 changes: 0 additions & 5 deletions utils/color.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package utils

import (
"fmt"
"io"
"os"

Expand Down Expand Up @@ -47,7 +46,3 @@ func isColorEnabled() bool {
// TODO ignores cmd.OutOrStdout
return IsTerminal(os.Stdout)
}

func RGB(r, g, b int, x string) string {
return fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, x)
}