diff options
Diffstat (limited to 'client/channel_list.go')
| -rw-r--r-- | client/channel_list.go | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/client/channel_list.go b/client/channel_list.go index 10b07f1..6ac2141 100644 --- a/client/channel_list.go +++ b/client/channel_list.go @@ -11,6 +11,7 @@ type channelList []channelListEntry type channelListEntry struct { name string location channelLocation + clicked bool } func (cl *channelList) Len() int { @@ -31,7 +32,7 @@ func (cl *channelList) setChannels(cs []proto.Object) { *cl = nil for _, c := range cs { *cl = append(*cl, channelListEntry { - c.Fields[""], channelLocation {c.Id}, + c.Fields[""], channelLocation {c.Id}, false, }) } sort.Sort(cl) @@ -76,28 +77,59 @@ func (cl *channelList) traverse(direction int) { func (cl *channelList) add(name string, location channelLocation) { cl.remove(location) - entry := channelListEntry {name, location} + entry := channelListEntry {name, location, false} *cl = append([]channelListEntry {entry}, *cl...) } func (cl *channelList) show() { - tui.Push("channel list", tui.Box {Width: 12, Height: tui.Fill}) + mouse := tui.Push("channel list", tui.Box {Width: 12, Height: tui.Fill}) for i, entry := range *cl { var style *tui.Style if entry.location == globalApp.currentWindow { style = &tui.Style {Fg: tui.Black, Bg: tui.White} + } else if entry.clicked { + style = &tui.Style {Fg: tui.Black, Bg: tui.BrightBlack} } - tui.Push("channel list." + entry.location.id, tui.Box { + mouse := tui.Push("channel list." + entry.location.id, tui.Box { Width: tui.Fill, Height: 1, NoWrap: true, Style: style, }) + + if mouse.Pressed { + globalApp.redraw = true + entry.clicked = true + } + if mouse.Released { + globalApp.redraw = true + if entry.clicked { + globalApp.goTo(entry.location) + } else { + for j, entry2 := range *cl { + if entry2.clicked { + entry2.clicked = false + (*cl)[j] = entry + entry = entry2 + } + } + } + } + ch := globalApp.cache.Get(entry.location.id) if ch != nil { entry.name = ch.Fields[""] - (*cl)[i] = entry } + tui.Text(entry.name, nil) tui.Pop() + + (*cl)[i] = entry + } + if mouse.ReleasedAnywhere { + for i, entry := range *cl { + globalApp.redraw = globalApp.redraw || entry.clicked + entry.clicked = false + (*cl)[i] = entry + } } tui.Pop() } |
