summary refs log tree commit diff
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
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.
-rw-r--r--bin/man1/shotty.14
-rw-r--r--bin/shotty.c16
2 files changed, 17 insertions, 3 deletions
diff --git a/bin/man1/shotty.1 b/bin/man1/shotty.1
index 1f747ee8..3ca3ef4b 100644
--- a/bin/man1/shotty.1
+++ b/bin/man1/shotty.1
@@ -35,6 +35,10 @@ and
 .Ev TERM Ns = Ns Cm xterm-256color
 as used by
 .Xr ncurses 3 .
+A snapshot of the terminal
+is output each time
+a media copy sequence occurs,
+or once at the end of the capture.
 .
 .Pp
 HTML output uses the classes
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();
 }
ef='/catgirl/commit/ui.c?h=1.1p1&id=fe21b1410f3a2a0ee756a4b30dbd9ba91434cca3&follow=1'>Convert input to multibyte before handlingJune McEnroe 2018-08-07Populate tab-complete listJune McEnroe 2018-08-07Fix /me formatting side-effectsJune McEnroe NEVER pass side-effects to a macro. 2018-08-07Define ui.c BUF_LEN with enumJune McEnroe 2018-08-07Hack clang into checking uiFmt format stringsJune McEnroe 2018-08-07Handle PART and QUIT without messagesJune McEnroe 2018-08-07Make safe filling the who bufferJune McEnroe 2018-08-07Add reverse and reset IRC formatting codesJune McEnroe 2018-08-06Rewrite line editing again, add formattingJune McEnroe 2018-08-06Fix allocation size in vaswprintfJune McEnroe This is so embarrassing. It only started crashing once it had strings that were long enough, and then it took me so long to notice this mistake. I was worried I was still doing va_list wrong somehow. 2018-08-06Implement word wrappingJune McEnroe 2018-08-06Use wchar_t strings for all of UIJune McEnroe vaswprintf is a nightmare. 2018-08-06Rename line editing functionsJune McEnroe 2018-08-05Initialize all possible color pairsJune McEnroe This is actually possible with use_default_colors! 2018-08-05Refactor color initializationJune McEnroe 2018-08-05Add ^L redrawJune McEnroe 2018-08-05Use 16 colors if availableJune McEnroe Fall back to using bold if there are only 8 colors. This also allowed bright background colors in 16-color terminals. I must port this system to torus. I'll be able to remove the awful termcap patch hack. 2018-08-05Limit parsed colors to number of mIRC colorsJune McEnroe Oh boy that's embarrassing. 2018-08-04Show source link on exitJune McEnroe 2018-08-04Implement line editing, scrollingJune McEnroe Don't really have a way to implement the M-* keys, and currently missing C-w. 2018-08-04Handle /topicJune McEnroe