X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/2532718d5288e1a2586fe5716cc41bb2a0210e16..97274864799ac2eea84bf80c9727a810b695db55:/memory.go?ds=sidebyside diff --git a/memory.go b/memory.go index ca8277c..a3665a1 100644 --- a/memory.go +++ b/memory.go @@ -543,6 +543,39 @@ func (m *Memory) View() string { return m.chat.Render() } +// ViewLines returns the lines of the chat view, each with its newline, without +// the leaf lines of the messages in skip. +func (m *Memory) ViewLines(skip map[int]bool) []string { + m.mutex.Lock() + defer m.mutex.Unlock() + + return m.chat.LinesWithout(skip) +} + +// Len returns the number of messages in the log. +func (m *Memory) Len() int { + m.mutex.Lock() + defer m.mutex.Unlock() + + return m.log.Len() +} + +// Message reads the message with the given ID. +func (m *Memory) Message(id int) (Message, error) { + m.mutex.Lock() + defer m.mutex.Unlock() + + return m.log.Message(id) +} + +// Node reads the node (l, i) if it is built. +func (m *Memory) Node(level, index int) (Node, bool, error) { + m.mutex.Lock() + defer m.mutex.Unlock() + + return m.tree.Node(level, index) +} + // Context returns the compaction view for the build of node (l, i). It ends // before the message of a leaf, or after the last message of a merge, and it // stops at the first line that is not built.