Last active
March 2, 2016 22:37
-
-
Save Komosa/6e32e8c84d05aba405e3 to your computer and use it in GitHub Desktop.
termbox: drawString
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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