summary refs log tree commit diff
path: root/bin/shotty.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-20 17:05:14 -0400
committerJune McEnroe <june@causal.agency>2019-07-20 17:05:14 -0400
commit2d1ccaaea70c6b977c169f9f5d721a940b80377a (patch)
tree804ee421ee85f47ead889c5ea5f73453a4d0675a /bin/shotty.c
parentHandle shotty output options more centrally (diff)
downloadsrc-2d1ccaaea70c6b977c169f9f5d721a940b80377a.tar.gz
src-2d1ccaaea70c6b977c169f9f5d721a940b80377a.zip
Handle media copy sequence in shotty
This all still feels a bit gross for some reason.
Diffstat (limited to 'bin/shotty.c')
-rw-r--r--bin/shotty.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/bin/shotty.c b/bin/shotty.c
index b394ece8..7cdf2d4a 100644
--- a/bin/shotty.c
+++ b/bin/shotty.c
@@ -74,7 +74,10 @@ static void move(struct Cell *dst, struct Cell *src, uint len) {
 }
 
 static struct {
-	bool debug, cursor, bright;
+	bool debug;
+	bool cursor;
+	bool bright;
+	bool done;
 } opts;
 
 static void span(const struct Style *prev, const struct Cell *cell) {
@@ -186,6 +189,7 @@ static char updateNUL(wchar_t ch) {
 	X(']', OSC) \
 	X('d', VPA) \
 	X('h', SM)  \
+	X('i', MC)  \
 	X('l', RM)  \
 	X('m', SGR) \
 	X('r', DECSTBM)
@@ -211,6 +215,7 @@ static char updateESC(wchar_t ch) {
 	switch (ch) {
 		case '(': discard = true; return ESC;
 		case '=': return NUL;
+		case '>': return NUL;
 		case CSI: return CSI;
 		case OSC: return OSC;
 		default: warnx("unhandled ESC %lc", ch); return NUL;
@@ -338,8 +343,13 @@ static char updateCSI(wchar_t ch) {
 			scroll.bot = (n > 1 ? ps[1] - 1 : rows - 1);
 		}
 
-		break; case 't': // ignore
+		break; case MC: {
+			if (ps[0] != 10) break;
+			opts.done = true;
+			html();
+		}
 
+		break; case 't': // ignore
 		break; default: warnx("unhandled CSI %lc", ch);
 	}
 
@@ -432,5 +442,5 @@ int main(int argc, char *argv[]) {
 	}
 	if (ferror(file)) err(EX_IOERR, "getwc");
 
-	html();
+	if (!opts.done) html();
 }