text

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bold      = "\033[1m"
	Normal    = "\033[22m"
	Black     = "\033[30m"
	Red       = "\033[31m"
	Green     = "\033[32m"
	Yellow    = "\033[33m"
	Blue      = "\033[34m"
	Magenta   = "\033[35m"
	Cyan      = "\033[36m"
	White     = "\033[37m"
	Default   = "\033[39m"
	BGBlack   = "\033[40m"
	BGRed     = "\033[41m"
	BGGreen   = "\033[42m"
	BGYellow  = "\033[43m"
	BGBlue    = "\033[44m"
	BGMagenta = "\033[45m"
	BGCyan    = "\033[46m"
	BGWhite   = "\033[47m"
	BGDefault = "\033[49m"

	// Setup brown as an alias for yellow
	Brown   = Yellow
	BGBrown = BGYellow
)

ANSI escape sequences for setting colors. These sequences can be concatenated into strings or appended to slice directly. This is preferable to calling Colorize with embedded colour place holders due to the slower performance of Colorize.

Variables

This section is empty.

Functions

func Colorize

func Colorize(in []byte) []byte

Colorize returns a []byte with color place holders replaced with their ANSI escape sequence equivalent. Color place holders have the format [COLOR] where COLOR represents the name of the color (uppercased) to be used. For example:

Colorize([]byte("[RED]Hello [GREEN]World![DEFAULT]"))

Would return a []byte with [RED] and [GREEN] replaced with the ANSI escape sequences \033[31m and \033[32m respectively causing Hello to be displayed in red and World! to be displayed in green.

The returned slice is always a copy even it the original contains no colors.

Use of this function is discouraged due to relatively poor performance. It's main use is to render text from files, such as those loaded when the server is initially started. In code it is better to use the ANSI escape sequence constants directly.

func Dictionary

func Dictionary(s ...string) (d dictionary)

Dictionary returns a new dictionary containing the specified strings. The dictionary can then be checked to see if it contains a specific string (case insensitive) by calling the Contains method.

NOTE: The strings in the dictionary are converted to uppercase.

func Fold

func Fold(in []byte, width int) []byte

Fold takes a string and reformats it so lines have a maximum length of the passed width. Fold will handle multibyte runes. However it cannot handle 'wide' runes - those that are wider than a normal single character when displayed. This is because the required information is actually contained in the font files of the font in use at the 'client' end.

For example the Chinese for 9 is 九 (U+4E5D). Even in a monospaced font 九 will take up the space of two columns.

It is expected that the incoming end of lines are Unix linefeeds (LF, \n) only and will be output as carridge return and linefeed pairs (CR+LF, \r\n) for Telnet. For more information see RFC854 - Telnet Protocol Specification.

Types

This section is empty.

Source Files

  • color.go
  • dictionary.go
  • fold.go

Jump to

Keyboard shortcuts

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