Documentation ¶
Index ¶
- Constants
- Variables
- func AddToResizeHandlers(f func(*Size)) error
- func ClearLine(w io.Writer)
- func ColorString(c uint8, s string) string
- func FmtColorForeground(c uint8) string
- func GetColorInt(r, g, b float64) uint8
- func GetColorIntAdv(r, g, b float64) (uint8, float64)
- func GetRGBInt(rgb int64) uint8
- func GetRGBIntAdv(rgb int64) (uint8, float64)
- func HideCursor(w io.Writer)
- func MoveCursorDown(w io.Writer, line int)
- func MoveCursorLeft(w io.Writer, line int)
- func MoveCursorLine(w io.Writer, line int)
- func MoveCursorRight(w io.Writer, line int)
- func MoveCursorTo(w io.Writer, row, col int)
- func MoveCursorToLineStart(w io.Writer)
- func MoveCursorUp(w io.Writer, line int)
- func NewPrinterMu(w io.Writer) io.Writer
- func ShowCursor(w io.Writer)
- type CLIContext
- type MessagePrinter
- type PrinterMu
- type Size
Constants ¶
const ( Bold = "\033[1m" Reset = "\033[0m" )
const AvatarLines = 3
AvatarLines sets the avatar to be 3 lines big. This means the minimum padding should be 4 lines away. Here's how it works.
First, we print the author name. That's one line. As we print the content, that's n more lines. We should now print the new lines for the next message. Where? To calculate that, we get max(ImageLines - 1, n + 1)
const EmbedColor = 0x00B0F4
const EmbedPill = Bold + "│" + Reset
const EmojiLines = 2
const ImageLines = 8
ImageLines sets the avatar to be at most 3 lines big. This means the minimum
const TextLeftPadding = 2 // characters to pad from the avatar
Variables ¶
var ( // Colors contains a list of terminal colors // https://jonasjacek.github.io/colors/ Colors = map[uint8]colorful.Color{}/* 256 elements not displayed */ )
var ResizeHandlers []func(sz *Size)
Functions ¶
func AddToResizeHandlers ¶
func ColorString ¶
func FmtColorForeground ¶
FmtColorForeground turns a terminal color ID into string
func GetColorInt ¶
GetColorInt is a shotthand to GetColorIntAdv, to prevent breaking changes
func GetColorIntAdv ¶
GetColorIntAdv takes in (r|g|b)/255 and returns with the distance (accuracy, the less the closer)
func GetRGBIntAdv ¶
GetRGBIntAdv takes in an RGB int64 and return a terminal color ID. It uses GetColorIntAdv. The result are NOT cached. For cached results, use GetRGBInt.
func HideCursor ¶
func MoveCursorDown ¶
func MoveCursorLeft ¶
func MoveCursorLine ¶
func MoveCursorRight ¶
func MoveCursorTo ¶
func MoveCursorToLineStart ¶
func MoveCursorUp ¶
func ShowCursor ¶
Types ¶
type CLIContext ¶
type CLIContext struct { *readline.Instance ChannelID string // contains filtered or unexported fields }
func (*CLIContext) SetChannel ¶
func (c *CLIContext) SetChannel(channel *discordgo.Channel)
type MessagePrinter ¶
type MessagePrinter struct { Current *discordgo.Channel Stdout io.Writer // contains filtered or unexported fields }
func NewMessagePrinter ¶
func NewMessagePrinter(dg *discordgo.Session, rl *readline.Instance) *MessagePrinter
func (*MessagePrinter) GetHandler ¶
func (p *MessagePrinter) GetHandler() func(*discordgo.Session, *discordgo.MessageCreate)