Skip to content

Commit

Permalink
define message methods for SharedBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias314 committed Dec 27, 2024
1 parent 2898f15 commit 5e360be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/buffer/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ func (m *Message) Style() tcell.Style {
return config.DefStyle
}

func (b *Buffer) AddMessage(m *Message) {
func (b *SharedBuffer) AddMessage(m *Message) {
b.Messages = append(b.Messages, m)
}

func (b *Buffer) removeMsg(i int) {
func (b *SharedBuffer) removeMsg(i int) {
copy(b.Messages[i:], b.Messages[i+1:])
b.Messages[len(b.Messages)-1] = nil
b.Messages = b.Messages[:len(b.Messages)-1]
}

func (b *Buffer) ClearMessages(owner string) {
func (b *SharedBuffer) ClearMessages(owner string) {
for i := len(b.Messages) - 1; i >= 0; i-- {
if b.Messages[i].Owner == owner {
b.removeMsg(i)
}
}
}

func (b *Buffer) ClearAllMessages() {
func (b *SharedBuffer) ClearAllMessages() {
b.Messages = make([]*Message, 0)
}

Expand Down

0 comments on commit 5e360be

Please sign in to comment.