My mirror of the Barnard terminal client for Mumble.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

label.go 762 B

il y a 10 ans
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package uiterm
  2. import (
  3. "strings"
  4. "github.com/nsf/termbox-go"
  5. )
  6. type Label struct {
  7. Text string
  8. Fg Attribute
  9. Bg Attribute
  10. x0, y0, x1, y1 int
  11. }
  12. func (l *Label) SetActive(ui *Ui, active bool) {
  13. }
  14. func (l *Label) SetBounds(ui *Ui, x0, y0, x1, y1 int) {
  15. l.x0 = x0
  16. l.y0 = y0
  17. l.x1 = x1
  18. l.y1 = y1
  19. }
  20. func (l *Label) Draw(ui *Ui) {
  21. reader := strings.NewReader(l.Text)
  22. for y := l.y0; y < l.y1; y++ {
  23. for x := l.x0; x < l.x1; x++ {
  24. var chr rune
  25. if ch, _, err := reader.ReadRune(); err != nil {
  26. chr = ' '
  27. } else {
  28. chr = ch
  29. }
  30. termbox.SetCell(x, y, chr, termbox.Attribute(l.Fg), termbox.Attribute(l.Bg))
  31. }
  32. }
  33. }
  34. func (l *Label) KeyEvent(ui *Ui, mod Modifier, key Key) {
  35. }
  36. func (l *Label) CharacterEvent(ui *Ui, chr rune) {
  37. }