~sircmpwn/hare-vt

608cbac4346e184f687317d752993e46b6a7e95d — Drew DeVault 1 year, 1 month ago e5772d1
Implement vt::move
3 files changed, 13 insertions(+), 6 deletions(-)

M example.ha
M vt/draw.ha
M vt/xterm.ha
M example.ha => example.ha +1 -0
@@ 27,6 27,7 @@ fn run() (void | vt::error) = {
	defer vt::close(term);
	vt::enablealt(term)?;
	vt::disablecur(term)?;
	vt::move(term, 1, 1)?;

	const p1 = vt::newpen(void, color::RED, style::ULINE);
	const p2 = vt::newpen(color::YELLOW, color::RED);

M vt/draw.ha => vt/draw.ha +10 -5
@@ 8,6 8,16 @@ export type styled = struct {
	args: [](fmt::formattable | styled),
};

// Clears the terminal display and moves the cursor to the top left corner.
export fn clear(term: *term) (void | error) = {
	return term.driver.clear(term);
};

// Moves the cursor to the provided row and column, from 1.
export fn move(term: *term, row: uint, col: uint) (void | error) = {
	return term.driver.movecur(term, row, col);
};

// Prepares a styled value with a given pen, for use with [[fprint]].
export fn tag(
	pen: pen,


@@ 36,8 46,3 @@ export fn print(
	};
	term.driver.chpen(term, &prev)?;
};

// Clears the terminal display and moves the cursor to the top left corner.
export fn clear(term: *term) (void | error) = {
	return term.driver.clear(term);
};

M vt/xterm.ha => vt/xterm.ha +2 -1
@@ 482,5 482,6 @@ fn xterm_chcur(term: *term, enable: bool) (void | error) = {
};

fn xterm_movecur(term: *term, row: uint, col: uint) (void | error) = {
	abort(); // TODO
	let term = term: *xterm;
	fmt::fprintf(term.out, "\x1b[{};{}H", row, col)?;
};