Only in Implementation/: CVS
diff -c Implementation.beta-1d//XGetHClrs.c Implementation//XGetHClrs.c
*** Implementation.beta-1d//XGetHClrs.c	Wed Jan 17 18:34:44 1996
--- Implementation//XGetHClrs.c	Mon Jan 22 09:42:59 1996
***************
*** 21,27 ****
  			   anything, but that would be ugly C, not? */
  }
  
- 
  Status XAllocColors(register Display *dpy,Colormap cmap, XColor *defs, int ndefs, Status *statuses)
  {
      xAllocColorReply rep;
--- 21,26 ----
***************
*** 67,90 ****
      
      return(status);
  }
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
--- 66,68 ----
diff -c Implementation.beta-1d//bridge.c Implementation//bridge.c
*** Implementation.beta-1d//bridge.c	Wed Jan 17 18:34:44 1996
--- Implementation//bridge.c	Wed Jan 24 10:46:38 1996
***************
*** 44,49 ****
--- 44,50 ----
  
  
  #include "www.h"
+ #include "neweditor.h"
  
  #include "bridge.h"
  #include "bridge_decl.h"
***************
*** 1744,1751 ****
          HTCacheDeleteAll();
  
      /* delete various other chunks -- purify, thanks! */
! 
!     HTList_free (reqlist);
  
      if (context) {
  	l = context->registered_anchors;
--- 1745,1753 ----
          HTCacheDeleteAll();
  
      /* delete various other chunks -- purify, thanks! */
!     
!     if(!reqlist)
! 	HTList_free (reqlist);
  
      if (context) {
  	l = context->registered_anchors;
diff -c Implementation.beta-1d//display.c Implementation//display.c
*** Implementation.beta-1d//display.c	Wed Jan 17 18:34:45 1996
--- Implementation//display.c	Mon Jan 29 15:18:34 1996
***************
*** 2,7 ****
--- 2,8 ----
  
  #include <stdio.h>
  #include "www.h"
+ #include "style.h"
  
  #define IsWhiteSpace(c)  (c == ' ' || c == '\n' || c == '\t' || c == '\r')
  
***************
*** 99,105 ****
  void SetColor(GC gc, int color_text_ix, int color_background_ix)
  {
      XSetForeground(display, gc, ix2color(color_text_ix));
!     XSetBackground(display, gc, /*ix2color( --Spif 27-Oct-95 STUPID BUG ! i HATE this ! ;) */color_background_ix/*)*/);
  
  #if 0
  
--- 100,107 ----
  void SetColor(GC gc, int color_text_ix, int color_background_ix)
  {
      XSetForeground(display, gc, ix2color(color_text_ix));
!     /* GRR:  this works now that html.c is fixed */
!     XSetBackground(display, gc, ix2color(color_background_ix));
  
  #if 0
  
***************
*** 565,571 ****
  	Window windump;
  
  	windump = win;
! 	win = XCreatePixmap(display, RootWindow(display, screen),WinWidth+WinLeft,WinHeight+WinTop,DefaultDepth(display,screen));
          rect.x = WinLeft;
          rect.y = WinTop;
          rect.width = WinWidth;
--- 567,573 ----
  	Window windump;
  
  	windump = win;
! 	win = XCreatePixmap(display, RootWindow(display, screen),WinWidth+WinLeft,WinHeight+WinTop,depth); /* tor@cs.brown.edu 22-Jan-96 */
          rect.x = WinLeft;
          rect.y = WinTop;
          rect.width = WinWidth;
***************
*** 875,881 ****
      if(do_buffering)
      {
  	windump = win;
! 	win = XCreatePixmap(display, RootWindow(display, screen),WinWidth+WinLeft,WinHeight+WinTop,DefaultDepth(display,screen));
      };
   	
      if ((DocHTML(CurrentDoc) || DocImage(CurrentDoc)) && (!CurrentDoc->show_raw))
--- 877,883 ----
      if(do_buffering)
      {
  	windump = win;
! 	win = XCreatePixmap(display, RootWindow(display, screen),WinWidth+WinLeft,WinHeight+WinTop, depth);
      };
   	
      if ((DocHTML(CurrentDoc) || DocImage(CurrentDoc)) && (!CurrentDoc->show_raw))
***************
*** 954,971 ****
  	FormatElementStart(TAG_HTML_SOURCE, NULL, 0);
  
  	font_color_ix = StyleGet(S_COLOR);
! 	bg_style = StyleGet(S_BACKGROUND); 
  	
  	if(bg_style)
  	{
  	    if(bg_style->flag & S_BACKGROUND_COLOR) /* background color */
  	    {
! 		if(!((bg_style->image) && (bg_style->flag & S_BACKGROUND_X_REPEAT) && (bg_style->flag & S_BACKGROUND_Y_REPEAT)))
! 		    /* don't put color if there's an image --Spif 31-Oct-95 */
! 		{
! 		    XSetForeground(display, disp_gc, rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0)); 
! 		    XFillRectangle(display, win, disp_gc, x,y,w,h);	                          /* testing background 25-Oct-95 --Spif */
! 		} 
  	    }
  	    if(bg_style->flag & S_BACKGROUND_IMAGE) /* background image */
  	    {
--- 956,969 ----
  	FormatElementStart(TAG_HTML_SOURCE, NULL, 0);
  
  	font_color_ix = StyleGet(S_COLOR);
! 	bg_style = (BG_Style *)StyleGet(S_BACKGROUND); 
  	
  	if(bg_style)
  	{
  	    if(bg_style->flag & S_BACKGROUND_COLOR) /* background color */
  	    {
! 		XSetForeground(display, disp_gc, rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0)); 
! 		XFillRectangle(display, win, disp_gc, x,y,w,h);	 
  	    }
  	    if(bg_style->flag & S_BACKGROUND_IMAGE) /* background image */
  	    {
diff -c Implementation.beta-1d//dither.c Implementation//dither.c
*** Implementation.beta-1d//dither.c	Wed Jan 17 18:34:45 1996
--- Implementation//dither.c	Thu Feb  8 10:03:23 1996
***************
*** 20,25 ****
--- 20,26 ----
  #include <stdlib.h>
  
  #include "www.h"
+ #include "image.h"
  
  #define MAXCOLORMAPSIZE 256
  
***************
*** 39,44 ****
--- 40,46 ----
  
  extern Display *display;
  extern int screen;
+ extern int RPixelShift;
  extern int depth;
  extern Colormap colormap;
  extern int imaging;  /* set to COLOR888, COLOR232, GREY4 or MONO */
***************
*** 51,57 ****
  extern BOOL Quiet; /* howcome 11/8/95 */
  extern unsigned char* gamma_table;
  
! unsigned long stdcmap[128];  /* 2/3/2 color maps for gifs etc */
  unsigned long mycmap[256];
  
  
--- 53,59 ----
  extern BOOL Quiet; /* howcome 11/8/95 */
  extern unsigned char* gamma_table;
  
! extern unsigned long stdcmap[128];  /* 2/3/2 color maps for gifs etc */
  unsigned long mycmap[256];
  
  
***************
*** 288,331 ****
      /* return ???; */ 
  }
  
- #if 0
- 
- Byte old_rgb2ix(int r, int g, int b)
- {
-     XColor xc;
-     int cr, cg, cb;
- /*
-     cr = Voltage2Brightness(r);
-     cg = Voltage2Brightness(g);
-     cb = Voltage2Brightness(b);
- */
-     xc.red = r << 8;
-     xc.green = g << 8;
-     xc.blue = b << 8;
- 
-     if (!XAllocColor(display, colormap, &xc)) {
- 	fprintf(stderr,"rgb2ix: cant allocate color\n");
-     } else {
- 	Byte i;
- 
- 	for (i=0; i<color_ix_end; i++) {
- 	    if (mycmap[i] == xc.pixel) {
- 		if (COLOR_TRACE)
- 		    fprintf(stderr,"rgb2ix my_ix=%d x_ix=%ld rgb: %d %d %d reuse\n", i, xc.pixel, cr, cg, cb);
- 		return(i);
- 	    }
- 	}
- 	mycmap[color_ix_end] = xc.pixel;
- 	if (COLOR_TRACE)
- 	    fprintf(stderr,"rgb2ix my_ix=%d x_ix=%ld rgb: %d %d %d new\n", color_ix_end, xc.pixel, cr, cg, cb);
- 	color_ix_end++;
- 	return (color_ix_end - 1);
-     }
- }
- 
- #endif
- 
- 
  long rgb2color(int status, int r, int g, int b, Bool rw)
  {
      return(ix2color(rgb2ix(status, r, g, b, rw)));
--- 290,295 ----
***************
*** 397,414 ****
  
  		    switch (idata->components) {
  		      case 1:
! /*			cr = cg = cb = Voltage2Brightness(scan_buffer[xpos]);*/
! 			cr = cg = cb = gamma_table[scan_buffer[xpos]];
  			break;
  		      case 3:
- #if 0
  			cr = Voltage2Brightness(scan_buffer [0+(xpos * 3)]);
  			cg = Voltage2Brightness(scan_buffer [1+(xpos * 3)]);
  			cb = Voltage2Brightness(scan_buffer [2+(xpos * 3)]);
! #endif
  			cr = gamma_table[scan_buffer [0+(xpos * 3)]];
  			cg = gamma_table[scan_buffer [1+(xpos * 3)]];
  			cb = gamma_table[scan_buffer [2+(xpos * 3)]];
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_1_2_4, components = %d\n",idata->components);
--- 361,378 ----
  
  		    switch (idata->components) {
  		      case 1:
! 			cr = cg = cb = Voltage2Brightness(scan_buffer[xpos]);
! /*			cr = cg = cb = gamma_table[scan_buffer[xpos]]; */
  			break;
  		      case 3:
  			cr = Voltage2Brightness(scan_buffer [0+(xpos * 3)]);
  			cg = Voltage2Brightness(scan_buffer [1+(xpos * 3)]);
  			cb = Voltage2Brightness(scan_buffer [2+(xpos * 3)]);
! #if 0
  			cr = gamma_table[scan_buffer [0+(xpos * 3)]];
  			cg = gamma_table[scan_buffer [1+(xpos * 3)]];
  			cb = gamma_table[scan_buffer [2+(xpos * 3)]];
+ #endif
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_1_2_4, components = %d\n",idata->components);
***************
*** 450,469 ****
  
  		    switch (idata->components) {
  		      case 1:
! /*			cg = Voltage2Brightness(scan_buffer[xpos]);*/
! 			cg = gamma_table[scan_buffer[xpos]];
  			break;
  		      case 3:
- #if 0
  			cg = Voltage2Brightness(
  						(0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]));
! #endif			
  			cg = gamma_table[(int)
  						((0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]))];
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
--- 414,433 ----
  
  		    switch (idata->components) {
  		      case 1:
! 			cg = Voltage2Brightness(scan_buffer[xpos]);
! /*			cg = gamma_table[scan_buffer[xpos]]; */
  			break;
  		      case 3:
  			cg = Voltage2Brightness(
  						(0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]));
! #if 0			
  			cg = gamma_table[(int)
  						((0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]))];
+ #endif
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
***************
*** 484,500 ****
  
  		else {
  
- #if 0
  		    cg = Voltage2Brightness(
  			(0.59*scan_buffer [0+(xpos * 3)]) +
  			(0.20*scan_buffer [1+(xpos * 3)]) +
  			(0.11*scan_buffer [2+(xpos * 3)]));
! #endif
  		   cg = gamma_table[(int)
  			((0.59*scan_buffer [0+(xpos * 3)]) +
  			(0.20*scan_buffer [1+(xpos * 3)]) +
  			(0.11*scan_buffer [2+(xpos * 3)]))];
! 
                      g = cg & 0xF0;
  
                      if (cg - g > Magic16[(row << 4) + col]) {
--- 448,463 ----
  
  		else {
  
  		    cg = Voltage2Brightness(
  			(0.59*scan_buffer [0+(xpos * 3)]) +
  			(0.20*scan_buffer [1+(xpos * 3)]) +
  			(0.11*scan_buffer [2+(xpos * 3)]));
! #if 0
  		   cg = gamma_table[(int)
  			((0.59*scan_buffer [0+(xpos * 3)]) +
  			(0.20*scan_buffer [1+(xpos * 3)]) +
  			(0.11*scan_buffer [2+(xpos * 3)]))];
! #endif
                      g = cg & 0xF0;
  
                      if (cg - g > Magic16[(row << 4) + col]) {
***************
*** 561,568 ****
  			/* do grayscale */
  			
  		      case 1:
! /*			cr = cg = cb = Voltage2Brightness(scan_buffer[xpos]);*/
! 			cr = cg = cb = gamma_table[scan_buffer[xpos]];
  			g = cg & 0xF0;
  			if (cg - g > Magic16[(row << 4) + col])
  			    g += 16;
--- 524,531 ----
  			/* do grayscale */
  			
  		      case 1:
! 			cr = cg = cb = Voltage2Brightness(scan_buffer[xpos]);
! /*			cr = cg = cb = gamma_table[scan_buffer[xpos]]; */
  			g = cg & 0xF0;
  			if (cg - g > Magic16[(row << 4) + col])
  			    g += 16;
***************
*** 571,585 ****
  			break;
  
  		      case 3:
- #if 0
  			cr = Voltage2Brightness(scan_buffer [0+(xpos * 3)]);
  			cg = Voltage2Brightness(scan_buffer [1+(xpos * 3)]);
  			cb = Voltage2Brightness(scan_buffer [2+(xpos * 3)]);
! #endif
  			cr = gamma_table[scan_buffer [0+(xpos * 3)]];
  			cg = gamma_table[scan_buffer [1+(xpos * 3)]];
  			cb = gamma_table[scan_buffer [2+(xpos * 3)]];
! 
  			r = cr & 0xC0;
  			g = cg & 0xE0;
  			b = cb & 0xC0;
--- 534,547 ----
  			break;
  
  		      case 3:
  			cr = Voltage2Brightness(scan_buffer [0+(xpos * 3)]);
  			cg = Voltage2Brightness(scan_buffer [1+(xpos * 3)]);
  			cb = Voltage2Brightness(scan_buffer [2+(xpos * 3)]);
! #if 0
  			cr = gamma_table[scan_buffer [0+(xpos * 3)]];
  			cg = gamma_table[scan_buffer [1+(xpos * 3)]];
  			cb = gamma_table[scan_buffer [2+(xpos * 3)]];
! #endif
  			r = cr & 0xC0;
  			g = cg & 0xE0;
  			b = cb & 0xC0;
***************
*** 613,632 ****
  
  		    switch (idata->components) {
  		      case 1:
! /*			cg = Voltage2Brightness(scan_buffer[xpos]);*/
  			cg = gamma_table[scan_buffer[xpos]];
  			break;
  		      case 3:
- #if 0
  			cg = Voltage2Brightness(
  						(0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]));
! #endif			
  			cg = gamma_table[(int)
  						((0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]))];
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
--- 575,594 ----
  
  		    switch (idata->components) {
  		      case 1:
! 			cg = Voltage2Brightness(scan_buffer[xpos]);
  			cg = gamma_table[scan_buffer[xpos]];
  			break;
  		      case 3:
  			cg = Voltage2Brightness(
  						(0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]));
! #if 0			
  			cg = gamma_table[(int)
  						((0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]))];
+ #endif	
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
***************
*** 641,660 ****
  		else {
  		    switch (idata->components) {
  		      case 1:
! /*			cg = Voltage2Brightness(scan_buffer[xpos]);*/
! 			cg = gamma_table[scan_buffer[xpos]];
  			break;
  		      case 3:
- #if 0
  			cg = Voltage2Brightness(
  						(0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]));
! #endif			
  			cg = gamma_table[(int)
  						((0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]))];
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
--- 603,622 ----
  		else {
  		    switch (idata->components) {
  		      case 1:
! 			cg = Voltage2Brightness(scan_buffer[xpos]);
! /*			cg = gamma_table[scan_buffer[xpos]]; */
  			break;
  		      case 3:
  			cg = Voltage2Brightness(
  						(0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]));
! #if 0
  			cg = gamma_table[(int)
  						((0.59*scan_buffer [0+(xpos * 3)]) +
  						(0.20*scan_buffer [1+(xpos * 3)]) +
  						(0.11*scan_buffer [2+(xpos * 3)]))];
+ #endif
  			break;
  		      default:
  			fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
***************
*** 719,727 ****
  		    *dp++ = scan_buffer [xpos];
  		    break;
  		  case 3:
! 		    *dp++ = scan_buffer [0+(xpos*3)];
  		    *dp++ = scan_buffer [1+(xpos*3)];
! 		    *dp++ = scan_buffer [2+(xpos*3)];
  		    break;
  		  default:
  		    fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
--- 681,689 ----
  		    *dp++ = scan_buffer [xpos];
  		    break;
  		  case 3:
! 		    *dp++ = scan_buffer [((RPixelShift) ? 0 : 2)+(xpos*3)];
  		    *dp++ = scan_buffer [1+(xpos*3)];
! 		    *dp++ = scan_buffer [((RPixelShift) ? 2 : 0)+(xpos*3)];
  		    break;
  		  default:
  		    fprintf(stderr,"ImageOutputScanlines_8, components = %d\n",idata->components);
***************
*** 732,738 ****
--- 694,755 ----
      return TRUE;	/* janet 1/8/95: added. should it return other value? */
  } 
  
+ static int ImageOutputScanlines_16 (output_image_data *output, 
+ 			image_data *idata) {
  
+     int             xpos = 0, ypos = 0, yindex;
+     unsigned char   *dp, *scan_buffer;
+     int             row, col, cr, cg, cb; 
+     long            ulp;
+   
+     if (TRUE) {	
+         dp = output->data + output->row * output->bytes_per_row;
+ 
+ 	if (IMAGE_TRACE)
+ 	    fprintf(stderr,"ImageOutputScanlines_16 %d %d\n", output->row, output->bytes_per_row);
+ 
+         for (yindex = 0; yindex < idata->rows; yindex++) {
+ 	    ypos = yindex + output->row;
+ 	    scan_buffer = idata->buffer + (yindex * output->width * 3);
+ 
+ 	    if (IMAGE_TRACE)
+ 		fprintf(stderr,"ImageOutputScanlines_24: y %d scanbuffer %lx\n",yindex, scan_buffer);
+ 
+             col = ypos & 15;
+ 
+             for (xpos = 0; xpos < idata->width; ++xpos) {
+                 row = xpos & 15;
+ 
+ /*
+                 cr = scan_buffer [0+(xpos * 3)];
+                 cg = scan_buffer [1+(xpos * 3)];
+                 cb = scan_buffer [2+(xpos * 3)];
+ 		*/
+ 
+ 		switch (idata->components) {
+ 		  case 1:
+ 		      cr = cg = cb = scan_buffer [xpos];
+ 		      GetColor(cr, cg, cb, &ulp);
+ 		      *dp++ = ((char*)&ulp)[1]; 
+ 		      *dp++ = ((char*)&ulp)[0];
+ 		      break;
+ 		  case 3:
+ 		      cr = scan_buffer [0+(xpos * 3)];
+ 		      cg = scan_buffer [1+(xpos * 3)];
+ 		      cb = scan_buffer [2+(xpos * 3)];
+ 		      GetColor(cr, cg, cb, &ulp);
+ 		      *dp++ = ((char*)&ulp)[1]; 
+ 		      *dp++ = ((char*)&ulp)[0];
+ 		      break; 
+ 		default:
+ 		    fprintf(stderr,"ImageOutputScanlines_16, components = %d\n",idata->components);
+ 		}
+             }
+         }
+     }
+     return TRUE;	/* janet 1/8/95: added. should it return other value? */
+ } 
+ 
  #ifdef NEVER
  static int ReadColorMap(Block *bp, Image *image, int ncolors, Color *colors, int *grey)
  {
***************
*** 820,834 ****
  	}
      else if (output->depth == 8) {
  	output->bytes_per_row = 1 * data->width;
! 	}    
      else if (output->depth == 24) {
!         output->bytes_per_row = 4 * data->width;
! 	}    
      else {
! 	fprintf(stderr,"sorry, images are not supported for depth %d\n",depth);
  	output->data = NULL;
  	return FALSE;
! 	}
  
      blocksize = output->bytes_per_row * data->height;
      output->data = malloc (blocksize);
--- 837,854 ----
  	}
      else if (output->depth == 8) {
  	output->bytes_per_row = 1 * data->width;
!     }
!     else if (output->depth == 16) {
!         output->bytes_per_row = 2 * data->width;
!     }  
      else if (output->depth == 24) {
!         output->bytes_per_row = 4 * data->width;  /* 4 ???? */
!     }    
      else {
! 	fprintf(stderr,"sorry, images are not supported for depth %d (%d)\n",depth, output->depth);
  	output->data = NULL;
  	return FALSE;
!     }
  
      blocksize = output->bytes_per_row * data->height;
      output->data = malloc (blocksize);
***************
*** 855,861 ****
      else if (output->depth == 24) {
          ImageOutputScanlines_24 (output, data);
  	output->row = output->row + data->rows;	/* howcome 9/2/94: phill forgot this one */
! 	}    
      else {
  	fprintf(stderr,"sorry, images are not supported for depth %d\n",depth);
  	return FALSE;
--- 875,885 ----
      else if (output->depth == 24) {
          ImageOutputScanlines_24 (output, data);
  	output->row = output->row + data->rows;	/* howcome 9/2/94: phill forgot this one */
! 	} 
!     else if (output->depth == 16) {
!         ImageOutputScanlines_16 (output, data);
! 	output->row = output->row + data->rows;
! 	} 
      else {
  	fprintf(stderr,"sorry, images are not supported for depth %d\n",depth);
  	return FALSE;
diff -c Implementation.beta-1d//editor.c Implementation//editor.c
*** Implementation.beta-1d//editor.c	Wed Jan 17 18:34:45 1996
--- Implementation//editor.c	Fri Jan 26 11:03:57 1996
***************
*** 340,347 ****
  }
  
  
! void FreeEditBuffer()
  {
  }
  
  
--- 340,348 ----
  }
  
  
! void FreeEditBuffer(EditBuffer *eb)
  {
+     Free(eb);
  }
  
  
***************
*** 391,397 ****
      eb->break_table_size = MAX_CHAR_VALUE;
      eb->break_table = (char *)malloc(MAX_CHAR_VALUE);
      if (!eb->break_table) {
! 	FreeEditBuffer(/*eb*/);
  	return FALSE;
      }
  
--- 392,398 ----
      eb->break_table_size = MAX_CHAR_VALUE;
      eb->break_table = (char *)malloc(MAX_CHAR_VALUE);
      if (!eb->break_table) {
! 	FreeEditBuffer(eb);
  	return FALSE;
      }
  
***************
*** 436,442 ****
  		ep = (EditParagraph *)malloc(sizeof(EditParagraph));
  
  		if (!ep) {
! 		    FreeEditBuffer(/*eb*/);
  		    return FALSE;
  		}
  
--- 437,443 ----
  		ep = (EditParagraph *)malloc(sizeof(EditParagraph));
  
  		if (!ep) {
! 		    FreeEditBuffer(eb);
  		    return FALSE;
  		}
  
***************
*** 444,450 ****
  		
  		ep->buffer = (char *) malloc (len + EXTRA_LENGTH);
  		if (! ep->buffer) {
! 		    FreeEditBuffer(/*eb*/);
  		    return FALSE;
  		}
  
--- 445,451 ----
  		
  		ep->buffer = (char *) malloc (len + EXTRA_LENGTH);
  		if (! ep->buffer) {
! 		    FreeEditBuffer(eb);
  		    return FALSE;
  		}
  
diff -c Implementation.beta-1d//forms.c Implementation//forms.c
*** Implementation.beta-1d//forms.c	Wed Jan 17 18:34:45 1996
--- Implementation//forms.c	Fri Jan 26 11:45:51 1996
***************
*** 455,461 ****
  
  /* howcome 27/7/95: should AddOption return Option ? */
  
! void *AddOption(Field *field, int flags, char *label, int len)
  {
      int width, font;
      Option *option, *last;
--- 455,461 ----
  
  /* howcome 27/7/95: should AddOption return Option ? */
  
! void AddOption(Field *field, int flags, char *label, int len)
  {
      int width, font;
      Option *option, *last;
***************
*** 468,474 ****
      {
          option = next_option;
          next_option = option->next;
!         return option;
      }
  
      option = (Option *)malloc(sizeof(Option));
--- 468,474 ----
      {
          option = next_option;
          next_option = option->next;
!         return /*option*/;
      }
  
      option = (Option *)malloc(sizeof(Option));
***************
*** 498,504 ****
  			free(option->label);
  			free(option);
  		    };
! 		    return NULL;
  		}; /* don't add 2 times the same option --Spif 18-Oct-95 */
              last = last->next;
  	};
--- 498,504 ----
  			free(option->label);
  			free(option);
  		    };
! 		    return /*NULL*/;
  		}; /* don't add 2 times the same option --Spif 18-Oct-95 */
              last = last->next;
  	};
***************
*** 508,514 ****
  	    if ( strncmp( last->label, label, len))
  		last->next = option;
  	    else
! 		return NULL;
      }
      else
      {
--- 508,514 ----
  	    if ( strncmp( last->label, label, len))
  		last->next = option;
  	    else
! 		return/* NULL*/;
      }
      else
      {
***************
*** 517,525 ****
      };
  
      field->y_indent++;
- 
-     /* janet: return value? (option or last?) */
-     return NULL; /* howcome 10/8/95: better than nothing */
  }
  
  Field *CurrentRadioButton(Form *form, char *name, int nlen)
--- 517,522 ----
***************
*** 938,944 ****
  		if(s[i] == '&')
  		{
  		    for(ok= FALSE,j=i; !ok && j< len; j++)
! 			ok == ((s[j]==';') || (s[j]==' ')); 
  		    the_string[k] = entity(s+i+1, &j);
  		    i += j - 1;
  		}
--- 935,941 ----
  		if(s[i] == '&')
  		{
  		    for(ok= FALSE,j=i; !ok && j< len; j++)
! 			ok = ((s[j]==';') || (s[j]==' ')); 
  		    the_string[k] = entity(s+i+1, &j);
  		    i += j - 1;
  		}
diff -c Implementation.beta-1d//gif.c Implementation//gif.c
*** Implementation.beta-1d//gif.c	Wed Jan 17 18:34:45 1996
--- Implementation//gif.c	Wed Feb  7 17:41:54 1996
***************
*** 30,35 ****
--- 30,36 ----
  #include <stdlib.h>
  
  #include "www.h"
+ #include "image.h"
  
  #define MAXCOLORMAPSIZE 256
  
***************
*** 60,66 ****
  extern int tileWidth, tileHeight;
  extern unsigned char *tileData;
  extern unsigned long windowColor;
! unsigned long stdcmap[128];  /* 2/3/2 color maps for gifs etc */
  extern unsigned long greymap[16];
  extern debug; /* howcome 16/10/94 */
  extern unsigned long transparent; /* howcome 30/10/94 */
--- 61,67 ----
  extern int tileWidth, tileHeight;
  extern unsigned char *tileData;
  extern unsigned long windowColor;
! extern unsigned long stdcmap[128];  /* 2/3/2 color maps for gifs etc */
  extern unsigned long greymap[16];
  extern debug; /* howcome 16/10/94 */
  extern unsigned long transparent; /* howcome 30/10/94 */
***************
*** 661,667 ****
      int             cr, cg, cb, r, g, b, row, col;
      Color           color;
  
!   /*
     *  Initialize the Compression routines
     */
  
--- 662,668 ----
      int             cr, cg, cb, r, g, b, row, col;
      Color           color;
  
!    /*
     *  Initialize the Compression routines
     */
  
***************
*** 885,891 ****
      int             v, trans;
      int             xpos = 0, ypos = 0; /* janet 21/07/95: not used: pass = 0 */
      unsigned char   *dp;
!     unsigned long pixels[MAXCOLORMAPSIZE], *pp, *data24;
      unsigned long int ulp;
  
     /* setup pixel table for faster rendering */
--- 886,892 ----
      int             v, trans;
      int             xpos = 0, ypos = 0; /* janet 21/07/95: not used: pass = 0 */
      unsigned char   *dp;
!     unsigned char pixels[4*MAXCOLORMAPSIZE], *pp, *data24;
      unsigned long int ulp;
  
     /* setup pixel table for faster rendering */
***************
*** 908,923 ****
          /* From Scott Nelson <snelson@canopus.llnl.gov> 24bit color  1/12/94  Dec 1 1994 */
  
          GetColor(colors[v].red, colors[v].green, colors[v].blue, &ulp);
          *dp++ = '\0';
-         *dp++ = ((char*)&ulp)[1]; 
-         *dp++ = ((char*)&ulp)[2]; 
-         *dp++ = ((char*)&ulp)[3];
- /*
-         *dp++ = '\0';
          *dp++ = colors[v].red;
          *dp++ = colors[v].green;
          *dp++ = colors[v].blue;
! */
      }
  
      if (!tileData)   /* default to window background */
--- 909,925 ----
          /* From Scott Nelson <snelson@canopus.llnl.gov> 24bit color  1/12/94  Dec 1 1994 */
  
          GetColor(colors[v].red, colors[v].green, colors[v].blue, &ulp);
+ 	
+ 	*dp++ = '\0';
+ 	*dp++ = (ulp >> 16) & 0xff; 
+ 	*dp++ = (ulp >> 8) & 0xff; 
+ 	*dp++ = ulp & 0xff; 
+ #if 0
          *dp++ = '\0';
          *dp++ = colors[v].red;
          *dp++ = colors[v].green;
          *dp++ = colors[v].blue;
! #endif
      }
  
      if (!tileData)   /* default to window background */
***************
*** 950,956 ****
          return NULL;
      }
  
!     data24 = (unsigned long *)malloc(len * height * sizeof(unsigned long));
  
      if (data24 == NULL)
      {
--- 952,958 ----
          return NULL;
      }
  
!     data24 = (unsigned char *)malloc(len * height * 4);
  
      if (data24 == NULL)
      {
***************
*** 969,975 ****
  
          for (i = 0; i < height; ++i)
          {
!             pp = &data24[len*ypos];
  
              for (xpos = 0; xpos < len; ++xpos)
              {
--- 971,977 ----
  
          for (i = 0; i < height; ++i)
          {
!             pp = &data24[len*ypos*4];
  
              for (xpos = 0; xpos < len; ++xpos)
              {
***************
*** 979,989 ****
                  if (v == trans)
                  {
                      Transparent((unsigned char *)pp, xpos, ypos);
!                     ++pp;
                      continue;
                  }
  
!                 *pp++ = pixels[v];
              }
  
              if ((ypos += step) >= height)
--- 981,994 ----
                  if (v == trans)
                  {
                      Transparent((unsigned char *)pp, xpos, ypos);
!                     pp+=4;
                      continue;
                  }
  
!                 *pp++ = pixels[4*v];
! 		*pp++ = pixels[4*v+1];
! 		*pp++ = pixels[4*v+2];
! 		*pp++ = pixels[4*v+3];
              }
  
              if ((ypos += step) >= height)
***************
*** 1009,1019 ****
                  if (v == trans)
                  {
                      Transparent((unsigned char *)pp, xpos, ypos);
!                     ++pp;
                      continue;
                  }
  
!                 *pp++ = pixels[v];
              }
          }
      }
--- 1014,1027 ----
                  if (v == trans)
                  {
                      Transparent((unsigned char *)pp, xpos, ypos);
!                     pp+=4;
                      continue;
                  }
  
!                 *pp++ = pixels[4*v];
! 		*pp++ = pixels[4*v+1];
! 		*pp++ = pixels[4*v+2];
! 		*pp++ = pixels[4*v+3];
              }
          }
      }
***************
*** 1026,1031 ****
--- 1034,1178 ----
      return (unsigned char *)data24;
  }
  
+ static unsigned char *ReadImage16(Block *bp, int len, int height,
+      Color colors[MAXCOLORMAPSIZE], int nColors, int interlace, int ignore)
+ {
+     unsigned char   c;      
+     int             v, trans;
+     int             xpos = 0, ypos = 0; /* janet 21/07/95: not used: pass = 0 */
+     unsigned char   *dp;
+     unsigned char pixels[2*MAXCOLORMAPSIZE];
+     unsigned char *data16, *pp;
+     unsigned long int ulp;
+ 
+    /* setup pixel table for faster rendering */
+ 
+     dp = (unsigned char *)&(pixels[0]);
+     trans = Gif89.transparent;
+ 
+     for (v = 0; v < nColors; ++v)
+     {
+ 
+         if (v == trans)
+         {
+             *dp++ = (windowColor >> 8) & 0xFF;
+             *dp++ = (windowColor) & 0xFF;
+             continue;
+         }
+ 
+          GetColor(colors[v].red, colors[v].green, colors[v].blue, &ulp);
+         *dp++ = ((char*)&ulp)[1]; 
+         *dp++ = ((char*)&ulp)[0];
+     }
+ 
+     if (!tileData)   /* default to window background */
+         trans = -1;
+ 
+   /*
+    *  Initialize the Compression routines
+    */
+ 
+     if (! ReadOK(bp,&c,1))
+     {
+ 	if (VERBOSE_TRACE)
+ 	    fprintf(stderr, "EOF / read error on image data\n");
+         return(NULL);
+     }
+ 
+     initLWZ(c);
+ 
+    /*
+     *  If this is an "uninteresting picture" ignore it.
+     */
+ 
+     if (ignore)
+     {
+         if (VERBOSE_TRACE)
+             fprintf(stderr, "skipping image...\n" );
+ 
+         while (readLWZ(bp) >= 0);
+ 
+         return NULL;
+     }
+ 
+     data16 = (unsigned char *)malloc(len * height * 2);
+ 
+     if (data16 == NULL)
+     {
+         fprintf(stderr, "Cannot allocate space for image data\n");
+         return(NULL);
+     }
+ 
+     if (verbose)
+         fprintf(stderr, "reading %d by %d%s GIF image\n",
+                  len, height, interlace ? " interlaced" : "" );
+ 
+     if (interlace)
+     {
+         int i;
+         int pass = 0, step = 8;
+ 
+         for (i = 0; i < height; ++i)
+         {
+             pp = &data16[len*ypos*2];
+ 
+             for (xpos = 0; xpos < len; ++xpos)
+             {
+                 if ((v = readLWZ(bp)) < 0)
+                     goto fini;
+ 
+                 if (v == trans)
+                 {
+                     Transparent((unsigned char *)pp, xpos, ypos);
+                     pp+=2;
+                     continue;
+                 }
+ 
+                 *pp++ = pixels[2*v];
+ 		*pp++ = pixels[2*v+1];
+             }
+ 
+             if ((ypos += step) >= height)
+             {
+                 if (pass++ > 0)
+                     step /= 2;
+ 
+                 ypos = step /2;
+             }
+         }
+     }
+     else
+     {
+         pp = data16;
+ 
+         for (ypos = 0; ypos < height; ++ypos)
+         {
+             for (xpos = 0; xpos < len; ++xpos)
+             {
+                 if ((v = readLWZ(bp)) < 0)
+                     goto fini;
+ 
+                 if (v == trans)
+                 {
+                     Transparent((unsigned char *)pp, xpos, ypos);
+                     pp +=2;
+                     continue;
+                 }
+ 
+                 *pp++ = pixels[2*v];
+ 		*pp++ = pixels[2*v+1];
+             }
+         }
+     }
+ 
+  fini:
+ 
+     if (readLWZ(bp) >= 0)
+         fprintf(stderr, "too much input data, ignoring extra...\n");
+ 
+     return (unsigned char *)data16;
+ }
+ 
  static int DoExtension(Block *bp, int label)
  {
      static char buf[256];
***************
*** 1102,1108 ****
          colors->green = rgb[1];
          colors->blue = rgb[2];
  	
! #if 0
       /* apply gamma correction to map voltages to brightness values */
  
          if (imaging != COLOR888)
--- 1249,1255 ----
          colors->green = rgb[1];
          colors->blue = rgb[2];
  	
! 
       /* apply gamma correction to map voltages to brightness values */
  
          if (imaging != COLOR888)
***************
*** 1111,1117 ****
              colors->green = Voltage2Brightness(colors->green);
              colors->blue = Voltage2Brightness(colors->blue);
          }
! #endif
  	/* Always gamma correct palette (if needed) */
  /*	if(gamma_table) {*/
  	colors->red = gamma_table[colors->red];
--- 1258,1264 ----
              colors->green = Voltage2Brightness(colors->green);
              colors->blue = Voltage2Brightness(colors->blue);
          }
! #if 0
  	/* Always gamma correct palette (if needed) */
  /*	if(gamma_table) {*/
  	colors->red = gamma_table[colors->red];
***************
*** 1118,1124 ****
  	colors->green = gamma_table[colors->green];
  	colors->blue = gamma_table[colors->blue];
  /*	}*/
! 	
       /* set grey value iff color is very close to grey (or GREY/MONO imaging) */
  
          drb = abs(rgb[1] - rgb[0]);
--- 1265,1271 ----
  	colors->green = gamma_table[colors->green];
  	colors->blue = gamma_table[colors->blue];
  /*	}*/
! #endif
       /* set grey value iff color is very close to grey (or GREY/MONO imaging) */
  
          drb = abs(rgb[1] - rgb[0]);
***************
*** 1128,1134 ****
          if (*grey || (drb < 20 && dgb < 20 && dbr < 20))
          {   
              flag &= 1;
!             colors->grey = (3*colors->red + 6*colors->green + colors->blue)/10;
          }
          else
          {
--- 1275,1281 ----
          if (*grey || (drb < 20 && dgb < 20 && dbr < 20))
          {   
              flag &= 1;
!             colors->grey = (30*colors->red + 59*colors->green + 11*colors->blue)/100;
          }
          else
          {
***************
*** 1300,1305 ****
--- 1447,1458 ----
          if (depth == 24 || depth == 12)
          {
              data = ReadImage24(bp, LM_to_uint(buf[4],buf[5]),
+                              LM_to_uint(buf[6],buf[7]), cmap, bitPixel,
+                  BitSet(buf[8], INTERLACE), imageCount != imageNumber);
+         } 
+ 	else if (depth == 16)
+ 	{
+             data = ReadImage16(bp, LM_to_uint(buf[4],buf[5]),
                               LM_to_uint(buf[6],buf[7]), cmap, bitPixel,
                   BitSet(buf[8], INTERLACE), imageCount != imageNumber);
          }
diff -c Implementation.beta-1d//history.c Implementation//history.c
*** Implementation.beta-1d//history.c	Wed Jan 17 18:34:45 1996
--- Implementation//history.c	Fri Jan 26 11:08:03 1996
***************
*** 342,348 ****
  	if (HISTORY_TRACE)
  	    fprintf(stderr, "HistoryRecord: in loop %d\n",i);	    
  	h = (History *)HTList_objectAt(context->history, i);
! 	if (h->state == HISTORY_VERIFIED) {
  	    h->state = HISTORY_DELETED;
  	    if (HISTORY_TRACE)
  		fprintf(stderr, "HistoryRecord: deleting %d\n",i);	    
--- 342,348 ----
  	if (HISTORY_TRACE)
  	    fprintf(stderr, "HistoryRecord: in loop %d\n",i);	    
  	h = (History *)HTList_objectAt(context->history, i);
! 	if (h && h->state == HISTORY_VERIFIED) {
  	    h->state = HISTORY_DELETED;
  	    if (HISTORY_TRACE)
  		fprintf(stderr, "HistoryRecord: deleting %d\n",i);	    
diff -c Implementation.beta-1d//html.c Implementation//html.c
*** Implementation.beta-1d//html.c	Wed Jan 17 18:34:45 1996
--- Implementation//html.c	Wed Feb  7 10:29:47 1996
***************
*** 28,33 ****
--- 28,34 ----
  #include "www.h"
  #include "tools.h"
  #include "forms.h"
+ #include "style.h"
  
  extern Display *display;
  extern int screen;
***************
*** 249,255 ****
  #ifdef STYLE_BACKGROUND
  	bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  	if(bg_style)
! 	    color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0) : 255;
  	else
  	    color_background_ix = 255;	 
  #endif
--- 250,256 ----
  #ifdef STYLE_BACKGROUND
  	bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  	if(bg_style)
! 	    color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2ix(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; /* GRR */ 
  	else
  	    color_background_ix = 255;	 
  #endif
***************
*** 951,957 ****
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if (bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; 
  		    else
  			color_background_ix = 255;	
  #endif
--- 952,958 ----
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if (bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2ix(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; /* GRR */
  		    else
  			color_background_ix = 255;	
  #endif
***************
*** 1309,1315 ****
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if(bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0) : 255;
  		    else
  			color_background_ix = 255;	 
  #endif
--- 1310,1316 ----
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if(bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2ix(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; /* GRR */
  		    else
  			color_background_ix = 255;	 
  #endif
***************
*** 1877,1884 ****
      unsigned int valuemask;
      Pixmap bg_pixmap;
      XRectangle frameRect,bgRect;
!     int dirtyscroll=0;
  
      displayRect.x = WinLeft;
      displayRect.y = WinTop;
      displayRect.width = WinWidth;
--- 1878,1886 ----
      unsigned int valuemask;
      Pixmap bg_pixmap;
      XRectangle frameRect,bgRect;
!     int dirtyscroll;
  
+     dirtyscroll=0;
      displayRect.x = WinLeft;
      displayRect.y = WinTop;
      displayRect.width = WinWidth;
***************
*** 2030,2052 ****
  #endif
              c1 = *p++; c2 = *p++; length = c1 | c2<<8;
  
! 	    /* printf("BEGIN_FRAME %xh (x1 %d, y1 %d, width %d, height %d, length %d\n",(p-12),x1,y1,width,height,length);  */
! 
!     
           /* call self to paint this frame */
! 
! 	    if(dirtyscroll)
  	    {
  		PaintFrame(bg_pixmap, p, p + length, x1, y, h);
  	    }
! 	    else
! 		PaintFrame(w, p, p + length, x1, y, h);
  	    p += length+2; /* to skip over frame's contents */
! 	    if(dirtyscroll)
  	    {
! 		XCopyGC(display,disp_gc,0xFFFF,gc_bg);
! 		valuemask = GCTile|GCFillStyle|GCGraphicsExposures;
! 		values.tile = bg_style->image->pixmap;
  		values.fill_style = FillTiled;
  		values.graphics_exposures = 0;
  		XChangeGC(display, gc_bg, valuemask, &values);
--- 2032,2055 ----
  #endif
              c1 = *p++; c2 = *p++; length = c1 | c2<<8;
  
! 	    /* printf("BEGIN_FRAME %xh (x1 %d, y1 %d, width %d, height %d, length %d\n",(p-12),x1,y1,width,height,length);  
! 	     */
! 	    
           /* call self to paint this frame */
! 	    
! 	    if(dirtyscroll && bg_style)
  	    {
  		PaintFrame(bg_pixmap, p, p + length, x1, y, h);
  	    }
! 		else
! 		    PaintFrame(w, p, p + length, x1, y, h);
  	    p += length+2; /* to skip over frame's contents */
! 	    if(dirtyscroll && bg_style)
  	    {
! 		XCopyGC(display,gc_fill,0xFFFF,gc_bg);	
! 		valuemask = GCGraphicsExposures;
! 		valuemask |= GCTile|GCFillStyle;
! 		values.tile = bg_style->image->pixmap; 
  		values.fill_style = FillTiled;
  		values.graphics_exposures = 0;
  		XChangeGC(display, gc_bg, valuemask, &values);
***************
*** 2054,2079 ****
  		XSetClipRectangles(display, gc_fill, 0, 0, &displayRect, 1, Unsorted); 
  		XSetClipRectangles(display, gc_bg, 0, 0, &displayRect, 1, Unsorted);
  		XCopyArea(display,bg_pixmap,w,gc_bg,frameRect.x,frameRect.y,frameRect.width,frameRect.height,frameRect.x,frameRect.y); 
! 		XFreePixmap(display,bg_pixmap);
  		XFreeGC(display, gc_bg); 
  	    };
  	    if (border)
!                 DrawBorder(border, x+x1-PixelIndent, y1, width, height, 0 /* cb_ix */);
!             continue;
!         }
  
          /* skip end of frame marker */
!         if (tag == END_FRAME)
          {
!             p += FRAMENDLEN - 1;  /* skip start/size params */
              continue;
          }
  
          if (tag != TEXTLINE)
          {
!             fprintf(stderr, "Unexpected internal tag (10) %d at %Xh \n", tag, p-1);
! 	    Exit(1);
!         }
  
          c1 = *p++; c2 = *p++; offset = c1 | c2<<8;
          c1 = *p++; c2 = *p++; offset |= (c1 | c2<<8) << 16;
--- 2057,2083 ----
  		XSetClipRectangles(display, gc_fill, 0, 0, &displayRect, 1, Unsorted); 
  		XSetClipRectangles(display, gc_bg, 0, 0, &displayRect, 1, Unsorted);
  		XCopyArea(display,bg_pixmap,w,gc_bg,frameRect.x,frameRect.y,frameRect.width,frameRect.height,frameRect.x,frameRect.y); 
! 		XFreePixmap(display,bg_pixmap); 
  		XFreeGC(display, gc_bg); 
  	    };
  	    if (border)
! 		DrawBorder(border, x+x1-PixelIndent, y1, width, height, 0 /* cb_ix */);
! 	    continue;
! 	}
  
          /* skip end of frame marker */
!   
!        if (tag == END_FRAME)
          {
! 	    p += FRAMENDLEN - 1;  /* skip start/size params */
              continue;
          }
  
          if (tag != TEXTLINE)
          {
! 	    printf("Unexpected Internal Tag %d at %X\n",tag,(p-1));
! 	    tag = *p++;
! 	}
  
          c1 = *p++; c2 = *p++; offset = c1 | c2<<8;
          c1 = *p++; c2 = *p++; offset |= (c1 | c2<<8) << 16;
***************
*** 2089,2099 ****
          c1 = *p++; c2 = *p++; xi = x + (c1 | c2<<8);
          c1 = *p++; c2 = *p++; height = (c1 | c2<<8);
  
!         while ((tag = *p++) != '\0')
          {
              switch (tag & 0xF)
              {
!                 case RULE:
                      c1 = *p++; c2 = *p++; x1 = xi + (c1 | c2<<8);
                      c1 = *p++; c2 = *p++; x2 = c1 | c2<<8;
                      c1 = *p++; c2 = *p++; yi = c1 | c2<<8;
--- 2093,2103 ----
          c1 = *p++; c2 = *p++; xi = x + (c1 | c2<<8);
          c1 = *p++; c2 = *p++; height = (c1 | c2<<8);
  
! 	while ((tag = *p++) != '\0')
          {
              switch (tag & 0xF)
              {
! 	    case RULE:
                      c1 = *p++; c2 = *p++; x1 = xi + (c1 | c2<<8);
                      c1 = *p++; c2 = *p++; x2 = c1 | c2<<8;
                      c1 = *p++; c2 = *p++; yi = c1 | c2<<8;
***************
*** 2154,2160 ****
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if(bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR ) ? rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; 
  		    else
  			color_background_ix = 255;	
  #endif
--- 2158,2164 ----
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if(bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR ) ? rgb2ix(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; 
  		    else
  			color_background_ix = 255;	
  #endif
***************
*** 2177,2183 ****
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if (bg_style)
  		    {
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; 
  		    }	
  		    else
  			color_background_ix = 255;
--- 2181,2190 ----
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if (bg_style)
  		    {
! 			if(!bg_style->image)
! 			    color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2ix(0, bg_style->r, bg_style->g, bg_style->b,0) : 255; 
! 			else
! 			    color_background_ix = 255; 
  		    }	
  		    else
  			color_background_ix = 255;
***************
*** 2252,2258 ****
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if (bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2color(0, bg_style->r, bg_style->g, bg_style->b,0) : 255;
  		    else
  			color_background_ix = 255;	
  #endif
--- 2259,2265 ----
  #ifdef STYLE_BACKGROUND
  		    bg_style=(BG_Style *)GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  		    if (bg_style)
! 			color_background_ix = (bg_style->flag & S_BACKGROUND_COLOR) ? rgb2ix(0, bg_style->r, bg_style->g, bg_style->b,0) : 255;
  		    else
  			color_background_ix = 255;	
  #endif
***************
*** 2391,2402 ****
  #ifdef STYLE_BACKGROUND
  		    GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  #endif
!                     if (y2 > y + (int)h)
                          break;
  
                      if (y2 + height < y)
                          continue;
! 
                      x1 -= PixelIndent;
  
                      if (tag & (ISMAP | EMPH_ANCHOR))
--- 2398,2409 ----
  #ifdef STYLE_BACKGROUND
  		    GetPointer(&p); /* must be set to the structures defined by the style --Spif 18-Oct-95 */
  #endif
! 		    if (y2 > y + (int)h)
                          break;
  
                      if (y2 + height < y)
                          continue;
! 			
                      x1 -= PixelIndent;
  
                      if (tag & (ISMAP | EMPH_ANCHOR))
***************
*** 2468,2474 ****
  #else
  	fprintf(stderr,"PaintFrame: after while p = %lx, p_end = %lx\n", p, p_end);
  #endif /* PRINTF_HAS_PFORMAT */
- 
  }
  
  /* search for anchor point in document */
--- 2475,2480 ----
diff -c Implementation.beta-1d//icon.c Implementation//icon.c
*** Implementation.beta-1d//icon.c	Wed Jan 17 18:34:45 1996
--- Implementation//icon.c	Tue Feb  6 18:24:20 1996
***************
*** 32,38 ****
  extern Pixmap icon_pixmap;
  
  Image *image = NULL;
! Window win;
  GC icon_gc;
  extern GC gc_fill, toolbar_gc;
  extern unsigned long windowColor;
--- 32,38 ----
  extern Pixmap icon_pixmap;
  
  Image *image = NULL;
! extern Window win;
  GC icon_gc;
  extern GC gc_fill, toolbar_gc;
  extern unsigned long windowColor;
***************
*** 43,49 ****
  
  /* Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) */
  
! #if defined(sco) && !defined(sco_os5)
  #define index strchr
  #else
  extern char *index();
--- 43,49 ----
  
  /* Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) */
  
! #if defined __QNX__ || (defined(sco) && !defined(sco_os5))
  #define index strchr
  #else
  extern char *index();
***************
*** 154,160 ****
      
      if ((ximage = XCreateImage(display, DefaultVisual(display, screen),
  			       depth, ZPixmap, 0, data,
! 			       width, height, (depth == 24 ? 32 : 8), 0)) == 0)
  	{
  	    fprintf(stderr,"LoadIcon: Failed to create image\n");
  	    Free(data);	
--- 154,160 ----
      
      if ((ximage = XCreateImage(display, DefaultVisual(display, screen),
  			       depth, ZPixmap, 0, data,
! 			       width, height, (depth == 24 ? 32 : (depth == 16) ? 16 : 8), 0)) == 0)
  	{
  	    fprintf(stderr,"LoadIcon: Failed to create image\n");
  	    Free(data);	
***************
*** 165,171 ****
      /* howcome 22/2/95: do we need to set these?? */
  
      ximage->byte_order = MSBFirst;
!     ximage->bitmap_bit_order = MSBFirst;
  
      if ((pixmap = XCreatePixmap(display, win, width, height, depth)) == 0)
  	{
--- 165,171 ----
      /* howcome 22/2/95: do we need to set these?? */
  
      ximage->byte_order = MSBFirst;
!     ximage->bitmap_bit_order = BitmapBitOrder(display);
  
      if ((pixmap = XCreatePixmap(display, win, width, height, depth)) == 0)
  	{
diff -c Implementation.beta-1d//image.c Implementation//image.c
*** Implementation.beta-1d//image.c	Wed Jan 17 18:34:45 1996
--- Implementation//image.c	Wed Feb  7 17:56:41 1996
***************
*** 17,22 ****
--- 17,25 ----
  
  extern unsigned long labelColor, textColor, statusColor, strikeColor,
              transparent, windowColor, windowBottomShadow, windowShadow;
+ 
+ extern int RPixelShift, GPixelShift, BPixelShift;
+ extern int RPixelMask, GPixelMask, BPixelMask;
  extern int depth;
  extern int IsIndex;
  extern Doc *CurrentDoc;
***************
*** 134,160 ****
   0xfc,0x80,0xff,0x07,0xfc,0x80,0xff,0x07,0xfc,0x00,0x00,0x00,0xfc,0x00,0x00,
   0x00,0xfc};
  
- #if 0
- Image *DefaultImage(Image *image)
- {
-     if (image->npixels > 0)
-     {
-         XFreeColors(display, colormap, image->pixels, image->npixels, 0);
-         Free(image->pixels);
-         image->pixels = NULL;
-         image->npixels = 0;
-     }
- 
-     image->pixmap = default_pixmap;
-     image->width = default_pixmap_width;
-     image->height = default_pixmap_height;
-     image->next = images;
-     images = image;
- 
-     return image;
- }
- #endif
- 
  Image *DefaultImage()
  {
      if (default_image)
--- 137,142 ----
***************
*** 172,178 ****
--- 154,190 ----
      return default_image;
  }
  
+ int Brightness2Voltage(int brightness)
+ {
+     double voltage;
+     static double log_a = 0; /* howcome added double */
  
+     if (brightness == 0)
+         return 0;
+ 
+     if (log_a == 0)
+         log_a = (Gamma - 1.0) * log((double)65535);      /* cast added by howcome 21/9/94 */
+ 
+     voltage = (log_a + log((double)brightness))/Gamma;   /* cast added by howcome 21/9/94 */
+ 
+     return (int)(0.5 + exp(voltage));
+ }
+ 
+ int Voltage2Brightness(int voltage)
+ {
+     double brightness;
+     static double log_a;
+ 
+     if (voltage == 0)
+         return 0;
+ 
+     if (log_a == 0)
+         log_a = (Gamma - 1.0) * log((double)255);   /* cast added by howcome 21/9/94 */
+ 
+     brightness = Gamma * log((double)voltage) - log_a;    /* cast added by howcome 21/9/94 */
+ 
+     return (int)(0.5 + exp(brightness));
+ }
  /* don't add this to images list to avoid trouble when freeing document images */
  
  Image *MakeIcon(unsigned int depth, char *name, int width, int height, char *bits)
***************
*** 221,226 ****
--- 233,262 ----
                  byte = byte >> 1;
              }
      }
+     else  if (depth == 16)
+     {
+         p = data = (unsigned char *)malloc(size * 2);
+ 
+         for (i = 0; i < height; ++i)
+             for (j = 0, k= 8; j < width; ++j)
+             {
+                 if (++k > 8)  /* need to read next 8 pixel values */
+                 {
+                     byte = *s++;
+                     k = 1;
+                 }
+ 
+                 if (byte & 1)
+                 {
+ 		    *p++ = (textColor >>  8) & 0xFF;
+ 		    *p++ = textColor & 0xFF;
+ 		}
+                 else
+                     p = Transparent(p, j, i);
+ 
+                 byte = byte >> 1;
+             }
+     }
      else  if (depth == 24)
      {
          p = data = (unsigned char *)malloc(size * 4);
***************
*** 305,311 ****
  
      if ((ximage = XCreateImage(display, DefaultVisual(display, screen),
               depth, ZPixmap, 0, (char *)data,
!              width, height, (depth == 24 ? 32 : 8), 0)) == 0)
      {
          Warn("Failed to create XImage: %s", image->url);
          Free(data);
--- 341,347 ----
  
      if ((ximage = XCreateImage(display, DefaultVisual(display, screen),
               depth, ZPixmap, 0, (char *)data,
!              width, height, (depth == 24 ? 32 :(depth == 16 ? 16 : 8)), 0)) == 0)
      {
          Warn("Failed to create XImage: %s", image->url);
          Free(data);
***************
*** 316,322 ****
      /* howcome 22/2/95: do we need to set these?? */
  
      ximage->byte_order = MSBFirst;
!     ximage->bitmap_bit_order = MSBFirst;
  
      if ((pixmap = XCreatePixmap(display, win, width, height, depth)) == 0)
      {
--- 352,359 ----
      /* howcome 22/2/95: do we need to set these?? */
  
      ximage->byte_order = MSBFirst;
!                        
!     ximage->bitmap_bit_order = BitmapBitOrder(display);
  
      if ((pixmap = XCreatePixmap(display, win, width, height, depth)) == 0)
      {
***************
*** 353,396 ****
      warning_image = MakeIcon(depth, "warning", warning_width, warning_height, warning_bits);
  }
  
- #if 0
- void MakeFaces(unsigned int depth)
- {
-     smile = XCreateBitmapFromData(display, win, smile_xbm_bits,
-                     smile_xbm_width, smile_xbm_height);
- 
-     frown = XCreateBitmapFromData(display, win, frown_xbm_bits,
-                     frown_xbm_width, frown_xbm_height);
- }
- 
- void PaintFace(int sad)
- {
-     int x1, y1, w, h;
-     Pixmap face;
-     XRectangle displayRect;
- 
-     face = (sad ? frown : smile);
-     x1 = win_width - smile_xbm_width - 4;
-     y1 = win_height - smile_xbm_height - 6;
-     w = smile_xbm_width;
-     h = smile_xbm_height;
- 
-     displayRect.x = 0;
-     displayRect.y = 0;
-     displayRect.width = win_width;
-     displayRect.height = win_height;
-     XSetClipRectangles(display, disp_gc, 0, 0, &displayRect, 1, Unsorted);
- 
-     XSetForeground(display, disp_gc, strikeColor);
-     XSetBackground(display, disp_gc, windowColor);
- 
-     XCopyPlane(display, face, win, disp_gc, 0, 0, w, h, x1, y1, 0x01);
- 
-     XSetForeground(display, disp_gc, textColor);
- }
- #endif
- 
- 
  unsigned char *gamma_table=NULL;
  
  
--- 390,395 ----
***************
*** 407,416 ****
      int i;
      double file_gamma = 1.0/2.2;
      double g = 1.0 / (file_gamma * Gamma);
!     
      gamma_table = (unsigned char *) malloc(256 * sizeof(char));
      for (i = 0; i < 256; i++)
! 	gamma_table[i] = (unsigned char)range((pow((double)i / 255.0, g) * 255.0 + 0.5), 255);
    }
  }
  
--- 406,415 ----
      int i;
      double file_gamma = 1.0/2.2;
      double g = 1.0 / (file_gamma * Gamma);
!   
      gamma_table = (unsigned char *) malloc(256 * sizeof(char));
      for (i = 0; i < 256; i++)
! 	gamma_table[i] = (unsigned char)range((pow((double)i / 255.0, g) * 255.0), 255);
    }
  }
  
***************
*** 424,474 ****
    }
  }
  
! #if 0
! /* Not used anymore */
! 
! /* range is 0 to 65535 for use in getting colors from X11 */
! int Brightness2Voltage(int brightness)
  {
!     double voltage;
!     static double log_a = 0; /* howcome added double */
  
!     if (brightness == 0)
!         return 0;
  
!     if (log_a == 0)
!         log_a = (Gamma - 1.0) * log((double)65535);      /* cast added by howcome 21/9/94 */
  
!     voltage = (log_a + log((double)brightness))/Gamma;   /* cast added by howcome 21/9/94 */
  
!     return (int)(0.5 + exp(voltage));
! }
! #endif
  
! #if 0
! /* range is 0 to 255 for GIF colormap */
! int Voltage2Brightness(int voltage)
! {
!     double brightness;
!     static double log_a;
  
!     if (voltage == 0)
!         return 0;
  
!     if (log_a == 0)
!         log_a = (Gamma - 1.0) * log((double)255);   /* cast added by howcome 21/9/94 */
  
!     brightness = Gamma * log((double)voltage) - log_a;    /* cast added by howcome 21/9/94 */
! 
!     return (int)(0.5 + exp(brightness));
  }
- #endif
  
  int AllocStandardColors(void)
  {
      unsigned long i;
!     XColor colors[127];  /* howcome 5/10/94 */
!     int status[127];  /* howcome 5/10/94 */
      XColor color;
      int color_ok=1;
  
--- 423,471 ----
    }
  }
  
! int AllocGreyScale(void)
  {
!     unsigned long g;
!     XColor color;
  
!     greymap[0] = BlackPixel(display, screen);
!     greymap[15] = WhitePixel(display, screen);
  
! /*    mycmap[128 & 0] = BlackPixel(display, screen);
!     mycmap[128 & 15] = WhitePixel(display, screen);
!     */
!     for (g = !OwnColorMap; g < 16+OwnColorMap; ++g)
!     {
!         color.red = color.green = color.blue = (g * 65535)/15;
  
!      /* map brightness values into voltages for Gamma correction */
  
!         color.red = Brightness2Voltage(color.red);
!         color.green = Brightness2Voltage(color.green);
!         color.blue = Brightness2Voltage(color.blue);
  
!         if (XAllocColor(display, colormap, &color) == 0)
!         {
!             fprintf(stderr, "Can't allocate standard grey palette\n");
  
!             while (g > 1)
!                 XFreeColors(display, colormap, &(greymap[--g]), 1, 0);
  
!             return 0;
!         }
!         greymap[g] = color.pixel;
! /*	mycmap[128 & g] = color.pixel;*/
!     }
  
!     return 1;
  }
  
+ 
  int AllocStandardColors(void)
  {
      unsigned long i;
!     XColor colors[128];  /* howcome 5/10/94 */
!     int status[128];  /* howcome 5/10/94 */
      XColor color;
      int color_ok=1;
  
***************
*** 478,489 ****
      mycmap[0] = BlackPixel(display, screen);
      mycmap[127] = WhitePixel(display, screen);
  
!     for (i = 1; i < 127; ++i)
      {
! 	double gammaC = 0.8;
!         color.red = /*(i & 0x3) * 65535/3*/ pow((((double)(i & 0x3))/3.0), gammaC)*65535;
!         color.green = /*((i >> 2) & 0x7) * 65535/7 */ pow((((double)((i >> 2) & 0x7))/7.0), gammaC)*65535;
!         color.blue = /*((i >> 5) & 0x3) * 65535/3*/ pow((((double)((i >> 5) & 0x3))/3.0), gammaC)*65535;
  
  	if (COLOR_TRACE)
  	    fprintf(stderr,"AllocStandardColors exact %d %d %d\n", (color.red >> 8), (color.green >> 8), (color.blue >> 8));
--- 475,491 ----
      mycmap[0] = BlackPixel(display, screen);
      mycmap[127] = WhitePixel(display, screen);
  
!     for (i = 0; i < 128; ++i)
      {
! #if 0
! 	double gammaC = 0.7;
!         color.red = /*(i & 0x3) * 65535/3 ; */ pow((((double)(i & 0x3))/3.0), gammaC)*65535;
!         color.green = /*((i >> 2) & 0x7) * 65535/7 ;*/ pow((((double)((i >> 2) & 0x7))/7.0), gammaC)*65535;	   
!         color.blue = /*((i >> 5) & 0x3) * 65535/3 ;*/ pow((((double)((i >> 5) & 0x3))/3.0), gammaC)*65535;
! #endif
! 	color.red = (i & 0x3) * 65535/3;
!         color.green = ((i >> 2) & 0x7) * 65535/7;
!         color.blue = ((i >> 5) & 0x3) * 65535/3;
  
  	if (COLOR_TRACE)
  	    fprintf(stderr,"AllocStandardColors exact %d %d %d\n", (color.red >> 8), (color.green >> 8), (color.blue >> 8));
***************
*** 492,505 ****
             speed things up. */
  
  	/* map brightness values into voltages for Gamma correction */
! #if 0
!         colors[i].red = Brightness2Voltage(color.red);
          colors[i].green = Brightness2Voltage(color.green);
          colors[i].blue = Brightness2Voltage(color.blue);
! #endif
!         colors[i].red = color.red;
          colors[i].green = color.green;
!         colors[i].blue = color.blue;
  	if (COLOR_TRACE)
  	    fprintf(stderr,"AllocStandardColors %d %d %d\n", (colors[i].red >> 8), (colors[i].green >> 8), (colors[i].blue >> 8));
      }
--- 494,508 ----
             speed things up. */
  
  	/* map brightness values into voltages for Gamma correction */
! 
! 	colors[i].red = Brightness2Voltage(color.red);
          colors[i].green = Brightness2Voltage(color.green);
          colors[i].blue = Brightness2Voltage(color.blue);
! #if 0
! 	colors[i].red = color.red;
          colors[i].green = color.green;
!         colors[i].blue = color.blue; 
! #endif
  	if (COLOR_TRACE)
  	    fprintf(stderr,"AllocStandardColors %d %d %d\n", (colors[i].red >> 8), (colors[i].green >> 8), (colors[i].blue >> 8));
      }
***************
*** 514,593 ****
  		mycmap[i] = colors[i].pixel;
  	    }
  	} else {
  	    OwnColorMap = 1; /* --Spif 25-Oct-95 -cm flag now works */
  	    color_ok=0;
  	}
      };
!     if(OwnColorMap){
! 
!         /* howcome 10/8/05: added support for own colormap */
  	
!         if (OwnColorMap) {
! 	  if(!color_ok) 
! 		fprintf(stderr,"Can't alloc colors, creating new colormap..\n");
! 
! 	    colormap = XCreateColormap(display, RootWindow(display, screen),
! 				       visual, AllocNone);
! 
! 	    if (XAllocColors(display, colormap, colors, i, status)) {
! 	        for (i = 1; i < 127; i++ ) {
! 		    stdcmap[i] = colors[i].pixel;
! 		    mycmap[i] = colors[i].pixel;
! 		}
! 	    }
! 	    return 1; /* assume success, what could go wrong? */
! 
! 	} else {	
! 
! 	    for (i = 1; i < 127; i++ )
! 	        if (status[i]) {
! 		    XFreeColors( display, colormap, &colors[i].pixel, 1, 0L );
! 		}
! 	    fprintf(stderr,"Can't alloc colors, consider the \"-cm\" flag\n");
! 	    return 0;
  	}
      }
  
      return 1;
  }
  
- int AllocGreyScale(void)
- {
-     unsigned long g;
-     XColor color;
- 
-     greymap[0] = BlackPixel(display, screen);
-     greymap[15] = WhitePixel(display, screen);
- 
-     mycmap[128 & 0] = BlackPixel(display, screen);
-     mycmap[128 & 15] = WhitePixel(display, screen);
- 
-     for (g = 1; g < 15; ++g)
-     {
-         color.red = color.green = color.blue = (65535/15) * g;
- 
-      /* map brightness values into voltages for Gamma correction */
- #if 0
-         color.red = Brightness2Voltage(color.red);
-         color.green = Brightness2Voltage(color.green);
-         color.blue = Brightness2Voltage(color.blue);
- #endif
-         if (XAllocColor(display, colormap, &color) == 0)
-         {
-             fprintf(stderr, "Can't allocate standard grey palette\n");
- 
-             while (g > 1)
-                 XFreeColors(display, colormap, &(greymap[--g]), 1, 0);
- 
-             return 0;
-         }
-         greymap[g] = color.pixel;
- 	mycmap[128 & g] = color.pixel;
-     }
- 
-     return 1;
- }
- 
  int SupportTrueColor(void)
  {
      long visual_info_mask;
--- 517,565 ----
  		mycmap[i] = colors[i].pixel;
  	    }
  	} else {
+ 	    int j;
+ 	    for(j = 1; j < i ; j++)
+ 		if (status[j])
+ 		    XFreeColors( display, colormap, &colors[j].pixel, 1, 0L );
  	    OwnColorMap = 1; /* --Spif 25-Oct-95 -cm flag now works */
  	    color_ok=0;
  	}
      };
!   
!     /* howcome 10/8/05: added support for own colormap */
  	
!     if (OwnColorMap) {
! 	int j;
! 	if(!color_ok) {
! 	    fprintf(stderr,"Can't alloc colors, creating new colormap..\n");
! 	    for(i=1; i < 15 ; i++)
! 		XFreeColors(display, colormap, &(greymap[i]), 1, 0);
! 	};
! 	colormap = XCreateColormap(display, RootWindow(display, screen),
! 				   visual, AllocNone);
! 	AllocGreyScale();
! 	for(j=0;j<128;j++)
! 	{
! 	    if (XAllocColor(display, colormap, &colors[j]) == 0)
! 	    {
! 		int g;
! 		fprintf(stderr, "FATAL ERROR:Can't allocate my own palette!!\n");
! 		g=j;
! 		while (g > 1)
! 		    XFreeColors(display, colormap, &(stdcmap[--g]), 1, 0);
! 		return 0;
! 	    };
! 	    stdcmap[j] = colors[j].pixel;
! 	    mycmap[j] = colors[j].pixel;
  	}
+ 	
+ 	return 1; /* assume success, what could go wrong? */
+ 	
      }
  
      return 1;
  }
  
  int SupportTrueColor(void)
  {
      long visual_info_mask;
***************
*** 604,614 ****
  
      for (i = flag = 0; i < number_visuals; ++i)
      {
!         if (visual_array[i].depth == 24)
          {
              flag = 1;
              break;
!         }
      }
  
      XFree((void *)visual_array);
--- 576,654 ----
  
      for (i = flag = 0; i < number_visuals; ++i)
      {
! 	if (visual_array[i].depth == 16)
! 	{
! 	    long int maskval;
! 	    int j=0, k;
! 
! 	    maskval = (*visual).blue_mask;
! 	    while ((maskval & 1) == 0) { j++; maskval = maskval >> 1; }
! 	    maskval = (*visual).blue_mask;
! 	    BPixelMask = 0;
! 	    for(k=0; k<16; k++)
! 	    {
! 		if(maskval & 1)
! 		{
! 		    if(!BPixelMask)
! 			BPixelMask = 1;
! 		    else
! 			BPixelMask += BPixelMask + 1;
! 		};
! 		maskval = maskval >> 1;
! 	    }
! 	    j=0;
! 	    maskval = (*visual).green_mask;
! 	    while ((maskval & 1) == 0) { j++; maskval = maskval >> 1; }
! 	    GPixelShift = j;
! 	    GPixelMask = 0;
! 	    for(k=0; k<16; k++)
! 	    {
! 		if(maskval & 1)
! 		{
! 		    if(!GPixelMask)
! 			GPixelMask = 1;
! 		    else
! 			GPixelMask += GPixelMask + 1;
! 		};
! 		maskval = maskval >> 1;
! 	    }
! 	    j=0;
! 	    maskval = (*visual).red_mask;
! 	    while ((maskval & 1) == 0) { j++; maskval = maskval >> 1; }
! 	    RPixelShift = j;
! 	    RPixelMask = 0;
! 	    for(k=0; k<16; k++)
! 	    {
! 		if(maskval & 1)
! 		{
! 		    if(!RPixelMask)
! 			RPixelMask = 1;
! 		    else
! 			RPixelMask += RPixelMask + 1;
! 		};
! 		maskval = maskval >> 1;
! 	    };
!             flag = 1;
! 	}
! 	if (visual_array[i].depth == 24)
          {
+ 	    long int maskval;
+ 	    int j=0;
+ 	    
+ 	    maskval = (*visual).blue_mask;
+ 	    while ((maskval & 1) == 0) { j++; maskval = maskval >> 1; }
+ 	    BPixelShift = j;
+ 	    j=0;
+ 	    maskval = (*visual).green_mask;
+ 	    while ((maskval & 1) == 0) { j++; maskval = maskval >> 1; }
+ 	    GPixelShift = j;
+ 	    j=0;
+ 	    maskval = (*visual).red_mask;
+ 	    while ((maskval & 1) == 0) { j++; maskval = maskval >> 1; }
+ 	    RPixelShift = j;
              flag = 1;
              break;
! 	}
      }
  
      XFree((void *)visual_array);
***************
*** 636,648 ****
          return imaging;
      }
  
      if (AllocGreyScale())
      {
          imaging = GREY4;
! 
          if (ColorStyle == GREY4)
              return imaging;
! 
          if (AllocStandardColors())
              imaging = COLOR232;
      } else 
--- 676,695 ----
          return imaging;
      }
  
+     if(OwnColorMap)
+ 	if (AllocStandardColors())
+ 	{
+ 	    imaging = COLOR232;
+ 	    return imaging;
+ 	};
+     
      if (AllocGreyScale())
      {
          imaging = GREY4;
! 	
          if (ColorStyle == GREY4)
              return imaging;
! 	
          if (AllocStandardColors())
              imaging = COLOR232;
      } else 
***************
*** 814,819 ****
--- 861,868 ----
      }
      else if (depth == 24)
          size = width * height * 4;
+     else if (depth == 16)
+ 	size = width * height *2;
      else
          return NULL;
  
***************
*** 834,847 ****
  	      *p++ = paperrgb[rand() % 3].pixel;
              }
      }
!     else
      {
          for (i = 0; i < height; ++i)
              for (j = 0; j < width; ++j)
! 	      {
  		int col,r,g,b;
                  
  		col=rand() % 3;
  		r=paperrgb[col].red;
  		g=paperrgb[col].green;
  		b=paperrgb[col].blue;
--- 883,897 ----
  	      *p++ = paperrgb[rand() % 3].pixel;
              }
      }
!     else if (depth == 24)
      {
          for (i = 0; i < height; ++i)
              for (j = 0; j < width; ++j)
! 	    {
  		int col,r,g,b;
                  
  		col=rand() % 3;
+ 
  		r=paperrgb[col].red;
  		g=paperrgb[col].green;
  		b=paperrgb[col].blue;
***************
*** 849,860 ****
  		GetColor(r, g, b, &ulp);
                  
  		*p++ = '\0';
! 		*p++ = ((char*)&ulp)[1]; 
! 		*p++ = ((char*)&ulp)[2]; 
! 		*p++ = ((char*)&ulp)[3];
              }
      }
- 
      return data;
  }
  
--- 899,932 ----
  		GetColor(r, g, b, &ulp);
                  
  		*p++ = '\0';
! 		*p++ = (ulp >> 16) & 0xff; 
! 		*p++ = (ulp >> 8) & 0xff; 
! 		*p++ = ulp & 0xff; 		
! #if 0
! 		*p++ = '\0';
! 		*p++ = paperrgb[col].red;
! 		*p++ = paperrgb[col].green;
! 		*p++ = paperrgb[col].blue;
! #endif
              }
+     } else if (depth == 16) 
+     {
+ 	 for (i = 0; i < height; ++i)
+             for (j = 0; j < width; ++j)
+ 	    {
+ 		int col,r,g,b;
+                 
+ 		col=rand() % 3;
+ 		r=paperrgb[col].red;
+ 		g=paperrgb[col].green;
+ 		b=paperrgb[col].blue;
+ 		
+ 		GetColor(r, g, b, &ulp);
+                 
+ 		*p++ = ((char*)&ulp)[1]; 
+ 		*p++ = ((char*)&ulp)[0]; 
+ 	    }
      }
      return data;
  }
  
***************
*** 944,964 ****
          x = x % tileWidth;
          y = y % tileHeight;
          i = y * tileWidth + x;
! 
!         if (depth == 24)
          {
              s = tileData + 4 * i;
! 
              *p++ = *s++;
              *p++ = *s++;
              *p++ = *s++;
              *p++ = *s++;
! 
              return p;
          }
! 
!         *p++ = tileData[i];
!         return p;
      }
  
      if (depth == 24)
--- 1016,1046 ----
          x = x % tileWidth;
          y = y % tileHeight;
          i = y * tileWidth + x;
! 	
! 	if (depth == 24)
          {
              s = tileData + 4 * i;
! 	    
              *p++ = *s++;
              *p++ = *s++;
              *p++ = *s++;
              *p++ = *s++;
! 	    
              return p;
          }
! 	
! 	if (depth == 16)
! 	{
! 	    s = tileData + 2 * i;
! 	    
! 	    *p++ = *s++;
! 	    *p++ = *s++;
! 	    
! 	    return p;
! 	};
! 	
! 	*p++ = gamma_table[tileData[i]];
! 	return p;
      }
  
      if (depth == 24)
***************
*** 966,975 ****
          *p++ = '\0';
          *p++ = (transparent  >> 16) & 0xFF;
          *p++ = (transparent  >> 8) & 0xFF;
!          *p++ = transparent & 0xFF;
          return p;
      }
  
      *p++ = transparent;
      return p;
  }
--- 1048,1064 ----
          *p++ = '\0';
          *p++ = (transparent  >> 16) & 0xFF;
          *p++ = (transparent  >> 8) & 0xFF;
! 	*p++ = transparent & 0xFF;
          return p;
      }
  
+     if (depth == 16) 
+     {
+ 	*p++ = (transparent  >> 8) & 0xFF;
+ 	*p++ = transparent & 0xFF;
+         return p;
+     };
+ 
      *p++ = transparent;
      return p;
  }
***************
*** 982,987 ****
--- 1071,1077 ----
      unsigned int width, height;
      /*    unsigned long pixel, *pixdata; */ /* janet 21/07/95: not used */
      unsigned char *data, *p;
+     unsigned long ccolor;
      char *name, *s;
      Color *colors, color;
      XColor xcolor;
***************
*** 1033,1046 ****
  
          if (imaging != COLOR888)
          {
! #if 0
! 	    r = Voltage2Brightness(r);
!             g = Voltage2Brightness(g);
!             b = Voltage2Brightness(b);
! #endif
  	    r = gamma_table[r];
              g = gamma_table[g];
!             b = gamma_table[b];
          }
  
          colors[i].red = r;
--- 1123,1135 ----
  
          if (imaging != COLOR888)
          {
! 	    /*
  	    r = gamma_table[r];
              g = gamma_table[g];
!             b = gamma_table[b];*/
! 	    r = Voltage2Brightness(r);
! 	    g = Voltage2Brightness(g);
! 	    b = Voltage2Brightness(b);
          }
  
          colors[i].red = r;
***************
*** 1160,1165 ****
--- 1249,1278 ----
              s = FindCh(s, '\n');
          }
      } 
+     else if (depth == 16)
+     {
+ 	p = data = malloc(size * 2);
+ 	
+         for (i = 0; i < height; ++i)
+         {
+             s = FindCh(s, '"');
+ 	    
+             for (j = 0; j < width; ++j)
+             {
+                 if ((c = map[*s++]) < 0)
+                 {
+                     p = Transparent(p, j, i);
+                     continue;
+                 };
+ 		
+                 color = colors[c];
+ 		GetColor(color.red, color.green, color.blue, &ccolor);
+                 *p++ = (ccolor >> 8 )& 0xff;
+                 *p++ = (ccolor & 0xff);
+ 	    }
+ 	    s = FindCh(s, '\n');
+         }	
+     }
      else if (depth == 1 || depth == 2 || depth == 4)  /* howcome added support for these */
      {
  	int             ppb, bpl, shift;
***************
*** 1406,1411 ****
--- 1519,1551 ----
                  byte = byte >> 1;
              }
      }
+     else if (depth == 16)
+     {
+         p = data = (unsigned char *)malloc(size * 2);
+         
+ 
+         for (i = 0; i < height; ++i)
+             for (j = 0, k= 8; j < width; ++j)
+             {
+                 if (++k > 8)  /* need to read next 8 pixel values */
+                 {
+                     s = FindCh(s, '0');
+                     sscanf(s-1, "%x", &byte);
+                     while ((c = NEXTCHAR(s)) != ',' && c != '}');
+                     k = 1;
+                 }
+ 
+                 if (byte & 1)
+                 {
+ 		    *p++ = (textColor >>  8) & 0xFF;
+                     *p++ = textColor & 0xFF;
+                 }
+                 else
+                     p = Transparent(p, j, i);
+ 
+                 byte = byte >> 1;
+             }
+     }
      else if (depth == 1 || depth == 2 || depth == 4)  /* howcome added support for these */
      {
  	int             ppb, bpl, shift;
***************
*** 1574,1581 ****
      height = image->height;
      
      if ((ximage = XCreateImage(display, DefaultVisual(display, screen),
! 			       depth, ZPixmap, 0, data,
! 			       width, height, (depth == 24 ? 32 : 8), 0)) == 0)
  	{	
  	    Warn("Failed to create XImage: %s", doc->url);
  	    doc->state = DOC_REJECTED;
--- 1714,1721 ----
      height = image->height;
      
      if ((ximage = XCreateImage(display, DefaultVisual(display, screen),
! 			       depth, ZPixmap, 0, data, width, height,
! 			       (depth == 24 ? 32 :(depth == 16 ? 16 : 8)), 0)) == 0)
  	{	
  	    Warn("Failed to create XImage: %s", doc->url);
  	    doc->state = DOC_REJECTED;
***************
*** 1587,1594 ****
      /* howcome 22/2/95: do we need to set these?? */
  
      ximage->byte_order = MSBFirst;
!     ximage->bitmap_bit_order = MSBFirst;
! 
      if ((pixmap = XCreatePixmap(display, win, width, height, depth)) == 0)
  	{
  	    Warn("Failed to create Pixmap: %s", doc->url);
--- 1727,1734 ----
      /* howcome 22/2/95: do we need to set these?? */
  
      ximage->byte_order = MSBFirst;
!     ximage->bitmap_bit_order = BitmapBitOrder(display);
!        
      if ((pixmap = XCreatePixmap(display, win, width, height, depth)) == 0)
  	{
  	    Warn("Failed to create Pixmap: %s", doc->url);
Only in Implementation/: image.h
diff -c Implementation.beta-1d//mailcap.c Implementation//mailcap.c
*** Implementation.beta-1d//mailcap.c	Wed Jan 17 18:34:45 1996
--- Implementation//mailcap.c	Fri Jan 26 11:09:30 1996
***************
*** 272,284 ****
  		    if (strncmp("test",field,4) == 0) {
  			pp = field + 4;
  			while (isspace(*pp) || *pp == '=')
! 			    *pp++;
  			test_command = strdup(pp);
  		    }
  		    else if (strncmp("quality",field,7) == 0) {
  			pp = field + 7;
  			while (isspace(*pp) || *pp == '=')
! 			    *pp++;
  			quality = (double)atof(pp);
  		    }
  		}
--- 272,284 ----
  		    if (strncmp("test",field,4) == 0) {
  			pp = field + 4;
  			while (isspace(*pp) || *pp == '=')
! 			    pp++;
  			test_command = strdup(pp);
  		    }
  		    else if (strncmp("quality",field,7) == 0) {
  			pp = field + 7;
  			while (isspace(*pp) || *pp == '=')
! 			    pp++;
  			quality = (double)atof(pp);
  		    }
  		}
diff -c Implementation.beta-1d//math.c Implementation//math.c
*** Implementation.beta-1d//math.c	Wed Jan 17 18:34:46 1996
--- Implementation//math.c	Fri Jan 26 11:48:27 1996
***************
*** 250,256 ****
--- 250,258 ----
  #define ROWS 24
  /* janet 1/8/95: #define COLS 80 */
  
+ #ifndef max
  #define     max(a, b)   ((a) > (b) ? (a) : (b))
+ #endif
  
  struct math_box
  {
diff -c Implementation.beta-1d//parsehtml.c Implementation//parsehtml.c
*** Implementation.beta-1d//parsehtml.c	Wed Jan 17 18:34:46 1996
--- Implementation//parsehtml.c	Wed Feb  7 16:58:04 1996
***************
*** 33,38 ****
--- 33,39 ----
  
  #include "www.h"
  #include "tools.h"
+ #include "style.h"
  
  #define LBUFSIZE 1024
  
***************
*** 56,62 ****
  extern unsigned long windowColor;
  extern unsigned int win_width, win_height, tileWidth, tileHeight;
  extern BOOL NoStyle;
- 
  extern unsigned long textColor, labelColor, windowTopShadow,
                       strikeColor, windowBottomShadow, windowShadow, windowColor;
  
--- 57,62 ----
***************
*** 364,370 ****
   which end before PixOffset are first flushed.
  */
  
! Frame *BeginFrame(Frame *parent, int style, int border, int left, int right, int cb_ix)
  {
      Frame *frame;
  
--- 364,370 ----
   which end before PixOffset are first flushed.
  */
  
! Frame *BeginFrame(Frame *parent, int style, int border, int left, int right, BG_Style *bg)
  {
      Frame *frame;
  
***************
*** 379,385 ****
      frame->style = style;
      frame->border = border;
  #ifdef STYLE_COLOR_BORDER
!     frame->cb_ix = cb_ix;
  #else
      frame->cb_ix = 0;
  #endif
--- 379,385 ----
      frame->style = style;
      frame->border = border;
  #ifdef STYLE_COLOR_BORDER
!     frame->cb_ix = (int)bg;
  #else
      frame->cb_ix = 0;
  #endif
***************
*** 962,968 ****
  
  	    if (buf[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<len; j++)
! 	       		    ok == ((buf[j]==';') || (buf[j]==' '));  /* ' ' is here for dummy html writers ;) */		
  		index = *dump_char = (char)entity(buf+i+1, &j);
  		if (index < 0)
  		    index+=256; 
--- 962,968 ----
  
  	    if (buf[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<len; j++)
! 	       		    ok = ((buf[j]==';') || (buf[j]==' '));  /* ' ' is here for dummy html writers ;) */		
  		index = *dump_char = (char)entity(buf+i+1, &j);
  		if (index < 0)
  		    index+=256; 
***************
*** 1000,1006 ****
      {
  	for(i=k=0; k<len; i++, k++) {
  	    sc_width=CompoundTextWidth(buf + i, 0, 1,&dumpint) + StyleGet(S_TEXT_SPACING); /* a hack... rename this stuff */
! 	    OldTextLineWidth = TextLineWidth ;    /* --Spif 6-Oct-95 keep this to update TextLineWidth with the right width */     
  	    OldHere = Here;
  	    /* we must give the entire width if it is emphasized, to tell the paint stream to display a beeautiful box around
  	       the text, but the real TextLineWidth must be calculated with the width of only ONE character at a time */
--- 1000,1006 ----
      {
  	for(i=k=0; k<len; i++, k++) {
  	    sc_width=CompoundTextWidth(buf + i, 0, 1,&dumpint) + StyleGet(S_TEXT_SPACING); /* a hack... rename this stuff */
! 	    OldTextLineWidth = TextLineWidth ;  
  	    OldHere = Here;
  	    /* we must give the entire width if it is emphasized, to tell the paint stream to display a beeautiful box around
  	       the text, but the real TextLineWidth must be calculated with the width of only ONE character at a time */
***************
*** 1007,1013 ****
  	    
  	    if (buf[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<len; j++)
! 		    ok == ((buf[j]==';') || (buf[j]==' '));  /* ' ' is here for dummy html writers ;) */		
  		RealPrintString(frame, (emph_set ? 0 : emph), fix, delta, buf, buf + i, 1, width,  /* how can we capitalize entities? */
  				FALSE, (Byte) StyleGet(S_COLOR), (BG_Style *)StyleGet(S_BACKGROUND));
  		emph_set = TRUE;
--- 1007,1013 ----
  	    
  	    if (buf[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<len; j++)
! 		    ok = ((buf[j]==';') || (buf[j]==' '));  /* ' ' is here for dummy html writers ;) */		
  		RealPrintString(frame, (emph_set ? 0 : emph), fix, delta, buf, buf + i, 1, width,  /* how can we capitalize entities? */
  				FALSE, (Byte) StyleGet(S_COLOR), (BG_Style *)StyleGet(S_BACKGROUND));
  		emph_set = TRUE;
***************
*** 1022,1035 ****
  		emph_set = TRUE;
  		Here += XTextWidth(Fonts[fix], buf + i, 1) + StyleGet(S_TEXT_SPACING); 
  	    }
! 	    if( OldHere + sc_width > OldTextLineWidth)  /* -- Spif: 6-Oct-95 small caps fix */ 
  	        TextLineWidth = OldHere + sc_width;
  	};
  	TextLineWidth -= StyleGet(S_TEXT_SPACING);
  	Here -= + StyleGet(S_TEXT_SPACING);
      } else {
! 	RealPrintString(frame, (emph_set ? 0 : emph), fix, delta, buf, buf, len, width, 
! 			FALSE, (Byte) StyleGet(S_COLOR), (BG_Style *)StyleGet(S_BACKGROUND));
  	emph_set = TRUE;
  	Here += (width - icw);
      }
--- 1022,1051 ----
  		emph_set = TRUE;
  		Here += XTextWidth(Fonts[fix], buf + i, 1) + StyleGet(S_TEXT_SPACING); 
  	    }
! 	    if( OldHere + sc_width > OldTextLineWidth)
  	        TextLineWidth = OldHere + sc_width;
  	};
  	TextLineWidth -= StyleGet(S_TEXT_SPACING);
  	Here -= + StyleGet(S_TEXT_SPACING);
      } else {
! 	if(StyleGet(S_ALIGN) != ALIGN_JUSTIFY)
! 	    RealPrintString(frame, (emph_set ? 0 : emph), fix, delta, buf, buf, len, width, 
! 			    FALSE, (Byte) StyleGet(S_COLOR), (BG_Style *)StyleGet(S_BACKGROUND));
! 	else
! 	{
! 	    int nb_space = 0;
! 	    int remaining_space;
! 
! 	    for(k=0; k<len; k++)
! 		nb_space += buf[k++]==' ';
! 	    if(!nb_space)
! 		RealPrintString(frame, (emph_set ? 0 : emph), fix, delta, buf, buf, len, width, 
! 				FALSE, (Byte) StyleGet(S_COLOR), (BG_Style *)StyleGet(S_BACKGROUND));
! 	    else
! 	    {
! 		remaining_space = frame->offset + frame->width - Here - width;
! 	    }
! 	}
  	emph_set = TRUE;
  	Here += (width - icw);
      }
***************
*** 1056,1062 ****
  		width += XTextWidth(Fonts[StyleGet(S_SMALL_CAPS_FONT)], &small_caps[s[i]], 1);
  	    else if (s[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<(len+start); j++)
! 		    ok == ((s[j]==';') || (s[j]==' ')); 
  		*dump_char = entity(s+i+1, &j);
  		dump_char[1]=0;
  		i+=j-1;
--- 1072,1078 ----
  		width += XTextWidth(Fonts[StyleGet(S_SMALL_CAPS_FONT)], &small_caps[s[i]], 1);
  	    else if (s[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<(len+start); j++)
! 		    ok = ((s[j]==';') || (s[j]==' ')); 
  		*dump_char = entity(s+i+1, &j);
  		dump_char[1]=0;
  		i+=j-1;
***************
*** 1073,1079 ****
  	    width += StyleGet(S_TEXT_SPACING);
  	    if (s[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<(len+start); j++)
! 		    ok == ((s[j]==';') || (s[j]==' ')); 
  		*dump_char = entity(s+i+1, &j);
  		dump_char[1]=0;
  		i+=j-1;
--- 1089,1095 ----
  	    width += StyleGet(S_TEXT_SPACING);
  	    if (s[i]=='&') {
  		for(ok= FALSE,j=i; !ok && j<(len+start); j++)
! 		    ok = ((s[j]==';') || (s[j]==' ')); 
  		*dump_char = entity(s+i+1, &j);
  		dump_char[1]=0;
  		i+=j-1;
***************
*** 3850,3855 ****
--- 3866,3872 ----
      int WordLen, emph;
      int font;
      int align = -1;
+     Frame *new_frame, *old_frame;
  
      if (EndTag)
      {
***************
*** 3859,3865 ****
  
      if (!implied) {
          ParseParaAttrs(&align, &class, &class_len);
!     }
  
      FormatElementStart(tag, class, class_len);
      if (align < 0)
--- 3876,3882 ----
  
      if (!implied) {
          ParseParaAttrs(&align, &class, &class_len);
!     };/* else printf("implied P\n");*/
  
      FormatElementStart(tag, class, class_len);
      if (align < 0)
***************
*** 3874,3882 ****
  
      if (Here < left)
          Here = left;
! 
! /*    PixOffset += style->margin_top;*/
! 
      emph = EMPH_NORMAL;
  
      /* skip leading white space - subsequently contigous
--- 3891,3921 ----
  
      if (Here < left)
          Here = left;
! #if 0
!     if(!implied)
!     {
! 	new_frame = (Frame *)calloc(1, sizeof(Frame));
! 	PixOffset += StyleGet(S_PADDING)+ StyleGet(S_MARGIN_TOP); /* must be S_PADDING_TOP */
! 	new_frame->offset = PixOffset;
! 	new_frame->indent = StyleGet(S_MARGIN_LEFT) + StyleGet(S_PADDING); /* S_PADDING_LEFT */
! 	new_frame->width = frame->width - StyleGet(S_MARGIN_LEFT) - StyleGet(S_MARGIN_RIGHT);
! 	new_frame->style = 0;
! 	new_frame->border = 0;
! #ifdef STYLE_COLOR_BORDER
! 	new_frame->cb_ix = 0;
! #else
! 	new_frame->cb_ix = 0;
! #endif
! 	new_frame->flow = align;
! 	new_frame->next = new_frame->child = NULL;
! 	PrintBeginFrame(new_frame);
! 	left = StyleGet(S_PADDING); /* S_PADDING_LEFT */
! 	right = StyleGet(S_PADDING); /* S_PADDING_RIGHT */
! 	Here = left;
!     }
!     else
! #endif
! 	new_frame = frame;
      emph = EMPH_NORMAL;
  
      /* skip leading white space - subsequently contigous
***************
*** 3926,3932 ****
              /* check that we have a word */
  
              if ((WordLen = LineLen - WordStart) > 0)
!                 WrapIfNeeded(frame, align, emph, font, left, right);
  
              if (LineLen < LBUFSIZE - 1)
                  LineBuf[LineLen++] = ' ';
--- 3965,3971 ----
              /* check that we have a word */
  
              if ((WordLen = LineLen - WordStart) > 0)
!                 WrapIfNeeded(new_frame, align, emph, font, left, right);
  
              if (LineLen < LBUFSIZE - 1)
                  LineBuf[LineLen++] = ' ';
***************
*** 3947,3953 ****
              }
  
              FlushLine(NOBREAK, frame, align, emph, font, left, right);
!             ParseEmph(frame, align, emph, font, left, right);
  	    StartOfLine = StartOfWord = bufptr; /* howcome 28/10/95: added to reset buffer after math -- does it break anything? */
  /*	    if (Token != TAG_BR && Token !=TAG_HR)
  		FormatElementStart(revert_tag, class, class_len);  *//* howcome 30/2/95: revert style after emph section */
--- 3986,3992 ----
              }
  
              FlushLine(NOBREAK, frame, align, emph, font, left, right);
!             ParseEmph(new_frame, align, emph, font, left, right);
  	    StartOfLine = StartOfWord = bufptr; /* howcome 28/10/95: added to reset buffer after math -- does it break anything? */
  /*	    if (Token != TAG_BR && Token !=TAG_HR)
  		FormatElementStart(revert_tag, class, class_len);  *//* howcome 30/2/95: revert style after emph section */
***************
*** 3961,3970 ****
      }    
  
      LineBuf[LineLen] = '\0';
!     FlushLine(BREAK, frame, align, emph, font, left, right);
  /*    PixOffset += LineSpacing[font]/3;*/
!     PixOffset += StyleGet(S_MARGIN_BOTTOM);
  
      FormatElementEnd();
  }
  
--- 4000,4030 ----
      }    
  
      LineBuf[LineLen] = '\0';
!     FlushLine(BREAK, new_frame, align, emph, font, left, right);
  /*    PixOffset += LineSpacing[font]/3;*/
! #if 0
!     if(!implied)
!     {
! 	char *p;
  
+ 	new_frame->length = paintlen - new_frame->info - FRAMESTLEN;
+ 	new_frame->height = PixOffset - new_frame->offset + 2*StyleGet(S_PADDING);
+ 	new_frame->offset -= StyleGet(S_PADDING);
+ 	PixOffset += StyleGet(S_PADDING);
+ 	new_frame->indent -= StyleGet(S_PADDING); 
+ 	p = paint + new_frame->info + 1;
+         PushValue(p, new_frame->offset & 0xFFFF);
+         PushValue(p, (new_frame->offset >> 16) & 0xFFFF);
+         PushValue(p, new_frame->indent);
+         PushValue(p, new_frame->width);
+ 	PushValue(p, new_frame->height & 0xFFFF);
+ 	PushValue(p, (new_frame->height >> 16) & 0xFFFF);
+ 	PrintFrameLength(new_frame);
+ 	PrintEndFrame(frame, new_frame);
+ 	free(new_frame);   
+     };
+ #endif
+     PixOffset += StyleGet(S_MARGIN_BOTTOM);
      FormatElementEnd();
  }
  
***************
*** 5067,5073 ****
              indent = left;
  
          FigureStart = PixOffset;
!         figframe = BeginFrame(frame, 0, 0, indent, indent+width, 255);
  
          if (align == ALIGN_LEFT || align == ALIGN_BLEEDLEFT)
          {
--- 5127,5133 ----
              indent = left;
  
          FigureStart = PixOffset;
!         figframe = BeginFrame(frame, 0, 0, indent, indent+width,NULL);
  
          if (align == ALIGN_LEFT || align == ALIGN_BLEEDLEFT)
          {
***************
*** 5215,5221 ****
          if (image)
          {
              indent = 20 + image->width;
!             blockframe = BeginFrame(frame, 0, 0, left, left+indent, 255);
              Here = 0;
              above = 0;
              below = image->height;    
--- 5275,5281 ----
          if (image)
          {
              indent = 20 + image->width;
!             blockframe = BeginFrame(frame, 0, 0, left, left+indent, NULL);
              Here = 0;
              above = 0;
              below = image->height;    
***************
*** 5299,5305 ****
  
  /* tag is TAG_TH or TAG_TD, col is column number starting from 1 upwards, returns cell height */
  long ParseTableCell(int implied, Frame *frame, int row, Frame **cells, int border,
!                       ColumnWidth **pwidths, int *pcol, int tag, int left, int right, int cb_ix)
  {
      int align, nowrap, col, rowspan, colspan, m, font;
      long cellTop, cellHeight;
--- 5359,5365 ----
  
  /* tag is TAG_TH or TAG_TD, col is column number starting from 1 upwards, returns cell height */
  long ParseTableCell(int implied, Frame *frame, int row, Frame **cells, int border,
!                       ColumnWidth **pwidths, int *pcol, int tag, int left, int right, BG_Style *bg)
  {
      int align, nowrap, col, rowspan, colspan, m, font;
      long cellTop, cellHeight;
***************
*** 5344,5350 ****
          cellTop = PixOffset;
          left = widths[col].left;
          right = widths[col + colspan - 1].right;
!         cellframe = BeginFrame(frame, 0, border, left-3, right+4, cb_ix);
          cellframe->lastrow = row + rowspan - 1;
  
       /* left and right now adjusted to indents from frame margins */
--- 5404,5410 ----
          cellTop = PixOffset;
          left = widths[col].left;
          right = widths[col + colspan - 1].right;
!         cellframe = BeginFrame(frame, 0, border, left-3, right+4, bg);
          cellframe->lastrow = row + rowspan - 1;
  
       /* left and right now adjusted to indents from frame margins */
***************
*** 5368,5373 ****
--- 5428,5455 ----
          while (GetToken() == WHITESPACE);
  /*	style = FormatElementStart(Token, class, class_len);*/
  
+ /*
+ 	if (Token == TAG_TABLE && !EndTag)
+ 	{
+ 	       Push(bufptr); 
+ 	       if(prepass) 
+ 		   ParseTable(0, cellframe, left, right);
+ 	       else
+ 	       {
+ 		   UnGetToken();
+ 		   ParseTable(1, cellframe, left, right);
+ 	       }
+ 	       bufptr = (char *)Pop();
+ 	       printf(", after : %X\n", bufptr);
+ 	       while(strncasecmp(bufptr,"/TABLE",5))
+ 	       {
+ 		   bufptr++;
+ 	       }
+ 	       bufptr += 6;
+ 	       printf("and then... %X\n", bufptr); 
+ 	       break;
+ 	}
+ */	
          if (Token == TAG_DD && EndTag)
          {
              SwallowAttributes();
***************
*** 5554,5560 ****
  
      left = widths[col].left;
      right = widths[COLS(widths)].right;
!     cellframe = BeginFrame(frame, 0, border, left-3, right+4, 255);
      cellframe->lastrow = row;
      cellframe->length = paintlen - cellframe->info - FRAMESTLEN;
      PrintFrameLength(cellframe);
--- 5636,5642 ----
  
      left = widths[col].left;
      right = widths[COLS(widths)].right;
!     cellframe = BeginFrame(frame, 0, border, left-3, right+4, NULL);
      cellframe->lastrow = row;
      cellframe->length = paintlen - cellframe->info - FRAMESTLEN;
      PrintFrameLength(cellframe);
***************
*** 5562,5568 ****
  }
  
  void ParseTableRow(int implied, Frame *frame, int row, Frame **cells,
!                     int border, ColumnWidth **pwidths, int left, int right, int cb_ix)
  {
      int cols = 1;
      long rowTop, rowHeight, cellHeight;
--- 5644,5650 ----
  }
  
  void ParseTableRow(int implied, Frame *frame, int row, Frame **cells,
!                     int border, ColumnWidth **pwidths, int left, int right, BG_Style *bg)
  {
      int cols = 1;
      long rowTop, rowHeight, cellHeight;
***************
*** 5625,5631 ****
          if (Token == TAG_TH)
          {
              cellHeight = ParseTableCell(0, frame, row, cells, border,
!                                         pwidths, &cols, TAG_TH, left, right, cb_ix);
  
              if (cellHeight > rowHeight)
                  rowHeight = cellHeight;
--- 5707,5713 ----
          if (Token == TAG_TH)
          {
              cellHeight = ParseTableCell(0, frame, row, cells, border,
!                                         pwidths, &cols, TAG_TH, left, right, bg);
  
              if (cellHeight > rowHeight)
                  rowHeight = cellHeight;
***************
*** 5635,5641 ****
          if (Token == TAG_TD)
          {
              cellHeight = ParseTableCell(0, frame, row, cells, border,
!                                         pwidths, &cols, TAG_TD, left, right, cb_ix);
  
              if (cellHeight > rowHeight)
                  rowHeight = cellHeight;
--- 5717,5723 ----
          if (Token == TAG_TD)
          {
              cellHeight = ParseTableCell(0, frame, row, cells, border,
!                                         pwidths, &cols, TAG_TD, left, right, bg);
  
              if (cellHeight > rowHeight)
                  rowHeight = cellHeight;
***************
*** 5647,5653 ****
              UnGetToken();
              break;
          }
! 
          if (TokenClass == EN_LIST || TokenClass == EN_TEXT ||
              TokenClass == EN_HEADER || TokenClass == EN_BLOCK)
          {
--- 5729,5735 ----
              UnGetToken();
              break;
          }
! 	
          if (TokenClass == EN_LIST || TokenClass == EN_TEXT ||
              TokenClass == EN_HEADER || TokenClass == EN_BLOCK)
          {
***************
*** 5659,5665 ****
  
              UnGetToken();
              cellHeight = ParseTableCell(1, frame, row, cells, border,
!                                         pwidths, &cols, TAG_TD, left, right, cb_ix);
  
              if (cellHeight > rowHeight)
                  rowHeight = cellHeight;
--- 5741,5747 ----
  
              UnGetToken();
              cellHeight = ParseTableCell(1, frame, row, cells, border,
!                                         pwidths, &cols, TAG_TD, left, right, bg);
  
              if (cellHeight > rowHeight)
                  rowHeight = cellHeight;
***************
*** 5727,5738 ****
      row = 0;
      cells = NULL;
  
!     for (;;)
      {
          while (GetToken() == WHITESPACE);
  
!         if (Token == TAG_TABLE && EndTag)
          {
              if (EndTag)
              {
                  SwallowAttributes();
--- 5809,5828 ----
      row = 0;
      cells = NULL;
  
!     for (; row < 1000 ;) 
      {
          while (GetToken() == WHITESPACE);
  
! 	if (Token == TAG_TABLE && !EndTag)
          {
+ 	    while(strncasecmp(bufptr,"/TABLE",5))
+ 		bufptr++;
+ 	    bufptr+=6;
+ 	    break;
+ 	}
+ 	
+ 	if (Token == TAG_TABLE && EndTag)
+         {
              if (EndTag)
              {
                  SwallowAttributes();
***************
*** 5758,5764 ****
          if (Token == TAG_TR)
          {
              ++row;
!             ParseTableRow(0, frame, row, &cells, border, &widths, left, right, StyleGet(S_BACKGROUND));
              continue;
  
          }
--- 5848,5854 ----
          if (Token == TAG_TR)
          {
              ++row;
!             ParseTableRow(0, frame, row, &cells, border, &widths, left, right,(BG_Style *)StyleGet(S_BACKGROUND));
              continue;
  
          }
***************
*** 5774,5780 ****
  
              UnGetToken();
              ++row;
!             ParseTableRow(1, frame, row, &cells, border, &widths, left, right, StyleGet(S_BACKGROUND));
              continue;
          }
  
--- 5864,5870 ----
  
              UnGetToken();
              ++row;
!             ParseTableRow(1, frame, row, &cells, border, &widths, left, right, (BG_Style *)StyleGet(S_BACKGROUND));
              continue;
          }
  
***************
*** 5841,5847 ****
          ProcessTableForm(2);
          goto draw_table;
      }
! 
      Free(widths);   /* free column widths */
      Here = left;
      PixOffset += StyleGet(S_MARGIN_BOTTOM);
--- 5931,5937 ----
          ProcessTableForm(2);
          goto draw_table;
      }
!    
      Free(widths);   /* free column widths */
      Here = left;
      PixOffset += StyleGet(S_MARGIN_BOTTOM);
***************
*** 6133,6138 ****
--- 6223,6230 ----
      }
  
      InitBackgroundFrame();
+ 
+     Push(&background);
  
   /* Reserve space for background's begin frame object
      which is needed to simplify display and scrolling routines */
diff -c Implementation.beta-1d//png.c Implementation//png.c
*** Implementation.beta-1d//png.c	Wed Jan 17 18:34:46 1996
--- Implementation//png.c	Wed Feb  7 17:53:27 1996
***************
*** 6,11 ****
--- 6,16 ----
  
  #include "png.h"
  
+ extern Visual *visual;
+ extern int RPixelShift;   /* GRR */
+ extern int GPixelShift;   /* GRR */
+ extern int BPixelShift;   /* GRR */
+ extern int RPixelMask, GPixelMask, BPixelMask;
  extern int depth;         /* Depth of display in bits */
  extern Colormap colormap;
  extern int imaging;       /* set to COLOR888, COLOR232, GREY4 or MONO */
***************
*** 303,311 ****
  		  int y = ypos % tileHeight;
  		  int i = y * tileWidth + x;
  		  unsigned char *s = tileData + 4 * i;
! 		  tr=s[1];
  		  tg=s[2];
! 		  tb=s[3];
  		}
  	      else
  		{
--- 308,316 ----
  		  int y = ypos % tileHeight;
  		  int i = y * tileWidth + x;
  		  unsigned char *s = tileData + 4 * i;
! 		  tr=s[(RPixelShift) ? 1 : 3];
  		  tg=s[2];
! 		  tb=s[(RPixelShift) ? 3 : 1];
  		}
  	      else
  		{
***************
*** 319,331 ****
  	      cg=(a/255.0)*cg + ((255.0-a)/255.0) * tg;
  	      cb=(a/255.0)*cb + ((255.0-a)/255.0) * tb;
  	    }
! 	  
  	  GetColor(cr, cg, cb, &ulp);
  	  *dp++ = '\0';
! 	  *dp++ = ((char*)&ulp)[1];
! 	  *dp++ = ((char*)&ulp)[2];
! 	  *dp++ = ((char*)&ulp)[3];
  
  	} /* xpos */
        
      } /* ypos */      
--- 324,421 ----
  	      cg=(a/255.0)*cg + ((255.0-a)/255.0) * tg;
  	      cb=(a/255.0)*cb + ((255.0-a)/255.0) * tb;
  	    }
! 
  	  GetColor(cr, cg, cb, &ulp);
  	  *dp++ = '\0';
! 	  *dp++ = (ulp >> 16) & 0xff; 
! 	  *dp++ = (ulp >> 8) & 0xff; 
! 	  *dp++ = ulp & 0xff; 
! 	  
! 	} /* xpos */
!       
!     } /* ypos */      
!   
!   return data;
! }
  
+ /* Read image into displays 16 bit deep */
+ unsigned char *ReadPNGImage_16(png_struct *png_ptr, png_info *info_ptr, png_byte *png_image) 
+ {
+   png_byte *pp;
+   unsigned char *data, *dp;
+   unsigned long int ulp;
+   int ypos;
+   int len=info_ptr->width;
+   int color_type=info_ptr->color_type;
+   int alpha;
+   
+   data = (unsigned char *)malloc(2 * len * info_ptr->height);
+   if (data == NULL)
+     png_error (png_ptr, "couldn't alloc space for X image data");
+   
+   /* Remove alpha channel from type,  but remember it */
+   alpha=color_type & PNG_COLOR_MASK_ALPHA;
+   color_type &= ~PNG_COLOR_MASK_ALPHA;
+   
+   pp=png_image;
+   dp=data;
+   for (ypos = 0; ypos < png_ptr->height; ypos++)
+     {
+       int xpos;
+       
+       for (xpos = 0; xpos < len; ++xpos)
+ 	{
+ 	  int cr, cg, cb, cgr, a;
+ 	  
+ 	  if (color_type == PNG_COLOR_TYPE_GRAY) {
+ 	    cr=cg=cb=cgr=(*pp++);
+ 	  } else if (color_type == PNG_COLOR_TYPE_RGB) {
+ 	    cr= (*pp++);
+ 	    cg= (*pp++);
+ 	    cb= (*pp++);
+ 	    cgr = (0.59*cr) + (0.20*cg) + (0.11*cb);
+ 	  } else {
+ 	    png_error(png_ptr, "Unknown PNG color type seen (ReadPNGImage_16)");
+ 	  }
+ 	  
+ 	  /* Process alpha channel if present */
+ 	  if (alpha)
+ 	    a=(*pp++);
+ 	  
+ 	  if (alpha && a != 0xff)
+ 	    {
+ 	      int tr,tg,tb;
+ 	    
+ 	      /* Get tile colour without gamma - from www.c */
+ 	      if (tileData)
+ 	      {
+ 		  int x = xpos % tileWidth;
+ 		  int y = ypos % tileHeight;
+ 		  int i = y * tileWidth + x;
+ 		  unsigned char *s = (tileData + 2 * i);
+ 		  unsigned short val;
+ 		  val = *s * 256  + *(s+1);
+ 		  tr= (((val & visual->red_mask) >> RPixelShift) << 8) / (RPixelMask+1);
+ 		  tg= (((val & visual->green_mask) >> GPixelShift) << 8) /  (GPixelMask+1);
+ 		  tb= (((val & visual->blue_mask) >> BPixelShift) << 8 ) / (BPixelMask+1);
+ 	      }
+ 	      else
+ 	      {
+  		  tr = (((transparent & visual->red_mask) >> RPixelShift) << 8) / (RPixelMask+1);
+  		  tg = (((transparent & visual->green_mask) >> GPixelShift) << 8) /  (GPixelMask+1);
+ 		  tb = (((transparent & visual->blue_mask)  >> BPixelShift) << 8 ) / (BPixelMask+1);
+ 	      }
+ 	      
+ 	      /* Add picture pixel to background pixel */
+ 	      cr=(a/255.0)*cr + ((255.0-a)/255.0) * tr;
+ 	      cg=(a/255.0)*cg + ((255.0-a)/255.0) * tg;
+ 	      cb=(a/255.0)*cb + ((255.0-a)/255.0) * tb;
+ 	    }
+ 	  
+ 	  GetColor(cr, cg, cb, &ulp);
+ 	  *dp++ = (unsigned char)((ulp >> 8) & 0xff);
+ 	  *dp++ = (unsigned char)((ulp) & 0xff);
+ 	  
  	} /* xpos */
        
      } /* ypos */      
***************
*** 333,340 ****
    return data;
  }
  
! 
! /* Read image into displays, not 1,2,4 or 24 bit deep */
  unsigned char *ReadPNGImage(png_struct *png_ptr, png_info *info_ptr, png_byte *png_image) 
  {
    png_byte *pp;
--- 423,429 ----
    return data;
  }
  
! /* Read image into displays, not 1,2,4,16 or 24 bit deep */
  unsigned char *ReadPNGImage(png_struct *png_ptr, png_info *info_ptr, png_byte *png_image) 
  {
    png_byte *pp;
***************
*** 397,403 ****
  	    } else if(a != 0xff) {
  	      int tcolor, tr,tg,tb;
  	      int drb, dgb, dbr;
! 	    
  	      /* Get tile colour without gamma - from www.c */
  	      if (tileData)
  		{
--- 486,492 ----
  	    } else if(a != 0xff) {
  	      int tcolor, tr,tg,tb;
  	      int drb, dgb, dbr;
! 	      
  	      /* Get tile colour without gamma - from www.c */
  	      if (tileData)
  		{
***************
*** 412,418 ****
  	      tr=papercols[tcolor].red;
  	      tg=papercols[tcolor].green;
  	      tb=papercols[tcolor].blue;
! 	      
  	      /* Add picture pixel to background pixel */
  	      cr=(a/255.0)*cr + ((255.0-a)/255.0) * tr;
  	      cg=(a/255.0)*cg + ((255.0-a)/255.0) * tg;
--- 501,507 ----
  	      tr=papercols[tcolor].red;
  	      tg=papercols[tcolor].green;
  	      tb=papercols[tcolor].blue;
! 
  	      /* Add picture pixel to background pixel */
  	      cr=(a/255.0)*cr + ((255.0-a)/255.0) * tr;
  	      cg=(a/255.0)*cg + ((255.0-a)/255.0) * tg;
***************
*** 558,564 ****
  
    /* tell libpng to convert 16 bits per channel to 8 */
    if (info_ptr->bit_depth == 16)
!     png_set_strip_16(png_ptr);
    
    /* read all the image into the rows allocated above */
    /* (Automatically handles interlacing) */
--- 647,653 ----
  
    /* tell libpng to convert 16 bits per channel to 8 */
    if (info_ptr->bit_depth == 16)
!       png_set_strip_16(png_ptr); 
    
    /* read all the image into the rows allocated above */
    /* (Automatically handles interlacing) */
***************
*** 581,587 ****
    
    for (pass = 0; pass < number_passes; pass++)
      {
! /*      if (depth == 24)
  	row_pointer=(png_byte*)ximage;
  	else    --patch dsr 24-bits display 8-Dec-95 */
  	row_pointer=png_image;
--- 670,676 ----
    
    for (pass = 0; pass < number_passes; pass++)
      {
! /*      if ((depth == 24)||(depth == 16))
  	row_pointer=(png_byte*)ximage;
  	else    --patch dsr 24-bits display 8-Dec-95 */
  	row_pointer=png_image;
***************
*** 595,605 ****
    
    /* Now convert PNG image to X one */
    if (depth == 1 || depth == 2 || depth == 4)
!     ximage = ReadPNGImage_1_2_4(png_ptr, info_ptr, png_image);
    else if (depth == 24)
!     ximage = ReadPNGImage_24(png_ptr, info_ptr, png_image);
!   else 
!     ximage = ReadPNGImage(png_ptr, info_ptr, png_image);
    
    image->npixels = 0; /* Set to 0 in gif.c, icon.c, image.c  */
    image->width = info_ptr->width;
--- 684,696 ----
    
    /* Now convert PNG image to X one */
    if (depth == 1 || depth == 2 || depth == 4)
!       ximage = ReadPNGImage_1_2_4(png_ptr, info_ptr, png_image);
    else if (depth == 24)
!       ximage = ReadPNGImage_24(png_ptr, info_ptr, png_image);
!   else if (depth == 16) 
!       ximage = ReadPNGImage_16(png_ptr, info_ptr, png_image);
!   else
!       ximage = ReadPNGImage(png_ptr, info_ptr, png_image);
    
    image->npixels = 0; /* Set to 0 in gif.c, icon.c, image.c  */
    image->width = info_ptr->width;
diff -c Implementation.beta-1d//scrollbar.c Implementation//scrollbar.c
*** Implementation.beta-1d//scrollbar.c	Wed Jan 17 18:34:46 1996
--- Implementation//scrollbar.c	Fri Jan 26 11:18:54 1996
***************
*** 42,48 ****
  int leftarrow = 0, rightarrow = 0;
  int vertical;
  
! Window win;
  GC sb_gc;
  
  void SetScrollBarWin(Window aWin)
--- 42,48 ----
  int leftarrow = 0, rightarrow = 0;
  int vertical;
  
! extern Window win;
  GC sb_gc;
  
  void SetScrollBarWin(Window aWin)
diff -c Implementation.beta-1d//status.c Implementation//status.c
*** Implementation.beta-1d//status.c	Wed Jan 17 18:34:46 1996
--- Implementation//status.c	Fri Jan 26 11:22:36 1996
***************
*** 42,48 ****
  #define STATSIZ 256
  #define ActiveTextColor labelColor
  
! Window win;
  GC status_gc;
  int statusHeight;
  char status[STATSIZ];
--- 42,48 ----
  #define STATSIZ 256
  #define ActiveTextColor labelColor
  
! extern Window win;
  GC status_gc;
  int statusHeight;
  char status[STATSIZ];
diff -c Implementation.beta-1d//style.c Implementation//style.c
*** Implementation.beta-1d//style.c	Wed Jan 17 18:34:46 1996
--- Implementation//style.c	Mon Feb  5 17:17:59 1996
***************
*** 106,112 ****
  extern int debug;
  extern Doc *CurrentDoc;
  extern Context *context;
! 
  extern unsigned int win_width, win_height;
  extern int fontsize;
  
--- 106,115 ----
  extern int debug;
  extern Doc *CurrentDoc;
  extern Context *context;
! extern int PixOffset;
! extern int paintlen;
! extern Byte *paint;
! extern unsigned int ui_n;
  extern unsigned int win_width, win_height;
  extern int fontsize;
  
***************
*** 441,446 ****
--- 444,450 ----
  	      case S_MARGIN_BOTTOM:
  	      case S_MARGIN_LEFT:
  	      case S_INDENT:
+ 	      case S_PADDING:
  	      case S_BACKGROUND:
  	      case S_ALT_BACKGROUND:
  		break;
***************
*** 696,701 ****
--- 700,707 ----
  
  /*     s = TOLOWER(s);*/
  
+     if(!strncmp(s,"padding",7))
+ 	return S_PADDING;
      if(!strncmp(s,"bg", 2))
      {
  	if((l == 8 )&&(!strcmp(s+3,"style")))
***************
*** 1435,1441 ****
  
  
  
! Bool ParseAssignment(char *s, StyleProperty *prop_p, long *value_p, int *level_p, char delimiter)
  {
      char *str;
      char *elem, *value;
--- 1441,1447 ----
  
  
  
! static Bool ParseAssignment(char *s, StyleProperty *prop_p, long *value_p, int *level_p, char delimiter)
  {
      char *str;
      char *elem, *value;
***************
*** 1558,1563 ****
--- 1564,1571 ----
  		*value_p = ALIGN_CENTER;
  	    } else if (strcasecmp(str,"right") == 0) {	
  		*value_p = ALIGN_RIGHT;
+ 	    } else if (strcasecmp(str,"justify") == 0) {
+ 		*value_p = ALIGN_JUSTIFY;
  	    } else
  		return False;
  	    break;
***************
*** 1583,1593 ****
  	    } else {		/* try looking up the name */
  		*value_p = ParseColor(str);
  	    }
! 
! 
! 
! 	    break;
! 
  	  case S_BACKGROUND:
  	  case S_ALT_BACKGROUND:
  	      *value_p = (long) StyleGetBackground(*value_p, str);
--- 1591,1600 ----
  	    } else {		/* try looking up the name */
  		*value_p = ParseColor(str);
  	    }
! 	    break;	    
!   	  case S_PADDING:
! 	      *value_p = atoi(str); /* only x & y & i & j */
! 	      break;
  	  case S_BACKGROUND:
  	  case S_ALT_BACKGROUND:
  	      *value_p = (long) StyleGetBackground(*value_p, str);
***************
*** 1800,1806 ****
  		    } while((sc = sc->ancestor));
  		    fprintf(stderr,"\n");
  		}
! 		StyleAddRule(sheet, selector, S_BACKGROUND, bg_save, bg_weight);
  	    }
  	};
  	if (STYLE_TRACE)
--- 1807,1813 ----
  		    } while((sc = sc->ancestor));
  		    fprintf(stderr,"\n");
  		}
! 		StyleAddRule(sheet, selector, S_BACKGROUND,(long)bg_save, bg_weight);
  	    }
  	};
  	if (STYLE_TRACE)
***************
*** 1820,1944 ****
      Free(s);
  }
  
- 
- void StyleParse()
- {
-     if (STYLE_TRACE)
- 	fprintf(stderr,"StyleParse\n");
- 
-     if (!CurrentDoc->head_style && !CurrentDoc->link_style) {
- 	CurrentDoc->style = NULL; /* i.e. style->default */
- 	return;
-     }
- 
-     if (CurrentDoc->user_style) {
- 
- 	/* this document contains the user's style sheet if it exists */
- 
- 	Announce("applying personal style sheet.. ");
- 
- /*	rgbClear();*/
- 
- 	if (context->style) {
- 	    FreeStyleSheet(context->style);
- 	    context->style = StyleGetInit();
- 	}
- 
- 	StyleChew(context->style, CurrentDoc->head_style, S_USER);
- 	StyleChew(context->style, CurrentDoc->link_style, S_USER);
- 	CurrentDoc->style = context->style;
- 	if (STYLE_TRACE) {
- 	    fprintf(stderr,"Stylesane: context->style\n");
- 	    StyleSane(context->style);
- 	}
- 	return;
-     }
- 
-     /* this is a normal incoming document with style sheet attached */
- 
-     Announce("applying document's style sheet.. ");
- 
-     rgbClear();
-     CurrentDoc->style = StyleCopy(context->style);
-     StyleChew(CurrentDoc->style, CurrentDoc->head_style, S_USER);
-     StyleChew(CurrentDoc->style, CurrentDoc->link_style, S_USER);
-     if (STYLE_TRACE) {
- 	fprintf(stderr,"Stylesane: CurrentDoc->style\n");
- 	StyleSane(context->style);
-     }
- 
-     Announce("applying document's style sheet.. done");
- }
- 
- 
  /*
- void StyleWindowChange()
- {
-     fprintf(stderr,"StyleWindowChange w %d h %d\n", win_width, win_height);
- }
- */
- 
- /* StyleZoom is a bit too Arena-specific */
- 
- void StyleZoomChange(double f)
- {
-     Announce("loading fonts..");
-     ShowBusy();
- 
-     lens_factor *= f;
-     DisplaySizeChanged(1);
-     Redraw(0,0,WinWidth,WinHeight + WinTop); 
-     Announce("%s",CurrentDoc->url);
-     HideBusy();
- }
- 
- 
- char *StyleLoad(char *href, int hreflen, BOOL reload)
- {
-     Doc *doc = NULL;
- 
-     /* check for null name */
- 
-     doc = GetInline(href, hreflen, reload);
-     if (doc) {
- /*	fprintf(stderr,"StyleLoad succedded ??\n");*/
- 	return(doc->content_buffer);
-     }
-     return NULL;
- }
- 
- /* 
-   StyleGet is used by the UA to pull values out of a flattened stylesheet
- */
- 
- 
- long StyleGet(StyleProperty property)
- {
-     if (REGISTER_TRACE && VERBOSE_TRACE)
- 	fprintf(stderr,"StyleGet: property %d\n", property);
-     if ((REGISTER_TRACE) && (current_flat->status[property] == S_UNSET))
- 	fprintf(stderr, "StyleGet, property not set %d\n", property);
- 
-     switch (property) {
-        case S_SMALL_CAPS_FONT: /* this one is expensive and not often used */
- 	if (current_flat->status[S_SMALL_CAPS_FONT] != S_INFERRED) {
- 	    current_flat->value[S_SMALL_CAPS_FONT] = 
- 		GetFont((HTList *)current_flat->value[S_FONT_FAMILY], 
- 			current_flat->value[S_FONT_SIZE] * 4 / 5,
- 			current_flat->value[S_FONT_WEIGHT], 
- 			current_flat->value[S_FONT_STYLE], True);
- 	    current_flat->status[S_FONT] = S_INFERRED;
- 	    current_flat->weight[S_SMALL_CAPS_FONT] = current_flat->weight[S_FONT];
- 	}
- 	return(current_flat->value[S_SMALL_CAPS_FONT]);
- 	break;
-       default:
- 	return (current_flat->value[property]);
-     }
-     return 0;
- }
- 
- /*
    StyleGetInit returns an initialized style sheet, typically the application's default 
  */
  
--- 1827,1833 ----
***************
*** 1962,1969 ****
      StyleAddSimpleRule(sheet, TAG_HTML, S_ALT_BACKGROUND,	(long)StyleGetBackground(NULL, "#AAA"),	S_FALLBACK - S_ANY); /* i.e. transparent */
  
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_SPACING, 	0, 		S_FALLBACK - S_ANY);
! 
!     StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_DECORATION, 		0, 		S_FALLBACK - S_ANY);
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_POSITION,	0, 		S_FALLBACK - S_ANY);
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_TRANSFORM,	0, 		S_FALLBACK - S_ANY);
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_EFFECT,		0,		S_FALLBACK - S_ANY);
--- 1851,1866 ----
      StyleAddSimpleRule(sheet, TAG_HTML, S_ALT_BACKGROUND,	(long)StyleGetBackground(NULL, "#AAA"),	S_FALLBACK - S_ANY); /* i.e. transparent */
  
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_SPACING, 	0, 		S_FALLBACK - S_ANY);
!     /*  
! 	 For Debugging
! 	StyleAddSimpleRule(sheet, TAG_P, S_BACKGROUND,		(long)StyleGetBackground(NULL, "#BBB"),	S_FALLBACK - S_ANY); 
!     StyleAddSimpleRule(sheet, TAG_P, S_PADDING,		        5,	S_FALLBACK - S_ANY);
!     StyleAddSimpleRule(sheet, TAG_P, S_MARGIN_LEFT,		       40,	S_FALLBACK - S_ANY);
!     StyleAddSimpleRule(sheet, TAG_P, S_MARGIN_RIGHT,		       40,	S_FALLBACK - S_ANY);
!     StyleAddSimpleRule(sheet, TAG_P, S_MARGIN_TOP,		       60,	S_FALLBACK - S_ANY);
!     StyleAddSimpleRule(sheet, TAG_P, S_MARGIN_BOTTOM,		       40,	S_FALLBACK - S_ANY);
! /*
!     StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_DECORATION, 		10, 		S_FALLBACK - S_ANY);
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_POSITION,	0, 		S_FALLBACK - S_ANY);
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_TRANSFORM,	0, 		S_FALLBACK - S_ANY);
      StyleAddSimpleRule(sheet, TAG_HTML, S_TEXT_EFFECT,		0,		S_FALLBACK - S_ANY);
***************
*** 2066,2072 ****
--- 1963,2085 ----
      return sheet;
  }
  
+ void StyleParse()
+ {
+     if (STYLE_TRACE)
+ 	fprintf(stderr,"StyleParse\n");
  
+     if (!CurrentDoc->head_style && !CurrentDoc->link_style) {
+ 	CurrentDoc->style = NULL; /* i.e. style->default */
+ 	return;
+     }
+ 
+     if (CurrentDoc->user_style) {
+ 
+ 	/* this document contains the user's style sheet if it exists */
+ 
+ 	Announce("applying personal style sheet.. ");
+ 
+ /*	rgbClear();*/
+ 
+ 	if (context->style) {
+ 	    FreeStyleSheet(context->style);
+ 	    context->style = StyleGetInit();
+ 	}
+ 
+ 	StyleChew(context->style, CurrentDoc->head_style, S_USER);
+ 	StyleChew(context->style, CurrentDoc->link_style, S_USER);
+ 	CurrentDoc->style = context->style;
+ 	if (STYLE_TRACE) {
+ 	    fprintf(stderr,"Stylesane: context->style\n");
+ 	    StyleSane(context->style);
+ 	}
+ 	return;
+     }
+ 
+     /* this is a normal incoming document with style sheet attached */
+ 
+     Announce("applying document's style sheet.. ");
+ 
+     rgbClear();
+     CurrentDoc->style = StyleCopy(context->style);
+     StyleChew(CurrentDoc->style, CurrentDoc->head_style, S_USER);
+     StyleChew(CurrentDoc->style, CurrentDoc->link_style, S_USER);
+     if (STYLE_TRACE) {
+ 	fprintf(stderr,"Stylesane: CurrentDoc->style\n");
+ 	StyleSane(context->style);
+     }
+ 
+     Announce("applying document's style sheet.. done");
+ }
+ 
+ 
+ /*
+ void StyleWindowChange()
+ {
+     fprintf(stderr,"StyleWindowChange w %d h %d\n", win_width, win_height);
+ }
+ */
+ 
+ /* StyleZoom is a bit too Arena-specific */
+ 
+ void StyleZoomChange(double f)
+ {
+     Announce("loading fonts..");
+     ShowBusy();
+ 
+     lens_factor *= f;
+     DisplaySizeChanged(1);
+     Redraw(0,0,WinWidth,WinHeight + WinTop); 
+     Announce("%s",CurrentDoc->url);
+     HideBusy();
+ }
+ 
+ 
+ char *StyleLoad(char *href, int hreflen, BOOL reload)
+ {
+     Doc *doc = NULL;
+ 
+     /* check for null name */
+ 
+     doc = GetInline(href, hreflen, reload);
+     if (doc) {
+ /*	fprintf(stderr,"StyleLoad succedded ??\n");*/
+ 	return(doc->content_buffer);
+     }
+     return NULL;
+ }
+ 
+ /* 
+   StyleGet is used by the UA to pull values out of a flattened stylesheet
+ */
+ 
+ 
+ long StyleGet(StyleProperty property)
+ {
+     if (REGISTER_TRACE && VERBOSE_TRACE)
+ 	fprintf(stderr,"StyleGet: property %d\n", property);
+     if ((REGISTER_TRACE) && (current_flat->status[property] == S_UNSET))
+ 	fprintf(stderr, "StyleGet, property not set %d\n", property);
+ 
+     switch (property) {
+        case S_SMALL_CAPS_FONT: /* this one is expensive and not often used */
+ 	if (current_flat->status[S_SMALL_CAPS_FONT] != S_INFERRED) {
+ 	    current_flat->value[S_SMALL_CAPS_FONT] = 
+ 		GetFont((HTList *)current_flat->value[S_FONT_FAMILY], 
+ 			current_flat->value[S_FONT_SIZE] * 4 / 5,
+ 			current_flat->value[S_FONT_WEIGHT], 
+ 			current_flat->value[S_FONT_STYLE], True);
+ 	    current_flat->status[S_FONT] = S_INFERRED;
+ 	    current_flat->weight[S_SMALL_CAPS_FONT] = current_flat->weight[S_FONT];
+ 	}
+ 	return(current_flat->value[S_SMALL_CAPS_FONT]);
+ 	break;
+       default:
+ 	return (current_flat->value[property]);
+     }
+     return 0;
+ }
+ 
  void StyleClearDoc()
  {
      HTList *l = style_stack;
***************
*** 2097,2104 ****
--- 2110,2122 ----
    pushed onto the stack.
  */
  
+ extern void Push(void *);
+ extern void *Pop();
+ 
  void FormatElementStart(int element, char *class, int class_len)
  {
+     Frame *new_frame, *old_frame;
+     
      StyleStackElement *stack_el = NewStackElement();
      StyleSheet *sheet = (CurrentDoc->style ? CurrentDoc->style : context->style);
  
***************
*** 2150,2155 ****
--- 2168,2199 ----
  	StyleSetFlag(S_INDENT_FLAG,StyleGet(S_INDENT));
  	StyleSetFlag(S_LEADING_FLAG,TRUE);
      };
+ 
+     if(element == TAG_HTML || element == TAG_HTML_SOURCE || 
+ 	(element != TAG_TABLE)) 
+ /*
+ 	(element != TAG_ABSTRACT &&
+ 	 element != TAG_BLOCKQUOTE && element != TAG_CAPTION &&
+ 	 element != TAG_NOTE && element != TAG_P && element != TAG_PRE &&
+ 	 element != TAG_QUOTE && element != TAG_TABLE))  */
+ 	return;
+ /*    old_frame = (Frame *)Pop();
+     Push(old_frame);
+     new_frame = (Frame *)calloc(1, sizeof(Frame));
+     new_frame->offset = PixOffset;
+     new_frame->indent = (old_frame ?  old_frame->leftmargin + StyleGet(S_MARGIN_LEFT) : StyleGet(S_MARGIN_LEFT));
+     new_frame->width = (old_frame ?  old_frame->width - StyleGet(S_MARGIN_LEFT) - StyleGet(S_MARGIN_RIGHT) : 12);
+     new_frame->style = 0;
+     new_frame->border = 0;
+ #ifdef STYLE_COLOR_BORDER
+     new_frame->cb_ix = 0;
+ #else
+     new_frame->cb_ix = 0;
+ #endif
+     new_frame->flow = ALIGN_CENTER;
+     new_frame->next = new_frame->child = NULL;
+     PrintBeginFrame(new_frame);
+     Push(new_frame);*/
  }
  
  /*
***************
*** 2161,2171 ****
  
  void FormatElementEnd()
  {
!     StyleStackElement *stack_el = (StyleStackElement *) HTList_removeLastObject(style_stack);
  
!     if (REGISTER_TRACE)
  	fprintf(stderr,"FormatElementEnd:   %d, %d elements left\n", stack_el->unit.element, HTList_count(style_stack));
! 
      Free(stack_el->flat);
      Free(stack_el->unit.class);
      Free(stack_el);
--- 2205,2218 ----
  
  void FormatElementEnd()
  {
!     Frame *old_frame;
!     int element;
  
!     StyleStackElement *stack_el = (StyleStackElement *) HTList_removeLastObject(style_stack);
!     element = stack_el->unit.element;
!     if (REGISTER_TRACE) 
  	fprintf(stderr,"FormatElementEnd:   %d, %d elements left\n", stack_el->unit.element, HTList_count(style_stack));
!     
      Free(stack_el->flat);
      Free(stack_el->unit.class);
      Free(stack_el);
***************
*** 2180,2183 ****
--- 2227,2260 ----
      } else {
  	current_flat = stack_el->flat;
      }
+ 
+     if(element == TAG_HTML || element == TAG_HTML_SOURCE || 
+ 	(element != TAG_TABLE))
+ /*
+        (element != TAG_ABSTRACT &&
+ 	element != TAG_BLOCKQUOTE && element != TAG_CAPTION &&
+ 	element != TAG_NOTE && element != TAG_P && element != TAG_PRE &&
+ 	element != TAG_QUOTE && element != TAG_TABLE))*/
+ 	return;
+ /*    old_frame = (Frame *)Pop();
+     if(old_frame)
+     {
+ 	Frame *parent_frame;
+ 	char *p;
+ #define PushValue(p, value) ui_n = (unsigned int)value; *p++ = ui_n & 0xFF; *p++ = (ui_n >> 8) & 0xFF
+ 
+ 	parent_frame = (Frame *)Pop();
+ 	if(parent_frame)
+ 	    Push(parent_frame);
+ 	old_frame->length = paintlen - old_frame->info - FRAMESTLEN;
+ 	old_frame->height = PixOffset - old_frame->offset;
+ 	p = paint + old_frame->info + 9;
+ 	PushValue(p, old_frame->height & 0xFFFF);
+ 	PushValue(p, (old_frame->height >> 16) & 0xFFFF);
+ 	PrintFrameLength(old_frame);
+ 	PrintEndFrame(parent_frame, old_frame);
+ 	free(old_frame);   
+     }; */
  }
+ 
+ 
Only in Implementation/: style.h
diff -c Implementation.beta-1d//toolbar.c Implementation//toolbar.c
*** Implementation.beta-1d//toolbar.c	Wed Jan 17 18:34:46 1996
--- Implementation//toolbar.c	Fri Jan 26 11:34:46 1996
***************
*** 14,19 ****
--- 14,20 ----
  #include "HTAccess.h"
  
  #include "www.h"
+ #include "style.h"
  
  extern Display *display;
  extern int screen;
***************
*** 42,48 ****
  static int nButtons;
  static int nButtonDown;
  
! Window win;
  GC toolbar_gc;
  int ToolBarHeight;
  
--- 43,49 ----
  static int nButtons;
  static int nButtonDown;
  
! extern Window win;
  GC toolbar_gc;
  int ToolBarHeight;
  
***************
*** 351,356 ****
--- 352,360 ----
      int c;
      FILE *fp;
      char *tmpfile, *p, buf[256];
+ #if defined __QNX__
+     char *tempnam(); /* this machine doesn't have tempnam... */
+ #endif
  
  /*    XDefineCursor(display, win, hourglass);*/
  /*    XFlush(display);*/
diff -c Implementation.beta-1d//www.c Implementation//www.c
*** Implementation.beta-1d//www.c	Wed Jan 17 18:34:47 1996
--- Implementation//www.c	Wed Feb  7 17:35:46 1996
***************
*** 20,30 ****
--- 20,36 ----
  #endif
  
  #ifndef NFDBITS
+ #if defined __QNX__
+ #define NFDBITS 0
+ #else
  #define NFDBITS FD_SETSIZE
  #endif
+ #endif
  
  #include "www.h"
  #include "popup.h"
+ #include "style.h"
+ #include "neweditor.h"
  
  #ifndef XK_DeleteChar
  #define XK_DeleteChar XK_Delete
***************
*** 67,73 ****
  int OpenSubnet = 0;   /* if true host is on OpenSubnet */
  int UsePaper = 1; 
  int fontsize = 0;
! int NoTerminal = 1; /* howcome 5/11/94: can we ask for passwd? */
  char *CacheRoot = "/tmp"; /* howcome 5/10/94: command line option to turn caching on */
  char *Printer = NULL; /* howcome 5/10/94: command line option enables printing */
  char *Editor = NULL; /* howcome 5/10/94: command line option turns the editor on */
--- 73,79 ----
  int OpenSubnet = 0;   /* if true host is on OpenSubnet */
  int UsePaper = 1; 
  int fontsize = 0;
! int NoTerminal = 0; /* howcome 5/11/94: can we ask for passwd? */
  char *CacheRoot = "/tmp"; /* howcome 5/10/94: command line option to turn caching on */
  char *Printer = NULL; /* howcome 5/10/94: command line option enables printing */
  char *Editor = NULL; /* howcome 5/10/94: command line option turns the editor on */
***************
*** 79,84 ****
--- 85,93 ----
  BOOL Quiet = FALSE; /* howcome 10/8/95 */
  BOOL OwnColorMap = FALSE; /* howcome 10/8/95 */
  
+ long main_stack[256];
+ long *stack;
+ 
  int library_trace = 0; /* howcome 20/11/94 */
  
  Doc *CurrentDoc;
***************
*** 172,177 ****
--- 181,187 ----
  /* From Scott Nelson <snelson@canopus.llnl.gov> 24 bit color  1/12/94 */
  /* these are here for speed reasons */
  int RPixelShift=16, GPixelShift=8, BPixelShift=0;
+ int RPixelMask=0xff, GPixelMask=0xff, BPixelMask=0xff;
  
  
  /* pause for delay milliseconds */
***************
*** 448,453 ****
--- 458,464 ----
  	while ((maskval & 1) == 0) { i++; maskval = maskval >> 1; }
  	
  	BPixelShift = i;
+ 	printf("RPS %d, GPS %d, BPS %d\n", RPixelShift, GPixelShift, BPixelShift);
  }
  
  
***************
*** 460,472 ****
      b = color->blue >> 8;
  
  /*    *pixel = (b | g << 8 | r << 16); */ /* From Scott Nelson <snelson@canopus.llnl.gov> 24bit color  1/12/94  Dec 1 1994 */
! /*	   *pixel = (r | g << 8 | b << 16); */ /* some systems use RGB masks, others use BGR masks */
!     *pixel = (b << BPixelShift | g << GPixelShift | r << RPixelShift );
! 
  	 
      return 1;
  }
  
  int GetNamedColor(char *name, unsigned long *pix)
  {
      XColor color;
--- 471,494 ----
      b = color->blue >> 8;
  
  /*    *pixel = (b | g << 8 | r << 16); */ /* From Scott Nelson <snelson@canopus.llnl.gov> 24bit color  1/12/94  Dec 1 1994 */
! /*	   *pixel = (r | g << 8 | b << 16);*/  /* some systems use RGB masks, others use BGR masks */
!     *pixel = (b << BPixelShift | g << GPixelShift | r << RPixelShift ); 
  	 
      return 1;
  }
  
+ int Pixel2Color(XColor *color, unsigned long *pixel)
+ {
+     unsigned long r, g, b;
+ 
+     r = (color->red * (long)(RPixelMask+1)) >> 16;
+     g = (color->green *(long)(GPixelMask+1)) >> 16;
+     b = (color->blue *(long)(BPixelMask+1)) >> 16;
+ 
+     *pixel = (b << BPixelShift | g << GPixelShift | r << RPixelShift );
+     return 1;
+ }
+ 
  int GetNamedColor(char *name, unsigned long *pix)
  {
      XColor color;
***************
*** 483,488 ****
--- 505,521 ----
  
          return Pixel4Color(&color, pix);
      }
+     if (depth == 16)
+     {
+         if (XParseColor(display, colormap, name, &color) == 0)
+         {
+             if (X_TRACE)
+                 fprintf(stderr, "www: can't allocate named color `%s'\n", name);
+ 
+             return 0;
+         }
+         return Pixel2Color(&color, pix);
+     }
      else if (XParseColor(display, colormap, name, &color) == 0 ||
                       XAllocColor(display, colormap, &color) == 0)
      {
***************
*** 518,523 ****
--- 551,558 ----
  
      if (depth == 24)
          return Pixel4Color(&color, pix);
+     else if (depth == 16)
+ 	return Pixel2Color(&color, pix);
      else if (XAllocColor(display, colormap, &color) == 0)
      {
  /*        if (X_TRACE)*/
***************
*** 1200,1206 ****
  
      InitPaperRGB ();
  
!     if (! (UsePaper && (depth == 8 || depth == 24)))
      {
          UsePaper = 0;
          XSetForeground(display, gc_fill, windowColor);
--- 1235,1241 ----
  
      InitPaperRGB ();
  
!     if (! (UsePaper && (depth == 8 || depth == 16 || depth == 24)))
      {
          UsePaper = 0;
          XSetForeground(display, gc_fill, windowColor);
***************
*** 1231,1238 ****
          }
  
          if ((image = XCreateImage(display, DefaultVisual(display, screen),
!              depth, ZPixmap, 0, (char *)tileData,
!              tileWidth, tileHeight, (depth == 24 ? 32 : 8), 0)) == 0)
          {
              /* Free(tileData); keep for transparent backgrounds */
              XFreePixmap(display, pixmap);
--- 1266,1273 ----
          }
  
          if ((image = XCreateImage(display, DefaultVisual(display, screen),
! 				  depth, ZPixmap, 0, (char *)tileData,
! 				  tileWidth, tileHeight, (depth == 24 ? 32 : (depth == 16 ? 16 : 8)), 0)) == 0)
          {
              /* Free(tileData); keep for transparent backgrounds */
              XFreePixmap(display, pixmap);
***************
*** 1243,1249 ****
  	/* howcome 22/2/95: do we need to set these?? */
  
  	image->byte_order = MSBFirst;
! 	image->bitmap_bit_order = MSBFirst;
  
          drawGC = XCreateGC(display, pixmap, 0, 0);
          XSetFunction(display, drawGC, GXcopy);
--- 1278,1284 ----
  	/* howcome 22/2/95: do we need to set these?? */
  
  	image->byte_order = MSBFirst;
! 	image->bitmap_bit_order = BitmapBitOrder(display); /* was MSBFirst*/ ;
  
          drawGC = XCreateGC(display, pixmap, 0, 0);
          XSetFunction(display, drawGC, GXcopy);
***************
*** 1451,1457 ****
--- 1486,1505 ----
  
  }
  
+ void Push(void *item)
+ {
+     *stack = (long)item;
+     stack += sizeof(long);
+ }
  
+ void *Pop()
+ {
+     if(stack == main_stack)
+ 	return NULL;
+     
+     stack -= sizeof(long);
+     return((void *)*stack);
+ }
  
  void main(int argc, char **argv)
  {
***************
*** 1470,1483 ****
  #ifdef SIGWAITING_IGN
      signal(SIGWAITING, SIG_IGN);           /* howcome: solaris binaries receive this signal, but why? */
  #endif
! 
      signal(SIGPIPE, SIG_IGN);
!     signal(SIGINT, (void *) Exit);   /* howcome 4/10/94: trap C-C so that we can delete cache */
!     signal(SIGIOT, (void *) CatchCore);
      signal(SIGSEGV, CatchCore);
! 
      cmask = umask(0000);
  
      UseHTTP2 = 1;
      UsePaper = 1;
  
--- 1518,1534 ----
  #ifdef SIGWAITING_IGN
      signal(SIGWAITING, SIG_IGN);           /* howcome: solaris binaries receive this signal, but why? */
  #endif
!     signal(SIGABRT, SIG_IGN);
      signal(SIGPIPE, SIG_IGN);
!     signal(SIGINT, Exit);   /* howcome 4/10/94: trap C-C so that we can delete cache */
!     signal(SIGIOT, CatchCore);
! #if !defined __QNX__
      signal(SIGSEGV, CatchCore);
! #endif
      cmask = umask(0000);
  
+     stack = main_stack;
+ 
      UseHTTP2 = 1;
      UsePaper = 1;
  
***************
*** 1826,1841 ****
      if (depth == 1)
        ColorStyle = MONO;
      
!     visual = BestVisual(DirectColor, &best_depth);
      if (best_depth == 24){
  
  	/* From Scott Nelson <snelson@canopus.llnl.gov> 24bit color: 12/5/94 */
  	/* visual = BestVisual(DirectColor, &best_depth); */ 
- 	
  	visual=BestVisual(TrueColor, &best_depth); 
  	CalcPixelShift();
      }
! 	 
      if (ColorStyle != COLOR888 || best_depth <= depth)
      {
          colormap = DefaultColormap(display, screen);
--- 1877,1893 ----
      if (depth == 1)
        ColorStyle = MONO;
      
!     visual = BestVisual(TrueColor, &best_depth);
      if (best_depth == 24){
  
  	/* From Scott Nelson <snelson@canopus.llnl.gov> 24bit color: 12/5/94 */
  	/* visual = BestVisual(DirectColor, &best_depth); */ 
  	visual=BestVisual(TrueColor, &best_depth); 
  	CalcPixelShift();
+     } else {
+ 	visual = BestVisual(DirectColor, &best_depth);
      }
! 
      if (ColorStyle != COLOR888 || best_depth <= depth)
      {
          colormap = DefaultColormap(display, screen);
***************
*** 1922,1928 ****
         icon. Befor we can get the icon, we need to initialize the
         library */
  
!     context = NewContext(NULL);
      context->registered_anchors = HTList_new();
      context->pending_docs = HTList_new();
      context->pending_anchors = HTList_new();
--- 1974,1980 ----
         icon. Befor we can get the icon, we need to initialize the
         library */
  
!     context = NewContext();
      context->registered_anchors = HTList_new();
      context->pending_docs = HTList_new();
      context->pending_anchors = HTList_new();
diff -c Implementation.beta-1d//www.h Implementation//www.h
*** Implementation.beta-1d//www.h	Wed Jan 17 18:34:47 1996
--- Implementation//www.h	Thu Feb  8 10:07:21 1996
***************
*** 33,39 ****
  #endif
  
  
! #define VERSION         "beta-1d"      /* REMEMBER!!! also update DEFAULT_URL and HELP_URL and INITIAL_HTML*/
  #define BANNER 		"Arena"     /* also used as APPNAME !!!!! */
  
  /* janet: added, as they are needed within www.h  is this the right place (line)? */
--- 33,39 ----
  #endif
  
  
! #define VERSION         "beta-1e"      /* REMEMBER!!! also update DEFAULT_URL and HELP_URL and INITIAL_HTML*/
  #define BANNER 		"Arena"     /* also used as APPNAME !!!!! */
  
  /* janet: added, as they are needed within www.h  is this the right place (line)? */
***************
*** 215,223 ****
  back through the document.
  */
  
! #define TEXTLINE    1   /* frame containing elements on a line */
! #define BEGIN_FRAME 2   /* begining of a frame */
! #define END_FRAME   3   /* end of a frame */
  
  #ifdef STYLE_COLOR_BORDER
  #define FRAME_STLEN  18  /* number of bytes in start of frame marker */
--- 215,223 ----
  back through the document.
  */
  
! #define TEXTLINE    11   /* frame containing elements on a line */
! #define BEGIN_FRAME 12   /* begining of a frame */
! #define END_FRAME   13   /* end of a frame */
  
  #ifdef STYLE_COLOR_BORDER
  #define FRAME_STLEN  18  /* number of bytes in start of frame marker */
***************
*** 415,424 ****
--- 415,427 ----
  
  #define B_SIZE 10 /* 6 */     /* size of bullet graphic */
  
+ #ifndef max
  #define max(a, b)   ((a) > (b) ? (a) : (b))
  #define min(a, b)   ((a) < (b) ? (a) : (b))
+ #endif
  #define str_cmp(a, b) ((a && b) ? strcasecmp(a, b) : (a || b))
  
+ 
  #define CHWIDTH(font)    XTextWidth(Fonts[font], " ", 1)
  #define SPACING(font)    (2 + font->max_bounds.ascent + font->max_bounds.descent)
  #define BASELINE(font)   (1 + font->max_bounds.ascent)
***************
*** 673,678 ****
--- 676,685 ----
  /* properties for internal use */
      S_SMALL_CAPS_FONT,
  
+ /* new css1 properties */
+ 
+     S_PADDING,
+ 
      S_NPROPERTY
  } StyleProperty;
  
***************
*** 794,800 ****
  #define S_ADDRESSING_SEQUENTIAL		1
  #define S_ADDRESSING_HIERARCHICAL	2
  
- void StyleSetFlag(int flag, BOOL value);
  
  /* new style.h */
  
--- 801,806 ----
***************
*** 1364,1371 ****
  void PaintFace(int happy);
  void MakeFaces(unsigned int depth);
  void MakeIcons(unsigned int depth);
- int Brightness2Voltage(int brightness);
- int Voltage2Brightness(int voltage);
  Image *DefaultImage();
  
  /* dither.c */
--- 1370,1375 ----
***************
*** 1400,1406 ****
  Form *GetForm(int method, char *url, int len);
  Field *GetField(Form *form, int type, int x, char *name, int nlen,
                 char *value, int vlen, int rows, int cols, int flags);
! void *AddOption(Field *field, int flags, char *label, int len);
  int ClickedInField(GC gc, int indent, int baseline, Field *field, int x, int y, int event);
  void PaintField(GC gc, int indent, int baseline, Field *field);
  void PaintDropDown(GC gc, Field *field, int indent);
--- 1404,1410 ----
  Form *GetForm(int method, char *url, int len);
  Field *GetField(Form *form, int type, int x, char *name, int nlen,
                 char *value, int vlen, int rows, int cols, int flags);
! void AddOption(Field *field, int flags, char *label, int len);
  int ClickedInField(GC gc, int indent, int baseline, Field *field, int x, int y, int event);
  void PaintField(GC gc, int indent, int baseline, Field *field);
  void PaintDropDown(GC gc, Field *field, int indent);
