~sircmpwn/most

7c4310b54f12b13f9f4ed434e5dea0d3fd3a68a1 — Curtis Arthaud 5 months ago e63e20b
support ascii color escapes

Signed-off-by: Curtis Arthaud <uku82@gmx.fr>
1 files changed, 14 insertions(+), 1 deletions(-)

M cmd/most/main.ha
M cmd/most/main.ha => cmd/most/main.ha +14 -1
@@ 203,6 203,7 @@ fn drawline(state: *state) (void | vt::error) = {

	const iter = strings::iter(line);

	let ansi_seq: []u8 = [];
	let col = 0z;
	for (col < state.cols - 1) {
		const rn = match (strings::next(&iter)) {


@@ 212,6 213,19 @@ fn drawline(state: *state) (void | vt::error) = {
			break;
		};

		if (rn == '\x1b') {
			append(ansi_seq, rn: u8);
			continue;
		};
		if (len(ansi_seq) > 0) {
			append(ansi_seq, rn: u8);
			if (rn == 'm') {
				io::write(state.term, ansi_seq)?;
				delete(ansi_seq[..]);
			};
			continue;
		};

		if (!state.conf.nonprint &&
			ascii::valid(rn) && !ascii::isprint(rn) && rn != '\t') {
			continue;


@@ 220,7 234,6 @@ fn drawline(state: *state) (void | vt::error) = {
		vt::print(state.term, rn)?;

		// TODO: measure dimensions properly
		// - skip escape codes in input?
		// - measure unicode sequences
		if (rn == '\t') {
			col += 8;