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

Glenn Spell glenn at gs.fay.nc.us
Mon Mar 21 12:57:16 CET 2016


On 21 Mar 2016 around  7:36AM (-0400) Thomas Dickey wrote:
> On Tue, Mar 15, 2016 at 08:04:12AM +0100, Urs Janßen wrote:
> > On Mon, Mar 14, 2016 at 08:45:13PM -0400, Glenn Spell wrote:
> > > For years the following note has been in the tin feed.c file
> > > concerning the piping and printing messages:
> > > 
> > >     /* TODO: looks odd because screen mode is raw */
> > > 
> > > As an illustration, the following patch provides me with a workaround
> > > for this issue.
> 
> > It doesn't make any differfence here - looks as ugly as always on
> > x86_64-pc-linux-gnu; ncursesw5.

Please check and see if the patch below provides any improvement.
 
> The code looks "okay", but (reading the source), I think the fix should
> be in screen.c within show_progress().

OK.  I've made some changes to show_progress().  How does this look?

I changed the display of the "Press <RETURN> to continue..." message to
be centered with color.  That may not be the desired display format.

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-21 11:20:01.000000000 +0000
@@ -1605,6 +1605,7 @@ extern char *input_history[HIST_MAXNUM +
 #	endif /* NNTP_INEWS */
 #endif /* FORGERY */
 
+extern t_bool feed_raw_mode;
 extern t_bool word_highlight;
 #ifdef HAVE_COLOR
 	extern constext txt_tinrc_colors[];
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-21 11:16:13.000000000 +0000
@@ -439,21 +439,25 @@ 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);
+			feed_raw_mode = TRUE;
+			show_progress(fmt_string("%s (%d/%d)", _(txt_piping), counter->total, counter->max), counter->total, counter->max);
+			feed_raw_mode = FALSE;
 			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);
+			feed_raw_mode = TRUE;
+			show_progress(fmt_string("%s (%d/%d)", _(txt_printing), counter->total, counter->max), counter->total, counter->max);
+			feed_raw_mode = FALSE;
 			break;
 #endif /* !DISABLE_PRINTING */
 
 		case FEED_SAVE:
 		case FEED_AUTOSAVE:
-			progress_mesg = fmt_string("%s (%d/%d)", _(txt_saving), counter->total, counter->max);
+			feed_raw_mode = TRUE;
+			show_progress(fmt_string("%s (%d/%d)", _(txt_saving), counter->total, counter->max), counter->total, counter->max);
+			feed_raw_mode = FALSE;
 			break;
 	}
 
Index: src/init.c
--- tin-2.3.2.orig/src/init.c	2015-11-22 00:14:30.000000000 +0000
+++ tin-2.3.2/src/init.c	2016-03-21 11:16:05.000000000 +0000
@@ -127,6 +127,7 @@ t_bool created_rcdir;			/* checks if fir
 t_bool dangerous_signal_exit;		/* no get_respcode() in nntp_command when dangerous signal exit */
 t_bool disable_gnksa_domain_check;	/* disable checking TLD in From: etc. */
 t_bool disable_sender;			/* disable generation of Sender: header */
+t_bool feed_raw_mode = FALSE;		/* show_progress() for feed_article() */
 #ifdef NO_POSTING
 	t_bool force_no_post = TRUE;		/* force no posting mode */
 #else
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-21 07:36:28.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-21 08:38:37.000000000 +0000
@@ -465,6 +465,7 @@ show_progress(
 	static int last_ratio;
 	static t_artnum last_total;
 	static time_t last_update;
+	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 +482,9 @@ show_progress(
 	if (batch_mode || count <= 0 || total <= 0)
 		return;
 
+	if (feed_raw_mode)
+		cmd_line = FALSE;
+
 	/* If this is a new progress meter, start recalculating */
 	if ((last_txt != txt) || (last_total != total)) {
 		last_ratio = -1;
@@ -490,7 +494,7 @@ show_progress(
 
 	curr_time = time(NULL);
 	ratio = (int) ((count * 100) / total);
-	if ((ratio == last_ratio) && (curr_time - last_update < 2))
+	if ((ratio == last_ratio) && (curr_time - last_update < 2) && (!feed_raw_mode))
 		/*
 		 * return if ratio did not change and less than 1-2 seconds since last
 		 * update to reduce output
@@ -499,6 +503,7 @@ show_progress(
 
 	last_update = curr_time;
 
+	if (!feed_raw_mode) {
 #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETTIMEOFDAY)
 	display_format = my_malloc(strlen(DISPLAY_FMT) + strlen(_(txt_remaining)) + 1);
 	strcpy(display_format, DISPLAY_FMT);
@@ -556,6 +561,9 @@ show_progress(
 #else
 	snprintf(display, sizeof(display), "%s %3d%%", txt, ratio);
 #endif /* HAVE_CLOCK_GETTIME || HAVE_GETTIMEOFDAY */
+	} else {
+	snprintf(display, sizeof(display), "%s %3d%%", txt, ratio);
+	}
 
 	/* Only display text if it changed from last time */
 	if (strcmp(display, last_display)) {
@@ -587,4 +595,7 @@ show_progress(
 	last_txt = txt;
 	last_total = total;
 	last_ratio = ratio;
+
+	if (feed_raw_mode)
+		cmd_line = save_cmd_line;
 }

Glenn




More information about the tin-users mailing list