ui

package
v0.0.0-...-16605f2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BottomLineHeight = 4

Variables

View Source
var (
	Screen tcell.Screen

	StatusLineNumber  int
	InputLineNumber   int
	OptionsLineNumber int
)
View Source
var (

	// The following four global variables are updated by the ShowCharacterInCenter function
	CharacterXPos           int
	CharacterYPos           int
	LongestCharacterSection int
	ClearCurrentCharacter   func()
)
View Source
var ErrorInputTerminated = errors.New("input interrupted")

ErrorInputTerminated is the error returned when a user presses CTRL+C during a text input

Functions

func AnimateSlideIn

func AnimateSlideIn(image []string)

AnimateSlideIn shows an animation of the specified image scrolling in from the left hand side of the screen and vanishing as is passes the center point of the display on the X axis.

func BeforeShutdown

func BeforeShutdown()

BeforeShutdown is called before the program exits. It clears the console and terminates the tcell.Screen instance, which means that any error messages or stacktraces that may have arisen can be printed normally and automatically by Go without being messed up.

func Box

func Box(topLeftX, topLeftY, bottomRightX, bottomRightY int, title string)

Box prints a box between a specified top left position and bottom right position, as well as an optional title

func CharacterSay

func CharacterSay(in string, yOffset, xOffset int) (clearFunc func())

CharacterSay prints the specified string prefixed by "> " at the specified offset from the top right hand corner of the currently displayed character. If the string has newlines in it, it is split and each line is printed underneath the previous, with a prefix of " ". A function that can be used to clear the text printed by this function is returned.

func CollectInputAtPosition

func CollectInputAtPosition(reader io.Reader, posX, posY int, clearAfter bool, limit int) (string, error)

CollectInputAtPosition collects input from the provided io.Reader from the specified position on the screen. If clearAfter is true, the input echoed to the display is cleared after a newline is entered. limit specifies the maximum number of bytes that will be accepted as input.

func FindTopLeftCoord

func FindTopLeftCoord(character []string, longestStringLen int) (int, int)

FindTopLeftCoord is used to find the top left coordinate of an image based on its length and the length of its longest part if that image is to be placed in the center of the console

func MakeClearFunction

func MakeClearFunction(character []string, printedXPos, printedYPos int) func()

MakeClearFunction returns a function the clear any images that are printed to the console based on the image itself and position it was printed in.

func PrintLine

func PrintLine(fixedPos int, char rune, isVertical bool)

PrintLine prints a line of the specified rune along a certain point on the X or Y axis. If isVertical is true, then the line is printed along x = fixedPos. Else, if isVertical is false, the line is printed along y = fixedPos

func PrintString

func PrintString(in string, posX, posY int)

PrintString prints a string in a specified position. This function acquires and releases the display lock before it does anything and after is has updated the display accordingly.

func PrintTransparentMultiRuneSlice

func PrintTransparentMultiRuneSlice(in [][]rune, posX, posY int)

PrintTransparentMultiString prints a slice of slices of runes beneath each other while not printing spaces (" "), with the top left hand corner of the printed set being at the provided coordinate.

func PrintTransparentMultiString

func PrintTransparentMultiString(in []string, posX, posY int)

PrintTransparentMultiString prints a slice of strings beneath each other while not printing spaces (" "), with the top left hand corner of the printed set being at the provided coordinate.

func Scaffold

func Scaffold()

Scaffold draws the inital screen layout, with the Tux character, the info box, a line across the bottom of the screen for the status bar and the ">" symbol where text is inputted from.

func SelectOption

func SelectOption(opts []string) (int, string, error)

SelectOption wraps ShowOptions, but also adds a prompt for the user to input one of the options. The selected option index and value are returned, and the printed text is cleared afterwards

func ShowCharacterInCenter

func ShowCharacterInCenter(character []string)

ShowCharacterInCenter prints the current character in the center of the console and updates the following global variables: * ClearCurrentCharacter * LongestCharacterSection * CharacterXPos * CharacterYPos

func ShowOptions

func ShowOptions(opts []string)

ShowOptions shows a set of options with a corresponding letter based off the position in the slice in the options line of the bottom bar of the display.

func StartStatLoop

func StartStatLoop(pt *pet.Pet)

StartStatLoop starts a background worker that updates that statistics in the UI whenever they are modified in the worker. Further explanation about how this function works can be found in the README.md file for this project.

func UpdateStats

func UpdateStats(petInfo *pet.Pet)

UpdateStats takes a reference to a pet and shows its statistics in the info box in the console

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳