~sircmpwn/hare-vt

c57b8290dbf50897e4dc6f6623420be93253b53e — Drew DeVault 1 year, 1 month ago f982bfd
vt/driver.ha: flesh out lifecycle functions
1 files changed, 11 insertions(+), 3 deletions(-)

M vt/driver.ha
M vt/driver.ha => vt/driver.ha +11 -3
@@ 1,3 1,4 @@
use fs;
use io;
use os;



@@ 24,17 25,24 @@ export type term = struct {
//
// Opens /dev/tty if available, and falls back to stdin/stdout if not.
export fn open() *term = {
	abort(); // TODO
	match (os::open("/dev/tty", fs::flags::RDWR, fs::flags::CTTY)) {
	case let tty: io::file =>
		return xterm_init(tty, tty);
	case =>
		yield;
	};

	return xterm_init(os::stdin_file, os::stdout_file);
};

// Opens a given file as a terminal. The caller should pass the return value to
// [[close]] when finished.
export fn openfile(file: io::file) *term = {
	abort(); // TODO
	return xterm_init(file, file);
};

// Closes a terminal driver, releases state associated with it, and cleans up
// the associated terminal.
export fn close(term: *term) void = {
	abort(); // TODO
	term.driver.destroy(term);
};