M app.go => app.go +6 -0
@@ 455,6 455,8 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
if ev.Buttons()&tcell.ButtonPrimary != 0 {
if x < app.win.ChannelWidth() {
app.win.ClickBuffer(y + app.win.ChannelOffset())
+ } else if app.win.ChannelWidth() == 0 && y == h-1 {
+ app.win.ClickBuffer(app.win.HorizontalBufferOffset(x))
} else if x > w-app.win.MemberWidth() {
app.win.ClickMember(y + app.win.MemberOffset())
}
@@ 464,6 466,10 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) {
if i := y + app.win.ChannelOffset(); i == app.win.ClickedBuffer() {
app.win.GoToBufferNo(i)
}
+ } else if app.win.ChannelWidth() == 0 && y == h-1 {
+ if i := app.win.HorizontalBufferOffset(x); i == app.win.ClickedBuffer() {
+ app.win.GoToBufferNo(i)
+ }
} else if x > w-app.win.MemberWidth() {
if i := y + app.win.MemberOffset(); i == app.win.ClickedMember() {
netID, target := app.win.CurrentBuffer()
M ui/buffers.go => ui/buffers.go +23 -0
@@ 593,6 593,29 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width,
}
}
+func (bs *BufferList) HorizontalBufferOffset(x int, offset int) int {
+ for i, b := range bs.list[offset:] {
+ if i > 0 {
+ x--
+ if x < 0 {
+ return -1
+ }
+ }
+ if b.title == "" {
+ x -= stringWidth(b.netName)
+ } else {
+ x -= stringWidth(b.title)
+ }
+ if 0 < b.highlights {
+ x -= 2 + len(fmt.Sprintf("%d", b.highlights))
+ }
+ if x < 0 {
+ return offset + i
+ }
+ }
+ return -1
+}
+
func (bs *BufferList) DrawHorizontalBufferList(screen tcell.Screen, x0, y0, width int, offset *int) {
x := width
for i := len(bs.list) - 1; i >= 0; i-- {
M ui/ui.go => ui/ui.go +4 -0
@@ 180,6 180,10 @@ func (ui *UI) ScrollChannelDownBy(n int) {
ui.channelOffset += n
}
+func (ui *UI) HorizontalBufferOffset(x int) int {
+ return ui.bs.HorizontalBufferOffset(x, ui.channelOffset)
+}
+
func (ui *UI) ChannelOffset() int {
return ui.channelOffset
}