~sircmpwn/gmni

d5421dd9e0039b128be37d7b2925932633a31c90 — OndÅ™ej Fiala 2 years ago 4f04fb4
gmnlm: strip control sequences from plaintext rendering
1 files changed, 5 insertions(+), 1 deletions(-)

M src/gmnlm.c
M src/gmnlm.c => src/gmnlm.c +5 -1
@@ 1012,7 1012,6 @@ repeat:
static bool
display_plaintext(struct browser *browser, struct gemini_response *resp)
{
	// TODO: Strip ANSI escape sequences
	struct winsize ws;
	int row = 0, col = 0;
	ioctl(fileno(browser->tty), TIOCGWINSZ, &ws);


@@ 1027,6 1026,11 @@ display_plaintext(struct browser *browser, struct gemini_response *resp)
		if (n < 0) {
			n = 0;
		}
		for (int i = 0; i < n; i++) {
			if (iscntrl(buf[i]) && (buf[i] < '\t' || buf[i] > '\v')) {
				buf[i] = '.';
			}
		}
		ssize_t w = 0;
		while (w < (ssize_t)n) {
			ssize_t x = fwrite(&buf[w], 1, n - w, browser->tty);