Api/ApiLib/cPrint

From Minux Wiki
Jump to navigation Jump to search

3rd party api/utlility Created by jesusthekiller [1]

An API primarily used to replace term.setTextColor and term.setBackgroundColor.

If you're creating a program that utilizes many differently colored strings, labels, or buttons, this API can be used to significantly reduce the size of your code.

By default, cPrint uses paint/blit codes. ("b" instead of colors.blue) These values are all a part of the colors.API.

Usage Example:

-- Using cPrint
cprint.cprint("$7&4Yellow text on a dark gray background.")
os.pullEvent("mouse_click")
cprint.clear()

-- Using term.blit
local str = "Yellow text on a dark gray background."
term.blit(str, string.rep("4",#str), string.rep("7",#str)
os.pullEvent("mouse_click")
term.clear()
term.setCursorPos(1,1)

Functions: [1]

cprint.cprint(string)

Prints color parsed string.

Returns: nothing


cprint.toCode(int)

Changes int to it's string-hexadecimal form.

Returns: string


cprint.cCode(string)

Turns color code to color

Returns: int


cprint.clear(bool)

Clears terminal and if bool is not equal to false (or unset) sets cursor pos to 1, 1


cprint.sb(int)

Wrapper for term.setBackgroundColor()


cprint.st(int)

Wrapper for term.setTextColor()


cprint.sc(int, int)

Wrapper for term.setCursorPos()