diff options
author | Tulir Asokan <tulir@maunium.net> | 2020-03-01 01:05:00 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2020-03-01 01:05:00 +0200 |
commit | 6b29d90fb419a466b5f90fbae15c6db46ebc03fa (patch) | |
tree | e5ba7eb0f3cafd655315e0465cb4ef593676c671 /ui | |
parent | 9d132d328bbf3cdcb66d34538583a96268b6dd09 (diff) |
Fix minor issues
Diffstat (limited to 'ui')
-rw-r--r-- | ui/room-view.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/room-view.go b/ui/room-view.go index a54a5de..07aaef9 100644 --- a/ui/room-view.go +++ b/ui/room-view.go @@ -188,7 +188,7 @@ func (view *RoomView) GetStatus() string { buf.WriteString(view.replying.Sender) buf.WriteString(" - ") } else if view.selecting { - buf.WriteString("Selecting message to") + buf.WriteString("Selecting message to ") buf.WriteString(string(view.selectReason)) buf.WriteString(" - ") } @@ -280,9 +280,19 @@ func (view *RoomView) Draw(screen mauview.Screen) { } } +func (view *RoomView) ClearAllContext() { + view.MessageView().SetSelected(nil) + view.SetEditing(nil) + view.replying = nil + view.selecting = false + view.selectContent = "" +} + func (view *RoomView) OnKeyEvent(event mauview.KeyEvent) bool { msgView := view.MessageView() switch event.Key() { + case tcell.KeyEscape: + view.ClearAllContext() case tcell.KeyPgUp: if msgView.IsAtTop() { go view.parent.LoadHistory(view.Room.ID) @@ -510,7 +520,6 @@ func (view *RoomView) InputSubmit(text string) { } view.editMoveText = "" view.SetInputText("") - view.MessageView().SetSelected(nil) } func (view *RoomView) SendReaction(eventID string, reaction string) { @@ -562,8 +571,7 @@ func (view *RoomView) SendMessage(msgtype mautrix.MessageType, text string) { evt := view.parent.matrix.PrepareMarkdownMessage(view.Room.ID, msgtype, text, rel) msg := view.parseEvent(evt.SomewhatDangerousCopy()) view.content.AddMessage(msg, AppendMessage) - view.editing = nil - view.replying = nil + view.ClearAllContext() view.status.SetText(view.GetStatus()) eventID, err := view.parent.matrix.SendEvent(evt) if err != nil { |