Documentation
¶
Index ¶
- Constants
- func FormatBadgeReplacement(settings save.Settings, replacements map[string]string) string
- func GraphicRows(settings save.Settings) int
- func Snippet(message string) string
- func StripANSI(s string) string
- func TruncateToWidth(s string, width int) string
- type Buffer
- func (b *Buffer) Append(msg ChatEventMessage) tea.Cmd
- func (b *Buffer) Badge() (string, int)
- func (b *Buffer) BadgeHit(row, col int) bool
- func (b *Buffer) BadgeSpan(renderStart, height, width int) (row, col int, ok bool)
- func (b *Buffer) CaughtUp() bool
- func (b *Buffer) ClearFilter()
- func (b *Buffer) ClipboardText(id EntryID) string
- func (b *Buffer) Current() (int, *Entry)
- func (b *Buffer) CursorLine() int
- func (b *Buffer) DebugDump()
- func (b *Buffer) EmoteNameAt(row, col int) (string, bool)
- func (b *Buffer) Entries() []Entry
- func (b *Buffer) Entry(id EntryID) (Entry, bool)
- func (b *Buffer) EntryAtLine(line int) (int, *Entry)
- func (b *Buffer) FilterStatus() FilterStatus
- func (b *Buffer) HandleChatClick(row, col int) bool
- func (b *Buffer) Hit(row int) (EntryID, bool)
- func (b *Buffer) IsFiltering() bool
- func (b *Buffer) LineRange(id EntryID) (int, int, bool)
- func (b *Buffer) MessageDown(n int)
- func (b *Buffer) MessageUp(n int)
- func (b *Buffer) Move(n int)
- func (b *Buffer) MoveToBottom()
- func (b *Buffer) MoveToTop()
- func (b *Buffer) NewMessages() int
- func (b *Buffer) Newest() (Entry, bool)
- func (b *Buffer) NewestPtr() *Entry
- func (b *Buffer) PageDown()
- func (b *Buffer) PageUp()
- func (b *Buffer) Palette() *Palette
- func (b *Buffer) RawRows() []string
- func (b *Buffer) ReplaceNotice(id, message string) bool
- func (b *Buffer) ResetFilter()
- func (b *Buffer) Resize(width, height int)
- func (b *Buffer) Rows(height int) ([]string, int)
- func (b *Buffer) ScrollByLines(n int)
- func (b *Buffer) Select(id EntryID) bool
- func (b *Buffer) SelectAtViewportRow(row int)
- func (b *Buffer) SelectLine(line int)
- func (b *Buffer) Selected() (Entry, bool)
- func (b *Buffer) SetFilter(query string) FilterStatus
- func (b *Buffer) SetSearchActive(active bool)
- func (b *Buffer) SetTheme(theme save.Theme)
- func (b *Buffer) SetTimeFormat(format string)
- func (b *Buffer) SnapScroll()
- func (b *Buffer) TimePaddingWidth() int
- func (b *Buffer) Update(msg tea.Msg) (cmd tea.Cmd, handled bool)
- func (b *Buffer) UpdatePort()
- func (b *Buffer) UsePalette(palette *Palette)
- func (b *Buffer) ViewportRenderStart() int
- type ChatEventMessage
- type Entry
- type EntryID
- type FilterStatus
- type MessageContentModifier
- type Palette
- type WordReplacement
Constants ¶
const DuplicateBypass = rune(917504)
DuplicateBypass is the invisible rune the tab inserts to keep Twitch from collapsing an intentionally repeated message. It must never be rendered.
Variables ¶
This section is empty.
Functions ¶
func FormatBadgeReplacement ¶
FormatBadgeReplacement renders a badge set for text-mode output.
func GraphicRows ¶
GraphicRows returns the number of terminal rows graphic emotes and badges occupy, or 1 when graphics are disabled.
func TruncateToWidth ¶
TruncateToWidth shortens s so it renders in at most width cells.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is one chat transcript: entries, rendered rows, selection, viewport, search filter and new-message badge. It has no key handling, search widget or tab mode; the tab shell owns those and calls this module.
func (*Buffer) Append ¶
func (b *Buffer) Append(msg ChatEventMessage) tea.Cmd
Append adds one event and returns a smooth-scroll command when the viewport follows the newest message.
func (*Buffer) ClearFilter ¶
func (b *Buffer) ClearFilter()
ClearFilter removes the search filter and shows the whole transcript again.
func (*Buffer) ClipboardText ¶
ClipboardText returns the plain-text form of one entry.
func (*Buffer) CursorLine ¶
func (*Buffer) EmoteNameAt ¶
EmoteNameAt returns the graphic emote name at a viewport cell.
func (*Buffer) EntryAtLine ¶
EntryAtLine returns the index and pointer of the entry containing an absolute rendered line.
func (*Buffer) FilterStatus ¶
func (b *Buffer) FilterStatus() FilterStatus
FilterStatus returns the last filter result.
func (*Buffer) HandleChatClick ¶
HandleChatClick consumes a click on the new-message badge or a reply reference.
func (*Buffer) IsFiltering ¶
IsFiltering reports whether a filter is currently applied.
func (*Buffer) MessageDown ¶
MessageDown moves the selection down n messages.
func (*Buffer) MoveToBottom ¶
func (b *Buffer) MoveToBottom()
MoveToBottom selects the newest entry.
func (*Buffer) NewMessages ¶
NewMessages returns the number of messages that arrived while scrolled up.
func (*Buffer) ReplaceNotice ¶
ReplaceNotice rewrites an existing notice in place and reflows the rows after its text changed. It returns false when the notice left the buffer.
func (*Buffer) ResetFilter ¶
func (b *Buffer) ResetFilter()
ResetFilter removes the filter without moving the selection. The search widget calls it when it opens, so entering search does not jump to the tail.
func (*Buffer) Rows ¶
Rows returns the visible rows and the absolute line the first row represents. The selection indicator and the new-message badge are already applied.
func (*Buffer) ScrollByLines ¶
ScrollByLines moves the selection by n rendered lines.
func (*Buffer) SelectAtViewportRow ¶
SelectAtViewportRow selects the entry at a viewport row.
func (*Buffer) SelectLine ¶
SelectLine selects the entry containing the absolute rendered line.
func (*Buffer) SetFilter ¶
func (b *Buffer) SetFilter(query string) FilterStatus
SetFilter applies a search query. Queries shorter than three characters show the hint and leave the transcript unfiltered.
func (*Buffer) SetSearchActive ¶
func (*Buffer) SetTheme ¶
SetTheme repaints the transcript with a new theme.
Rendered rows carry their colors inline, so the whole transcript is re-rendered from its entries. Selection, scroll position, search filter and the new-message counter are carried over: a theme switch must not move the user's viewport.
func (*Buffer) SetTimeFormat ¶
SetTimeFormat changes the timestamp format of rendered messages.
func (*Buffer) SnapScroll ¶
func (b *Buffer) SnapScroll()
SnapScroll stops the smooth-scroll animation at the current viewport.
func (*Buffer) TimePaddingWidth ¶
func (*Buffer) Update ¶
Update handles the messages the transcript owns. handled is false for every other message, so the tab shell can route keys and the search widget.
func (*Buffer) UpdatePort ¶
func (b *Buffer) UpdatePort()
func (*Buffer) UsePalette ¶
UsePalette shares another transcript's user colors.
func (*Buffer) ViewportRenderStart ¶
ViewportRenderStart returns the absolute line of the first visible row.
type ChatEventMessage ¶
type ChatEventMessage struct {
// IsFakeEvent marks an event created by local input or history load rather
// than a live IRC connection.
IsFakeEvent bool
AccountID string
Channel string
ChannelID string
ChannelGuestID string // source-room-id by twitch
ChannelGuestDisplayName string // set later when the tab reads the message
Message twitchirc.IRCer
DisplayModifier MessageContentModifier // modifier for the original irc message
// TabID addresses the event to one tab. Empty means every tab.
TabID string
// PrepareCommand is a kitty graphics command the shell writes before the
// event is rendered. The transcript itself never consumes it.
PrepareCommand string
}
ChatEventMessage is one event shown in a chat transcript. The fields are exported because the shell assembles the message: it owns the emote/badge replacers and the link checker, and it builds the event before it knows which transcript will receive it.
type Entry ¶
type Entry struct {
ID EntryID
Event ChatEventMessage
Deleted bool
// contains filtered or unexported fields
}
Entry is one chat event in the transcript. Position, selection and filter state stay private: callers identify an entry by EntryID and read its Event.
type EntryID ¶
type EntryID int
EntryID identifies one transcript entry. It stays valid for the lifetime of the buffer; positions and line numbers are deliberately not part of the interface because they change on every reflow.
type FilterStatus ¶
FilterStatus reports what happened to the search filter.
type MessageContentModifier ¶
type MessageContentModifier struct {
WordReplacements WordReplacement
BadgeReplacement WordReplacement
MessageSuffix string
Strikethrough bool
Italic bool
}
type Palette ¶
type Palette struct {
// contains filtered or unexported fields
}
Palette owns the per-user color render functions. Rendered chat messages, the user inspect window and the composer suggestions all read from the same palette, so a user keeps the same color everywhere.
The zero value is not usable; construct one with NewPalette.
func NewPalette ¶
func NewPalette() *Palette