render

package
v1.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectAttachments

func CollectAttachments(msg *gmailapi.Message) (atts []AttachmentMeta, images []AttachmentMeta)

CollectAttachments traverses MIME parts to collect attachments and inline images

func FormatEmailForTerminal

func FormatEmailForTerminal(ctx context.Context, msg *gmailwrap.Message, opts FormatOptions, touchUp TouchUpFunc) (string, error)

FormatEmailForTerminal builds terminal-friendly text with [BODY], [ATTACHMENTS], [IMAGES], [LINKS] It preserves quotes (>), code/pre/PGP blocks, lists and rudimentary ASCII tables.

func MarkdownToTerminal added in v1.4.0

func MarkdownToTerminal(markdown, theme string, width int) (string, error)

MarkdownToTerminal renders Markdown to terminal text styled by glamour, then translates ANSI escapes to tview color tags for the message TextView.

func RenderEmailMarkdown added in v1.4.0

func RenderEmailMarkdown(msg *gmailwrap.Message, opts MarkdownOptions) (string, error)

RenderEmailMarkdown converts an email's HTML to cleaned, glamour-styled terminal text. Returns an error if the message has no HTML body; callers fall back to FormatEmailForTerminal on error.

func WrapTextPreserving

func WrapTextPreserving(input string, width int) string

WrapTextPreserving wraps text to width preserving quotes (> ), code/PGP blocks and URLs

Types

type AttachmentMeta

type AttachmentMeta struct {
	Filename  string
	MimeType  string
	Size      int64
	Inline    bool
	ContentID string
}

AttachmentMeta contains attachment or inline image metadata

type ColumnCell

type ColumnCell struct {
	Content   string
	Alignment int // tview alignment constant
	MaxWidth  int // 0 = unlimited
	Expansion int // Weight for width distribution
}

ColumnCell represents individual cell data within a table row

type ColumnConfig

type ColumnConfig struct {
	Header    string
	Alignment int // tview alignment constant
	Expansion int // Weight for extra width distribution
	MaxWidth  int // 0 = unlimited
	MinWidth  int // Minimum guaranteed width
}

ColumnConfig defines column behavior and styling

func GetColumnConfig

func GetColumnConfig(mode DisplayMode) []ColumnConfig

GetColumnConfig returns column configuration for the specified display mode

type DisplayMode

type DisplayMode int

DisplayMode represents different email list display modes

const (
	ModeFlatList DisplayMode = iota
	ModeThreaded
)

type EmailColorer

type EmailColorer struct {
	UnreadColor    tcell.Color
	ReadColor      tcell.Color
	ImportantColor tcell.Color
	SentColor      tcell.Color
	DraftColor     tcell.Color
	DefaultColor   tcell.Color
}

EmailColorer maneja los colores de emails

func NewEmailColorer

func NewEmailColorer(unreadColor, readColor, importantColor, sentColor, draftColor, defaultColor tcell.Color) *EmailColorer

NewEmailColorer creates a new email colorer with theme-aware colors

func NewEmailColorerDefault

func NewEmailColorerDefault() *EmailColorer

NewEmailColorerDefault creates a new email colorer with default fallback colors

func (*EmailColorer) ColorerFunc

func (ec *EmailColorer) ColorerFunc() func(*googleGmail.Message, string) tcell.Color

ColorerFunc returns a colorer function for emails

func (*EmailColorer) UpdateFromStyles

func (ec *EmailColorer) UpdateFromStyles(colors *config.ColorsConfig)

UpdateFromStyles updates colors from configuration using v2.0 hierarchical themes

type EmailColumnData

type EmailColumnData struct {
	Columns []ColumnCell
	RowType EmailRowType
	Color   tcell.Color
}

EmailColumnData represents structured data for any display mode

type EmailRenderer

type EmailRenderer struct {
	// contains filtered or unexported fields
}

EmailRenderer handles email rendering and formatting

func NewEmailRenderer

func NewEmailRenderer(cfg *config.Config) *EmailRenderer

NewEmailRenderer creates a new email renderer

func (*EmailRenderer) ExtractAttachmentIcon

func (er *EmailRenderer) ExtractAttachmentIcon(message *googleGmail.Message) string

ExtractAttachmentIcon returns attachment icon (📎) padded to 2 characters

func (*EmailRenderer) ExtractCalendarIcon

func (er *EmailRenderer) ExtractCalendarIcon(message *googleGmail.Message) string

ExtractCalendarIcon returns calendar icon (📅) padded to 2 characters

func (*EmailRenderer) ExtractSenderName

func (er *EmailRenderer) ExtractSenderName(from string) string

ExtractSenderName extracts the sender name from a From header

func (*EmailRenderer) FormatEmailHeader

func (er *EmailRenderer) FormatEmailHeader(message *googleGmail.Message) string

FormatEmailHeader formats email header for display

func (*EmailRenderer) FormatEmailList

func (er *EmailRenderer) FormatEmailList(message *googleGmail.Message, maxWidth int) (string, tcell.Color)

FormatEmailList formats an email for list display

func (*EmailRenderer) FormatFlatMessageColumns

func (er *EmailRenderer) FormatFlatMessageColumns(message *googleGmail.Message) EmailColumnData

FormatFlatMessageColumns formats a message for flat list display using columns

func (*EmailRenderer) FormatHeaderANSI

func (er *EmailRenderer) FormatHeaderANSI(subject, from, to, cc string, date time.Time, labels []string) string

FormatHeaderANSI returns the email header formatted using ANSI escape codes (green block)

func (*EmailRenderer) FormatHeaderPlain

func (er *EmailRenderer) FormatHeaderPlain(subject, from, to, cc string, date time.Time, labels []string) string

FormatHeaderPlain returns a plain header without markup/tags

func (*EmailRenderer) FormatHeaderPlainWithWidth

func (er *EmailRenderer) FormatHeaderPlainWithWidth(subject, from, to, cc string, date time.Time, labels []string, width int) string

FormatHeaderPlainWithWidth returns a plain header with line wrapping for long fields

func (*EmailRenderer) FormatHeaderStyled

func (er *EmailRenderer) FormatHeaderStyled(subject, from, to, cc string, date time.Time, labels []string) string

FormatHeaderStyled: simple header without colors/markup

func (*EmailRenderer) FormatLabelsForColumn

func (er *EmailRenderer) FormatLabelsForColumn(message *googleGmail.Message, maxWidth int) string

FormatLabelsForColumn formats labels specifically for dedicated column display Returns labels formatted for the given available width with intelligent truncation

func (*EmailRenderer) GetDate

func (er *EmailRenderer) GetDate(message *googleGmail.Message) time.Time

GetDate extracts the date from a message

func (*EmailRenderer) GetHeader

func (er *EmailRenderer) GetHeader(message *googleGmail.Message, name string) string

GetHeader extracts a header value from a message

func (*EmailRenderer) GetMessageColor

func (er *EmailRenderer) GetMessageColor(message *googleGmail.Message) tcell.Color

GetMessageColor returns the appropriate color for a message based on its state

func (*EmailRenderer) IsDraft

func (er *EmailRenderer) IsDraft(message *googleGmail.Message) bool

IsDraft checks if a message is a draft

func (*EmailRenderer) IsImportant

func (er *EmailRenderer) IsImportant(message *googleGmail.Message) bool

IsImportant checks if a message is important

func (*EmailRenderer) IsSent

func (er *EmailRenderer) IsSent(message *googleGmail.Message) bool

IsSent checks if a message is sent

func (*EmailRenderer) IsUnread

func (er *EmailRenderer) IsUnread(message *googleGmail.Message) bool

IsUnread checks if a message is unread

func (*EmailRenderer) SetLabelMap

func (er *EmailRenderer) SetLabelMap(m map[string]string)

SetLabelMap sets a map of label ID -> label Name used when rendering list chips

func (*EmailRenderer) SetShowSystemLabelsInList

func (er *EmailRenderer) SetShowSystemLabelsInList(v bool)

SetShowSystemLabelsInList toggles whether system labels (Inbox, Sent, Spam, etc.) should be rendered as chips in the list view.

func (*EmailRenderer) TruncateRecipientField added in v1.0.1

func (er *EmailRenderer) TruncateRecipientField(fieldName, value string, maxLines int, lineWidth int) string

TruncateRecipientField truncates recipient fields to fit within specified line limit

func (*EmailRenderer) UpdateColorer

func (er *EmailRenderer) UpdateColorer(unreadColor, readColor, importantColor, sentColor, draftColor, defaultColor tcell.Color)

UpdateColorer updates the email colorer with theme-aware colors

func (*EmailRenderer) UpdateFromConfig

func (er *EmailRenderer) UpdateFromConfig(colors *config.ColorsConfig)

UpdateFromConfig updates the renderer with new configuration

type EmailRowType

type EmailRowType int

EmailRowType represents the type of row being displayed

const (
	RowTypeFlatMessage EmailRowType = iota
	RowTypeThreadHeader
	RowTypeThreadMessage
	RowTypeHeader
)

type FormatOptions

type FormatOptions struct {
	WrapWidth int
	UseLLM    bool
}

FormatOptions controls terminal formatting behavior

type LinkRef

type LinkRef struct {
	Index int
	URL   string
	Text  string
}

LinkRef represents a collected hyperlink reference

type MarkdownOptions added in v1.4.0

type MarkdownOptions struct {
	WrapWidth          int
	GlamourTheme       string
	DropTrackingImages bool
}

MarkdownOptions controls markdown rendering and cleanup.

type TouchUpFunc

type TouchUpFunc func(ctx context.Context, input string, wrapWidth int) (string, error)

TouchUpFunc is an optional post-processing function (e.g., LLM) to adjust whitespace only

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL