color

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Handle colors in Weechat strings.

Index

Constants

View Source
const (
	TitleColor   = "green"
	DefaultColor = "-:-:-"
	TimeColor    = "grey"
	MsgColor     = "white"
	ChatColor    = "grey"
	ChanColor    = "blue"
	NickColor    = "pink"
	UnreadColor  = "purple"
	// Color for messages that have particular sub-strings,
	// like join and leave
	JoinColor       = "grey"
	LeaveColor      = "grey"
	NickChangeColor = "grey"

	// color with bold
	BoldBlue = "blue::b"
)

Variables

View Source
var (
	// Mostly copied verbatim from qweechat.
	// https://github.com/weechat/qweechat/blob/master/qweechat/weechat/color.py#L25
	ColorsRegex = `[*!/_]*`
	ColorsStd   = fmt.Sprintf(`(?:%s\d{2})`, ColorsRegex)
	ColorsExt   = fmt.Sprintf(`(?:@%v\d{5})`, ColorsRegex)
	ColorsAny   = fmt.Sprintf(`(?:%s|%s)`, ColorsStd, ColorsExt)
	ColorsRe    = fmt.Sprintf(
		`(\x19(?:\d{2}|F%v|B\d{2}|B@\d{5}|E|\\*%v(,%v)?|@\d{5}|b.|\x1C))|\x1A.|\x1B.|\x1C`,
		ColorsAny, ColorsAny, ColorsAny)
)
View Source
var Blue = "\033[34m"
View Source
var Cyan = "\033[36m"
View Source
var Gray = "\033[37m"
View Source
var Green = "\033[32m"
View Source
var Purple = "\033[35m"
View Source
var Red = "\033[31m"
View Source
var Reset = "\033[0m"
View Source
var White = "\033[97m"
View Source
var Yellow = "\033[33m"

Functions

func Colorize

func Colorize(in string) string

When fully implemented, will replace weechat colors with colors that tview understands. Currently, not in a functional state.

func RemoveColor

func RemoveColor(with_color string) string

Parse out colors of the form [color]text[color] from the string if it exists.

func ReplaceWeechatColors added in v0.0.3

func ReplaceWeechatColors(with_color string, replacefunc func(string) string) string

Replace the weechat colors parsed using regex and use the replaceFund to find substituations.

Types

This section is empty.

Jump to

Keyboard shortcuts

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