Documentation ¶
Overview ¶
A simple package for adding colourful comments onto source code lines primarily for the use of user-friendly error messages.
Index ¶
- Constants
- type Decorator
- func (dec *Decorator) AddBottomComment(line int, at int, comment string) error
- func (dec *Decorator) AddLine(line string, meta LineMetadata) error
- func (dec *Decorator) AddTopComment(line int, at int, comment string) error
- func (dec *Decorator) ColourBottomComment(line int, comment int, colour LineColour) error
- func (dec *Decorator) ColourLine(line int, colour LineColour) error
- func (dec *Decorator) ColourTopComment(line int, comment int, colour LineColour) error
- func (dec *Decorator) String() string
- type LineColour
- type LineColourEnum
- type LineMetadata
Constants ¶
const ( Normal = "\033[0m" Bold = "\033[1m" FgBlack = "\033[30m" FgRed = "\033[31m" FgGreen = "\033[32m" FgYellow = "\033[33m" FgBlue = "\033[34m" FgMagenta = "\033[35m" FgCyan = "\033[36m" FgWhite = "\033[37m" BgBlack = "\033[40m" BgRed = "\033[41m" BgGreen = "\033[42m" BgYellow = "\033[43m" BgBlue = "\033[44m" BgMagenta = "\033[45m" BgCyan = "\033[46m" BgWhite = "\033[47m" )
The different styles that can be applied to a line. Currently you can only specify one value per line.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decorator ¶
type Decorator struct {
// contains filtered or unexported fields
}
The main type responsible for this library's functionality.
func (*Decorator) AddBottomComment ¶
Adds a comment below the specified line, pointing at a specific character in that line. Lines can have multiple bottom comments.
func (*Decorator) AddLine ¶
func (dec *Decorator) AddLine(line string, meta LineMetadata) error
Adds a new line to be decorated.
func (*Decorator) AddTopComment ¶
Adds a comment above the specified line, pointing at a specific character in that line. Lines can have multiple top comments.
func (*Decorator) ColourBottomComment ¶
func (dec *Decorator) ColourBottomComment(line int, comment int, colour LineColour) error
Applies colouring to the specified comment for the specified line.
func (*Decorator) ColourLine ¶
func (dec *Decorator) ColourLine(line int, colour LineColour) error
Applies colouring to the specified line.
func (*Decorator) ColourTopComment ¶
func (dec *Decorator) ColourTopComment(line int, comment int, colour LineColour) error
Applies colouring to the specified comment for the specified line.
type LineColour ¶
type LineColour struct { // The index of the first character to colour. From int // The index of the last character (non-inclusive) to colour. To int // The colouring to apply. Colour LineColourEnum }
Describes how to colour a particular segment of a line.
type LineMetadata ¶
type LineMetadata struct { // The line number that this line was extracted from. LineNumber int // The file that this line belongs to. FileName string // contains filtered or unexported fields }
Describes metadata about a line.