This is a patch #1 to Xew-2.1 release. Apply this above Xew and demo directories with "patch -p0 < thisfile". This patch is not essential (except if you use PGM files). -------------------------------------------------------------------------- A bug in RasterPBM.c fixed (allocated wrong size of memory for PGM images). XeTextInsertPrefix function implemented. This function sets the prefix string that will be automaticly inserted before any input after a new insert point is opened. (The prefix should only contain control sequences.) Added characterset encodings "default-1" and "default-2". These are used if an unrecognized designation occurs (for one byte and multibyte (two bytes) encodins). Both encodings will use the bytes in source as they are. (The change was necessary to make it possible to use BIG5 encoded content.) -------------------------------------------------------------------------- *** Xew/TextEd.c.orig Fri Mar 11 10:47:29 1994 --- Xew/TextEd.c Thu Mar 17 16:25:31 1994 *************** *** 344,349 **** --- 344,351 ---- w->texted.cursor_x = w->texted.cursor_y = 0; w->texted.cursor_valid = False; w->texted.refresh = 0; + w->texted.insert_prefix = NULL; + w->texted.insert_prefix_length = 0; } *************** *** 1224,1229 **** --- 1226,1232 ---- if (t->texted.refresh) XDestroyRegion(t->texted.refresh); + XtFree(t->texted.insert_prefix); XFreePixmap(XtDisplay(w), t->texted.cursor); XFree((char *)t->texted.s.selections); } *************** *** 1935,1940 **** --- 1938,1951 ---- w->texted.cursor_location.snip, w->texted.cursor_location.offset, mode); + if (w->texted.insert_prefix != NULL) + { + _XeTextLock(w->text.inserting, FALSE); + _XeTextFeedContent(w->text.inserting, + w->texted.insert_prefix, + w->texted.insert_prefix_length); + _XeTextLock(w->text.inserting, TRUE); + } } return 1; } *************** *** 2433,2448 **** if (ctx->texted.display_caret == display_caret) return; } - StartMoving(ctx, e); if (ctx->texted.display_caret != display_caret) { /* State has really changed */ ! ctx->texted.display_caret = display_caret; UpdateCursorPosition(ctx, ctx->texted.cursor_position, False, True, False); } - EndMoving(ctx); } /* --- 2444,2458 ---- if (ctx->texted.display_caret == display_caret) return; } if (ctx->texted.display_caret != display_caret) { /* State has really changed */ ! InitRefreshRegion(ctx); ctx->texted.display_caret = display_caret; UpdateCursorPosition(ctx, ctx->texted.cursor_position, False, True, False); + DoRefreshRegion(ctx); } } /* *************** *** 2947,2952 **** --- 2957,2992 ---- long length; { XeTextReplaceTagged(w, start, end, value, length, (XeTextTag)0); + } + + /* + ** XeTextInsertPrefix + ** defines a control string that will be executed every time + ** an insert point is opened, before any other data is inserted. + ** The graphic rendition modes set by this sequence will be locked + ** in same way as initialState modes (insertPrefix can be used to + ** override initialState). + */ + void XeTextInsertPrefix(w, value, length) + Widget w; + char *value; + long length; + { + XeTextEdWidget t = (XeTextEdWidget)w; + if (!IsTextEdWidget(w)) + return; + XtFree(t->texted.insert_prefix); + if (value && length > 0) + { + t->texted.insert_prefix = (char *)XtMalloc((int)length); + t->texted.insert_prefix_length = length; + memcpy(t->texted.insert_prefix, value, (int)length); + } + else + { + t->texted.insert_prefix = NULL; + t->texted.insert_prefix_length = 0; + } } /* *** Xew/TextEd.h.orig Tue Mar 1 16:56:40 1994 --- Xew/TextEd.h Thu Mar 17 16:23:17 1994 *************** *** 162,167 **** --- 162,176 ---- #endif ); + void XeTextInsertPrefix + ( + #if NeedFunctionPrototypes + Widget, /* TextEd Widget pointer */ + char *, /* Pointer to octets to be used as prefix */ + long /* Length of the prefix */ + #endif + ); + long XeTextGetInsertionPoint ( #if NeedFunctionPrototypes *** Xew/TextEdP.h.orig Wed Mar 9 15:45:24 1994 --- Xew/TextEdP.h Thu Mar 17 16:10:36 1994 *************** *** 50,55 **** --- 50,66 ---- /* private state */ + /* + ** insert_prefix and insert_prefix_length define an octet string + ** that will be implicitly inserted every time an insert point + ** is opened. It should contain only control sequences to change + ** the graphic presentation from the default initialState. The + ** modes set by insert_prefix will be locked. The value can be set + ** with XeTextInsertPrefix function. + */ + char *insert_prefix; + long insert_prefix_length; + Pixmap cursor; /* Cursor Image Bitmap */ /* ** Information about the cursor location in various levels. To *** Xew/TextImport.c.orig Fri Mar 4 11:08:05 1994 --- Xew/TextImport.c Thu Mar 17 14:08:40 1994 *************** *** 98,103 **** --- 98,108 ---- static char gb2312_1980_0[] = "gb2312-1980-0"; static char jisx0208_1983_0[] = "jisx0208.1983-0"; static char ksc5601_1987_0[] = "ksc5601.1987-0"; + /* + ** Unknown Charsets (non-standard) will be dealt as "default" encodings + */ + static char default_1[] = "default-1"; /* Single byte sets */ + static char default_2[] = "default-2"; /* Two byte sets */ /* ** ISO 2022 Code Switching export support *************** *** 880,885 **** --- 885,961 ---- } /* + ** Copy1_GX + ** Copy string of one byte characters into SnipData. + ** Conversion table is ignored. In each byte is copied as it is. + ** This is for non-standard (NON ISO 2022) single byte charsets) + */ + #if NeedFunctionPrototypes + static int Copy1_GX(Context *, int, unsigned char *, unsigned char *, char *); + #endif + static int Copy1_GX(cx, n, s, tt, cset) + Context *cx; + int n; + unsigned char *s; + unsigned char *tt; + char *cset; + { + Snip *t; + SnipData *head; + register unsigned char *p; + + if (n <= 0) + return 0; + if (cx == NULL || (t = BeginAppend(cx, n, cset, 1)) == NULL) + return 1; + head = t->head; + p = (unsigned char *)t->data + (head->bytes * t->length); + cx->pendingAccent = 0; + for ( ; n > 0; n -= 1 ) + { + *p++ = *s++; + t->length += 1; + } + return 0; + } + + /* + ** Copy2_GX + ** Copy string of two byte characters into SnipData. + ** Conversion table is ignored. Each byte is copied as it is. + ** This is for non-standard (NON ISO 2022) two byte charsets). + */ + #if NeedFunctionPrototypes + static int Copy2_GX(Context *, int, unsigned char *, unsigned char *, char *); + #endif + static int Copy2_GX(cx, n, s, tt, cset) + Context *cx; + int n; + unsigned char *s; + unsigned char *tt; + char *cset; + { + Snip *t; + SnipData *head; + register unsigned char *p; + + if (n == 0) + return 0; + if (cx == NULL || (t = BeginAppend(cx, n, cset, 2)) == NULL) + return 1; + head = t->head; + p = (unsigned char *)t->data + (head->bytes * t->length); + cx->pendingAccent = 0; /* No support for this here! --msa */ + for ( ; n > 0; n -= 1) + { + *p++ = *s++; + *p++ = *s++; + t->length += 1; + } + return 0; + } + + /* ** ccfilter callback functions */ typedef enum *************** *** 1615,1625 **** break; } /* ! ** As a default, use iso 8859-1 left side for all unsupported. */ g->tt = NULL; ! g->charset = iso8859_1; ! g->move = Copy1_GL; return 1; } --- 1691,1701 ---- break; } /* ! ** Use default-1 for all unknown registrations */ g->tt = NULL; ! g->charset = default_1; ! g->move = Copy1_GX; return 1; } *************** *** 1715,1722 **** break; } g->tt = NULL; ! g->charset = iso8859_1; ! g->move = Copy1_GL; return 1; } /* --- 1791,1798 ---- break; } g->tt = NULL; ! g->charset = default_1; ! g->move = Copy1_GX; return 1; } /* *************** *** 1747,1754 **** g->move = Copy2_GL; return 2; default: ! return 2; } return 2; } --- 1823,1833 ---- g->move = Copy2_GL; return 2; default: ! break; } + g->tt = NULL; + g->charset = default_2; + g->move = Copy2_GX; return 2; } *************** *** 1758,1763 **** --- 1837,1845 ---- static int MultiByteSet96(F, g) int F; GxEntry *g; { + g->tt = NULL; + g->charset = default_2; + g->move = Copy2_GX; return 2; } *************** *** 2042,2047 **** --- 2124,2140 ---- cx->lock.bits = Content_MASK; cx->locked = TRUE; return cx; + } + + /* + ** _XeTextLock + */ + void _XeTextLock(cx, mode) + XeTextInsertContext cx; + int mode; + { + if (cx != NULL) + cx->locked = mode; } /* *** Xew/TextImport.h.orig Fri Mar 4 10:57:26 1994 --- Xew/TextImport.h Thu Mar 17 14:05:43 1994 *************** *** 105,111 **** Snip ** #endif ); ! _XFUNCPROTOEND --- 105,123 ---- Snip ** #endif ); ! ! /* ! ** _XeTextLock ! ** Set the value of the "mode lock" in the context. ! */ ! void _XeTextLock ! ( ! #if NeedFunctionPrototypes ! XeTextInsertContext, ! int ! #endif ! ); ! _XFUNCPROTOEND *** demo/texted.c.orig Wed Mar 16 15:34:39 1994 --- demo/texted.c Thu Mar 17 16:30:44 1994 *************** *** 378,386 **** { Arg args[1]; long start, end; ! XtSetArg(args[0], XtNinitialState, GetCurrentInsertState()); ! XtSetValues(edit_widget, args, 1); /* ** If a selection is currently active, then extract the selected ** text away from the widget, and then replace the text with the --- 378,386 ---- { Arg args[1]; long start, end; + char *prefix = GetCurrentInsertState(); ! XeTextInsertPrefix(edit_widget, prefix, prefix ? strlen(prefix) : 0); /* ** If a selection is currently active, then extract the selected ** text away from the widget, and then replace the text with the *** Xew/RasterPBM.c.orig Mon Feb 28 17:00:52 1994 --- Xew/RasterPBM.c Fri Mar 18 11:02:20 1994 *************** *** 165,171 **** } for (i = 0; i <= maxv; i++) scale[i] = (i * 255) / maxv; ! size = pic->width * pic->bytes_per_line; if (e - p < size) { /* Cope with short files */ --- 165,171 ---- } for (i = 0; i <= maxv; i++) scale[i] = (i * 255) / maxv; ! size = pic->height * pic->bytes_per_line; if (e - p < size) { /* Cope with short files */