[comp.sources.bugs] Mush 6.4 to 6.5 Patch Kit, Part 5 of 6

schaefer@ogccse.ogc.edu (Barton E. Schaefer) (04/29/89)

Part 5 of the Mush 6.5 Upgrade Kit.  Read the instructions in part 1.
To preserve mush-6.4, back up your .orig files before applying this part.
You should remove the file "help.c" after applying this part of the kit.
---------------------------------------------------------------------------
Prereq: Part4
*** mush-6.4/kit.check	Tue Apr 18 17:29:04 1989
--- kit.check	Tue Apr 18 17:29:04 1989
***************
*** 1 ****
!  Part4 
--- 1 ----
!  Part4-check 
*** phase1/README-6.5	Tue Apr 18 09:49:08 1989
--- README-6.5	Thu Apr 20 12:57:27 1989
***************
*** 3,8 ****
--- 3,10 ----
  
  Changed VERSION to 6.5 and date to 4/03/89.
  
+ [mmdf and suntools specific changes are at the bottom]
+ 
  Provision has been made for a compile-time defined TIMEZONE, for sytems
  that lack a timezone() call or other means of getting the time zone.
  See the installation instructions in README for details.  Thanks to
***************
*** 46,52 ****
  representing a successful exit status from your MTA (typically 0,
  except for MMDF which is 9).
  
! Improved the behavior of "quit" (q) in curses mode so thatwhen the folder
  needs to be updated, it is no longer needlessly reread before exiting.
  
  Interrupting the delay loop for an exclusive lock on a file (because
--- 48,54 ----
  representing a successful exit status from your MTA (typically 0,
  except for MMDF which is 9).
  
! Improved the behavior of "quit" (q) in curses mode so that when the folder
  needs to be updated, it is no longer needlessly reread before exiting.
  
  Interrupting the delay loop for an exclusive lock on a file (because
***************
*** 70,75 ****
--- 72,80 ----
  the top of the screen in curses mode) is now shortened when possible to a
  mush abbreviation form such as "+record" or "~/mbox".
  
+ Parsing of initialization files now recognizes backslash to escape quotes
+ and comment delimiters.
+ 
  ---------
  MMDF-specific changes:
  
***************
*** 84,86 ****
--- 89,117 ----
  updated and unlinked while new mail was being delivered.  The lock
  is now released after the file has been removed (if it is being
  removed) to prevent this.
+ 
+ ----------
+ Suntool-specific changes:
+ 
+ The "pager" is now connected up to the main message viewing window.
+ Now, whenever output exceeds the window size, it is paged in the
+ same manner as when messages are too long (sorry, there are still
+ no scrollbars :-( but you can still use the j,k,<CR>, etc... commands
+ to page as well as the mouse buttons).  This means that output from
+ selecting the "current aliases" menu item as well as the ignored headers
+ and anything else that outputs to the main viewing window is now paged.
+ 
+ "help" no longer prints a separate "window" to display help messages,
+ and therefore, help.c has gone away.  Help is now "paged" in the main
+ message viewing window.
+ 
+ "save" will now only update the menu items in the save and folder
+ popup menus if a new folder is created as a result of the action.
+ 
+ Header editing via $edit_hdrs does *not* work with the suntools version
+ -unless- you "reply" to a message.  This is due to a conflict with the
+ toolmode header field prompting.
+ 
+ Ringing the terminal bell is now done by opening the kbd device directly,
+ rather than by printing ctrl-G on stderr.  This corrects the problem of
+ flashing the wrong window when run under SunOS-4.0.
*** phase1/commands.c	Wed Apr 12 10:20:11 1989
--- commands.c	Wed Apr 19 16:57:27 1989
***************
*** 422,430 ****
  #ifdef SUNTOOL
      if (istool) {
  	unlock_cursors();
! 	(void) do_hdrs(0, DUBL_NULL, NULL);
! 	add_folder_to_menu(folder_item, 3);
! 	add_folder_to_menu(save_item, 1);
      }
  #endif /* SUNTOOL */
      return 0;
--- 422,432 ----
  #ifdef SUNTOOL
      if (istool) {
  	unlock_cursors();
! 	if (*mode == 'w' && n > 0) {
! 	    (void) do_hdrs(0, DUBL_NULL, NULL);
! 	    add_folder_to_menu(folder_item, 3);
! 	    add_folder_to_menu(save_item, 1);
! 	}
      }
  #endif /* SUNTOOL */
      return 0;
*** phase1/fkeys.c	Wed Apr 12 10:35:59 1989
--- fkeys.c	Wed Apr 19 16:57:29 1989
***************
*** 1,6 ****
--- 1,10 ----
  /* @(#)fkeys.c		(c) copyright 10/18/86 (Dan Heller) */
  
  #include "mush.h"
+ static short dat_shade_50[] = {
+ #include <images/square_50.pr>
+ };
+ mpr_static(shade_50,        16, 16, 1, dat_shade_50);
  #define draw(x1,y1,x2,y2,OP) pw_vector(msg_win, x1,y1,x2,y2,OP,1)
  #define box(x1,y1,x2,y2,OP)  \
  	draw(x1,y1, x1,y2,OP), draw(x1,y2, x2,y2,OP), \
*** phase1/folders.c	Thu Apr 13 16:52:25 1989
--- folders.c	Thu Apr 20 12:49:27 1989
***************
*** 151,160 ****
  	panel_set(next_scr, PANEL_SHOW_ITEM, FALSE, 0);
  	panel_set(prev_scr, PANEL_SHOW_ITEM, FALSE, 0);
  	pw_rop(hdr_win, 0,0, hdr_rect.r_width, hdr_rect.r_height,PIX_CLR,0,0,0);
- 	if (!msg_cnt) {
- 	    add_folder_to_menu(folder_item, 3);
- 	    add_folder_to_menu(save_item, 1);
- 	}
      }
  #endif /* SUNTOOL */
      current_msg = 0;
--- 151,156 ----
*** phase1/hdr_procs.c	Wed Apr 12 10:31:23 1989
--- hdr_procs.c	Wed Apr 19 16:57:29 1989
***************
*** 104,113 ****
  	return;
      }
      panel_set(item, PANEL_VALUE, 0, 0);
!     do_clear();
!     pw_text(msg_win, l_width(DEFAULT), 15, PIX_SRC, fonts[LARGE], p);
!     if (item != ignore_item)
! 	pw_text(msg_win, 30*l_width(DEFAULT),15,PIX_SRC,fonts[LARGE],"Values");
      turnon(glob_flags, IGN_BANG);
      (void) cmd_line(p, msg_list);
      if (!bang)
--- 104,110 ----
  	return;
      }
      panel_set(item, PANEL_VALUE, 0, 0);
!     strdup(more_prompt, p);
      turnon(glob_flags, IGN_BANG);
      (void) cmd_line(p, msg_list);
      if (!bang)
*** phase1/init.c	Wed Apr 12 10:15:38 1989
--- init.c	Thu Apr 20 12:49:33 1989
***************
*** 333,349 ****
  	} else
  	    cont_line = 0;
  	/* don't consider comments (#) in lines. check if # is within quotes */
!         if (p = any(line, "\"'#")) {
  	    register int balanced = 1;
! 	    while (p && (*p == '\'' || *p == '"') && balanced) {
! 		/* first find matching quote */
! 		register char *quote = index(p+1, *p);
! 		if (!quote) {
! 		    print("%s: line %d: unbalanced %c.\n", file, *line_no, *p);
! 		    balanced = 0;
! 		} else
! 		    p = any(quote+1, "'\"#");
! 	    }
  	    if (!balanced)
  		continue;
  	    if (p && *p == '#')
--- 333,354 ----
  	} else
  	    cont_line = 0;
  	/* don't consider comments (#) in lines. check if # is within quotes */
!         if (p = any(line, "\"'#\\")) {
  	    register int balanced = 1;
! 	    do {
! 		if (*p == '\\' && p[1])
! 		    p = any(p+2, "\"'#\\");
! 		else if (*p != '#') {
! 		    /* first find matching quote */
! 		    register char *quote = index(p+1, *p);
! 		    if (!quote) {
! 			print("%s: line %d: unbalanced %c.\n",
! 				file, *line_no, *p);
! 			balanced = 0;
! 		    } else
! 			p = any(quote+1, "\"'#\\");
! 		}
! 	    } while (p && *p != '#' && balanced);
  	    if (!balanced)
  		continue;
  	    if (p && *p == '#')
*** phase1/mail.c	Thu Apr 13 16:52:40 1989
--- mail.c	Wed Apr 19 16:57:31 1989
***************
*** 250,256 ****
  	turnon(flgs, DO_FORTUNE);
  #ifdef SUNTOOL
      if (istool) {
- 	do_clear();
  	panel_set(abort_item,   PANEL_SHOW_ITEM, TRUE,  0);
  	panel_set(comp_item,    PANEL_SHOW_ITEM, FALSE, 0);
  	panel_set(read_item,    PANEL_SHOW_ITEM, FALSE, 0);
--- 250,255 ----
***************
*** 421,427 ****
  	oldterm = signal(SIGTERM, rm_edfile);
      }
  
!     if ((isoff(flags, FORWARD) || ison(flags, EDIT)) &&
  	    do_set(set_options, "edit_hdrs")) {
  	turnon(flags, EDIT_HDRS);
  	if (add_headers(NULL, &ed_fp, 1, flags) == (long) -1)
--- 420,430 ----
  	oldterm = signal(SIGTERM, rm_edfile);
      }
  
!     if (
! #ifdef SUNTOOL
! 	(!istool || !get_hdr_field) &&
! #endif /* SUNTOOL */
! 	(isoff(flags, FORWARD) || ison(flags, EDIT)) &&
  	    do_set(set_options, "edit_hdrs")) {
  	turnon(flags, EDIT_HDRS);
  	if (add_headers(NULL, &ed_fp, 1, flags) == (long) -1)
***************
*** 661,666 ****
--- 664,672 ----
  		}
  	    if (line[1] == 'p' || line[1] == '|') {
  		rewind(ed_fp);
+ #ifdef SUNTOOL
+ 		strdup(more_prompt, "Letter composed so far");
+ #endif /* SUNTOOL */
  		(void) do_pager(p, TRUE); /* start the pager "p" */
  		if (isoff(flags, EDIT_HDRS)) {
  		    do_pager(sprintf(buf, "To: %s\n", To), FALSE);
***************
*** 677,682 ****
--- 683,690 ----
  		    if (do_pager(buf, FALSE) == EOF)
  			break;
  		(void) do_pager(NULL, FALSE); /* end pager */
+ 		if (istool)
+ 		    return 1;
  	    } else {
  		char **argv;
  		int argc;
***************
*** 972,977 ****
--- 980,986 ----
  #ifdef SUNTOOL
  	    if (istool) {
  		wprint("*Letter aborted*");
+ 		abort_mail(abort_item, 2);
  		type_cursor(PIX_CLR);
  	    }
  #endif /* SUNTOOL */
***************
*** 983,1014 ****
  		return 1;
  	    } else if (line[1] == '?') {
  		register int x;
! 		if (!istool)
! 		    (void) do_pager(NULL, TRUE); /* start pager */
  		for (x = 0; tilde_commands[x]; x++) {
  		    (void) sprintf(buf, "%s%s\n", escape, tilde_commands[x]);
! 		    if (!istool) {
! 			if (do_pager(buf, FALSE))
! 			    break;
! 		    } else
! 			wprint(buf);
  		}
! 		(void) sprintf(buf, "%s%s\t\tbegin a line with a single %s\n",
! 		    escape, escape, escape);
! 		if (istool)
! 		    wprint(buf);
! 		else {
! 		    if (tilde_commands[x] == NULL)
! 			(void) do_pager(buf, FALSE);
! 		    (void) do_pager(NULL, FALSE); /* end pager */
  		}
! #ifdef SUNTOOL
! 		if (istool)
! 		    (void) help(0, "compose", tool_help);
! #endif /* SUNTOOL */
  	    } else
  		wprint("`%c': unknown %c escape. Use %c? for help.\n",
  		    line[1], *escape, *escape);
      }
      (void) fseek(ed_fp, 0L, 2); /* seek to end of file in case there's more */
      wprint("(continue editing letter)\n");
--- 992,1017 ----
  		return 1;
  	    } else if (line[1] == '?') {
  		register int x;
! #ifdef SUNTOOL
! 		strdup(more_prompt, "Tilde Commands");
! #endif /* SUNTOOL */
! 		(void) do_pager(NULL, TRUE); /* start pager */
  		for (x = 0; tilde_commands[x]; x++) {
  		    (void) sprintf(buf, "%s%s\n", escape, tilde_commands[x]);
! 		    if (do_pager(buf, FALSE) == EOF)
! 			break;
  		}
! 		if (tilde_commands[x] == NULL) {
! 		    (void) sprintf(buf,
! 			"%s%s\t\tbegin a line with a single %s\n",
! 			escape, escape, escape);
! 		    (void) do_pager(buf, FALSE);
  		}
! 		(void) do_pager(NULL, FALSE); /* end pager */
  	    } else
  		wprint("`%c': unknown %c escape. Use %c? for help.\n",
  		    line[1], *escape, *escape);
+ 	    return 1;
      }
      (void) fseek(ed_fp, 0L, 2); /* seek to end of file in case there's more */
      wprint("(continue editing letter)\n");
*** phase1/makefile.bsd	Tue Apr 18 09:42:59 1989
--- makefile.bsd	Wed Apr 19 11:00:13 1989
***************
*** 5,15 ****
  
  SRCS= main.c init.c misc.c mail.c hdrs.c execute.c commands.c print.c dates.c \
        signals.c setopts.c msgs.c pick.c sort.c expr.c folders.c \
!       loop.c help.c viewopts.c curses.c curs_io.c bind.c file.c strings.c \
        lock.c macros.c options.c addrs.c malloc.c
  OBJS= main.o init.o misc.o mail.o hdrs.o execute.o commands.o print.o file.o \
        signals.o setopts.o msgs.o pick.o sort.o expr.o strings.o \
!       folders.o dates.o loop.o help.o viewopts.o curses.o curs_io.o bind.o \
        lock.o macros.o options.o addrs.o malloc.o
  
  HELP_FILES= README README-6.0 README-6.1 README-6.2 README-6.3 README-6.4 \
--- 5,15 ----
  
  SRCS= main.c init.c misc.c mail.c hdrs.c execute.c commands.c print.c dates.c \
        signals.c setopts.c msgs.c pick.c sort.c expr.c folders.c \
!       loop.c viewopts.c curses.c curs_io.c bind.c file.c strings.c \
        lock.c macros.c options.c addrs.c malloc.c
  OBJS= main.o init.o misc.o mail.o hdrs.o execute.o commands.o print.o file.o \
        signals.o setopts.o msgs.o pick.o sort.o expr.o strings.o \
!       folders.o dates.o loop.o viewopts.o curses.o curs_io.o bind.o \
        lock.o macros.o options.o addrs.o malloc.o
  
  HELP_FILES= README README-6.0 README-6.1 README-6.2 README-6.3 README-6.4 \
*** phase1/makefile.sun	Tue Apr 18 09:45:04 1989
--- makefile.sun	Wed Apr 19 11:00:14 1989
***************
*** 5,17 ****
  
  SRCS= main.c init.c misc.c mail.c hdrs.c execute.c commands.c rite.c \
        select.c doproc.c print.c signals.c addrs.c setopts.c msgs.c \
!       hdr_procs.c tool.c hdr_panel.c main_panel.c help.c viewopts.c sort.c \
        pick.c fkeys.c expr.c folders.c dates.c loop.c edit_menu.c malloc.c\
        curses.c curs_io.c bind.c file.c strings.c lock.c macros.c options.c
  
  OBJS= main.o init.o misc.o mail.o hdrs.o execute.o commands.o rite.o \
        select.o doproc.o print.o signals.o addrs.o setopts.o msgs.o \
!       hdr_procs.o tool.o hdr_panel.o main_panel.o help.o viewopts.o sort.o \
        pick.o fkeys.o expr.o folders.o dates.o loop.o edit_menu.o malloc.o\
        curses.o curs_io.o bind.o file.o strings.o lock.o macros.o options.o
  
--- 5,17 ----
  
  SRCS= main.c init.c misc.c mail.c hdrs.c execute.c commands.c rite.c \
        select.c doproc.c print.c signals.c addrs.c setopts.c msgs.c \
!       hdr_procs.c tool.c hdr_panel.c main_panel.c viewopts.c sort.c \
        pick.c fkeys.c expr.c folders.c dates.c loop.c edit_menu.c malloc.c\
        curses.c curs_io.c bind.c file.c strings.c lock.c macros.c options.c
  
  OBJS= main.o init.o misc.o mail.o hdrs.o execute.o commands.o rite.o \
        select.o doproc.o print.o signals.o addrs.o setopts.o msgs.o \
!       hdr_procs.o tool.o hdr_panel.o main_panel.o viewopts.o sort.o \
        pick.o fkeys.o expr.o folders.o dates.o loop.o edit_menu.o malloc.o\
        curses.o curs_io.o bind.o file.o strings.o lock.o macros.o options.o
  
*** phase1/makefile.sys.v	Tue Apr 18 09:43:31 1989
--- makefile.sys.v	Thu Apr 20 12:49:44 1989
***************
*** 7,19 ****
  SRCS1= commands.c dates.c execute.c expr.c folders.c \
  	hdrs.c init.c loop.c mail.c main.c misc.c msgs.c pick.c \
  	print.c setopts.c signals.c sort.c viewopts.c options.c lock.c
! SRCS2= bind.c curs_io.c curses.c help.c file.c strings.c macros.c \
  	addrs.c malloc.c
  
  OBJS1= commands.o dates.o execute.o expr.o folders.o \
  	hdrs.o init.o loop.o mail.o main.o misc.o msgs.o pick.o \
  	print.o setopts.o signals.o sort.o viewopts.o options.o lock.o
! OBJS2= bind.o curs_io.o curses.o help.o file.o strings.o macros.o \
  	addrs.o malloc.o
  
  HELP_FILES= README README-6.0 README-6.1 README-6.2 README-6.3 README-6.4 \
--- 7,19 ----
  SRCS1= commands.c dates.c execute.c expr.c folders.c \
  	hdrs.c init.c loop.c mail.c main.c misc.c msgs.c pick.c \
  	print.c setopts.c signals.c sort.c viewopts.c options.c lock.c
! SRCS2= bind.c curs_io.c curses.c file.c strings.c macros.c \
  	addrs.c malloc.c
  
  OBJS1= commands.o dates.o execute.o expr.o folders.o \
  	hdrs.o init.o loop.o mail.o main.o misc.o msgs.o pick.o \
  	print.o setopts.o signals.o sort.o viewopts.o options.o lock.o
! OBJS2= bind.o curs_io.o curses.o file.o strings.o macros.o \
  	addrs.o malloc.o
  
  HELP_FILES= README README-6.0 README-6.1 README-6.2 README-6.3 README-6.4 \
***************
*** 35,38 ****
  
  $(OBJS1): $(HDRS1) $(HDRS2)
  $(OBJS2): $(HDRS1) $(HDRS2) $(HDRS3)
- help.o: strings.h
--- 35,37 ----
*** phase1/makefile.xenix	Tue Apr 18 09:43:41 1989
--- makefile.xenix	Wed Apr 19 11:00:17 1989
***************
*** 9,15 ****
  HDRS= mush.h config.h-dist strings.h bindings.h options.h
  SRCS1= main.c init.c misc.c execute.c
  SRCS2= signals.c msgs.c pick.c viewopts.c
! SRCS3= sort.c expr.c folders.c dates.c help.c
  SRCS4= loop.c bind.c options.c
  SRCS5= commands.c setopts.c hdrs.c
  SRCS6= mail.c print.c
--- 9,15 ----
  HDRS= mush.h config.h-dist strings.h bindings.h options.h
  SRCS1= main.c init.c misc.c execute.c
  SRCS2= signals.c msgs.c pick.c viewopts.c
! SRCS3= sort.c expr.c folders.c dates.c
  SRCS4= loop.c bind.c options.c
  SRCS5= commands.c setopts.c hdrs.c
  SRCS6= mail.c print.c
***************
*** 18,24 ****
  SRCS9= lock.c macros.c addrs.c
  OBJS= main.o init.o misc.o mail.o hdrs.o execute.o commands.o print.o file.o \
        signals.o setopts.o msgs.o pick.o sort.o expr.o strings.o \
!       folders.o dates.o loop.o help.o viewopts.o bind.o curses.o curs_io.o \
        lock.o macros.o options.o addrs.o malloc.o
  HELP_FILES= README README-6.0 README-6.1 README-6.2 README-6.3 README-6.4 \
  	README-6.5 mush.1 Mailrc Gnurc cmd_help sample.mushrc advanced.mushrc
--- 18,24 ----
  SRCS9= lock.c macros.c addrs.c
  OBJS= main.o init.o misc.o mail.o hdrs.o execute.o commands.o print.o file.o \
        signals.o setopts.o msgs.o pick.o sort.o expr.o strings.o \
!       folders.o dates.o loop.o viewopts.o bind.o curses.o curs_io.o \
        lock.o macros.o options.o addrs.o malloc.o
  HELP_FILES= README README-6.0 README-6.1 README-6.2 README-6.3 README-6.4 \
  	README-6.5 mush.1 Mailrc Gnurc cmd_help sample.mushrc advanced.mushrc
*** phase1/misc.c	Thu Apr 13 16:52:51 1989
--- misc.c	Wed Apr 19 16:57:32 1989
***************
*** 60,66 ****
  }
  
  /* since this function does not affect messages, return -1 */
! help(fd, str, file)
  #ifdef SUNTOOL
  caddr_t *str;
  #else
--- 60,66 ----
  }
  
  /* since this function does not affect messages, return -1 */
! help(unused, str, file)
  #ifdef SUNTOOL
  caddr_t *str;
  #else
***************
*** 68,89 ****
  #endif /* SUNTOOL */
  char *file;
  {
  #ifdef SUNTOOL
!     if (istool > 1) {
! 	int oldmask;
! 	if (!fd)
! 	    fd = print_sw->ts_windowfd;
! 	oldmask = sigblock(1 << ((SIGALRM) - 1));
! 	lock_cursors();
! 	if (display_help(fd, str, file, fonts[LARGE]) && file)
! 	    error("can't read %s", file);
! 	unlock_cursors();
! 	(void) sigsetmask(oldmask);
!     } else
  #endif /* SUNTOOL */
!     if (find_help(str, file) && file)
! 	error("can't read %s", file);
!     return 0; /* doesn't affect any messages */
  }
  
  #ifdef SUNTOOL
--- 68,118 ----
  #endif /* SUNTOOL */
  char *file;
  {
+     register char	*p;
+     char		buf[BUFSIZ], help_str[32];
+     register int	height;
+     extern char		*no_newln(), *more_prompt;
+     FILE		*fp;
+ 
+     /* If no file given, take "str" arg as message to print */
+     if (!file || !*file) {
  #ifdef SUNTOOL
! 	strdup(more_prompt, "help");
  #endif /* SUNTOOL */
! 	/* use the pager on the args to the function */
! 	do_pager(NULL, TRUE);
! 	while (*str) {
! 	    (void) do_pager(*str++, FALSE);
! 	    if (do_pager("\n", FALSE) == EOF)
! 		break;
! 	}
! 	do_pager(NULL, FALSE);
! 	return 0;
!     }
! 
!     if (!(fp = fopen(file, "r")))
! 	return -1;
!     /* look for %str% in helpfile */
!     (void) sprintf(help_str, "%%%s%%\n", str);
! 
!     while (p = fgets(buf, sizeof buf, fp))
! 	if (*p == '%' && !strcmp(p, help_str))
! 	    break;
!     if (!p)
! 	print("There is no help found for \"%s\".\n", (char *)str);
!     else {
! #ifdef SUNTOOL
! 	strdup(more_prompt, sprintf(buf, "%s help", (char *)str));
! #endif /* SUNTOOL */
! 	do_pager(NULL, TRUE);
! 	while ((p = fgets(buf, sizeof buf, fp)) && strcmp(p, "%%\n"))
! 	    if (do_pager(buf, FALSE) == EOF)
! 		break;
! 	do_pager(NULL, FALSE);
!     }
!     fclose(fp);
! 
!     return 0;
  }
  
  #ifdef SUNTOOL
***************
*** 372,380 ****
   * core dump.  This is because constant strings are read-only.
   * Return EOF if pager died, user exited pager, or if user types 'q'
   * at the --more-- prompt for the internal pager.
   */
  do_pager(buf, start_pager)
! register char *buf;
  {
      static FILE *pp;
      static int cnt, len;
--- 401,414 ----
   * core dump.  This is because constant strings are read-only.
   * Return EOF if pager died, user exited pager, or if user types 'q'
   * at the --more-- prompt for the internal pager.
+  *
+  * For windows, copy all the info into a static string array and allocate
+  * msg_pix to be the size of the entire text once the end-pager request
+  * comes in.  The user then "pages" the text using the event driven code
+  * in select.c.
   */
  do_pager(buf, start_pager)
! char *buf;
  {
      static FILE *pp;
      static int cnt, len;
***************
*** 381,392 ****
      static u_long save_echo_flag;
  
  #ifdef SUNTOOL
      if (istool) {
  	if (buf && !start_pager)
! 	    if (istool < 2)
! 		printf(buf), fflush(stdout);
! 	    else
! 		Addstr(buf);
  	return 0;
      }
  #endif /* SUNTOOL */
--- 415,461 ----
      static u_long save_echo_flag;
  
  #ifdef SUNTOOL
+ #define STR_ARRAY 128
      if (istool) {
+ 	static int cnt, lines;
+ 	static char **strings;
+ 	char s[256];
  	if (buf && !start_pager)
! 	    if (istool < 2) /* can't use windows yet -- send to stdout */
! 		printf(buf);
! 	    else {
! 		if ((cnt % STR_ARRAY) == 0)
! 		    strings = (char **)realloc(strings,
! 			sizeof (char *) * (unsigned)(cnt + STR_ARRAY));
! 		do  {
! 		    int chars = count_chars(&buf, s);
! 		    if (*--buf) {
! 			s[chars++] = '\n', s[chars] = 0;
! 			lines++;
! 			if (*buf == '\n')
! 			    buf++;
! 		    }
! 		    strings[cnt++] = savestr(s); /* save all the strings */
! 		} while (*buf);
! 	    }
! 	else if (istool >= 2 && start_pager) {
! 	    cnt = lines = 0;
! 	    strings = (char **)malloc((unsigned)sizeof (char *));
! 	    do_clear();
! 	    lock_cursors();
! 	} else if (!buf && !start_pager) { /* pager is done */
! 	    int height = (lines+1) * l_height(curfont);
! 	    strings[cnt] = 0;
! 	    /* don't check for null; if NULL, no paging is done/text scrolls */
! 	    msg_pix = mem_create(msg_rect.r_width,
! 				 max(msg_rect.r_height, height), 1);
! 	    for (cnt = 0; strings[cnt]; cnt++)
! 		Addstr(strings[cnt]); /* put all the strings in the msg_pix */
! 	    free_vec(strings);
! 	    unlock_cursors();
! 	    txt.y = still_more = msg_rect.r_height;
! 	    scroll_win(0);  /* causes a display */
! 	}
  	return 0;
      }
  #endif /* SUNTOOL */
*** phase1/msgs.c	Tue Apr 18 09:38:20 1989
--- msgs.c	Thu Apr 20 15:42:22 1989
***************
*** 7,12 ****
--- 7,13 ----
  register int n;
  long flg;
  {
+     char buf[32], *pager = NULL;
      if (ison(msg[n].m_flags, DELETE) && !do_set(set_options, "show_deleted")) {
  	print("Message %d deleted; ", n+1);
  #ifdef SUNTOOL
***************
*** 31,50 ****
  #endif /* MMDF */
      if (!istool && isoff(flg, NO_PAGE) &&
  	    crt < msg[n].m_lines && isoff(flg, M_TOP)) {
! 	char buf[32], *pager = do_set(set_options, "pager");
! 	if (!pager)
  	    pager = DEF_PAGER;
  	if (!*pager || !strcmp(pager, "internal"))
  	    pager = NULL; /* default to internal pager if pager set to "" */
- 	(void) do_pager(pager, TRUE); /* start pager */
- 	(void) do_pager(sprintf(buf, "Message #%d (%d lines)\n",
- 			 n+1, msg[n].m_lines), FALSE);
- 	(void) copy_msg(n, NULL_FILE, flg);
- 	(void) do_pager(NULL, FALSE); /* end pager */
-     } else {
- 	print("Message #%d (%d lines)\n", n+1, msg[n].m_lines);
- 	(void) copy_msg(n, stdout, flg);
      }
  }
  
  /*
--- 32,47 ----
  #endif /* MMDF */
      if (!istool && isoff(flg, NO_PAGE) &&
  	    crt < msg[n].m_lines && isoff(flg, M_TOP)) {
! 	if (!(pager = do_set(set_options, "pager")))
  	    pager = DEF_PAGER;
  	if (!*pager || !strcmp(pager, "internal"))
  	    pager = NULL; /* default to internal pager if pager set to "" */
      }
+     (void) do_pager(pager, TRUE); /* start pager */
+     (void) do_pager(sprintf(buf, "Message #%d (%d lines)\n",
+ 		     n+1, msg[n].m_lines), FALSE);
+     (void) copy_msg(n, NULL_FILE, flg);
+     (void) do_pager(NULL, FALSE); /* end pager */
  }
  
  /*
***************
*** 80,108 ****
      }
  
  #ifdef SUNTOOL
!     if (istool && (!fp || fp == stdout)) {
! 	register int x = (msg[n].m_lines + 2) * l_height(curfont);
! 
! 	if (x > 32765) { /* to overcome a bug in pixrects that sun won't fix */
! 	    print("message too big to display using this font");
! 	    return 0;
! 	}
! 	if (x < msg_rect.r_height) /* make it at least as big as the window */
! 	    x = msg_rect.r_height;
! 	/* If the window isn't big enough, an infinite loop occurs in Addstr */
! 	if (x < 2 * l_height(curfont) || msg_rect.r_width < 3*l_width(curfont))
! 	    return 0;
! 	do_clear();
! 	lock_cursors();
! 	/* msg_pix is for Addstr() */
! 	if (!(msg_pix = mem_create(msg_rect.r_width, x, 1))) {
! 	    error("mem_create");
! 	    return 0;
! 	}
! 	pr_rop(msg_pix, 0,0, msg_rect.r_width-1, x-1, PIX_CLR, 0,0,0);
! 	on_hdr = 1;
!     }
  #endif /* SUNTOOL */
      if (ison(flags, INDENT)) {
  	if ((indent_str = do_set(set_options, "pre_indent_str"))) {
  	    char *old_fmt = hdr_format;
--- 77,85 ----
      }
  
  #ifdef SUNTOOL
!     xfree(more_prompt), more_prompt = NULL;
  #endif /* SUNTOOL */
+ 
      if (ison(flags, INDENT)) {
  	if ((indent_str = do_set(set_options, "pre_indent_str"))) {
  	    char *old_fmt = hdr_format;
***************
*** 198,209 ****
  	if (isoff(flags, NO_HEADER)) {
  	    /* note that function returns the number of lines */
  	    lines++;
- #ifdef SUNTOOL
- 	    if (istool && (!fp || fp == stdout)) {
- 		Addstr(line);
- 		continue;
- 	    }
- #endif /* SUNTOOL */
  	    if (ison(flags, INDENT))
  		fputs(indent_str, fp);
  	    if (!fp) {
--- 175,180 ----
***************
*** 221,233 ****
  	fprintf(fp, "%s\n", compose_hdr(n)+9); /* magic number 9 !! */
  	hdr_format = old_fmt;
      }
- #ifdef SUNTOOL
-     if (istool && (!fp || fp == stdout)) {
- 	unlock_cursors();
- 	txt.y = still_more = msg_rect.r_height;
- 	scroll_win(0);  /* causes a display */
-     }
- #endif /* SUNTOOL */
      return lines;
  }
  
--- 192,197 ----
***************
*** 468,484 ****
  mail_size()
  {
      struct stat buf;
!     if (strcmp(mailfile, spoolfile) && !stat(spoolfile, &buf))
  	spool_size = buf.st_size;
!     if (!*mailfile)
  	return 0;
!     if (stat(mailfile, &buf)) {
  	if (errno != ENOENT)
  	    error("Unable to stat %s", mailfile);
  	return 0;
      }
-     if (!strcmp(mailfile, spoolfile))
- 	spool_size = buf.st_size;
      if (buf.st_size != last_size) {
  	last_size = buf.st_size;
  	return 1;
--- 432,447 ----
  mail_size()
  {
      struct stat buf;
! 
!     if (!stat(spoolfile, &buf))
  	spool_size = buf.st_size;
!     if (!*mailfile || ison(glob_flags, IS_SENDING))
  	return 0;
!     if (strcmp(mailfile, spoolfile) && stat(mailfile, &buf)) {
  	if (errno != ENOENT)
  	    error("Unable to stat %s", mailfile);
  	return 0;
      }
      if (buf.st_size != last_size) {
  	last_size = buf.st_size;
  	return 1;
*** phase1/mush.h	Tue Apr 18 09:38:29 1989
--- mush.h	Thu Apr 20 12:49:56 1989
***************
*** 1,6 ****
  /* @(#)mush.h	(c) copyright 1986 (Dan Heller) */
  
! #define VERSION "Mail User's Shell (6.5 4/03/89)"
  
  #include "config.h"
  
--- 1,6 ----
  /* @(#)mush.h	(c) copyright 1986 (Dan Heller) */
  
! #define VERSION "Mail User's Shell (6.5 4/17/89)"
  
  #include "config.h"
  
***************
*** 101,107 ****
  #undef putchar
  #endif /* putchar */
  #define putchar(c)	fputc(c, stdout), fflush(stdout)
! #define bell() 		fputc('\007', stderr), fflush(stderr)
  
  /* For error recovery purposes, send keyboard generated signals to a special
   * routine (interrupt) to set a global flag (WAS_INTR) and return to the
--- 101,111 ----
  #undef putchar
  #endif /* putchar */
  #define putchar(c)	fputc(c, stdout), fflush(stdout)
! #ifdef SUNTOOL
! extern int bell();
! #else /* SUNTOOL */
! #define bell()		fputc('\007', stderr), fflush(stderr)
! #endif /* SUNTOOL */
  
  /* For error recovery purposes, send keyboard generated signals to a special
   * routine (interrupt) to set a global flag (WAS_INTR) and return to the
***************
*** 542,547 ****
--- 546,552 ----
      *key_set_to(),	/* pass fkey string, return string describing func */
      *panel_get(),      	/* returns what has been typed in a panel item */
      *tool_help,		/* help for tool-related things (sometimes, overlap) */
+     *more_prompt,	/* when NULL, we're paging a msg; else pager prompt */
      blank[128];		/* use to clear to end of line */
  
  int
***************
*** 597,603 ****
      help_item,		/* choose this to get various help */
      ignore_item,	/* set/view/change message headers to be ignored */
      input_item,		/* text item to get values for set/unsetting values */
!     msg_num_item,	/* text item to explicitly state which message to read */
      next_scr,		/* display the next screenful of message headers */
      option_item,	/* set/view/unset mail options */
      prev_scr,		/* display the previous screen of messages */
--- 602,608 ----
      help_item,		/* choose this to get various help */
      ignore_item,	/* set/view/change message headers to be ignored */
      input_item,		/* text item to get values for set/unsetting values */
!     msg_num_item,	/* text item explicitly states which message to read */
      next_scr,		/* display the next screenful of message headers */
      option_item,	/* set/view/unset mail options */
      prev_scr,		/* display the previous screen of messages */
*** phase1/print.c	Wed Apr 12 10:27:50 1989
--- print.c	Thu Apr 20 12:50:01 1989
***************
*** 173,179 ****
  	pw_rop(msg_win, 0, 5,
  	       msg_rect.r_width, crt * l_height(curfont),
  	       PIX_SRC, msg_pix, 0, txt.y - msg_rect.r_height + 3);
! 	tool_more(NULL);
  	return;
      }
      /* y must be positive (forward scrolling) so we're scrolling typed
--- 173,189 ----
  	pw_rop(msg_win, 0, 5,
  	       msg_rect.r_width, crt * l_height(curfont),
  	       PIX_SRC, msg_pix, 0, txt.y - msg_rect.r_height + 3);
! 	{
! 	    int percent = (still_more * 100) / msg_pix->pr_size.y;
! 	    if (more_prompt)
! 		print("%s (%%%d)", more_prompt, percent);
! 	    else if (percent >= 100)
! 		print( "--End of Message %d--", current_msg+1);
! 	    else
! 		print("--Message %d--(%d%%)", current_msg+1, percent);
! 	}
! 	if (ison(glob_flags, IS_GETTING))
! 	    print_more(" ('q' returns to type-in mode)");
  	return;
      }
      /* y must be positive (forward scrolling) so we're scrolling typed
***************
*** 192,194 ****
--- 202,232 ----
  {
      print("");
  }
+ 
+ #ifdef SUNTOOL
+ 
+ #include <sundev/kbio.h>
+ #include <sundev/kbd.h>
+ 
+ bell()
+ {
+ #ifdef KIOCCMD
+     if (istool) {
+ 	int kbd = open("/dev/kbd", O_WRONLY, 0);
+         struct timeval timer;
+         timer.tv_sec = 0;
+         timer.tv_usec = 100000;
+         if (kbd != -1) {
+ 	    int cmd = KBD_CMD_BELL;
+ 	    (void) ioctl(kbd, KIOCCMD, &cmd);
+ 	    (void) select(32, 0,0,0, &timer);
+ 	    cmd = KBD_CMD_NOBELL;
+ 	    (void) ioctl(kbd, KIOCCMD, &cmd);
+ 	    (void) close(kbd);
+ 	}
+     } else
+ #endif /* KIOCCMD */
+ 	fputc('\007', stderr), fflush(stderr);
+ }
+ 
+ #endif /* SUNTOOL */
*** phase1/rite.c	Thu Apr 13 16:52:58 1989
--- rite.c	Wed Apr 19 16:57:33 1989
***************
*** 112,137 ****
      }
  }
  
  Addstr(s)
! register char *s;
  {
      char buf[BUFSIZ];
!     register int cnt = 0, max_len;
!     register char *p = buf, newline = 0;
  
!     max_len = (msg_rect.r_width - 10) / l_width(curfont) + 1;
  
-     while ((*p = *s++) && *p != '\n' && cnt < max_len)
- 	if (*p == '\t')
- 	    do *p++ = ' ';
- 	    while (++cnt % 8);
- 	else p++, cnt++;
-     *p = 0;
- 
      if (*--s)
! 	newline = *s, *s = 0; /* newline may or may not be a '\n' */
!     else
! 	s = 0;
  
      if (*buf) {
  	if (msg_pix) {
--- 112,132 ----
      }
  }
  
+ /* display a string in the window -- expand tabs and wrap lines.  Return
+  * the number of lines displayed ... wrapped lines count as 2 and \n's
+  * always add 1.  Text that doesn't wrap or have a newline returns 0.
+  */
  Addstr(s)
! char *s;
  {
      char buf[BUFSIZ];
!     register int cnt;
!     register char newline = 0;
  
!     cnt = count_chars(&s, buf);
  
      if (*--s)
! 	newline = *s; /* newline may or may not be a '\n' */
  
      if (*buf) {
  	if (msg_pix) {
***************
*** 144,177 ****
  	txt.x += cnt * l_width(curfont);
      }
      if (newline) {
- 	if (newline != '\n')
- 	    *s = newline;
  	if ((txt.y += l_height(curfont)) >= LASTLINE && !msg_pix)
  	    scroll_win(1);
  	txt.x = 5;
  	if (newline == '\n' && !*++s)
! 	    return;
! 	Addstr(s);
      }
  }
  
! tool_more(p)
! register char *p;
  {
!     int percent;
!     /* we are typing -- scrool the window */
!     if (!msg_pix) {
! 	scroll_win(1);
! 	return;
!     }
!     if (p)
! 	print(p);
!     else {
! 	if ((percent = (still_more * 100) / msg_pix->pr_size.y) >= 100)
! 	    print( "--End of Message %d--", current_msg+1);
  	else
! 	    print("--Message %d--(%d%%)", current_msg+1, percent);
! 	if (ison(glob_flags, IS_GETTING))
! 	    print_more(" ('q' returns to type-in mode)");
!     }
  }
--- 139,166 ----
  	txt.x += cnt * l_width(curfont);
      }
      if (newline) {
  	if ((txt.y += l_height(curfont)) >= LASTLINE && !msg_pix)
  	    scroll_win(1);
  	txt.x = 5;
  	if (newline == '\n' && !*++s)
! 	    return 1;
! 	return 1 + Addstr(s);
      }
+     return 0;
  }
  
! /* expand tabs to spaces and count chars up to a newline or width of window */
! count_chars(s, p)
! register char **s, *p;
  {
!     int cnt = 0, max_len = (msg_rect.r_width - 10) / l_width(curfont) + 1;
! 
!     while ((*p = *((*s)++)) && *p != '\n' && cnt < max_len)
! 	if (*p == '\t')
! 	    do *p++ = ' ';
! 	    while (++cnt % 8);
  	else
! 	    p++, cnt++;
!     *p = 0;
!     return cnt;
  }
*** phase1/setopts.c	Thu Apr 13 16:53:02 1989
--- setopts.c	Wed Apr 19 16:57:34 1989
***************
*** 147,191 ****
  register char *str;
  {
      register struct options *opts;
- #ifdef SUNTOOL
-     int x,y;
  
!     if (istool >= 2 && !str)
! 	y = 10 + 2 * l_height(LARGE);
! #endif /* SUNTOOL */
! 
!     if (!str && istool < 2)
  	(void) do_pager(NULL, TRUE); /* page using internal pager */
  
      for (opts = list; opts; opts = opts->next)
  	if (!str) {
! #ifdef SUNTOOL
! 	    if (istool >= 2)
! 		pw_text(msg_win, 5, y, PIX_SRC, fonts[DEFAULT], opts->option);
! 	    else
! #endif /* SUNTOOL */
! 		(void) do_pager(opts->option, FALSE);
! 	    if (opts->value)
! #ifdef SUNTOOL
! 		if (istool >= 2) {
! 		    x = 30*l_width(DEFAULT);
! 		    pw_text(msg_win, x,y, PIX_SRC, fonts[DEFAULT], opts->value);
! 		    pw_text(msg_win, x+1, y, PIX_SRC|PIX_DST,
! 			     fonts[DEFAULT], opts->value);
! 		    x += strlen(opts->value)*l_width(DEFAULT);
! 		} else
! #endif /* SUNTOOL */
! 		{
! 		    (void) do_pager("     \t", FALSE);
! 		    (void) do_pager(opts->value, FALSE);
! 		}
! #ifdef SUNTOOL
! 	    if (istool >= 2)
! 		Clrtoeol(msg_win, x, y, DEFAULT), y += l_height(DEFAULT);
! 	    else
! #endif /* SUNTOOL */
! 		if (do_pager("\n", FALSE) == EOF)
! 		    break;
  	} else {
  	    if (strcmp(str, opts->option))
  		continue;
--- 147,165 ----
  register char *str;
  {
      register struct options *opts;
  
!     if (!str)
  	(void) do_pager(NULL, TRUE); /* page using internal pager */
  
      for (opts = list; opts; opts = opts->next)
  	if (!str) {
! 	    (void) do_pager(opts->option, FALSE);
! 	    if (opts->value && *opts->value) {
! 		(void) do_pager("     \t", FALSE);
! 		(void) do_pager(opts->value, FALSE);
! 	    }
! 	    if (do_pager("\n", FALSE) == EOF)
! 		break;
  	} else {
  	    if (strcmp(str, opts->option))
  		continue;
***************
*** 195,201 ****
  		return "";
  	}
  
!     if (!str && istool < 2)
  	(void) do_pager(NULL, FALSE); /* terminate internal pager */
  
      /* if we still haven't matched, check for environment vars */
--- 169,175 ----
  		return "";
  	}
  
!     if (!str)
  	(void) do_pager(NULL, FALSE); /* terminate internal pager */
  
      /* if we still haven't matched, check for environment vars */
*** phase1/signals.c	Wed Apr 12 10:28:16 1989
--- signals.c	Thu Apr 20 12:50:08 1989
***************
*** 300,306 ****
  	if (istool) {
  	    mail_status(0);
  	    (void) do_hdrs(0, DUBL_NULL, NULL);
! 	    window_bell(print_sw);
  	}
  #endif /* SUNTOOL */
  	if (msg_cnt < last_msg_cnt) {
--- 300,306 ----
  	if (istool) {
  	    mail_status(0);
  	    (void) do_hdrs(0, DUBL_NULL, NULL);
! 	    bell();
  	}
  #endif /* SUNTOOL */
  	if (msg_cnt < last_msg_cnt) {
*** mush-6.4/kit.check	Tue Apr 18 17:29:04 1989
--- kit.check	Tue Apr 18 17:29:04 1989
***************
*** 1 ****
!  Part4-check 
--- 1 ----
!  Part5 
-- 
Bart Schaefer       "And if you believe that, you'll believe anything."
							-- DangerMouse
CSNET / Internet                schaefer@cse.ogc.edu
UUCP                            ...{sun,tektronix,verdix}!ogccse!schaefer