[5337] in Athena Bugs

home help back first fref pref prev next nref lref last post

enhancements to xman; part 1 -- real "bullets"

daemon@ATHENA.MIT.EDU (vanharen@ATHENA.MIT.EDU)
Thu Jun 28 04:55:43 1990

From: vanharen@ATHENA.MIT.EDU
Date: Thu, 28 Jun 90 04:55:18 -0400
To: bugs@ATHENA.MIT.EDU


The patch following is a patch to 3 files:  ScrollByL{.c,.h,P.h}

These patches allow xman to display real bullet symbols where requested
instead of the old behavior of printing 2 lower-case "o's".  In troff
output for files or screen, a bullet is acheived by producing an "o" and
overstriking with a "+" (or is it vice-versa?).  The author of xman
chose to print out 2 "o's", though I think the real intent was to print
only 1 "o", but I'm not sure.  At any rate, this patch does real bullets
using the adobe symbol font which is a standard part of the X release.

A description of the patches:

	- ScrollByLP.h:  a new XFontStruct was declared to hold the
symbol font's font struct.  Additionally, a new GC was declared to hold
the GC for drawing with that font.

	- ScrollByL.h:  a new resource was added for "manualFontSymbol",
so that users may specify whatever font they like, as they can with
"manualFontItalic", "manualFontBold", and "manualFontNormal".  Also, a
#define was added for the default value, which is actually used in an
assignment in the C code.

	- ScrollByL.c:  the new resource and default value (both
described above) were added to the resource table.  The GC for drawing
with the symbol font was added to the CreateGCs and DestroyGCs routines.
	Several #define's were used to define the different types of
text to print (NORMAL, BOLD, ITALIC, SYMBOL), and DumpText was
re-written to take one flag for printing-style, rather than take a
boldflag and an italicflag.  This makes DumpText more flexible, as it
can be changed to take new printing-styles in the future.  Removed code
in DumpText that determined which attribute to use (either bold or
italic) and that printed an XtError if both were set.  In its place, a
macro "WHICH" was defined to choose between the two and always chooses
BOLD over ITALICS.  (This decision is a toss-up, since it never happens
anyway.)  All calls to DumpText were changed to reflect the above.
	If a bullet is encountered (either an "o" followed by a "+" or
vice-versa), the text stored-up to that point is dumped out and then the
character to be printed is set to dec 183 (a bullet in any adobe font),
this character is dumped out, and processing continues.

NOTE:
This patch contains context diffs against the original sources in the
x11 locker, thus, this patch should be applied without the bug-fix patch
reported to bugs earlier (to fix the mis-printing of the first line of
text on a manpage).

HOWEVER, IF applying this patch to the bug-fixed version of ScrollByL.c,
some hand editing will be necessary, as hunks 6 and 8 will be thrown
out.  It will be obvious what should be done, though, by looking at the
ScrollByL.c.rej file; only 3 or 4 lines will need to be changed to the
new versions.
						-Chris.

==============================================================================
*** /mit/x11/src/mit/clients/xman/ScrollByLP.h	Thu Dec  7 15:49:51 1989
--- ScrollByLP.h	Sat Jun  9 01:02:33 1990
***************
*** 54,62 ****
      use_right;			/* put scroll bar on right side of window. */
    FILE * file;			/* The file to display. */
    Dimension indent;		/* amount to indent the file. */
!   XFontStruct * bold_font,	/* The three fonts. */
      * normal_font,
!     * italic_font;
    
  /* variables not in resource list. */
  
--- 54,63 ----
      use_right;			/* put scroll bar on right side of window. */
    FILE * file;			/* The file to display. */
    Dimension indent;		/* amount to indent the file. */
!   XFontStruct * bold_font,	/* The four fonts. */
      * normal_font,
!     * italic_font,
!     * symbol_font;
    
  /* variables not in resource list. */
  
***************
*** 66,72 ****
  				   of the window being displayed. */
    Dimension offset;		/* Drawing offset because of scrollbar. */
    GC move_gc;			/* GC to use when moving the text. */
!   GC bold_gc, normal_gc, italic_gc; /* gc for drawing. */
  
    char ** top_line;		/* The top line of the file. */
    int lines;			/* number of line in the file. */
--- 67,73 ----
  				   of the window being displayed. */
    Dimension offset;		/* Drawing offset because of scrollbar. */
    GC move_gc;			/* GC to use when moving the text. */
!   GC bold_gc, normal_gc, italic_gc, symbol_gc; /* gc for drawing. */
  
    char ** top_line;		/* The top line of the file. */
    int lines;			/* number of line in the file. */
==============================================================================
*** /mit/x11/src/mit/clients/xman/ScrollByL.h	Fri Jul 21 17:33:50 1989
--- ScrollByL.h	Sat Jun  9 01:01:40 1990
***************
*** 37,46 ****
--- 37,48 ----
  #define MANPAGE_NORMAL   "fixed"
  #define MANPAGE_BOLD     "helvetica-bold12"
  #define MANPAGE_ITALIC   "helvetica-boldoblique12"
+ #define MANPAGE_SYMBOL   "symbol-medium12"
  #else
  #define MANPAGE_NORMAL   "*-new century schoolbook-medium-r-normal--*-120-*"
  #define MANPAGE_BOLD     "*-new century schoolbook-bold-r-normal--*-120-*"
  #define MANPAGE_ITALIC   "*-new century schoolbook-bold-i-normal--*-120-*"
+ #define MANPAGE_SYMBOL   "*-symbol-medium-r-normal--*-120-*"
  #endif /* ATHENA */
  
  #define XtNindent           "indent"
***************
*** 48,53 ****
--- 50,56 ----
  #define XtNmanualFontNormal "manualFontNormal"
  #define XtNmanualFontBold   "manualFontBold"
  #define XtNmanualFontItalic "manualFontItalic"
+ #define XtNmanualFontSymbol "manualFontSymbol"
  
  #define XtCIndent           "Indent"

==============================================================================
*** /mit/x11/src/mit/clients/xman/ScrollByL.c	Sat Jan 27 07:45:11 1990
--- ScrollByL.c	Thu Jun 28 04:25:09 1990
***************
*** 2,8 ****
   * xman - X window system manual page display program.
   *
   * $XConsortium: ScrollByL.c,v 1.13 90/01/11 20:09:00 keith Exp $
!  * $Header: /afs/testers.athena.mit.edu/src/x11r4/src/mit/clients/xman/RCS/ScrollByL.c,v 1.2 90/01/27 07:45:03 epeisach Exp $
   *
   * Copyright 1987, 1988 Massachusetts Institute of Technology
   *
--- 2,8 ----
   * xman - X window system manual page display program.
   *
   * $XConsortium: ScrollByL.c,v 1.13 90/01/11 20:09:00 keith Exp $
!  * $Header: /site/usr/local/xman.src/RCS/ScrollByL.c,v 1.3 90/06/28 03:36:11 vanharen Exp $
   *
   * Copyright 1987, 1988 Massachusetts Institute of Technology
   *
***************
*** 77,82 ****
--- 77,84 ----
         Offset(bold_font), XtRString, MANPAGE_BOLD},
      {XtNmanualFontItalic, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
         Offset(italic_font), XtRString, MANPAGE_ITALIC},
+     {XtNmanualFontSymbol, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
+        Offset(symbol_font), XtRString, MANPAGE_SYMBOL},
      {XtNfile, XtCFile, XtRFile, sizeof(FILE *),
         Offset(file), XtRImmediate, (caddr_t) NULL},
  };
***************
*** 648,653 ****
--- 650,658 ----
  
    values.font = sblw->scroll.bold_font->fid;
    sblw->scroll.bold_gc = XtGetGC(w, mask, &values);
+ 
+   values.font = sblw->scroll.symbol_font->fid;
+   sblw->scroll.symbol_gc = XtGetGC(w, mask, &values);
  }
  
  /*	Function Name: DestroyGCs
***************
*** 666,671 ****
--- 671,677 ----
    XtReleaseGC(w, sblw->scroll.bold_gc);
    XtReleaseGC(w, sblw->scroll.italic_gc);
    XtReleaseGC(w, sblw->scroll.move_gc);
+   XtReleaseGC(w, sblw->scroll.symbol_gc);
  }
  
  static void
***************
*** 871,876 ****
--- 877,890 ----
  				   me to bold the first line of each page.*/
  #define BACKSPACE 010		/* I doubt you would want to change this. */
  
+ #define NORMAL	0
+ #define BOLD	1
+ #define ITALIC	2
+ #define SYMBOL	3
+ #define WHICH(italic, bold)	((bold) ? BOLD : ((italic) ? ITALIC : NORMAL))
+ 				/* Choose BOLD over ITALICS.  If neither */
+ 				/* is chosen, use NORMAL. */
+ 
  /*	Function Name: PrintText
   *	Description: This function actually prints the text.
   *	Arguments: w - the ScrollByLine widget.
***************
*** 950,956 ****
      switch(*c) {
  
      case '\0':		      /* If we reach the end of the file then return */
!       DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, FALSE);
        return;
  
      case '\n':
--- 964,970 ----
      switch(*c) {
  
      case '\0':		      /* If we reach the end of the file then return */
!       DumpText(w, x_loc, y_loc, buf, bufp - buf, WHICH(italicflag, first));
        return;
  
      case '\n':
***************
*** 960,966 ****
  	bold = ( (first) || ((x_loc == (sblw->scroll.offset +
  			      sblw->scroll.indent)) && Boldify(buf)) );
  
! 	(void) DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, bold);
  	if (bold)
  	  first = FALSE;
        }
--- 974,982 ----
  	bold = ( (first) || ((x_loc == (sblw->scroll.offset +
  			      sblw->scroll.indent)) && Boldify(buf)) );
  
! 	(void) DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			WHICH(italicflag, bold));
! 	
  	if (bold)
  	  first = FALSE;
        }
***************
*** 984,992 ****
   */
  
      case '\t':			/* TAB */
!       x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, italicflag, FALSE);
        bufp = buf; 
!       italicflag = 0;
        x_loc += width - (x_loc % width);
        break;
  
--- 1000,1009 ----
   */
  
      case '\t':			/* TAB */
!       x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 		       WHICH(italicflag, first));
        bufp = buf; 
!       italicflag = FALSE;
        x_loc += width - (x_loc % width);
        break;
  
***************
*** 1003,1014 ****
        if (c[-1] == c[1] && c[1] != BACKSPACE) {	/* overstriking one char */
  	bufp--;		/* Zap 1st instance of char to bolden */
  	if (bufp > buf) {
! 	  x_loc = DumpText(w, x_loc, y_loc, buf,
! 			   bufp - buf, italicflag, FALSE);
  	  bufp = buf;
  	}
  	*bufp++ = c[1];
! 	x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, FALSE, TRUE);
  	bufp = buf;
  	first = FALSE;
  
--- 1020,1031 ----
        if (c[-1] == c[1] && c[1] != BACKSPACE) {	/* overstriking one char */
  	bufp--;		/* Zap 1st instance of char to bolden */
  	if (bufp > buf) {
! 	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			   WHICH(italicflag, FALSE));
  	  bufp = buf;
  	}
  	*bufp++ = c[1];
! 	x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, BOLD);
  	bufp = buf;
  	first = FALSE;
  
***************
*** 1025,1032 ****
        else {
  	if ((c[-1] == 'o' && c[1] == '+')          /* Nroff bullet */
  	    || (c[-1] == '+' && c[1] == 'o')) {	   /* Nroff bullet */
! 	  /* I would prefer to put a 'bullet' char here */
! 	  *bufp++ = 'o';
  	  c++;
  	}
  	else {		/* 'real' backspace - back up output ptr */
--- 1042,1056 ----
        else {
  	if ((c[-1] == 'o' && c[1] == '+')          /* Nroff bullet */
  	    || (c[-1] == '+' && c[1] == 'o')) {	   /* Nroff bullet */
! 				/* If we run into a bullet, print out */
! 				/* everything that's accumulated to this */
! 				/* point, then the bullet, then resume. */
! 	  bufp--;
! 	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			   WHICH(italicflag, FALSE));
! 	  bufp = buf;
! 	  *bufp = (char)183;
! 	  x_loc = DumpText(w, x_loc, y_loc, buf, 1, SYMBOL);
  	  c++;
  	}
  	else {		/* 'real' backspace - back up output ptr */
***************
*** 1041,1047 ****
        if(*(c + 1) == BACKSPACE) {
  	if(!italicflag) {	/* font change? */
  	  if (bufp != buf) {
! 	    x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, FALSE, FALSE);
  	    bufp = buf;
  	  }
  	  italicflag = TRUE;
--- 1065,1071 ----
        if(*(c + 1) == BACKSPACE) {
  	if(!italicflag) {	/* font change? */
  	  if (bufp != buf) {
! 	    x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, NORMAL);
  	    bufp = buf;
  	  }
  	  italicflag = TRUE;
***************
*** 1056,1062 ****
        if(italicflag) { 			/* font change? */
  	if (bufp != buf) {
  	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			   italicflag, FALSE);
  	  bufp = buf;
  	}
  	italicflag = FALSE;
--- 1080,1086 ----
        if(italicflag) { 			/* font change? */
  	if (bufp != buf) {
  	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			   WHICH(italicflag, FALSE));
  	  bufp = buf;
  	}
  	italicflag = FALSE;
***************
*** 1079,1112 ****
   */
  
  static int
! DumpText(w, x_loc, y_loc, buf, len, italic, bold)
  Widget w;
  int x_loc, y_loc;
  char * buf;
  int len;
! Boolean italic, bold;
  {
    ScrollByLineWidget sblw = (ScrollByLineWidget) w;
    GC gc;
    XFontStruct * font;
  
!   if (italic) {
!     if (bold) 
!       XtAppError(XtWidgetToApplicationContext(w),
! 		 "SBLW: cannot be both bold and italic.");
      gc = sblw->scroll.italic_gc;
      font = sblw->scroll.italic_font;
!   }
!   else {
!     if (bold) {
        gc = sblw->scroll.bold_gc;
        font = sblw->scroll.bold_font;
!     }
!     else {
        gc = sblw->scroll.normal_gc;
        font = sblw->scroll.normal_font;
      }
!   }  
    XDrawString(XtDisplay(w), XtWindow(w), gc, x_loc, y_loc, buf, len);
    return(x_loc + XTextWidth(font, buf, len));
  }
--- 1103,1142 ----
   */
  
  static int
! DumpText(w, x_loc, y_loc, buf, len, format)
  Widget w;
  int x_loc, y_loc;
  char * buf;
  int len;
! int format;
  {
    ScrollByLineWidget sblw = (ScrollByLineWidget) w;
    GC gc;
    XFontStruct * font;
  
!   switch(format) {
! 
!   case ITALIC:
      gc = sblw->scroll.italic_gc;
      font = sblw->scroll.italic_font;
!     break;
! 
!   case BOLD:
        gc = sblw->scroll.bold_gc;
        font = sblw->scroll.bold_font;
!     break;
! 
!   case SYMBOL:
!     gc = sblw->scroll.symbol_gc;
!     font = sblw->scroll.symbol_font;
!     break;
! 
!   default:
        gc = sblw->scroll.normal_gc;
        font = sblw->scroll.normal_font;
+     break;
      }
! 
    XDrawString(XtDisplay(w), XtWindow(w), gc, x_loc, y_loc, buf, len);
    return(x_loc + XTextWidth(font, buf, len));
  }

home help back first fref pref prev next nref lref last post