Skip to content

Instantly share code, notes, and snippets.

@Komosa
Last active March 2, 2016 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Komosa/6e32e8c84d05aba405e3 to your computer and use it in GitHub Desktop.
Save Komosa/6e32e8c84d05aba405e3 to your computer and use it in GitHub Desktop.
termbox: drawString
func drawString(s string, x, y int, fg, bg termbox.Attribute) {
// s = strings.Replace(s, "\t", " ", -1)
// s = strings.Replace(s, "\r", "^R", -1)
w, _ := termbox.Size()
for _, ch := range s {
if x+runewidth.RuneWidth(ch) >= w {
break
}
termbox.SetCell(x, y, ch, fg, bg)
x += runewidth.RuneWidth(ch)
}
for ; x < w; x++ {
termbox.SetCell(x, y, ' ', fg, bg)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment