diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-01 18:04:40 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-01 18:04:40 -0500 |
| commit | f50a839609847169702d76560dcdc7481099d7bc (patch) | |
| tree | 369ff2ca320b53a28e1d1dbea0effbf6f6388d9b /client/channel_window.go | |
| parent | ccea376f5750629c2a82b1f24251e52756876f5d (diff) | |
user list
Diffstat (limited to 'client/channel_window.go')
| -rw-r--r-- | client/channel_window.go | 63 |
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 { |
