[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xterm: Changes to 'upstream-unstable'



 MANIFEST       |    2 
 Tekproc.c      |   55 +++++++--
 button.c       |  336 +++++++++++++++++++++++++++++++++++++++++++--------------
 cachedGCs.c    |    6 -
 charproc.c     |   27 +++-
 input.c        |   80 +++++--------
 main.h         |   18 ++-
 menu.c         |   32 ++---
 minstall.sh    |   14 +-
 misc.c         |   33 ++---
 ptyx.h         |   11 +
 trace.c        |   27 ++++
 trace.h        |   15 ++
 util.c         |    8 -
 version.h      |    4 
 xterm.h        |   17 ++
 xterm.log.html |   54 ++++++++-
 xterm.man      |  127 ++++++++++++++++++++-
 xtermcap.c     |  252 +++++++++++++++++++++++++++---------------
 xtermcap.h     |   20 +--
 20 files changed, 818 insertions(+), 320 deletions(-)

New commits:
commit 5cc6c9ac6341aa3b67f68c5980c6d0349b5cfef0
Author: Julien Cristau <jcristau@debian.org>
Date:   Mon May 25 19:25:59 2009 +0200

    Import xterm 243

diff --git a/MANIFEST b/MANIFEST
index 3aa34db..0a8ae68 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST for xterm-242, version xterm-242
+MANIFEST for xterm-243, version xterm-243
 --------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
diff --git a/Tekproc.c b/Tekproc.c
index 01ae484..6edcee0 100644
--- a/Tekproc.c
+++ b/Tekproc.c
@@ -1,4 +1,4 @@
-/* $XTermId: Tekproc.c,v 1.163 2009/02/13 20:01:21 tom Exp $ */
+/* $XTermId: Tekproc.c,v 1.167 2009/03/28 17:03:35 tom Exp $ */
 
 /*
  * Warning, there be crufty dragons here.
@@ -897,8 +897,8 @@ TekClear(TekWidget tw)
 static void
 TekConfigure(Widget w)
 {
-    if (IsTekWidget(w)) {
-	TekWidget tw = (TekWidget) w;
+    TekWidget tw = getTekWidget(w);
+    if (tw != 0) {
 	TekScreen *tekscr = TekScreenOf(tw);
 	TScreen *screen = TScreenOf(term);
 	int border = 2 * screen->border;
@@ -922,11 +922,11 @@ TekExpose(Widget w,
 	  XEvent * event GCC_UNUSED,
 	  Region region GCC_UNUSED)
 {
-    if (IsTekWidget(w)) {
-	TekWidget tw = (TekWidget) w;
+    TekWidget tw = getTekWidget(w);
+    if (tw != 0) {
 	TekScreen *tekscr = TekScreenOf(tw);
 
-	TRACE(("TekExpose\n"));
+	TRACE(("TekExpose {{\n"));
 
 #ifdef lint
 	region = region;
@@ -937,8 +937,8 @@ TekExpose(Widget w,
 	Tpushback = Tpushb;
 	tekscr->cur_X = 0;
 	tekscr->cur_Y = TEKHOME;
-	TekSetFontSize(tw, tekscr->page.fontsize);
 	tekscr->cur = tekscr->page;
+	TekSetFontSize(tw, tekscr->cur.fontsize);
 	tekscr->margin = MARGIN1;
 	if (tekscr->TekGIN) {
 	    tekscr->TekGIN = NULL;
@@ -952,6 +952,7 @@ TekExpose(Widget w,
 	first_map_occurred();
 	if (!tekscr->waitrefresh)
 	    TekRefresh(tw);
+	TRACE(("}} TekExpose\n"));
     }
 }
 
@@ -979,6 +980,7 @@ TekRefresh(TekWidget tw)
 void
 TekRepaint(TekWidget tw)
 {
+    TRACE(("TekRepaint\n"));
     TekClear(tw);
     TekExpose((Widget) tw, (XEvent *) NULL, (Region) NULL);
 }
@@ -1655,7 +1657,7 @@ TekSetFontSize(TekWidget tw, int newitem)
 	int newsize = MI2FS(newitem);
 	Font fid;
 
-	TRACE(("TekSetFontSize(%d)\n", newitem));
+	TRACE(("TekSetFontSize(%d) size %d ->%d\n", newitem, oldsize, newsize));
 	if (newsize < 0 || newsize >= TEKNUMFONTS) {
 	    Bell(XkbBI_MinorError, 0);
 	} else if (oldsize != newsize) {
@@ -1663,6 +1665,9 @@ TekSetFontSize(TekWidget tw, int newitem)
 		TCursorToggle(tw, TOGGLE);
 	    set_tekfont_menu_item(oldsize, False);
 
+	    tekscr->cur.fontsize = newsize;
+	    tekscr->page.fontsize = newsize;
+
 	    fid = tw->tek.Tfont[newsize]->fid;
 	    if (fid == DefaultGCID) {
 		/* we didn't succeed in opening a real font
@@ -1674,10 +1679,15 @@ TekSetFontSize(TekWidget tw, int newitem)
 		XSetFont(XtDisplay(tw), tekscr->TnormalGC, fid);
 	    }
 
-	    tekscr->cur.fontsize = newsize;
 	    set_tekfont_menu_item(newsize, True);
 	    if (!Ttoggled)
 		TCursorToggle(tw, TOGGLE);
+
+	    /* we'll get an exposure event after changing fontsize, so we
+	     * have to clear the screen to avoid painting over the previous
+	     * text.
+	     */
+	    TekClear(tw);
 	}
     }
 }
@@ -1794,6 +1804,7 @@ TCursorToggle(TekWidget tw, int toggle)		/* TOGGLE or CLEAR */
     if (!TEK4014_SHOWN(term))
 	return;
 
+    TRACE(("TCursorToggle %s\n", (toggle == TOGGLE) ? "toggle" : "clear"));
     c = tekscr->cur.fontsize;
     cellwidth = (unsigned) tw->tek.Tfont[c]->max_bounds.width;
     cellheight = (unsigned) (tw->tek.Tfont[c]->ascent +
@@ -1891,8 +1902,8 @@ HandleGINInput(Widget w,
 	       String * param_list,
 	       Cardinal *nparamsp)
 {
-    if (IsTekWidget(w)) {
-	TekWidget tw = (TekWidget) w;
+    TekWidget tw = getTekWidget(w);
+    if (tw != 0) {
 	TekScreen *tekscr = TekScreenOf(tw);
 
 	if (tekscr->TekGIN && *nparamsp == 1) {
@@ -1916,3 +1927,25 @@ HandleGINInput(Widget w,
 	}
     }
 }
+
+/*
+ * Check if the current widget, or any parent, is the VT100 "xterm" widget.
+ */
+TekWidget
+getTekWidget(Widget w)
+{
+    TekWidget xw;
+
+    if (w == 0) {
+	xw = (TekWidget) CURRENT_EMU();
+	if (!IsTekWidget(xw)) {
+	    xw = 0;
+	}
+    } else if (IsTekWidget(w)) {
+	xw = (TekWidget) w;
+    } else {
+	xw = getTekWidget(XtParent(w));
+    }
+    TRACE2(("getTekWidget %p -> %p\n", w, xw));
+    return xw;
+}
diff --git a/button.c b/button.c
index 70e8ffc..86e7392 100644
--- a/button.c
+++ b/button.c
@@ -1,4 +1,4 @@
-/* $XTermId: button.c,v 1.306 2009/02/13 21:09:08 tom Exp $ */
+/* $XTermId: button.c,v 1.320 2009/03/27 00:00:56 tom Exp $ */
 
 /*
  * Copyright 1999-2008,2009 by Thomas E. Dickey
@@ -1076,12 +1076,12 @@ DECtoASCII(unsigned ch)
  */
 #if OPT_WIDE_CHARS
 static Char *
-UTF8toLatin1(Char * s, unsigned len, unsigned long *result)
+UTF8toLatin1(TScreen * screen, Char * s, unsigned len, unsigned long *result)
 {
     static Char *buffer;
     static Cardinal used;
 
-    Char *q;
+    Char *p, *q;
 
     if (len > used) {
 	used = 1 + (2 * len);
@@ -1094,9 +1094,11 @@ UTF8toLatin1(Char * s, unsigned len, unsigned long *result)
 	q = buffer;
 	fakePtyData(&data, s, s + len);
 	while (decodeUtf8(&data)) {
+	    Bool fails = False;
+	    Bool extra = False;
 	    IChar value = skipPtyData(&data);
 	    if (value == UCS_REPL) {
-		*q++ = '#';
+		fails = True;
 	    } else if (value < 256) {
 		*q++ = CharOf(value);
 	    } else {
@@ -1105,13 +1107,33 @@ UTF8toLatin1(Char * s, unsigned len, unsigned long *result)
 		    *q++ = (Char) DECtoASCII(eqv);
 		} else {
 		    eqv = AsciiEquivs(value);
-		    if (eqv == value)
-			eqv = '#';
-		    *q++ = (Char) eqv;
+		    if (eqv == value) {
+			fails = True;
+		    } else {
+			*q++ = (Char) eqv;
+		    }
 		    if (isWide((wchar_t) value))
-			*q++ = ' ';
+			extra = True;
+		}
+	    }
+
+	    /*
+	     * If we're not able to plug in a single-byte result, insert the
+	     * defaultString (which normally is a single "#", but could be
+	     * whatever the user wants).
+	     */
+	    if (fails) {
+		for (p = (Char *) screen->default_string; *p != '\0'; ++p) {
+		    len = (unsigned) (3 + q - buffer);
+		    if (len >= used) {
+			used = 1 + (2 * len);
+			allocXtermChars(&buffer, used);
+		    }
+		    *q++ = *p;
 		}
 	    }
+	    if (extra)
+		*q++ = ' ';
 	}
 	*q = 0;
 	*result = (unsigned long) (q - buffer);
@@ -1122,64 +1144,208 @@ UTF8toLatin1(Char * s, unsigned len, unsigned long *result)
 }
 #endif /* OPT_WIDE_CHARS */
 
-static Atom *
-_SelectionTargets(Widget w)
+static char *
+parseItem(char *value, char *nextc)
 {
-    static Atom *eightBitSelectionTargets = NULL;
-    TScreen *screen;
-    int n;
+    char *nextp = value;
+    while (*nextp != '\0' && *nextp != ',') {
+	*nextp = x_toupper(*nextp);
+	++nextp;
+    }
+    *nextc = *nextp;
+    *nextp = '\0';
+    x_strtrim(value);
+
+    return nextp;
+}
+
+/*
+ * All of the wanted strings are unique in the first character, so we can
+ * use simple abbreviations.
+ */
+static Bool
+sameItem(const char *actual, const char *wanted)
+{
+    Bool result = False;
+    size_t have = strlen(actual);
+    size_t need = strlen(wanted);
+
+    if (have != 0 && have <= need) {
+	if (!strncmp(actual, wanted, have)) {
+	    TRACE(("...matched \"%s\"\n", wanted));
+	    result = True;
+	}
+    }
+
+    return result;
+}
 
+/*
+ * Handle the eightBitSelectTypes or utf8SelectTypes resource values.
+ */
+static Bool
+overrideTargets(Widget w, String value, Atom ** resultp)
+{
+    Bool override = False;
     XtermWidget xw;
 
-    if ((xw = getXtermWidget(w)) == 0)
-	return NULL;
+    if ((xw = getXtermWidget(w)) != 0) {
+	TScreen *screen = TScreenOf(xw);
 
-    screen = TScreenOf(xw);
+	if (value != 0 && *value != '\0') {
+	    String copied = x_strdup(value);
+	    if (copied != 0) {
+		Atom *result = 0;
+		Cardinal count = 1;
+		int n;
+
+		TRACE(("decoding SelectTypes \"%s\"\n", value));
+		for (n = 0; copied[n] != '\0'; ++n) {
+		    if (copied[n] == ',')
+			++count;
+		}
+		result = (Atom *) XtMalloc(((2 * count) + 1) * sizeof(Atom));
+		if (result == NULL) {
+		    TRACE(("Couldn't allocate selection types\n"));
+		} else {
+		    char nextc = '?';
+		    char *listp = copied;
+		    count = 0;
+		    do {
+			char *nextp = parseItem(listp, &nextc);
+			size_t len = strlen(listp);
+
+			if (len == 0) {
+			    ;
+			}
+#if OPT_WIDE_CHARS
+			else if (sameItem(listp, "UTF8")) {
+			    result[count++] = XA_UTF8_STRING(XtDisplay(w));
+			}
+#endif
+			else if (sameItem(listp, "I18N")) {
+			    if (screen->i18nSelections) {
+				result[count++] = XA_TEXT(XtDisplay(w));
+				result[count++] = XA_COMPOUND_TEXT(XtDisplay(w));
+			    }
+			} else if (sameItem(listp, "TEXT")) {
+			    result[count++] = XA_TEXT(XtDisplay(w));
+			} else if (sameItem(listp, "COMPOUND_TEXT")) {
+			    result[count++] = XA_COMPOUND_TEXT(XtDisplay(w));
+			} else if (sameItem(listp, "STRING")) {
+			    result[count++] = XA_STRING;
+			}
+			*nextp++ = nextc;
+			listp = nextp;
+		    } while (nextc != '\0');
+		    if (count) {
+			result[count] = None;
+			override = True;
+			*resultp = result;
+		    } else {
+			XtFree((char *) result);
+		    }
+		}
+	    } else {
+		TRACE(("Couldn't allocate copy of selection types\n"));
+	    }
+	}
+    }
+    return override;
+}
 
 #if OPT_WIDE_CHARS
-    if (screen->wide_chars) {
-	static Atom *utf8SelectionTargets = NULL;
+static Atom *
+allocUtf8Targets(Widget w, TScreen * screen)
+{
+    Atom **resultp = &(screen->selection_targets_utf8);
 
-	if (utf8SelectionTargets == NULL) {
-	    utf8SelectionTargets = (Atom *) XtMalloc(5 * sizeof(Atom));
-	    if (utf8SelectionTargets == NULL) {
-		TRACE(("Couldn't allocate utf8SelectionTargets\n"));
-		return NULL;
-	    }
-	    n = 0;
-	    utf8SelectionTargets[n++] = XA_UTF8_STRING(XtDisplay(w));
+    if (*resultp == 0) {
+	Atom *result;
+
+	if (!overrideTargets(w, screen->utf8_select_types, &result)) {
+	    result = (Atom *) XtMalloc(5 * sizeof(Atom));
+	    if (result == NULL) {
+		TRACE(("Couldn't allocate utf-8 selection targets\n"));
+	    } else {
+		int n = 0;
+
+		result[n++] = XA_UTF8_STRING(XtDisplay(w));
 #ifdef X_HAVE_UTF8_STRING
-	    if (screen->i18nSelections) {
-		utf8SelectionTargets[n++] = XA_TEXT(XtDisplay(w));
-		utf8SelectionTargets[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
-	    }
+		if (screen->i18nSelections) {
+		    result[n++] = XA_TEXT(XtDisplay(w));
+		    result[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
+		}
 #endif
-	    utf8SelectionTargets[n++] = XA_STRING;
-	    utf8SelectionTargets[n] = None;
+		result[n++] = XA_STRING;
+		result[n] = None;
+	    }
 	}
-	return utf8SelectionTargets;
+
+	*resultp = result;
     }
+
+    return *resultp;
+}
 #endif
 
-    /* not screen->wide_chars */
-    if (eightBitSelectionTargets == NULL) {
-	eightBitSelectionTargets = (Atom *) XtMalloc(5 * sizeof(Atom));
-	if (eightBitSelectionTargets == NULL) {
-	    TRACE(("Couldn't allocate eightBitSelectionTargets\n"));
-	    return NULL;
-	}
-	n = 0;
+static Atom *
+alloc8bitTargets(Widget w, TScreen * screen)
+{
+    Atom **resultp = &(screen->selection_targets_8bit);
+
+    if (*resultp == 0) {
+	Atom *result = 0;
+
+	if (!overrideTargets(w, screen->eightbit_select_types, &result)) {
+	    result = (Atom *) XtMalloc(5 * sizeof(Atom));
+	    if (result == NULL) {
+		TRACE(("Couldn't allocate 8bit selection targets\n"));
+	    } else {
+		int n = 0;
+
 #ifdef X_HAVE_UTF8_STRING
-	eightBitSelectionTargets[n++] = XA_UTF8_STRING(XtDisplay(w));
+		result[n++] = XA_UTF8_STRING(XtDisplay(w));
+#endif
+		if (screen->i18nSelections) {
+		    result[n++] = XA_TEXT(XtDisplay(w));
+		    result[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
+		}
+		result[n++] = XA_STRING;
+		result[n] = None;
+	    }
+	}
+
+	*resultp = result;
+    }
+
+    return *resultp;
+}
+
+static Atom *
+_SelectionTargets(Widget w)
+{
+    Atom *result;
+    TScreen *screen;
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) == 0) {
+	result = NULL;
+    } else {
+	screen = TScreenOf(xw);
+
+#if OPT_WIDE_CHARS
+	if (screen->wide_chars) {
+	    result = allocUtf8Targets(w, screen);
+	} else
 #endif
-	if (screen->i18nSelections) {
-	    eightBitSelectionTargets[n++] = XA_TEXT(XtDisplay(w));
-	    eightBitSelectionTargets[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
+	{
+	    /* not screen->wide_chars */
+	    result = alloc8bitTargets(w, screen);
 	}
-	eightBitSelectionTargets[n++] = XA_STRING;
-	eightBitSelectionTargets[n] = None;
     }
-    return eightBitSelectionTargets;
+
+    return result;
 }
 
 #define isSELECT(value) (!strcmp(value, "SELECT"))
@@ -1321,14 +1487,16 @@ xtermGetSelection(Widget w,
     if ((xw = getXtermWidget(w)) == 0)
 	return;
 
-    TRACE(("xtermGetSelection\n"));
+    TRACE(("xtermGetSelection num_params %d\n", num_params));
     params = MapSelections(xw, params, num_params);
 
     XmuInternStrings(XtDisplay(w), params, (Cardinal) 1, &selection);
     cutbuffer = CutBuffer(selection);
 
-    TRACE(("Cutbuffer: %d, target: %lu\n", cutbuffer,
-	   targets ? (unsigned long) targets[0] : 0));
+    TRACE(("Cutbuffer: %d, target: %s\n", cutbuffer,
+	   (targets
+	    ? visibleSelectionTarget(XtDisplay(w), targets[0])
+	    : "None")));
 
     if (cutbuffer >= 0) {
 	int inbytes;
@@ -1618,6 +1786,11 @@ SelectionReceived(Widget w,
     text_prop.format = *format;
     text_prop.nitems = *length;
 
+    TRACE(("SelectionReceived %s format %d, nitems %ld\n",
+	   visibleSelectionTarget(dpy, text_prop.encoding),
+	   text_prop.format,
+	   text_prop.nitems));
+
 #if OPT_WIDE_CHARS
     if (screen->wide_chars) {
 	if (*type == XA_UTF8_STRING(dpy) ||
@@ -1664,7 +1837,7 @@ SelectionReceived(Widget w,
 		    for (i = 0; i < text_list_count; ++i) {
 			data = (Char *) text_list[i];
 			size = strlen(text_list[i]) + 1;
-			data = UTF8toLatin1(data, size, &size);
+			data = UTF8toLatin1(screen, data, size, &size);
 			new_size += size + 1;
 		    }
 		    new_text_list =
@@ -1673,7 +1846,7 @@ SelectionReceived(Widget w,
 		    for (i = 0; i < text_list_count; ++i) {
 			data = (Char *) text_list[i];
 			size = strlen(text_list[i]) + 1;
-			data = UTF8toLatin1(data, size, &size);
+			data = UTF8toLatin1(screen, data, size, &size);
 			memcpy(tmp, data, size + 1);
 			new_text_list[i] = tmp;
 			tmp += size + 1;
@@ -1737,6 +1910,8 @@ SelectionReceived(Widget w,
   fail:
     if (client_data != 0) {
 	struct _SelectionList *list = (struct _SelectionList *) client_data;
+
+	TRACE(("SelectionReceived ->xtermGetSelection\n"));
 	xtermGetSelection(w, list->time,
 			  list->params, list->count, list->targets);
 	XtFree((char *) client_data);
@@ -3012,15 +3187,14 @@ SaltTextAway(XtermWidget xw,
     TScreen *screen = TScreenOf(xw);
     int i, j = 0;
     int eol;
+    int tmp;
     Char *line;
     Char *lp;
     CELL first = *cellc;
     CELL last = *cell;
 
     if (isSameRow(&first, &last) && first.col > last.col) {
-	int tmp = first.col;
-	first.col = last.col;
-	last.col = tmp;
+	EXCHANGE(first.col, last.col, tmp);
     }
 
     --last.col;
@@ -3259,6 +3433,9 @@ ConvertSelection(Widget w,
     if (screen->selection_data == NULL)
 	return False;		/* can this happen? */
 
+    TRACE(("ConvertSelection %s\n",
+	   visibleSelectionTarget(dpy, *target)));
+
     if (*target == XA_TARGETS(dpy)) {
 	Atom *allocP;
 	Atom *targetP;
@@ -3266,10 +3443,12 @@ ConvertSelection(Widget w,
 	XPointer std_return = 0;
 	unsigned long std_length;
 
-	TRACE(("ConvertSelection XA_TARGETS(dpy)\n"));
 	if (XmuConvertStandardSelection(w, screen->selection_time, selection,
 					target, type, &std_return,
 					&std_length, format)) {
+	    Atom *my_targets = _SelectionTargets(w);
+
+	    TRACE(("XmuConvertStandardSelection - success\n"));
 	    std_targets = (Atom *) (std_return);
 	    *length = std_length + 6;
 
@@ -3278,18 +3457,9 @@ ConvertSelection(Widget w,
 
 	    *value = (XtPointer) targetP;
 
-	    *targetP++ = XA_STRING;
-	    *targetP++ = XA_TEXT(dpy);
-#ifdef X_HAVE_UTF8_STRING
-	    *targetP++ = XA_COMPOUND_TEXT(dpy);
-	    *targetP++ = XA_UTF8_STRING(dpy);
-#else
-	    *targetP = XA_COMPOUND_TEXT(dpy);
-	    if_OPT_WIDE_CHARS(screen, {
-		*targetP = XA_UTF8_STRING(dpy);
-	    });
-	    targetP++;
-#endif
+	    while (*my_targets != None) {
+		*targetP++ = *my_targets++;
+	    }
 	    *targetP++ = XA_LENGTH(dpy);
 	    *targetP++ = XA_LIST_LENGTH(dpy);
 
@@ -3300,37 +3470,39 @@ ConvertSelection(Widget w,
 	    *type = XA_ATOM;
 	    *format = 32;
 	    result = True;
+	} else {
+	    TRACE(("XmuConvertStandardSelection - failed\n"));
 	}
     }
 #if OPT_WIDE_CHARS
     else if (screen->wide_chars && *target == XA_STRING) {
-	TRACE(("ConvertSelection XA_STRING - wide\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    Xutf8TextListToTextProperty,
 				    XStringStyle);
+	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
     } else if (screen->wide_chars && *target == XA_UTF8_STRING(dpy)) {
-	TRACE(("ConvertSelection XA_UTF8_STRING(dpy) - wide\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    Xutf8TextListToTextProperty,
 				    XUTF8StringStyle);
+	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
     } else if (screen->wide_chars && *target == XA_TEXT(dpy)) {
-	TRACE(("ConvertSelection XA_TEXT(dpy) - wide\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    Xutf8TextListToTextProperty,
 				    XStdICCTextStyle);
+	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
     } else if (screen->wide_chars && *target == XA_COMPOUND_TEXT(dpy)) {
-	TRACE(("ConvertSelection XA_COMPOUND_TEXT(dpy) - wide\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    Xutf8TextListToTextProperty,
 				    XCompoundTextStyle);
+	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
     }
 #endif
 
@@ -3341,56 +3513,56 @@ ConvertSelection(Widget w,
 	   properly internationalised, and dump raw eight-bit data
 	   with no conversion into the selection.  Yes, this breaks
 	   the ICCCM in non-Latin-1 locales. */
-	TRACE(("ConvertSelection XA_STRING\n"));
 	*type = XA_STRING;
 	*value = (XtPointer) screen->selection_data;
 	*length = screen->selection_length;
 	*format = 8;
 	result = True;
+	TRACE(("...raw 8-bit data:%d\n", result));
     } else if (*target == XA_TEXT(dpy)) {	/* not wide_chars */
-	TRACE(("ConvertSelection XA_TEXT(dpy)\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    XmbTextListToTextProperty,
 				    XStdICCTextStyle);
+	TRACE(("...XmbTextListToTextProperty(StdICC):%d\n", result));
     } else if (*target == XA_COMPOUND_TEXT(dpy)) {	/* not wide_chars */
-	TRACE(("ConvertSelection XA_COMPOUND_TEXT(dpy)\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    XmbTextListToTextProperty,
 				    XCompoundTextStyle);
+	TRACE(("...XmbTextListToTextProperty(Compound):%d\n", result));
     }
 #ifdef X_HAVE_UTF8_STRING
     else if (*target == XA_UTF8_STRING(dpy)) {	/* not wide_chars */
-	TRACE(("ConvertSelection XA_UTF8_STRING(dpy)\n"));
 	result =
 	    _ConvertSelectionHelper(w,
 				    type, value, length, format,
 				    XmbTextListToTextProperty,
 				    XUTF8StringStyle);
+	TRACE(("...XmbTextListToTextProperty(UTF8):%d\n", result));
     }
 #endif
     else if (*target == XA_LIST_LENGTH(dpy)) {
-	TRACE(("ConvertSelection XA_LIST_LENGTH(dpy)\n"));
 	result = SaveConvertedLength(value, 1);
 	*type = XA_INTEGER;
 	*length = 1;
 	*format = 32;
+	TRACE(("...list of values:%d\n", result));
     } else if (*target == XA_LENGTH(dpy)) {
-	TRACE(("ConvertSelection XA_LENGTH(dpy)\n"));
 	/* This value is wrong if we have UTF-8 text */
 	result = SaveConvertedLength(value, screen->selection_length);
 	*type = XA_INTEGER;
 	*length = 1;
 	*format = 32;
+	TRACE(("...list of values:%d\n", result));
     } else if (XmuConvertStandardSelection(w,
 					   screen->selection_time, selection,
 					   target, type, (XPointer *) value,
 					   length, format)) {
-	TRACE(("ConvertSelection XmuConvertStandardSelection\n"));
 	result = True;
+	TRACE(("...XmuConvertStandardSelection:%d\n", result));
     }
 
     /* else */
@@ -3458,7 +3630,7 @@ _OwnSelection(XtermWidget xw,
     if (screen->selection_length == 0)
 	return;
 
-    TRACE(("_OwnSelection\n"));
+    TRACE(("_OwnSelection count %d\n", count));
     selections = MapSelections(xw, selections, count);
 
     if (count > screen->sel_atoms_size) {
@@ -3486,7 +3658,7 @@ _OwnSelection(XtermWidget xw,
 		unsigned long length = screen->selection_length;
 		Char *data = screen->selection_data;
 		if_OPT_WIDE_CHARS((screen), {
-		    data = UTF8toLatin1(data, length, &length);
+		    data = UTF8toLatin1(screen, data, length, &length);
 		});
 		TRACE(("XStoreBuffer(%d)\n", cutbuffer));
 		XStoreBuffer(XtDisplay((Widget) xw),
diff --git a/cachedGCs.c b/cachedGCs.c
index 88819fc..3c525ee 100644
--- a/cachedGCs.c
+++ b/cachedGCs.c
@@ -1,4 +1,4 @@
-/* $XTermId: cachedGCs.c,v 1.51 2009/02/13 00:37:46 tom Exp $ */
+/* $XTermId: cachedGCs.c,v 1.52 2009/03/26 23:59:32 tom Exp $ */
 
 /************************************************************
 
@@ -812,9 +812,7 @@ swapCgs(XtermWidget xw, VTwin * cgsWin, CgsEnum dstCgsId, CgsEnum srcCgsId)
 		int srcIndex = dataIndex(src);
 		int dstIndex = dataIndex(dst);
 
-		tmp = *dst;
-		*dst = *src;
-		*src = tmp;
+		EXCHANGE(*src, *dst, tmp);
 
 		relinkData(src, dstIndex);
 		relinkData(dst, srcIndex);
diff --git a/charproc.c b/charproc.c
index 97e1c9d..f2f3136 100644
--- a/charproc.c
+++ b/charproc.c
@@ -1,4 +1,4 @@
-/* $XTermId: charproc.c,v 1.892 2009/02/13 21:15:35 tom Exp $ */
+/* $XTermId: charproc.c,v 1.897 2009/03/29 00:23:12 tom Exp $ */
 
 /*
 
@@ -395,10 +395,10 @@ static XtActionsRec actionsList[] = {
 static XtResource resources[] =
 {
     Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False),
-    Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, True),
-    Bres(XtNallowTcapOps, XtCAllowTcapOps, screen.allowTcapOp0, False),
-    Bres(XtNallowTitleOps, XtCAllowTitleOps, screen.allowTitleOp0, True),
-    Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, True),
+    Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, DEF_ALLOW_FONT),
+    Bres(XtNallowTcapOps, XtCAllowTcapOps, screen.allowTcapOp0, DEF_ALLOW_TCAP),
+    Bres(XtNallowTitleOps, XtCAllowTitleOps, screen.allowTitleOp0, DEF_ALLOW_TITLE),
+    Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, DEF_ALLOW_FONT),
     Bres(XtNaltIsNotMeta, XtCAltIsNotMeta, screen.alt_is_not_meta, False),
     Bres(XtNaltSendsEscape, XtCAltSendsEscape, screen.alt_sends_esc, False),
     Bres(XtNalwaysBoldMode, XtCAlwaysBoldMode, screen.always_bold_mode, False),
@@ -474,10 +474,14 @@ static XtResource resources[] =
     Sres(XtNfont4, XtCFont4, screen.MenuFontName(fontMenu_font4), NULL),
     Sres(XtNfont5, XtCFont5, screen.MenuFontName(fontMenu_font5), NULL),
     Sres(XtNfont6, XtCFont6, screen.MenuFontName(fontMenu_font6), NULL),
+
     Sres(XtNanswerbackString, XtCAnswerbackString, screen.answer_back, ""),
     Sres(XtNboldFont, XtCBoldFont, misc.default_font.f_b, DEFBOLDFONT),
     Sres(XtNcharClass, XtCCharClass, screen.charClass, NULL),
     Sres(XtNdecTerminalID, XtCDecTerminalID, screen.term_id, DFT_DECID),
+    Sres(XtNdefaultString, XtCDefaultString, screen.default_string, "#"),
+    Sres(XtNeightBitSelectTypes, XtCEightBitSelectTypes,
+	 screen.eightbit_select_types, NULL),
     Sres(XtNfont, XtCFont, misc.default_font.f_n, DEFFONT),
     Sres(XtNgeometry, XtCGeometry, misc.geo_metry, NULL),
     Sres(XtNkeyboardDialect, XtCKeyboardDialect, screen.keyboard_dialect, DFT_KBD_DIALECT),
@@ -669,6 +673,7 @@ static XtResource resources[] =
     Ires(XtNutf8, XtCUtf8, screen.utf8_mode, uDefault),
     Sres(XtNwideBoldFont, XtCWideBoldFont, misc.default_font.f_wb, DEFWIDEBOLDFONT),
     Sres(XtNwideFont, XtCWideFont, misc.default_font.f_w, DEFWIDEFONT),
+    Sres(XtNutf8SelectTypes, XtCUtf8SelectTypes, screen.utf8_select_types, NULL),
 #endif
 
 #if OPT_LUIT_PROG
@@ -3731,9 +3736,9 @@ HandleStructNotify(Widget w GCC_UNUSED,
 
 #if OPT_BLINK_CURS
 static void
-SetCursorBlink(TScreen * screen, Boolean enable)
+SetCursorBlink(TScreen * screen, Bool enable)
 {
-    screen->cursor_blink = enable;
+    screen->cursor_blink = (Boolean) enable;
     if (DoStartBlinking(screen)) {
 	StartBlinking(screen);
     } else {
@@ -3747,7 +3752,7 @@ SetCursorBlink(TScreen * screen, Boolean enable)
 void
 ToggleCursorBlink(TScreen * screen)
 {
-    SetCursorBlink(screen, (Boolean) (!(screen->cursor_blink)));
+    SetCursorBlink(screen, (Bool) (!(screen->cursor_blink)));
 }
 #endif
 
@@ -5602,6 +5607,12 @@ VTInitialize(Widget wrequest,
     init_Bres(screen.allowTitleOp0);
     init_Bres(screen.allowWindowOp0);
 
+    init_Sres(screen.default_string);
+    init_Sres(screen.eightbit_select_types);
+#if OPT_WIDE_CHARS
+    init_Sres(screen.utf8_select_types);
+#endif
+
     /* make a copy so that editres cannot change the resource after startup */
     wnew->screen.allowSendEvents = wnew->screen.allowSendEvent0;
     wnew->screen.allowFontOps = wnew->screen.allowFontOp0;
diff --git a/input.c b/input.c
index 76e48c4..7de33bf 100644
--- a/input.c
+++ b/input.c
@@ -1,4 +1,4 @@
-/* $XTermId: input.c,v 1.304 2009/01/26 00:09:29 tom Exp $ */
+/* $XTermId: input.c,v 1.307 2009/03/15 18:53:57 tom Exp $ */
 
 /*
  * Copyright 1999-2008,2009 by Thomas E. Dickey
@@ -342,35 +342,23 @@ allowModifierParm(XtermWidget xw, KEY_DATA * kd)
 *       Meta+Ctrl+Alt+Shift  16 = 1(None)+8(Meta)+1(Shift)+2(Alt)+4(Ctrl)
 */
 
-#undef CTRL
-
-/* FIXME - make these used in xtermcap.c */
-#define	UNMOD	1
-#define	SHIFT	1
-#define	ALT	2
-#define	CTRL	4
-#define	META	8
-
-#define MODIFIER_NAME(parm, name) \
-	(((parm > UNMOD) && ((parm - UNMOD) & name)) ? " "#name : "")
-
 unsigned
 xtermParamToState(XtermWidget xw, unsigned param)
 {
     unsigned result = 0;
 #if OPT_NUM_LOCK
-    if (param > UNMOD
+    if (param > MOD_NONE
 	&& ((ShiftMask
 	     | ControlMask
 	     | xw->misc.alt_mods
 	     | xw->misc.meta_mods) & xw->misc.other_mods) == 0) {
-	if ((param - UNMOD) & SHIFT)
+	if ((param - MOD_NONE) & MOD_SHIFT)
 	    result |= ShiftMask;
-	if ((param - UNMOD) & CTRL)
+	if ((param - MOD_NONE) & MOD_CTRL)
 	    result |= ControlMask;
-	if ((param - UNMOD) & ALT)
+	if ((param - MOD_NONE) & MOD_ALT)
 	    result |= xw->misc.alt_mods;
-	if ((param - UNMOD) & META)
+	if ((param - MOD_NONE) & MOD_META)
 	    result |= xw->misc.meta_mods;
     }
 #else
@@ -378,10 +366,10 @@ xtermParamToState(XtermWidget xw, unsigned param)
     (void) param;
 #endif
     TRACE(("xtermParamToState(%d) %s%s%s%s -> %#x\n", param,
-	   MODIFIER_NAME(param, SHIFT),
-	   MODIFIER_NAME(param, ALT),
-	   MODIFIER_NAME(param, CTRL),
-	   MODIFIER_NAME(param, META),
+	   MODIFIER_NAME(param, MOD_SHIFT),
+	   MODIFIER_NAME(param, MOD_ALT),
+	   MODIFIER_NAME(param, MOD_CTRL),
+	   MODIFIER_NAME(param, MOD_META),
 	   result));
     return result;
 }
@@ -389,36 +377,39 @@ xtermParamToState(XtermWidget xw, unsigned param)
 unsigned
 xtermStateToParam(XtermWidget xw, unsigned state)
 {
-    unsigned modify_parm = UNMOD;
+    unsigned modify_parm = MOD_NONE;
 
+    TRACE(("xtermStateToParam %#x\n", state));
 #if OPT_NUM_LOCK
     if ((state & xw->misc.other_mods) == 0) {
 	if (state & ShiftMask) {
-	    modify_parm += SHIFT;
+	    modify_parm += MOD_SHIFT;
 	    state &= ~ShiftMask;
 	}
 	if (state & ControlMask) {
-	    modify_parm += CTRL;
+	    modify_parm += MOD_CTRL;
 	    state &= ~ControlMask;
 	}
 	if ((state & xw->misc.alt_mods) != 0) {
-	    modify_parm += ALT;
+	    modify_parm += MOD_ALT;
 	    state &= ~xw->misc.alt_mods;
 	}
 	if ((state & xw->misc.meta_mods) != 0) {
-	    modify_parm += META;
+	    modify_parm += MOD_META;
 	    state &= ~xw->misc.meta_mods;
 	}
     }
+    if (modify_parm == MOD_NONE)
+	modify_parm = 0;
 #else
     (void) xw;
     (void) state;
 #endif
     TRACE(("...xtermStateToParam %d%s%s%s%s\n", modify_parm,
-	   MODIFIER_NAME(modify_parm, SHIFT),
-	   MODIFIER_NAME(modify_parm, ALT),
-	   MODIFIER_NAME(modify_parm, CTRL),
-	   MODIFIER_NAME(modify_parm, META)));
+	   MODIFIER_NAME(modify_parm, MOD_SHIFT),
+	   MODIFIER_NAME(modify_parm, MOD_ALT),
+	   MODIFIER_NAME(modify_parm, MOD_CTRL),
+	   MODIFIER_NAME(modify_parm, MOD_META)));
     return modify_parm;
 }
 
@@ -572,26 +563,25 @@ ModifyOtherKeys(XtermWidget xw,
 		    break;
 #ifdef XK_ISO_Left_Tab
 		case XK_ISO_Left_Tab:
-		    if (computeMaskedModifier(xw, state, ShiftMask) > 1)
+		    if (computeMaskedModifier(xw, state, ShiftMask))
 			result = True;
 		    break;
 #endif
 		case XK_Return:
 		case XK_Tab:
-		    result = (modify_parm > 1);
+		    result = (modify_parm != 0);
 		    break;
 		default:
 		    if (IsControlInput(kd)) {
 			if (state == ControlMask || state == ShiftMask) {
 			    result = False;
 			} else {
-			    result = (modify_parm > 1);
+			    result = (modify_parm != 0);
 			}
 		    } else if (IsControlAlias(kd)) {
 			if (state == ShiftMask)
 			    result = False;
-			else if (computeMaskedModifier(xw, state, ControlMask)


Reply to: