summaryrefslogblamecommitdiff
path: root/src/user/lib/fwik/io/Term.cpp
blob: 1c6db66635f2d68e2af07728024126a7507d8245 (plain) (tree)


















































                                                             
#include <IO/Term.h>

Term::Term(const Node &n) : Node(n) {
	_init();
}

Term::Term(FILE f) : Node(f) {
	_init();
}

Term::Term(char* filename, int mode) : Node(filename, mode) {
	_init();
}

void Term::_init() {
	if (info.type & FT_TERMINAL) {
		w = info.size >> 16;
		h = info.size & 0xFFFF;
	} else {
		valid = false;
	}
	hist.str = 0;
	hist.max = 12;
}

Term::~Term() {
	//TODO : free readline history
}

void Term::print(char *s) {
	libc::fprint(fd, s);
}

void Term::printf(char* fmt, ...) {
	va_list ap;
	va_start(ap, fmt);
	libc::vfprintf(fd, fmt, ap);
	va_end(ap);
}

void Term::vprintf(char* fmt, va_list ap) {
	libc::vfprintf(fd, fmt, ap);
}

char* Term::readln() {
	return libc::freadln(fd);
}

char *Term::readline() {
	return libc::freadline(fd, &hist);
}