Documentation ¶
Index ¶
- Constants
- func UpdateMessage(ct Container, update cchat.MessageUpdate)
- type Container
- type Controller
- type ListContainer
- type ListStore
- func (c *ListStore) AddMessageAt(msg MessageRow, ix int)
- func (c *ListStore) Around(id cchat.ID) (before, after MessageRow)
- func (c *ListStore) DeleteEarliest(n int)
- func (c *ListStore) FindMessage(isMessage func(MessageRow) bool) (MessageRow, int)
- func (c *ListStore) Highlight(msg MessageRow)
- func (c *ListStore) HighlightReference(ref markup.ReferenceSegment)
- func (c *ListStore) Message(msgID cchat.ID, nonce string) MessageRow
- func (c *ListStore) MessagesLen() int
- func (c *ListStore) NthMessage(n int) MessageRow
- func (c *ListStore) PopMessage(id cchat.ID) (msg MessageRow)
- func (c *ListStore) Reset()
- func (c *ListStore) SetSelf(self *message.Author)
- func (c *ListStore) SwapMessage(msg MessageRow) bool
- type MessageRow
- type PresendMessageRow
Constants ¶
const BacklogLimit = 50
BacklogLimit is the maximum number of messages to store in the container at once.
const ColumnSpacing = 8
Variables ¶
This section is empty.
Functions ¶
func UpdateMessage ¶
func UpdateMessage(ct Container, update cchat.MessageUpdate)
UpdateMessage is a convenient function to update a message in the container. It does nothing if the message is not found.
Types ¶
type Container ¶
type Container interface { gtk.IWidget cchat.MessagesContainer // Reset resets the message container to its original state. Reset() // SetSelf sets the author for the current user. SetSelf(self *message.Author) // NewPresendMessage creates and adds a presend message state into the list. NewPresendMessage(state *message.PresendState) PresendMessageRow // AddMessageAt adds a new message into the list at the given index. AddMessageAt(row MessageRow, ix int) // MessagesLen returns the current number of messages. MessagesLen() int // NthMessage returns the nth message in the buffer or nil if there's // nothing. NthMessage(ix int) MessageRow // Message finds and returns the message, if any. It performs maximum 2 // constant-time lookups. Message(id cchat.ID, nonce string) MessageRow // FindMessage finds a message that satisfies the given callback. It // iterates the message buffer from latest to earliest. FindMessage(isMessage func(MessageRow) bool) (MessageRow, int) // Highlight temporarily highlights the given message for a short while. Highlight(msg MessageRow) SetFocusHAdjustment(*gtk.Adjustment) SetFocusVAdjustment(*gtk.Adjustment) }
Container is a generic messages container for children messages for children packages.
type Controller ¶
type Controller interface { // Connector is used for button press events to unselect messages. primitives.Connector // BindMenu expects the controller to add actioner into the message. BindMenu(MessageRow) // Bottomed returns whether or not the message scroller is at the bottom. Bottomed() bool // AuthorEvent is called on message create/update. This is used to update // the typer state. AuthorEvent(authorID cchat.ID) // SelectMessage is called when a message is selected. SelectMessage(list *ListStore, msg MessageRow) // UnselectMessage is called when the message selection is cleared. UnselectMessage() }
Controller is for menu actions.
type ListContainer ¶
type ListContainer struct { *handy.Clamp *ListStore Controller }
ListContainer is an implementation of Container, which allows flexible message grids.
func NewListContainer ¶
func NewListContainer(ctrl Controller) *ListContainer
func (*ListContainer) CleanMessages ¶
func (c *ListContainer) CleanMessages() bool
CleanMessages cleans up the oldest messages if the user is scrolled to the bottom. True is returned if there were changes.
func (*ListContainer) SetFocusHAdjustment ¶
func (c *ListContainer) SetFocusHAdjustment(adj *gtk.Adjustment)
func (*ListContainer) SetFocusVAdjustment ¶
func (c *ListContainer) SetFocusVAdjustment(adj *gtk.Adjustment)
type ListStore ¶
type ListStore struct { ListBox *gtk.ListBox Controller Controller // contains filtered or unexported fields }
func NewListStore ¶
func NewListStore(ctrl Controller) *ListStore
func (*ListStore) AddMessageAt ¶
func (c *ListStore) AddMessageAt(msg MessageRow, ix int)
func (*ListStore) Around ¶
func (c *ListStore) Around(id cchat.ID) (before, after MessageRow)
Around returns the message before and after the given ID, or nil if none.
func (*ListStore) DeleteEarliest ¶
DeleteEarliest deletes the n earliest messages. It does nothing if n is or less than 0.
func (*ListStore) FindMessage ¶
func (c *ListStore) FindMessage(isMessage func(MessageRow) bool) (MessageRow, int)
FindMessage iterates backwards and returns the message if isMessage() returns true on that message.
func (*ListStore) Highlight ¶
func (c *ListStore) Highlight(msg MessageRow)
func (*ListStore) HighlightReference ¶
func (c *ListStore) HighlightReference(ref markup.ReferenceSegment)
func (*ListStore) Message ¶
func (c *ListStore) Message(msgID cchat.ID, nonce string) MessageRow
Message finds the message state in the container. It is not thread-safe. This exists for backwards compatibility.
func (*ListStore) MessagesLen ¶
func (*ListStore) NthMessage ¶
func (c *ListStore) NthMessage(n int) MessageRow
NthMessage returns the nth message.
func (*ListStore) PopMessage ¶
func (c *ListStore) PopMessage(id cchat.ID) (msg MessageRow)
PopMessage deletes a message off of the list and return the deleted message.
func (*ListStore) SetSelf ¶
SetSelf sets the current author to presend. If ID is empty or Namer is nil, then the fallback author is used instead. The given author will be stopped on reset.
func (*ListStore) SwapMessage ¶
func (c *ListStore) SwapMessage(msg MessageRow) bool
Swap changes the message with the ID to the given message. This provides a low level API for edits that need a new Attach method.
TODO: combine compact and full so they share the same attach method.
type MessageRow ¶
func FirstMessage ¶
func FirstMessage(ct Container) MessageRow
FirstMessage returns the first message in the buffer. Nil is returned if there's nothing.
func InsertPosition ¶
func InsertPosition(ct Container, t time.Time) (MessageRow, int)
InsertPosition returns the message that is before the given time (or nil) and the new index of the message with the given timestamp. If -1 is returned, then there is no message prior, and the message should be prepended on top.
func LastMessage ¶
func LastMessage(ct Container) MessageRow
LastMessage returns the last message in the buffer or nil if there's nothing.
func LatestMessageFrom ¶
func LatestMessageFrom(ct Container, authorID cchat.ID) (MessageRow, int)
LatestMessageFrom returns the latest message from the given author ID.
type PresendMessageRow ¶
type PresendMessageRow interface { MessageRow message.Presender }