This is a collection of patches for chimera 1.65 that I've seen on the bug-chimera mailing list. Some are bug fixes, some are enhancements. Table support is not complete, but works amazingly well. If your name should be here but isn't, let me know and I'll add it. Extra ISO escapes by Jim Rees . Color allocation bug fix by Jim Rees. OpenDocument shortcut by Jim Rees. Many bug fixes by Roman Czyborra. Table support by clif@clif.ypsi.mi.us (Clif Flynt). -- diff -ub libhtmlw/HTML.c- libhtmlw/HTML.c --- libhtmlw/HTML.c- Sat Mar 25 01:43:21 1995 +++ libhtmlw/HTML.c Mon May 1 16:10:25 1995 @@ -693,8 +693,8 @@ static void setScrollBar (sb, topPosition, totalLength, currentLength) Widget sb; -Position topPosition; -Dimension totalLength, currentLength; +int topPosition; +int totalLength, currentLength; { float top = (float) topPosition / (float) (totalLength); float shown = (float) currentLength / (float) (totalLength); @@ -949,7 +949,7 @@ float scrollDir = (int) call_data < 0 ? -0.3 : 0.3; HTMLWidget hw = (HTMLWidget) client_data; int value, maxv; - Dimension totalLength, currentLength; + int totalLength, currentLength; if (w == hw->html.vbar) { diff -ub libhtmlw/HTML.h- libhtmlw/HTML.h --- libhtmlw/HTML.h- Sat Mar 4 02:54:22 1995 +++ libhtmlw/HTML.h Thu Dec 5 22:28:09 1996 @@ -309,6 +309,10 @@ #define M_SELECT 42 #define M_OPTION 43 #define M_TEXTAREA 44 +#define M_TABLE 45 +#define M_TABLE_ITEM 46 +#define M_TABLE_HEADER 47 +#define M_TABLE_ROW 48 /* syntax of Mark types */ #define MT_TITLE "title" @@ -355,7 +359,10 @@ #define MT_SELECT "select" #define MT_OPTION "option" #define MT_TEXTAREA "textarea" - +#define MT_TABLE "table" +#define MT_TABLE_ITEM "td" +#define MT_TABLE_HEADER "th" +#define MT_TABLE_ROW "tr" /* anchor tags */ #define AT_NAME "name" diff -ub libhtmlw/HTMLamp.h- libhtmlw/HTMLamp.h --- libhtmlw/HTMLamp.h- Sat Mar 4 02:54:21 1995 +++ libhtmlw/HTMLamp.h Mon Nov 13 18:40:34 1995 @@ -67,6 +67,40 @@ {"AMP", '&'}, {"quot", '\"'}, {"QUOT", '\"'}, + + {"nbsp", ' '}, + {"iexcl", '\241'}, + {"cent", '\242'}, + {"pound", '\243'}, + {"curren", '\244'}, + {"yen", '\245'}, + {"brvbar", '\246'}, + {"sect", '\247'}, + {"uml", '\250'}, + {"copy", '\251'}, + {"ordf", '\252'}, + {"laquo", '\253'}, + {"not", '\254'}, + {"shy", '\255'}, + {"reg", '\256'}, + {"hibar", '\257'}, + {"deg", '\260'}, + {"plusmn", '\261'}, + {"sup2", '\262'}, + {"sup3", '\263'}, + {"acute", '\264'}, + {"micro", '\265'}, + {"para", '\266'}, + {"middot", '\267'}, + {"cedil", '\270'}, + {"sup1", '\271'}, + {"ordm", '\272'}, + {"raquo", '\273'}, + {"frac14", '\274'}, + {"frac12", '\275'}, + {"frac34", '\276'}, + {"iquest", '\277'}, + {"Agrave", '\300'}, {"Aacute", '\301'}, {"Acirc", '\302'}, @@ -91,7 +125,7 @@ {"Otilde", '\325'}, {"Ouml", '\326'}, - {"?", '\327'}, /* ? */ + {"times", '\327'}, {"Oslash", '\330'}, {"Ugrave", '\331'}, @@ -125,7 +159,7 @@ {"otilde", '\365'}, {"ouml", '\366'}, - {"?", '\367'}, /* ? */ + {"divide", '\367'}, {"oslash", '\370'}, {"ugrave", '\371'}, diff -ub libhtmlw/HTMLformat.c- libhtmlw/HTMLformat.c --- libhtmlw/HTMLformat.c- Mon Mar 27 05:30:18 1995 +++ libhtmlw/HTMLformat.c Thu Dec 5 22:23:48 1996 @@ -2870,6 +2870,7 @@ * parsed HTML text we are formatting. * Some calls create elements that are added to the formatted element list. */ + static int tableWidth =40; void TriggerMarkChanges (hw, mptr, x, y) HTMLWidget hw; @@ -2879,6 +2880,7 @@ struct mark_up *mark; XFontStruct *font; int type, width; + static int TableEntry, lastTableLen; mark = mptr; type = mark->type; @@ -3241,6 +3243,7 @@ * Just insert the image for now */ case M_IMAGE: + if (!mark->is_end) ImagePlace (hw, mptr, x, y, Width); break; /* @@ -3774,6 +3777,41 @@ BulletPlace (hw, x, y); } } + break; + case M_TABLE_ITEM: + if (!mark->is_end) + { + int widstart; + if (TableEntry) { + int loc; + loc=tableWidth*TableEntry; + if (*x < loc) { *x=loc;} else {*x+=14;} + BulletPlace (hw, x, y); + *x = *x+8; + } + + tableWidth=60; + widstart=caseless_strindex(mark->start, "width"); + /* printf("tableWidth: %d -- %d (%s)\n", tableWidth, widstart, widstart+(mark->start)); */ + if (widstart >=0) { + widstart+=6; + sscanf(widstart+(mark->start), "%d", &tableWidth); + } + } + + /* printf("start: %xx (%s) end: %xx (%s) text: %xx (%s)\n", mark->start, mark->start, mark->end, mark->end, mark->text, mark->text); printf("lastlen: %d: x: %d\n", lastTableLen, *x); */ + TableEntry++; + break; + case M_TABLE_ROW: + TableEntry=0; + /* printf("Set First", firstTableEntry, &firstTableEntry); */ + if (mark->is_end) + { + ConditionalLineFeed (hw, x, y, 1); + } else { + ConditionalLineFeed (hw, x, y, 1); + } + break; /* * Description lists diff -ub libhtmlw/HTMLimages.c- libhtmlw/HTMLimages.c --- libhtmlw/HTMLimages.c- Fri Mar 24 05:20:28 1995 +++ libhtmlw/HTMLimages.c Tue Apr 4 20:16:10 1995 @@ -166,10 +166,18 @@ static int have_colors = 0; int NumCells; + NumCells = XDisplayCells(dsp, DefaultScreen(dsp)); + if (NumCells <= 2) + { + colr->pixel = (colr->red + colr->green + colr->blue > 98304) ? + WhitePixel(dsp, DefaultScreen(dsp)) : BlackPixel(dsp, DefaultScreen(dsp)) ; + XQueryColor(dsp, colormap, colr); + return; + } + match = XAllocColor (dsp, colormap, colr); if (match == 0) { - NumCells = DisplayCells (dsp, DefaultScreen (dsp)); if (!have_colors) { for (i = 0; i < NumCells; i++) @@ -298,6 +306,7 @@ { int linepad, shiftnum; int shiftstart, shiftstop, shiftinc; + int bitsperpixel, scanline_pad; int bytesperline; int temp; int w, h; @@ -308,7 +317,10 @@ unsigned long c; int rshift, gshift, bshift; - switch (depth) + bitsperpixel = _XGetBitsPerPixel(dsp, depth); + scanline_pad = _XGetScanlinePad(dsp, depth); + + switch (bitsperpixel) { case 6: case 8: @@ -327,15 +339,15 @@ { shiftstart = 0; shiftstop = 8; - shiftinc = depth; + shiftinc = bitsperpixel; } else { - shiftstart = 8 - depth; - shiftstop = -depth; - shiftinc = -depth; + shiftstart = 8 - bitsperpixel; + shiftstop = -bitsperpixel; + shiftinc = -bitsperpixel; } - linepad = 8 - (width % 8); + linepad = scanline_pad - (width % scanline_pad); bit_data = (unsigned char *) XtMalloc (((width + linepad) * height) + 1); bitp = bit_data; @@ -367,11 +379,11 @@ } } } - bytesperline = (width + linepad) * depth / 8; + bytesperline = (width + linepad) * bitsperpixel / 8; newimage = XCreateImage (dsp, DefaultVisual (dsp, DefaultScreen (dsp)), depth, ZPixmap, 0, (char *) bit_data, - (width + linepad), height, 8, bytesperline); + (width + linepad), height, scanline_pad, bytesperline); break; /* * WARNING: This depth 16 code is donated code for 16 bit diff -ub libhtmlw/HTMLparse.c- libhtmlw/HTMLparse.c --- libhtmlw/HTMLparse.c- Mon Mar 27 02:30:36 1995 +++ libhtmlw/HTMLparse.c Thu Dec 5 22:16:19 1996 @@ -1122,6 +1122,24 @@ { type = M_FORM; } + else if (caseless_equal (str, MT_TABLE)) + { + type = M_TABLE; + } + else if (caseless_equal (str, MT_TABLE_ITEM)) + { + type = M_TABLE_ITEM; + } + else if (caseless_equal (str, MT_TABLE_HEADER)) + { + type = M_TABLE_ITEM; + } + + else if (caseless_equal (str, MT_TABLE_ROW)) + { + type = M_TABLE_ROW; + } + else { #ifdef VERBOSE diff -ub src/Imakefile- src/Imakefile --- src/Imakefile- Mon Mar 27 05:24:33 1995 +++ src/Imakefile Thu Dec 5 22:19:47 1996 @@ -8,12 +8,12 @@ SRCS = main.c url.c net.c ftp.c convert.c gopher.c http.c \ util.c inline.c \ document.c local.c widget.c cache.c mime.c input.c md5.c auth.c \ - fallback.c lang.c stringdb.c + fallback.c lang.c stringdb.c strindex.c OBJS = main.o url.o net.o ftp.o gopher.o http.o \ util.o document.o local.o cache.o mime.o input.o \ md5.o auth.o lang.o stringdb.o inline.o widget.o convert.o \ - fallback.o + fallback.o strindex.o DEFINES = $(XRELEASE) $(CDEFINES) $(CSOCKS) $(CTERM) $(CEXTRA_DEFINES) INCLUDES = -I../libhtmlw -I../mxw -I../ -I../xloadimage $(CTERMINC) \ @@ -27,7 +27,7 @@ LOCAL_DEPLIBS = ../common/libcommon.a ../mxw/libmxw.a \ ../libhtmlw/libhtmlw.a \ - ../xloadimage/libxloadimage.a $(COMPATLIB) + ../xloadimage/libxloadimage.a $(DEPCOMPAT) AllTarget(chimera) diff -ub src/cache.c- src/cache.c --- src/cache.c- Wed Mar 29 04:55:32 1995 +++ src/cache.c Thu Nov 30 13:21:45 1995 @@ -196,7 +196,8 @@ { FILE *fp; char buffer[BUFSIZ]; - char path[MAXPATHLEN + 1], domain[BUFSIZ]; + char domain[BUFSIZ]; + char *path; int max, ttl, clean; CacheInfo *ci, *ti; DIR *dp; @@ -208,9 +209,11 @@ { if (buffer[0] == '#' || buffer[0] == '\n') continue; + path = alloc_mem(sizeof(char) * (MAXPATHLEN +1)); if (sscanf(buffer, "%s %s %d %d %d", path, domain, &max, &ttl, &clean) == 5) { + path = FixFilename(path); if ((dp = opendir(path)) != NULL) { ci = (CacheInfo *)alloc_mem(sizeof(CacheInfo)); @@ -364,6 +367,9 @@ default_cache.clist = NULL; default_cache.next = NULL; + if (!cache_list) { + cache_list = &default_cache; + } ScanCacheDirectories(); return; @@ -477,7 +483,7 @@ FILE *fp; char *u; char *filename; - int size = 0; + off_t size = 0; CacheInfo *ci; MIMEField *mf; time_t now, expires; diff -ub src/ftp.c- src/ftp.c --- src/ftp.c- Wed Mar 29 04:46:06 1995 +++ src/ftp.c Thu Jul 27 18:40:33 1995 @@ -102,7 +102,6 @@ r = alloc_mem(strlen(msg) + strlen(ftpmsg) + 1); sprintf (r, msg, ftpmsg); - free_mem(msg); free_mem(ftpmsg); d = BuildDocument(r, strlen(r), "text/html", 0, 0); d->status = DS_ERROR; diff -ub src/gopher.c- src/gopher.c --- src/gopher.c- Sat Apr 1 22:18:03 1995 +++ src/gopher.c Tue Apr 4 07:59:19 1995 @@ -10,6 +10,7 @@ #include #include +#include #ifdef HAVE_STRING_H #include diff -ub src/http.c- src/http.c --- src/http.c- Wed Mar 29 02:08:51 1995 +++ src/http.c Thu Dec 5 13:31:38 1996 @@ -40,7 +40,7 @@ Document *d; int error_code; { - if (error_code <= 200 && error_code < 300) + if (error_code >= 200 && error_code < 300) { if (error_code == 204) d->status = DS_NOTHING; else d->status = DS_OK; @@ -170,7 +170,7 @@ t = ReadBuffer(s, &tlen, 8, 8); if (t == NULL) return(NULL); - if (strncmp(t, "HTTP/1.0", 8) != 0) + if (strncmp(t, "HTTP/1.", 7) != 0) { char *x; int xlen; diff -ub src/main.c- src/main.c --- src/main.c- Fri Mar 31 20:45:19 1995 +++ src/main.c Thu Feb 29 14:03:02 1996 @@ -121,6 +121,8 @@ offset(showURL), XtRImmediate, (XtPointer)True }, { "showTitle", XtCBoolean, XtRBoolean, sizeof(Boolean), offset(showTitle), XtRImmediate, (XtPointer)True }, + { "anchorDisplay", XtCBoolean, XtRBoolean, sizeof(Boolean), + offset(anchorDisplay), XtRImmediate, (XtPointer)False }, { "button1Box", "BoxList", XtRString, sizeof(char *), offset(button1Box), XtRString, (XtPointer)BUTTON_LIST }, { "button2Box", "BoxList", XtRString, sizeof(char *), @@ -918,10 +920,10 @@ } /* - * Convert needs to be called in case there is a transfer or content - * encoding. + * Convert needs to be called in case there is a content transfer or content + * encoding. But not for downloads, says Roman. */ - if (d->ptext == NULL) + if (d->ptext == NULL && ! download) { /* * This frightens me. I know it is bad but I can't think of anything @@ -949,7 +951,26 @@ if (d->status == DS_OK && (download || (d->content == NULL && d->pcontent == NULL))) { - CreateStrReq("filename", root.savestr, False, SaveOCallback, + + /* Let's offer the save the downloaded file under the same name. + Roman Czyborra, 1995-04-13 */ + + char *filename=NULL, *basename; int length; + + if (d->up) if (filename= d->up->filename) if (length = strlen(filename)) + { + if (filename[length-1]=='/') + { + filename[length-1]='\0'; + } + if (basename = strrchr (filename, '/')) + { + filename = basename + 1; + } + } + if (! filename) filename=""; + + CreateStrReq("filename", filename, False, SaveOCallback, SaveDCallback, (XtPointer)d); } else if ((d->content != NULL && strcasecmp(d->content, "text/html") == 0) || @@ -979,7 +1000,7 @@ else { DestroyDocument(d); - d = NULL; + return; } } else @@ -1066,6 +1087,23 @@ return; } +/* rwmcm */ +/* + * AnchorURLDisplay + * + * Called when the mouse moves over an anchor + */ +void +AnchorURLDisplay(w, c) +Widget w; +char *c; +{ + Arg args[5]; + + XtSetArg(args[0], XtNlabel, c); + XtSetValues(root.anchordisplay,args,1); +} + /* * OpenDocument * @@ -1089,9 +1127,17 @@ else { if (root.loadstr) free_mem(root.loadstr); + /* + * short cut -- if user types in "foo.com" turn that into "https://foo.com/" + * this means you must type "./foo.com" if opening a local file by that name + */ + if (!strchr(url, '/')) { + root.loadstr = alloc_mem(strlen(url) + 9); + sprintf(root.loadstr, "https://%s/", url); + } else root.loadstr = alloc_string(url); - up = ParseURL(url); + up = ParseURL(root.loadstr); if (up != NULL) { d = LoadDoc(up, 0, 0); diff -ub src/strindex.c- src/strindex.c --- src/strindex.c- Thu Dec 5 22:46:33 1996 +++ src/strindex.c Thu Dec 5 22:16:20 1996 @@ -0,0 +1,33 @@ +/*** STRINDEX. Returns position of first occurence of string T in +/ string S. Returns -1 if T is not found. If either string is +/ null, STRINDEX returns -1. */ + + +#include +#define NOT ! + +int caseless_strindex (s, t) + char *s, *t; +{ + char *ps, *pt; + int pos; + + if (NOT *t) return (-1); + + pos = 0; + while (*s) { + ps = s; + pt = t; + while (((*ps)&0x5f) == ((*pt)&0x5f) && *pt) { + ++ps; + ++pt; + } + if (NOT *pt) return (pos); + ++s; + ++pos; + } + + return (-1); +} + + diff -ub src/widget.c- src/widget.c --- src/widget.c- Thu Mar 23 03:29:21 1995 +++ src/widget.c Thu Jul 27 18:32:56 1995 @@ -218,12 +218,30 @@ } /* + * rwmcm: Sixth pane, the URL anchor display + */ + if (r->anchorDisplay) + { + XtSetArg(args[0], XtNjustify, XtJustifyLeft); + XtSetArg(args[1], XtNlabel, " "); + XtSetArg(args[2], XtNskipAdjust, True); + r->anchordisplay=XtCreateManagedWidget("anchordisplay", + labelWidgetClass, paned, + args, 3); + } + + /* * Fifth pane, the HTML viewing area */ r->w = XtCreateManagedWidget("html", htmlWidgetClass, paned, NULL, ZERO); XtAddCallback(r->w, WbNanchorCallback, Anchor, r); + if (r->anchorDisplay) + { + XtSetArg(args[0], WbNpointerMotionCallback, AnchorURLDisplay); + XtSetValues(r->w, args, 1); + } /* * Set some callbacks for the HTML widget. diff -ub src/widget.h- src/widget.h --- src/widget.h- Fri Mar 31 20:45:22 1995 +++ src/widget.h Thu Apr 6 00:49:36 1995 @@ -50,6 +50,7 @@ char *printerName; /* default printer */ Boolean showURL; /* switch for the display of the current URL */ Boolean showTitle; /* switch for the display of the current title */ + Boolean anchorDisplay; /* display URL of current hyperlink */ int statusUpdate; /* frequency of download status update */ int inPort; /* the port that chimera listens on for data */ char *httpProxy; @@ -89,6 +90,7 @@ Widget search; Widget cancel; Widget quit; + Widget anchordisplay; /* rwmcm */ char *savestr; char *loadstr; char *printstr; @@ -117,6 +119,7 @@ void Quit(); void OpenDocument(); void Anchor(); +void AnchorURLDisplay(); void Home(); void Back(); void Help();