aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/message-view.go5
-rw-r--r--ui/messages/textbase.go8
-rw-r--r--ui/room-list.go13
-rw-r--r--ui/view-main.go5
4 files changed, 22 insertions, 9 deletions
diff --git a/ui/message-view.go b/ui/message-view.go
index ca03e73..2e33cd7 100644
--- a/ui/message-view.go
+++ b/ui/message-view.go
@@ -183,7 +183,8 @@ func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction ifc.Messag
} else if oldMsg != nil {
view.replaceBuffer(oldMsg, message)
} else {
- view.replaceBuffer(message, message)
+ debug.Print("Unexpected AddMessage() call: Direction is not append or prepend, but message is new.")
+ debug.PrintStack()
}
view.messageIDs[message.ID()] = message
@@ -232,7 +233,7 @@ func (view *MessageView) replaceBuffer(original messages.UIMessage, new messages
}
if start == -1 {
- debug.Print("Called replaceBuffer() with message that was not in the buffer:", original)
+ debug.Print("Called replaceBuffer() with message that was not in the buffer:", original.ID())
view.appendBuffer(new)
return
}
diff --git a/ui/messages/textbase.go b/ui/messages/textbase.go
index 0960a57..79913f8 100644
--- a/ui/messages/textbase.go
+++ b/ui/messages/textbase.go
@@ -73,7 +73,13 @@ func (msg *BaseTextMessage) calculateBufferWithText(text tstring.TString, width
matches := boundaryPattern.FindAllStringIndex(extract.String(), -1)
if len(matches) > 0 {
- extract = extract[:matches[len(matches)-1][1]]
+ match := matches[len(matches)-1]
+ if len(match) > 1 {
+ until := match[1]
+ if until < len(extract) {
+ extract = extract[:until]
+ }
+ }
}
}
msg.buffer = append(msg.buffer, extract)
diff --git a/ui/room-list.go b/ui/room-list.go
index a70fd68..19202f8 100644
--- a/ui/room-list.go
+++ b/ui/room-list.go
@@ -210,7 +210,7 @@ func (list *RoomList) Clear() {
func (list *RoomList) SetSelected(tag string, room *rooms.Room) {
list.selected = room
- list.selectedTag = ""
+ list.selectedTag = tag
}
func (list *RoomList) HasSelected() bool {
@@ -264,7 +264,9 @@ func (list *RoomList) Previous() (string, *rooms.Room) {
items := list.items[list.selectedTag]
index := list.indexInTag(list.selectedTag, list.selected)
- if index == len(items)-1 {
+ if index == -1 {
+ return list.First()
+ } else if index == len(items)-1 {
tagIndex := list.IndexTag(list.selectedTag)
tagIndex++
for ; tagIndex < len(list.tags); tagIndex++ {
@@ -288,7 +290,9 @@ func (list *RoomList) Next() (string, *rooms.Room) {
items := list.items[list.selectedTag]
index := list.indexInTag(list.selectedTag, list.selected)
- if index == 0 {
+ if index == -1 {
+ return list.Last()
+ } else if index == 0 {
tagIndex := list.IndexTag(list.selectedTag)
tagIndex--
for ; tagIndex >= 0; tagIndex-- {
@@ -332,6 +336,8 @@ func (list *RoomList) Get(n int) (string, *rooms.Room) {
// Tag items
n -= len(items)
+ // Tag footer
+ n--
}
return "", nil
}
@@ -420,5 +426,6 @@ func (list *RoomList) Draw(screen tcell.Screen) {
break
}
}
+ y++
}
}
diff --git a/ui/view-main.go b/ui/view-main.go
index ba3a55b..473ab94 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -336,12 +336,11 @@ func (view *MainView) RemoveRoom(roomID string) {
view.parent.Render()
}
-func (view *MainView) SetRooms(roomIDs []string) {
+func (view *MainView) SetRooms(rooms map[string]*rooms.Room) {
view.roomList.Clear()
view.roomView.Clear()
view.rooms = make(map[string]*RoomView)
- for _, roomID := range roomIDs {
- room := view.matrix.GetRoom(roomID)
+ for _, room := range rooms {
view.roomList.Add(room)
view.addRoomPage(room)
}