From 6b29d90fb419a466b5f90fbae15c6db46ebc03fa Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 1 Mar 2020 01:05:00 +0200 Subject: Fix minor issues --- ui/room-view.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'ui') 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 { -- cgit v1.2.3