Documentation
¶
Index ¶
- func RepeatRune(r rune, n uint) string
- func RepeatRune2(r rune, n uint) (string, error)
- func SplitTrim(s string) []string
- type Box
- func (b *Box) BottomCenter(container *Box)
- func (b *Box) Center(container *Box)
- func (b *Box) Fill(container *Box)
- func (b *Box) FillWithMargins(container *Box, margins int)
- func (b *Box) FillWithPercentageMargins(container *Box, horizmarginp float32, vertmarginp float32)
- func (b *Box) GetContentPos() (int, int)
- func (b *Box) GetFrame() *Rect
- func (b *Box) GetInner() *Rect
- func (b *Box) Place(container *Box)
- func (b *Box) SetFrame(r *Rect)
- func (b *Box) SetInner(r *Rect)
- func (b *Box) SetNicePlacement(container *Box)
- func (b *Box) SetThirdPlace(container *Box)
- func (b *Box) SetThirdSize(container *Box)
- type Rect
- type Theme
- func (t *Theme) DrawAsciiArt(c *vt100.Canvas, x, y int, text string) int
- func (t *Theme) DrawBackground()
- func (t *Theme) DrawBox(c *vt100.Canvas, r *Box, extrude bool) *Rect
- func (t *Theme) DrawButton(c *vt100.Canvas, r *Box, text string, active bool)
- func (t *Theme) DrawList(c *vt100.Canvas, r *Box, items []string, selected int)
- func (t *Theme) DrawRaw(c *vt100.Canvas, x, y int, text string) int
- func (t *Theme) Say(c *vt100.Canvas, x, y int, text string)
- func (t *Theme) SetBackgroundColor(c vt100.AttributeColor)
- func (t *Theme) SetTextColor(c vt100.AttributeColor)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RepeatRune ¶
Repeat a rune, n number of times. Returns an empty string if memory can not be allocated within append.
func RepeatRune2 ¶
Repeat a rune, n number of times
Types ¶
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box has one outer and one innner rectangle. This is useful when having margins that surrounds content.
func (*Box) BottomCenter ¶
Place a box at the bottom center of a given container
func (*Box) FillWithMargins ¶
Place a Box inside a given container, with the given margins. Margins are given in number of characters.
func (*Box) FillWithPercentageMargins ¶
Place a Box inside a given container, using the given percentage wise ratios. horizmarginp can for example be 0.1 for a 10% horizontal margin around the inner box. vertmarginp works similarly, but for the vertical margins.
func (*Box) GetContentPos ¶
Retrieves the position of the inner rectangle.
func (*Box) SetNicePlacement ¶
Place a Box so that it either fills the given container, or is placed 1/3 from the upper left edge, depending on how much space is left.
func (*Box) SetThirdPlace ¶
Set the position of the Box to 1/3 of the size of the inner rectangle of the given container.
func (*Box) SetThirdSize ¶
Set the size of the Box to 1/3 of the size of the inner rectangle of the given container.
type Theme ¶
type Theme struct {
Text, Background, Title,
BoxLight, BoxDark, BoxBackground,
ButtonFocus, ButtonText,
ListFocus, ListText, ListBackground vt100.AttributeColor
TL, TR, BL, BR, V, V2, H, H2 rune
}
func (*Theme) DrawAsciiArt ¶
Outputs a multiline string at the given coordinates. Uses the box background color. Returns the final y coordinate after drawing.
func (*Theme) DrawBackground ¶
func (t *Theme) DrawBackground()
Clear the canvas, set a background color and draw the canvas.
func (*Theme) DrawBox ¶
Draw a box using ASCII graphics. The given Box struct defines the size and placement. If extrude is True, the box looks a bit more like it's sticking out.
func (*Theme) DrawButton ¶
Draws a button widget at the given placement, with the given text. If active is False, it will look more "grayed out".
func (*Theme) DrawList ¶
Draw a list widget. Takes a Box struct for the size and position. Takes a list of strings to be listed and an int that represents which item is currently selected. Does not scroll or wrap.
func (*Theme) DrawRaw ¶
Outputs a multiline string at the given coordinates. Uses the default background color. Returns the final y coordinate after drawing.
func (*Theme) SetBackgroundColor ¶
func (t *Theme) SetBackgroundColor(c vt100.AttributeColor)
Set the background color
func (*Theme) SetTextColor ¶
func (t *Theme) SetTextColor(c vt100.AttributeColor)
Set the text color