[tin-users] Piping/Printing message looks odd TODO

Glenn Spell glenn at gs.fay.nc.us
Fri Mar 25 18:55:03 CET 2016


On 25 Mar 2016 around  1:27PM (-0400) Urs Janßen wrote:
> If you tag a few articles on the group or thread level and pipe them
> into a cmd. the tag mark is still present till the next manually forced
> screen redraw (^L)'.

I think that's fixed for piping, printing and saving in the patch below.

> Yet another new global var, why not passing a flag to show_progress() if
> you're calling it direct (which is IMHO still not right)?

OK. No new global variable for show_progress(), although I'm no longer
calling it direct.  The new global var is for the new piped message.

> progress_mesg is still NULL, but is passed on to art_open() in line 467,
> passing it to progress() in the end which then skips show_progress() - not
> very clean IMHO.

OK. I'm no longer changing any of that code in feed.c.

Please take a look at this and tell me what y'all think:


Index: include/extern.h
--- tin-2.3.2.orig/include/extern.h	2015-11-22 00:15:40.000000000 +0000
+++ tin-2.3.2/include/extern.h	2016-03-25 16:18:45.000000000 +0000
@@ -479,6 +479,9 @@ extern constext txt_articles_mailed[];
 #ifndef DISABLE_PRINTING
 	extern constext txt_articles_printed[];
 #endif /* !DISABLE_PRINTING */
+#ifndef DONT_HAVE_PIPING
+	extern constext txt_articles_piped[];
+#endif /* !DONT_HAVE_PIPING */
 extern constext txt_attach[];
 extern constext txt_attach_charset[];
 extern constext txt_attach_description[];
Index: src/feed.c
--- tin-2.3.2.orig/src/feed.c	2015-11-22 00:14:30.000000000 +0000
+++ tin-2.3.2/src/feed.c	2016-03-25 16:47:06.000000000 +0000
@@ -439,14 +439,12 @@ feed_article(
 	switch (function) {
 #ifndef DONT_HAVE_PIPING
 		case FEED_PIPE:
-			/* TODO: looks odd because screen mode is raw */
 			progress_mesg = fmt_string("%s (%d/%d)", _(txt_piping), counter->total, counter->max);
 			break;
 #endif /* !DONT_HAVE_PIPING */
 
 #ifndef DISABLE_PRINTING
 		case FEED_PRINT:
-			/* TODO: looks odd because screen mode is raw */
 			progress_mesg = fmt_string("%s (%d/%d)", _(txt_printing), counter->total, counter->max);
 			break;
 #endif /* !DISABLE_PRINTING */
@@ -668,6 +666,7 @@ feed_articles(
 		/* Setup printing - get print command line */
 		case FEED_PRINT:
 			snprintf(outpath, sizeof(outpath), "%s %s", tinrc.printer, REDIRECT_OUTPUT);
+			redraw_screen = TRUE;
 			break;
 #endif /* !DISABLE_PRINTING */
 
@@ -928,12 +927,11 @@ got_epipe_while_piping:
 			Raw(TRUE);
 			InitWin();
 #	endif /* USE_CURSES */
-			prompt_continue();
+			currmenu->redraw();
 #	ifndef USE_CURSES
 			Raw(TRUE);
 			InitWin();
 #	endif /* !USE_CURSES */
-			redraw_screen = TRUE;
 			break;
 #endif /* !DONT_HAVE_PIPING */
 
@@ -944,6 +942,7 @@ got_epipe_while_piping:
 				break;
 			}
 
+			currmenu->redraw();
 			print_save_summary(feed_type, counter.total);
 			if (pproc_func != POSTPROCESS_NO) {
 				t_bool delete_post_proc = FALSE;
@@ -1024,6 +1023,12 @@ got_epipe_while_piping:
 			}
 			break;
 
+#ifndef DONT_HAVE_PIPING
+		case FEED_PIPE: 
+			info_message(_(txt_articles_piped), counter.success, PLURAL(counter.success, txt_article));
+			break;
+#endif /* !DONT_HAVE_PIPING */
+
 #ifndef DISABLE_PRINTING
 		case FEED_PRINT:
 			info_message(_(txt_articles_printed), counter.success, PLURAL(counter.success, txt_article));
Index: src/lang.c
--- tin-2.3.2.orig/src/lang.c	2015-11-22 00:14:30.000000000 +0000
+++ tin-2.3.2/src/lang.c	2016-03-25 16:15:17.000000000 +0000
@@ -1145,6 +1145,7 @@ Tin will try to use XHDR XREF instead (s
 #endif /* !DISABLE_PRINTING */
 
 #ifndef DONT_HAVE_PIPING
+	constext txt_articles_piped[] = N_("%d %s piped");
 	constext txt_help_global_pipe[] = N_("pipe article/thread/hot/pattern/tagged articles into command");
 	constext txt_no_command[] = N_("No command");
 	constext txt_pipe[] = N_("Pipe");
Index: src/prompt.c
--- tin-2.3.2.orig/src/prompt.c	2015-11-22 00:14:31.000000000 +0000
+++ tin-2.3.2/src/prompt.c	2016-03-23 19:11:50.000000000 +0000
@@ -773,8 +773,9 @@ prompt_continue(
 {
 	int ch;
 	int save_signal_context = signal_context;
+	t_bool save_cmd_line = cmd_line;
 
-	cmd_line = TRUE;
+	cmd_line = FALSE;
 	info_message(_(txt_return_key));
 	signal_context = cMain;
 	input_context = cPromptCONT;
@@ -797,7 +798,7 @@ prompt_continue(
 #ifdef USE_CURSES
 	my_fputc('\n', stdout);
 #endif /* USE_CURSES */
-	cmd_line = FALSE;
+	cmd_line = save_cmd_line;
 #ifdef USE_CURSES
 	my_retouch();
 #endif /* USE_CURSES */
Index: src/screen.c
--- tin-2.3.2.orig/src/screen.c	2015-11-22 00:14:31.000000000 +0000
+++ tin-2.3.2/src/screen.c	2016-03-25 13:16:57.000000000 +0000
@@ -465,6 +465,8 @@ show_progress(
 	static int last_ratio;
 	static t_artnum last_total;
 	static time_t last_update;
+	t_bool feeding = FALSE;
+	t_bool save_cmd_line = cmd_line;
 #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETTIMEOFDAY)
 	static t_artnum last_count;
 	static int average;
@@ -481,6 +483,17 @@ show_progress(
 	if (batch_mode || count <= 0 || total <= 0)
 		return;
 
+	cmd_line = FALSE;
+
+	/* TODO: ratio and time remaining are unstable when feeding *
+	 * If feeding articles, don't print ratio or time remaining */
+	if (strncmp(txt, _(txt_piping), strlen(_(txt_piping))) == 0 ||
+	    strncmp(txt, _(txt_printing), strlen(_(txt_printing))) == 0 ||
+	    strncmp(txt, _(txt_saving), strlen(_(txt_saving))) == 0) {
+		feeding = TRUE;
+		goto feeding;
+	}
+
 	/* If this is a new progress meter, start recalculating */
 	if ((last_txt != txt) || (last_total != total)) {
 		last_ratio = -1;
@@ -557,6 +570,10 @@ show_progress(
 	snprintf(display, sizeof(display), "%s %3d%%", txt, ratio);
 #endif /* HAVE_CLOCK_GETTIME || HAVE_GETTIMEOFDAY */
 
+	feeding:
+	if (feeding)
+		snprintf(display, sizeof(display), "%s", txt);
+
 	/* Only display text if it changed from last time */
 	if (strcmp(display, last_display)) {
 		char *tmp;
@@ -584,7 +601,11 @@ show_progress(
 		STRCPY(last_display, display);
 	}
 
-	last_txt = txt;
-	last_total = total;
-	last_ratio = ratio;
+	if (!feeding) {
+		last_txt = txt;
+		last_total = total;
+		last_ratio = ratio;
+	}
+
+	cmd_line = save_cmd_line;
 }


Glenn




More information about the tin-users mailing list