Documentation
¶
Index ¶
- Variables
- func BoolPtr(b bool) *bool
- func DateFromString(dateStr string) (time.Time, error)
- func FormatSize(size uint32) string
- func GetConfirmation(prompt string) bool
- func IsUnread(flags []string) bool
- func ParseSize(text string) (uint32, error)
- func RenderFolders(folders []imaputils.FolderStatus, withDates bool) string
- func RenderMessages(messages []*imap.Message) (string, error)
- func RenderSenders(data [][]string) string
- func SelectMessages(messages []*imap.Message, action string, confirmRequired bool) (kept []*imap.Message, committed bool, err error)
- func StringPtr(s string) *string
- func TimePtr(t time.Time) *time.Time
- func TruncateString(str string, maxLength int) string
- func Uint32Ptr(value uint32) *uint32
- func UnreadMarker(flags []string) string
- type MessageDate
- type MessageRow
Constants ¶
This section is empty.
Variables ¶
var MessageColumns = []string{"Date", "Size", "From", "To", "Subject"}
MessageColumns are the message-table column headers, in order. The leading status column is intentionally omitted: unread state is carried on each MessageRow (rendered as bold), and the interactive picker prepends its own checkbox column. This is the single source of truth shared by the static table renderer and the picker.
Functions ¶
func DateFromString ¶
DateFromString takes a date string of format "yyyy-mm-dd" and returns a Time
func FormatSize ¶ added in v1.1.0
FormatSize renders a byte count as a short human-readable string using binary units, e.g. 1572864 -> "1.5M".
func GetConfirmation ¶
GetConfirmation prompts the user for confirmation before proceeding
func ParseSize ¶ added in v1.1.0
ParseSize parses a human-friendly size string into a number of bytes. It accepts a bare byte count ("1024") or a value with a binary unit suffix (K/KB, M/MB, G/GB, case-insensitive), e.g. "10M" = 10 MiB. The result must fit in a uint32, which is what IMAP SEARCH LARGER/SMALLER use.
func RenderFolders ¶ added in v1.3.0
func RenderFolders(folders []imaputils.FolderStatus, withDates bool) string
RenderFolders renders a folder listing with message and unread counts as a table string in the shared style. When withDates is true it also includes the date range of each folder's messages. Non-selectable container folders (and empty folders, for dates) show "-". The numeric count columns are right-aligned.
func RenderMessages ¶ added in v1.3.0
RenderMessages renders messages as a table string for static (non-interactive) display: the shared columns, with unread rows in bold (replacing the old dot column) and a trailing count caption. Borders are reduced to a single header rule so the static view matches the interactive picker, which draws the same shape plus a leading checkbox column.
func RenderSenders ¶ added in v1.3.0
RenderSenders renders sender/count data (data[0] is the header row) as a table string in the shared style, with the trailing count column right-aligned.
func SelectMessages ¶ added in v1.3.0
func SelectMessages(messages []*imap.Message, action string, confirmRequired bool) (kept []*imap.Message, committed bool, err error)
SelectMessages runs the interactive picker over messages (all pre-selected) and returns the subset the user keeps. committed is false when the user cancels, in which case the caller must not act. action labels the pending operation in the picker header (e.g. "delete", "move to Archive"). confirmRequired adds a final confirmation screen for state-changing actions (copy/move/delete); pass false for trivially reversible ones (mark read).
func TruncateString ¶
TruncateString truncates a string to the specified length and appends an ellipsis if needed.
func UnreadMarker ¶ added in v1.1.0
UnreadMarker returns a dot for messages lacking the \Seen flag (unread) and an empty string for read messages, for use as a compact status indicator.
Types ¶
type MessageDate ¶
MessageDate represents a normalized message date with timezone handling
func NewMessageDate ¶
func NewMessageDate(internalDate time.Time) MessageDate
NewMessageDate creates a new MessageDate from an IMAP internal date
func (MessageDate) FormatConsistent ¶
func (md MessageDate) FormatConsistent(timezone *time.Location) string
FormatConsistent returns a consistently formatted date string in the specified timezone
func (MessageDate) LocalizeToZone ¶
func (md MessageDate) LocalizeToZone(timezone *time.Location) time.Time
LocalizeToZone returns the date in the specified timezone
type MessageRow ¶ added in v1.3.0
MessageRow is one formatted message: its cells (aligned 1:1 with MessageColumns) and whether the message is unread, so renderers can style unread rows rather than carrying a separate marker column.
func FormatMessageRows ¶ added in v1.3.0
func FormatMessageRows(messages []*imap.Message) ([]MessageRow, error)
FormatMessageRows formats messages into display rows, the single source of truth for how a message renders. Cells are pre-truncated to their column widths. A message without an envelope (malformed or partial fetch) falls back to placeholders rather than panicking.