Add initial message selecting stuff
This commit is contained in:
parent
98dd1bcdc9
commit
032a83d70b
@ -64,6 +64,7 @@ type MessageView struct {
|
||||
messages []*messages.UIMessage
|
||||
msgBufferLock sync.RWMutex
|
||||
msgBuffer []*messages.UIMessage
|
||||
selected *messages.UIMessage
|
||||
|
||||
initialHistoryLoaded bool
|
||||
}
|
||||
@ -333,15 +334,25 @@ func (view *MessageView) recalculateBuffers() {
|
||||
view.prevPrefs = prefs
|
||||
}
|
||||
|
||||
func (view *MessageView) handleMessageClick(message *messages.UIMessage) bool {
|
||||
switch msg := message.Renderer.(type) {
|
||||
case *messages.ImageMessage:
|
||||
open.Open(msg.Path())
|
||||
default:
|
||||
debug.Print("Message clicked:", message)
|
||||
func (view *MessageView) SetSelected(message *messages.UIMessage) {
|
||||
if view.selected != nil {
|
||||
view.selected.IsSelected = false
|
||||
}
|
||||
view.selected = message
|
||||
if view.selected != nil {
|
||||
view.selected.IsSelected = true
|
||||
}
|
||||
}
|
||||
|
||||
func (view *MessageView) handleMessageClick(message *messages.UIMessage, mod tcell.ModMask) bool {
|
||||
if msg, ok := message.Renderer.(*messages.ImageMessage); ok && mod > 0 {
|
||||
open.Open(msg.Path())
|
||||
// No need to re-render
|
||||
return false
|
||||
}
|
||||
view.SetSelected(message)
|
||||
return true
|
||||
}
|
||||
|
||||
func (view *MessageView) handleUsernameClick(message *messages.UIMessage, prevMessage *messages.UIMessage) bool {
|
||||
if prevMessage != nil && prevMessage.Sender() == message.Sender() {
|
||||
@ -410,7 +421,7 @@ func (view *MessageView) OnMouseEvent(event mauview.MouseEvent) bool {
|
||||
messageX := usernameX + view.widestSender() + SenderMessageGap
|
||||
|
||||
if x >= messageX {
|
||||
return view.handleMessageClick(message)
|
||||
return view.handleMessageClick(message, event.Modifiers())
|
||||
} else if x >= usernameX {
|
||||
return view.handleUsernameClick(message, prevMessage)
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ type UIMessage struct {
|
||||
State event.OutgoingState
|
||||
IsHighlight bool
|
||||
IsService bool
|
||||
IsSelected bool
|
||||
Edited bool
|
||||
Event *event.Event
|
||||
ReplyTo *UIMessage
|
||||
@ -316,6 +317,18 @@ func (msg *UIMessage) Draw(screen mauview.Screen) {
|
||||
screen = msg.DrawReply(screen)
|
||||
msg.Renderer.Draw(screen)
|
||||
msg.DrawReactions(screen)
|
||||
if msg.IsSelected {
|
||||
w, h := screen.Size()
|
||||
for x := 0; x < w; x++ {
|
||||
for y := 0; y < h; y++ {
|
||||
mainc, combc, style, _ := screen.GetContent(x, y)
|
||||
_, bg, _ := style.Decompose()
|
||||
if bg == tcell.ColorDefault {
|
||||
screen.SetContent(x, y, mainc, combc, style.Background(tcell.ColorLightSkyBlue))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *UIMessage) Clone() *UIMessage {
|
||||
|
Loading…
Reference in New Issue
Block a user