term.jamo (built in)

term: colors, tables, progress bars and menus for programs in the console. use "term.jamo"

Colors use the codes every modern terminal understands. Windows' own console needs them turned on first, which these functions do for you. Widths count letters, so accented and other languages line up too (wide letters like Chinese take two columns, so those may not).

constTERM_COLOR_CODES

const TERM_COLOR_CODES = 4

functerm_escape

func term_escape(): string

The escape character that starts every terminal code

functerm_colors_on

func term_colors_on(): bool

Turns on color codes in Windows' own console. Answers false when there's no console to turn them on in

functerm_code

func term_code(number: int): string

funccolored

func colored(text: string, color: string): string

The text in a color: black, red, green, yellow, blue, magenta, cyan, white or gray

funcbold

func bold(text: string): string

funcclear_screen

func clear_screen()

Clears the console and puts the cursor at the top

funcpad_right

func pad_right(text: string, width: int): string

The text with spaces after it, up to width bytes

funcpad_left

func pad_left(text: string, width: int): string

The text with spaces before it, up to width bytes

functable

func table(rows: [[string]]): string

The rows as a table, each column as wide as its widest text. The first row is the heading, with a line under it

funcprogress_bar

func progress_bar(done: int, total: int, width: int): string

A bar like [##########----------] 50%, width characters wide between the brackets

funcmenu

func menu(title: string, options: [string]): int

Shows the options numbered from 1, and asks until a number is typed. Answers with the option's place, counting from 0, or -1 when the input runs out