Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(input int) int
- func ClampInt(input int, minimum int, maximum int) int
- func GetTerminalSize() (width int, height int, err error)
- func PlaceHorizontallyScrolled(viewWidth int, hPos int, input string) string
- func PlaceStacked(bottom string, top string, origin Position, vPos int, hPos int) string
- func PlaceVerticallyAndHorizontallyScrolled(viewHeight int, viewWidth int, vPos int, hPos int, input string) string
- func Round(input float64) int
- func WrapInt(value int, min int, max int) int
- type Position
Constants ¶
const ( WHITESPACE_CHAR = " " BULLET = "•" ELLIPSIS = "…" )
Variables ¶
Functions ¶
func Abs ¶
Returns the integer absolute value of the given integer. (Integer alternative to math.Abs)
func GetTerminalSize ¶
func PlaceHorizontallyScrolled ¶
Takes an input string and places it horizontally in a view of a given width. If the visible width of the input is larger than the view width or the provided horizontal position of the input string places it partially out of the view, it will be cropped. If the input gets cropped, only the visible characters in the string will be removed, so any ansi sequences in the string will still apply to the remaining visible characters (this avoids visual artifacts from mangled ansi sequences).
viewWidth: int - The width (in cells) of the view hPos: int - The horizontal offset of the input string input: int - The string to be placed
func PlaceStacked ¶
Takes a top string and places it on top of (in front of, i.e. visually obstructing) a given bottom string. This function also takes a position argument, specifying which corner the two strings should be joined on (if position is 2, the top-left corner of the top string should be over the top-left corner of the bottom string)
bottom: string - The input string to be placed on the bottom of the stack top: string - The input string to be placed on the top of the stack vPos: int - The vertical offset of the top string hPos: int - The horizontal offset of the top string
func PlaceVerticallyAndHorizontallyScrolled ¶
func PlaceVerticallyAndHorizontallyScrolled(viewHeight int, viewWidth int, vPos int, hPos int, input string) string
Takes an input string and places it in a view of a given width and height. If any of the visible dimensions of the input are larger than their corresponding view dimensions, or the provided position of the input string places it partially out of the view, it will be cropped. If the input gets cropped, only the visible characters in the string will be removed, so any ansi sequences in the string will still apply to the remaining visible characters (this avoids visual artifacts from mangled ansi sequences).
viewHeight: int - The height (in rows) of the view viewWidth: int - The width (in cells) of the view vPos: int - The vertical offset of the input string hPos: int - The horizontal offset of the input string input: int - The string to be placed