ui

package
v0.0.0-...-3b3c969 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bold  = "\033[1m"
	Reset = "\033[0m"
)
View Source
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)

View Source
const EmbedColor = 0x00B0F4
View Source
const EmbedPill = Bold + "│" + Reset
View Source
const EmojiLines = 2
View Source
const ImageLines = 8

ImageLines sets the avatar to be at most 3 lines big. This means the minimum

View Source
const TextLeftPadding = 2 // characters to pad from the avatar

Variables

View Source
var (
	// Colors contains a list of terminal colors
	// https://jonasjacek.github.io/colors/
	Colors = map[uint8]colorful.Color{}/* 256 elements not displayed */

)
View Source
var ResizeHandlers []func(sz *Size)

Functions

func AddToResizeHandlers

func AddToResizeHandlers(f func(*Size)) error

func ClearLine

func ClearLine(w io.Writer)

func ColorString

func ColorString(c uint8, s string) string

func FmtColorForeground

func FmtColorForeground(c uint8) string

FmtColorForeground turns a terminal color ID into string

func GetColorInt

func GetColorInt(r, g, b float64) uint8

GetColorInt is a shotthand to GetColorIntAdv, to prevent breaking changes

func GetColorIntAdv

func GetColorIntAdv(r, g, b float64) (uint8, float64)

GetColorIntAdv takes in (r|g|b)/255 and returns with the distance (accuracy, the less the closer)

func GetRGBInt

func GetRGBInt(rgb int64) uint8

GetRGBInt takes in an RGB int64 and return a terminal color ID.

func GetRGBIntAdv

func GetRGBIntAdv(rgb int64) (uint8, float64)

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 HideCursor(w io.Writer)

func MoveCursorDown

func MoveCursorDown(w io.Writer, line int)

func MoveCursorLeft

func MoveCursorLeft(w io.Writer, line int)

func MoveCursorLine

func MoveCursorLine(w io.Writer, line int)

func MoveCursorRight

func MoveCursorRight(w io.Writer, line int)

func MoveCursorTo

func MoveCursorTo(w io.Writer, row, col int)

func MoveCursorToLineStart

func MoveCursorToLineStart(w io.Writer)

func MoveCursorUp

func MoveCursorUp(w io.Writer, line int)

func NewPrinterMu

func NewPrinterMu(w io.Writer) io.Writer

func ShowCursor

func ShowCursor(w io.Writer)

Types

type CLIContext

type CLIContext struct {
	*readline.Instance

	ChannelID string
	// contains filtered or unexported fields
}

func NewCLI

func NewCLI(dg *discordgo.Session) (*CLIContext, error)

func (*CLIContext) SetChannel

func (c *CLIContext) SetChannel(channel *discordgo.Channel)

func (*CLIContext) Start

func (c *CLIContext) Start()

TODO: singleton for channelID

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)

type PrinterMu

type PrinterMu struct {
	// contains filtered or unexported fields
}

func (*PrinterMu) Write

func (p *PrinterMu) Write(b []byte) (int, error)

type Size

type Size struct {
	Row    int
	Col    int
	Xpixel int
	Ypixel int
}

func (*Size) CalculateCharSize

func (s *Size) CalculateCharSize() (int, int)

Jump to

Keyboard shortcuts

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