diff options
| -rw-r--r-- | client/channel_window.go | 19 | ||||
| -rw-r--r-- | tui/layout.go | 11 |
2 files changed, 26 insertions, 4 deletions
diff --git a/client/channel_window.go b/client/channel_window.go index 3aed4c0..0e16af2 100644 --- a/client/channel_window.go +++ b/client/channel_window.go @@ -28,6 +28,7 @@ type channelWindow struct { endOfHistory bool startOfHistory bool jumpedTo buffer.Message + highlight string } type channelMsg struct { @@ -375,11 +376,23 @@ func (cw *channelWindow) ShowComposingReply() { } func (cw *channelWindow) OnNavigate() { + if cw.location.jumpTo != "" { + cw.highlight = cw.location.jumpTo + } if cw.jumpedTo != nil { cw.Buf.ScrollTo(cw.jumpedTo.Id()) } } +func (cw *channelWindow) goToMessage(id string) { + if tui.IsVisible("buffer." + id) { + cw.highlight = id + } else { + globalApp.goTo(channelLocation {id: cw.location.id, jumpTo: id}) + } +} + + func (m channelMsg) Id() string { return "buffer." + m.Object.Id } @@ -446,9 +459,7 @@ func (m channelMsg) showReply(bg int32, replyTo *proto.Object) { }) if replyTo != nil && mouse.Button == 0 && mouse.Pressed { - globalApp.goTo(channelLocation { - id: m.window.location.id, jumpTo: replyTo.Id, - }) + m.window.goToMessage(replyTo.Id) globalApp.redraw = true } @@ -485,7 +496,7 @@ func (m channelMsg) showReply(bg int32, replyTo *proto.Object) { func (m channelMsg) Show(odd bool) { var bg int32 = colorDefault[odd] - if m.Object.Id == m.window.location.jumpTo { + if m.Object.Id == m.window.highlight { bg = 17 } tui.Push("", tui.Box { diff --git a/tui/layout.go b/tui/layout.go index d230a87..1cd3124 100644 --- a/tui/layout.go +++ b/tui/layout.go @@ -23,6 +23,7 @@ type Box struct { computedSize [2]int computedRect rect isOverflow bool + isVisible bool mouseEvent MouseEvent contextMenu []string } @@ -97,6 +98,14 @@ func Pop() { } } +func IsVisible(id string) bool { + b := layout.back[id] + if b != nil { + return b.isVisible + } + return false +} + func (b Box) axes() [2]BoxSize { return [2]BoxSize {b.Width, b.Height} } @@ -372,6 +381,8 @@ func (b *Box) drawComputed( bMax := b.computedRect.max[i] - b.Margins[i * 2 + 1] viewRect.max[i] = min(bMax, parentRect.max[i]) } + b.isVisible = viewRect.max[0] - viewRect.min[0] > 0 && + viewRect.max[1] - viewRect.min[1] > 0 style := parentStyle if b.Style != nil { |
