From c1d3d23701520b06f5b615b85fa57061afcb3e05 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Tue, 30 Jan 2018 03:04:20 +0000
Subject: [PATCH] Improvements to the screen capture feature: Only capture the
 terminal area, not the margins (if there are any) or the status bar. Also
 fixes an issue with odd-sized (width) windows being saved to .bin files (not
 supported). Also, if the current video mode is background-bright (ICE
 colors), set the appropriate ANSI flag in the SAUCE record. Fixed compiler
 warning (not all paths return a value) in doterm().

---
 src/syncterm/term.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/syncterm/term.c b/src/syncterm/term.c
index ecf5a0dfd4..83ac78d8c1 100644
--- a/src/syncterm/term.c
+++ b/src/syncterm/term.c
@@ -2024,6 +2024,7 @@ void font_control(struct bbslist *bbs)
 void capture_control(struct bbslist *bbs)
 {
 	char *buf;
+	char *cap;
 	struct	text_info txtinfo;
 	int i,j;
 
@@ -2032,6 +2033,9 @@ void capture_control(struct bbslist *bbs)
    	gettextinfo(&txtinfo);
 	buf=(char *)alloca(txtinfo.screenheight*txtinfo.screenwidth*2);
 	gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,buf);
+	cap=(char *)alloca(cterm->height*cterm->width*2);
+	gettext(cterm->x, cterm->y, cterm->x+cterm->width-1, cterm->y+cterm->height-1, cap);
+
 	init_uifc(FALSE, FALSE);
 
 	if(!cterm->log) {
@@ -2068,7 +2072,7 @@ void capture_control(struct bbslist *bbs)
 					} else {
 						char msg[256];
 						uifc.pop("Writing to file");
-						fwrite(buf, sizeof(uint8_t), txtinfo.screenwidth * txtinfo.screenheight * 2, fp);
+						fwrite(cap, sizeof(uint8_t), cterm->width * cterm->height * 2, fp);
 						if(i > 2) {
 							time_t t = time(NULL);
 							struct tm* tm;
@@ -2089,7 +2093,9 @@ void capture_control(struct bbslist *bbs)
 									,1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday);
 							sauce.filesize = ftell(fp);	// LE
 							sauce.datatype = sauce_datatype_bin;
-							sauce.filetype = txtinfo.screenwidth / 2;
+							sauce.filetype = cterm->width / 2;
+							if(ciolib_getvideoflags() & CIOLIB_VIDEO_BGBRIGHT)
+								sauce.tflags |= sauce_ansiflag_nonblink;
 
 							fputc(SAUCE_SEPARATOR, fp);
 							/* No comment block (no comments) */
@@ -3094,6 +3100,6 @@ BOOL doterm(struct bbslist *bbs)
 /*
 	hidemouse();
 	hold_update=oldmc;
-	return(FALSE);
  */
+	return(FALSE);
 }
-- 
GitLab