summaryrefslogtreecommitdiff
path: root/client/channel_window.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/channel_window.go')
-rw-r--r--client/channel_window.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/client/channel_window.go b/client/channel_window.go
index e5e7e84..43ce83f 100644
--- a/client/channel_window.go
+++ b/client/channel_window.go
@@ -107,6 +107,69 @@ func (cw *channelWindow) leaveChannel() {
globalApp.windowCache.Evict(cw.location)
}
+type userListMsg struct {
+ index int
+ channelName string
+ names []string
+}
+
+func (u userListMsg) Id() string {
+ return "user list." + strconv.Itoa(u.index)
+}
+
+func (u userListMsg) Show(odd bool) {
+ tui.Push("", tui.Box {
+ Width: tui.Fill, Height: tui.Children, Dir: tui.Right,
+ Style: &tui.Style {Bg: colorCmd[odd], Fg: tui.White},
+ })
+ nameStyle := &tui.Style {Bg: colorCmd[odd], Fg: tui.White, Bold: true}
+
+ tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize})
+ tui.Text("* ", nil)
+ tui.Pop()
+
+ tui.Push("", tui.Box {Width: tui.Fill, Height: tui.Children})
+ tui.Push("", tui.Box {Width: tui.Fill, Height: tui.TextSize})
+ tui.Text(strconv.Itoa(len(u.names)), nil)
+ tui.Text(" users in ", nil)
+ tui.Text(u.channelName, nameStyle)
+ tui.Pop()
+ for _, name := range u.names {
+ tui.Push("", tui.Box {
+ Width: tui.Fill, Height: tui.Children, Dir: tui.Right,
+ })
+
+ tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize})
+ tui.Text(" * ", nil)
+ tui.Pop()
+
+ tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize})
+ tui.Text(name, nameStyle)
+ tui.Pop()
+
+ tui.Pop()
+ }
+ tui.Pop()
+
+ tui.Pop()
+}
+
+func (cw *channelWindow) userList(callback func(userListMsg)) {
+ ch := cw.getChannel()
+ cb := func(response proto.Command) {
+ if response.Kind != "list" {
+ return
+ }
+ var names []string
+ for _, u := range response.Args {
+ names = append(names, u.Fields[""])
+ }
+ lastIndex++
+ callback(userListMsg {lastIndex, ch.Fields[""], names})
+ }
+ globalApp.Request(proto.NewCmd("list", cw.location.id), cb)
+}
+
func (cw *channelWindow) ShowStatusLine() {
ch := cw.getChannel()
if ch == nil {