My mirror of the Barnard terminal client for Mumble.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
pirms 10 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package barnard
  2. import (
  3. "github.com/layeh/barnard/uiterm"
  4. "github.com/layeh/gumble/gumble"
  5. )
  6. type TreeItem struct {
  7. User *gumble.User
  8. Channel *gumble.Channel
  9. }
  10. func (ti TreeItem) String() string {
  11. if ti.User != nil {
  12. return ti.User.Name
  13. }
  14. if ti.Channel != nil {
  15. return ti.Channel.Name
  16. }
  17. return ""
  18. }
  19. func (ti TreeItem) TreeItemStyle(fg, bg uiterm.Attribute, active bool) (uiterm.Attribute, uiterm.Attribute) {
  20. if ti.Channel != nil {
  21. fg |= uiterm.AttrBold
  22. }
  23. if active {
  24. fg, bg = bg, fg
  25. }
  26. return fg, bg
  27. }
  28. func (b *Barnard) TreeItemSelect(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem) {
  29. treeItem := item.(TreeItem)
  30. if treeItem.Channel != nil {
  31. b.Client.Self.Move(treeItem.Channel)
  32. }
  33. }
  34. func (b *Barnard) TreeItem(item uiterm.TreeItem) []uiterm.TreeItem {
  35. var treeItem TreeItem
  36. if ti, ok := item.(TreeItem); !ok {
  37. root := b.Client.Channels[0]
  38. if root == nil {
  39. return nil
  40. }
  41. return []uiterm.TreeItem{
  42. TreeItem{
  43. Channel: root,
  44. },
  45. }
  46. } else {
  47. treeItem = ti
  48. }
  49. if treeItem.User != nil {
  50. return nil
  51. }
  52. users := []uiterm.TreeItem{}
  53. for _, user := range treeItem.Channel.Users {
  54. users = append(users, TreeItem{
  55. User: user,
  56. })
  57. }
  58. channels := []uiterm.TreeItem{}
  59. for _, subchannel := range treeItem.Channel.Children {
  60. channels = append(channels, TreeItem{
  61. Channel: subchannel,
  62. })
  63. }
  64. return append(users, channels...)
  65. }