🍯 Glaze

package vtty

import "core:fmt"

ESC :: "\x1b"
CSI :: ESC + "["

CLEAR :: CSI + "2J"

CURSOR_HIDE :: CSI + "?25l"
CURSOR_SHOW :: CSI + "?25h"

CURSOR_POSITION :: CSI + "%d;%dH"
FORMAT :: CSI + "%d;%dm"
RESET_FORMAT :: CSI + "0m"

BOLD :: 1
ITALIC :: 2
UNDERLINE :: 4
STRIKETHROUGH :: 9
BRIGHT_BLACK :: 90

LINE_DRAWING_MODE :: ESC + "(0"
ASCII_DRAWING_MODE :: ESC + "(B"

Keys :: enum {
	unk,
	quit,
	back,
	forward,
}

Console :: struct {
	using _: _Console,
	width:   int,
	height:  int,
}

create :: proc(con: ^Console) {
	_create(con)
}

destroy :: proc(con: ^Console) {
	_destroy(con)
}

clear :: proc(con: ^Console) {
	_clear(con)
}

write :: proc(con: ^Console, msg: string) {
	_write(con, msg)
}

write_at :: proc(con: ^Console, msg: string, x, y: int) {
	_write_at(con, msg, x, y)
}

putch :: proc(con: ^Console, c: rune, x, y: int) {
	_putch(con, c, x, y)
}

putch_s :: proc(con: ^Console, c: rune, x, y: int) -> string {
	return fmt.tprintf(CURSOR_POSITION + "%c", y, x, c)
}

wait_for_input :: proc(con: ^Console) -> Keys {
	return _wait_for_input(con)
}

get_size :: proc(con: ^Console) -> (int, int) {
	return _get_size(con)
}