My mirror of the Barnard terminal client for Mumble.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 10 roky
před 10 roky
před 10 roky
před 10 roky
před 10 roky
před 10 roky
před 10 roky
před 10 roky
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. ui *Ui
  11. x0, y0, x1, y1 int
  12. }
  13. func (l *Label) uiInitialize(ui *Ui) {
  14. l.ui = ui
  15. }
  16. func (l *Label) uiSetActive(active bool) {
  17. }
  18. func (l *Label) uiSetBounds(x0, y0, x1, y1 int) {
  19. l.x0 = x0
  20. l.y0 = y0
  21. l.x1 = x1
  22. l.y1 = y1
  23. l.uiDraw()
  24. }
  25. func (l *Label) uiDraw() {
  26. l.ui.beginDraw()
  27. defer l.ui.endDraw()
  28. reader := strings.NewReader(l.Text)
  29. for y := l.y0; y < l.y1; y++ {
  30. for x := l.x0; x < l.x1; x++ {
  31. var chr rune
  32. if ch, _, err := reader.ReadRune(); err != nil {
  33. chr = ' '
  34. } else {
  35. chr = ch
  36. }
  37. termbox.SetCell(x, y, chr, termbox.Attribute(l.Fg), termbox.Attribute(l.Bg))
  38. }
  39. }
  40. }
  41. func (l *Label) uiKeyEvent(mod Modifier, key Key) {
  42. }
  43. func (l *Label) uiCharacterEvent(chr rune) {
  44. }