🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #2482

Re: Is a 132-column wide display in trn possible?

#2482
From: Bruce Lilly
Date: Sat, 07 Nov 1992 00:02
212 lines
8052 bytes
In article <1992Nov5.040659.3526@digi.lonestar.org> kgallagh@digi.lonestar.org (Kevin Gallagher) wrote:
>When I view the threaded news menu in a window configured as 132 columns wide
>(bsd 4.3), the lines are always truncated at column 80.
[...]
>When I read news articles, the threaded tree display is right justified to
>column 132, so I know trn is aware that the window is 132 columns wide.

As I recall, the problem is with the threads database(s), which
only store enough characters for an 80-column display.

>Anybody got a fix for this?

I sent the following patch some time ago (note: my address in
the headers no longer works due to a severe case of
Telebititis).

Note that you'll (y'all'll :-) have to rebuild the threads
database(s) to notice any improvement.

This works on an AT&T 3B1 using the SVR3 version of curses. No
guarantee that it (or anything else, for that matter) will work
on 4.3BSD...

=========================================================================
From: bruce%blilly@Broadcast.Sony.COM (Bruce Lilly)
Reply-To: bruce@Broadcast.Sony.COM (Bruce Lilly)
Date: Wed, 15 Jan 1992 02:59:11 UT
To: davison@borland.com
Subject: Patch to trn 2.2 to accommodate wide screens

Wayne,

This patch is primarily intended to allow for more flexibility
in the screen width supported by trn. The magic numbers (16, 55,
71, and 72) have been replaced.  When writing a .thread file,
enough characters are saved to give a reasonable display on
screens as wide as 256 characters (in practice, the size of the
.thread files is not appreciably increased, since most author
names and subjects are not longer than the previous magic
numbers; but for those that are longer, this patch will provide
a more readable display on wide screens). Display of the author
and subject field widths is controlled by the screen width as
held in the global variable COLS (if the scrren width should be
less than 9 characters, things may blow up; but then reading
news wouldn't be very practical on such a narrow screen anyway,
and the computational overhead to avoid problems in such a case
probably isn't justifiable). It might be worthwhile to calculate
author and subject field widths once, outside of all loops, and
use those pre-calculated values rather than the calculations in
each printf, but I doubt that those integer calculations are the
speed bottleneck.

The patch also includes sccs id strings, #ifdefs for some
variables which would otherwise be unused, and a workaround for
a clash between sys/time.h and time.h on systems using WIN/3B
(provided USELECT is undefined, which it must be since
Wollongong's implementation of select is buggy). There are other
patches to work around the sys/time.h vs. time.h bug, but
they're not related to the screen width issue, so I'll send
those separately. I find the sccs id strings to be helpful in
keeping track of which versions of files were used to create the
executable; they're not essential and can be eliminated.

Index: mt-process.c
@@ -6,6 +6,10 @@
 ** 
 */
 
+#ifndef lint
+static	char	*sccs_id = "%W% (local modifications)";
+#endif
+
 #include "EXTERN.h"
 #include "common.h"
 #include "threads.h"
@@ -22,7 +26,7 @@
 # include <sys/timeb.h>
 #endif
 
-#if defined(SERVER) && !defined(USLEEP)
+#if defined(SERVER) && !defined(USLEEP) && defined(USELECT)
 # include <sys/time.h>
 #endif
 
@@ -30,10 +34,12 @@
 
 char references[1024];
 
-char subject_str[80];
+#define	SUBJECT_LEN	190
+char subject_str[SUBJECT_LEN];
 bool found_Re;
 
-char author_str[20];
+#define	AUTHOR_LEN	64
+char author_str[AUTHOR_LEN];
 
 extern int log_verbosity, slow_down;
 
@@ -83,9 +89,11 @@
 #else
     int start = total.last + 1;
 #endif
+#ifndef SERVER
     extern int errno;
     extern int sys_nerr;
     extern char *sys_errlist[];
+#endif
 
     if (first_article > start) {
 	start = first_article;
@@ -562,7 +570,7 @@
 
 #define EQ(x,y) ((isupper(x) ? tolower(x) : (x)) == (y))
 
-/* Parse the subject into 72 characters or less.  Remove any "Re[:^]"s from
+/* Parse the subject into SUBJECT_LEN characters or less.  Remove any "Re[:^]"s from
 ** the front (noting that it's there), and any "(was: old)" stuff from
 ** the end.  Then, compact multiple whitespace characters into one space,
 ** trimming leading/trailing whitespace.  If it's still too long, unmercifully
@@ -619,7 +627,7 @@
 	}
     }
     /* Copy subject to a temporary string, compacting multiple spaces/tabs */
-    for (len = 0, cp = subject_str; len < 72 && *str; len++) {
+    for (len = 0, cp = subject_str; len < SUBJECT_LEN && *str; len++) {
 	if ((unsigned char)*str <= ' ') {
 	    while (*++str && (unsigned char)*str <= ' ') {
 		;
@@ -635,9 +643,9 @@
     *cp = '\0';
 }
 
-/* Try to fit the author name in 16 bytes.  Use the comment portion in
-** parenthesis if present.  Cut off non-commented names at the '@' or '%'.
-** Then, put as many characters as we can into the 16 bytes, packing multiple
+/* Try to fit the author name in AUTHOR_LEN bytes.  Use the comment portion in
+** parentheses if present.  
+** Then, put as many characters as we can into the AUTHOR_LEN bytes, packing multiple
 ** whitespace characters into a single space.
 ** We might want to implement a nice name shortening algorithm sometime.
 */
@@ -660,7 +668,7 @@
 	    *cp = '\0';
 	}
     }
-    for (cp = str, cp2 = author_str; *cp && cp2-author_str < 16;) {
+    for (cp = str, cp2 = author_str; *cp && cp2-author_str < AUTHOR_LEN;) {
 	/* Pack white space and turn ctrl-chars into spaces. */
 	if (*cp <= ' ') {
 	    while (*++cp && *cp <= ' ') {
@@ -781,7 +789,9 @@
 {
     register ARTICLE *node, *last;
     register char *cp, *end;
+#ifndef SERVER
     int len;
+#endif
 
     if (article->subject) {
 	if (log_verbosity) {
@@ -1483,6 +1493,7 @@
 }
 
 #if defined(SERVER) && !defined(USLEEP)
+void
 usleep(usec)
 long usec;
 {
Index: rt-select.c
@@ -6,6 +6,10 @@
 ** 
 */
 
+#ifndef	lint
+static	char	*sccsid = "%W% (local modifications)";
+#endif
+
 #include "EXTERN.h"
 #include "common.h"
 #include "rn.h"
@@ -873,12 +877,13 @@
     maybe_eol();
 #endif
     if (*display_mode == 's') {
-	printf("%s%3d  %s%.71s\n", first_two_chars,
-		subject_cnts[subj], str, subject_ptrs[subj]) FLUSH;
+	printf("%s%3d  %s%.*s\n", first_two_chars,
+		subject_cnts[subj], str, COLS-8, subject_ptrs[subj]) FLUSH;
     } else {
-	printf("%s%-16.16s%3d  %s%.55s", first_two_chars,
+	printf("%s%-*.*s%3d  %s%.*s", first_two_chars,
+		(COLS-8)/4, (COLS-8)/4,
 		author_ptrs[first_author],
-		subject_cnts[subj], str, subject_ptrs[subj]);
+		subject_cnts[subj], str, (COLS-8)*3/4,subject_ptrs[subj]);
 	if (author_cnt > 1) {
 	    author_cnts[first_author] = 0;
 	    author_cnt = 0;
@@ -906,7 +911,7 @@
 			break;
 		    }
 		    author_cnt += (*display_mode == 'm');
-		    printf("%-16.16s", author_ptrs[artp->author]);
+		    printf("%-*.*s", (COLS-8)/4, (COLS-8)/4, author_ptrs[artp->author]);
 		    author_cnts[artp->author] = 0;
 		}/* if */
 	    }/* for */
=========================================================================
-- 
	Bruce Lilly		blilly!bruce@Broadcast.Sony.COM
					...uunet!sonyusa!sonyd1!blilly!bruce
Technical Details
Message-ID: <1992Nov7.000249.2162@blilly.UUCP>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!sparky!uunet!europa.asd.contel.com!emory!wupost!spool.mu.edu!sgiblab!daver!hico2!sonyd1.Broadcast.Sony.COM!blilly.UUCP!bruce
References: <1992Nov5.040659.3526@digi.lonestar.org>

Show Full Headers
Complete Article Headers
Message-ID: <1992Nov7.000249.2162@blilly.UUCP>
Subject: Re: Is a 132-column wide display in trn possible?
Date: Sat, 07 Nov 1992 00:02:49 +0000
From: bruce@blilly.UUCP (Bruce Lilly)
References: <1992Nov5.040659.3526@digi.lonestar.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!sparky!uunet!europa.asd.contel.com!emory!wupost!spool.mu.edu!sgiblab!daver!hico2!sonyd1.Broadcast.Sony.COM!blilly.UUCP!bruce
Newsgroups: news.software.readers
Organization: Bruce Lilly
Reply-To: lilb@sony.compuserve.com
Lines: 212