messages

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Black        color = "\033[30m"
	Red          color = "\033[31m"
	Green        color = "\033[32m"
	Yellow       color = "\033[33m"
	Blue         color = "\033[34m"
	Purple       color = "\033[35m"
	Cyan         color = "\033[36m"
	White        color = "\033[37m"
	BrightBlack  color = "\033[90m"
	BrightRed    color = "\033[91m"
	BrightGreen  color = "\033[92m"
	BrightYellow color = "\033[93m"
	BrightBlue   color = "\033[94m"
	BrightPurple color = "\033[95m"
	BrightCyan   color = "\033[96m"
	BrightWhite  color = "\033[97m"

	BlackBg        color = "\033[40m"
	RedBg          color = "\033[41m"
	GreenBg        color = "\033[42m"
	YellowBg       color = "\033[43m"
	BlueBg         color = "\033[44m"
	PurpleBg       color = "\033[45m"
	CyanBg         color = "\033[46m"
	WhiteBg        color = "\033[47m"
	BrightBlackBg  color = "\033[100m"
	BrightRedBg    color = "\033[101m"
	BrightGreenBg  color = "\033[102m"
	BrightYellowBg color = "\033[103m"
	BrightBlueBg   color = "\033[104m"
	BrightPurpleBg color = "\033[105m"
	BrightCyanBg   color = "\033[106m"
	BrightWhiteBg  color = "\033[107m"

	Bold      color = "\033[1m"
	Dim       color = "\033[2m"
	Underline color = "\033[4m"
	Blink     color = "\033[5m"
	Reverse   color = "\033[7m"
	Hidden    color = "\033[8m"
)
View Source
const (
	BGTITLE = false
	ONLYBG  = true
)

Variables

View Source
var (
	TagOrder = []Tag{WIN, NOTE, FIX, TASK, URL, WORK, ALERT}
	StrToTag = map[string]Tag{
		"win":   WIN,
		"note":  NOTE,
		"fix":   FIX,
		"task":  TASK,
		"url":   URL,
		"work":  WORK,
		"alert": ALERT,
	}
	Tags = map[Tag]string{
		WIN:   winTag,
		NOTE:  noteTag,
		FIX:   fixTag,
		TASK:  taskTag,
		URL:   urlTag,
		WORK:  workTag,
		ALERT: alertTag,
	}
)

TODO: FIXME: refactor this mess when impl custom tags To add a hardcoded tag, follow these steps: 1. Add a new constant to the Tag type 2. Add a new constant to the Tags map 3. Add a new constant to the bgs map 4. Add a new constant to the StrToTag map

Functions

func ColorizeStr

func ColorizeStr(msg string, c ...color) string

func PrintAllTags added in v0.1.8

func PrintAllTags()

Prints all tags for display testing purposes.

func RenderDate added in v0.1.8

func RenderDate(d time.Time) string

func RenderMessages

func RenderMessages(msgs ...Message)

will always be sorted by timestamp

func RenderMsg

func RenderMsg(msg Message, bgOnly bool) string

func RenderTag added in v0.1.8

func RenderTag(msgType Tag, bgOnly bool) string

Types

type Message

type Message struct {
	Timestamp time.Time `db:"timestamp"`
	Msg       string    `db:"msg"`
	ID        int       `db:"id"`
	Tag       Tag       `db:"msgtype"`
}

id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp DATETIME, msg TEXT, msgtype INT

func NewMessage

func NewMessage(tagStr string, msg string) (Message, error)

type Tag added in v0.1.8

type Tag uint8
const (
	ANYTAG Tag = iota
	WIN
	NOTE
	FIX
	TASK
	URL
	WORK
	ALERT
)

Jump to

Keyboard shortcuts

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