MANIFEST | 2 Tekproc.c | 55 +++- button.c | 336 ++++++++++++++++++++++-------- cachedGCs.c | 6 charproc.c | 27 +- debian/changelog | 11 debian/local/xterm.faq.html | 38 +++ debian/patches/901_xterm_manpage.diff | 8 debian/patches/902_pointermode_never.diff | 8 debian/patches/903_windowops.diff | 19 - debian/patches/904_fontops.diff | 19 - debian/rules | 5 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 - 27 files changed, 883 insertions(+), 363 deletions(-)
New commits: commit 3f29c6fb445555b40b9ecb062c2a6f172023c51c Author: Julien Cristau <jcris...@debian.org> Date: Mon May 25 19:59:05 2009 +0200 Prepare changelog for upload diff --git a/debian/changelog b/debian/changelog index a47cc0c..90f5d2f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -xterm (243-1) UNRELEASED; urgency=low +xterm (243-1) unstable; urgency=low * New upstream release (closes: #526334) + fixes bell regression (closes: #520405) @@ -7,7 +7,7 @@ xterm (243-1) UNRELEASED; urgency=low instead of the relevant patches, which now only touch the manpage. * Update copy of XTerm FAQ to revision 1.105 (dated 2009/01/11). - -- Julien Cristau <jcris...@debian.org> Mon, 25 May 2009 19:32:11 +0200 + -- Julien Cristau <jcris...@debian.org> Mon, 25 May 2009 19:58:19 +0200 xterm (242-1) unstable; urgency=low commit f62506242b58320d56589448851e5a8e54636c23 Author: Julien Cristau <jcris...@debian.org> Date: Mon May 25 19:58:17 2009 +0200 Update copy of XTerm FAQ to revision 1.105 (dated 2009/01/11). diff --git a/debian/changelog b/debian/changelog index 01ce42d..a47cc0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ xterm (243-1) UNRELEASED; urgency=low * Refresh patch stack. * Defaults for allow-{tcap,window,font}ops are now set from debian/rules instead of the relevant patches, which now only touch the manpage. + * Update copy of XTerm FAQ to revision 1.105 (dated 2009/01/11). -- Julien Cristau <jcris...@debian.org> Mon, 25 May 2009 19:32:11 +0200 diff --git a/debian/local/xterm.faq.html b/debian/local/xterm.faq.html index e414fb1..c5f3e3a 100644 --- a/debian/local/xterm.faq.html +++ b/debian/local/xterm.faq.html @@ -1,7 +1,7 @@ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <!-- ***************************************************************************** - * Copyright 1997-2005,2007 by Thomas E. Dickey * + * Copyright 1997-2007,2009 by Thomas E. Dickey * * All Rights Reserved. * * * * Permission to use, copy, modify, and distribute this software and its * @@ -20,7 +20,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * ***************************************************************************** - $XTermId: xterm.faq.html,v 1.99 2007/11/29 22:26:28 tom Exp $ + $XTermId: xterm.faq.html,v 1.105 2009/01/11 01:27:40 tom Exp $ --> <HTML> <HEAD> @@ -30,7 +30,7 @@ </HEAD> <BODY> <HR> -Copyright 1997-2005,2007 by Thomas E. Dickey +Copyright 1997-2007,2009 by Thomas E. Dickey <HR> <H1>Contents</H1> <UL> @@ -937,6 +937,7 @@ and XFree86 xterm <LI><A HREF="#no_color">My terminal doesn't recognize color</A> <LI><A HREF="#xterm_terminfo">What $TERM should I use?</A> <LI><A HREF="#xterm_hilite">Reverse video is not reset</A> +<LI><A HREF="#vim_16colors">My colors changed in vim</A> </ul> <li>Odd behavior <ul> @@ -1412,6 +1413,37 @@ newer xterm. <p> However - see <a href="#xterm_terminfo">below</a>. +<H2><A NAME="vim_16colors">My colors changed in vim</A></H2> +Some <code>vim</code> users may notice their colors change after +updating to <a href="xterm.log.html#xterm_238">patch 238</a>. +Before, some text would display in a dark color using a bold font. +Now, it displays in a bright color and normal font. +<p> +This is not a bug, but the result of a feature <em>tcap-query</em> +which was added for vim in 2000. +Several vim users requested that it be enabled by default +in the configure script. +It allows vim to ask what characters the different function keys actually +send, eliminating the chance that the termcap does not match. +<p> +Vim also asks how many colors the terminal supports. +Since <a href="xterm.log.html#xterm_148">patch 148</a>, +xterm has responded with the number of distinct colors that it can display. +By default, that is 16 (8 ANSI colors with bright counterparts for displaying +PC-style "bold" text). +<p> +The interpretation of this depends on the application: +termcaps do not tell how to display more than 8 colors. +But vim understands how to tell xterm to display using 16 colors. +It makes a difference when displaying bright colors. +Vim has a table of 16 color names ("dos-colors"), which one can use to +define parts of the color scheme. +If the terminal supports only 8 colors (colors 0-7), +vim uses the bold attribute to simulate colors 8-15. +<p> +Changing the color scheme to use bold where it is wanted will make the +colors work as before – and work consistently with other terminals. + <H2><A NAME="xterm_terminfo">What $TERM should I use?</A></H2> <p> The <code>xterm-color</code> value for $TERM commit 51844f1e13766355f8eec88500c70209af12066a Author: Julien Cristau <jcris...@debian.org> Date: Mon May 25 19:50:48 2009 +0200 Refresh patch stack. Defaults for allow-{tcap,window,font}ops are now set from debian/rules instead of the relevant patches, which now only touch the manpage. diff --git a/debian/changelog b/debian/changelog index dba17f3..01ce42d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ xterm (243-1) UNRELEASED; urgency=low * New upstream release (closes: #526334) + fixes bell regression (closes: #520405) + * Refresh patch stack. + * Defaults for allow-{tcap,window,font}ops are now set from debian/rules + instead of the relevant patches, which now only touch the manpage. -- Julien Cristau <jcris...@debian.org> Mon, 25 May 2009 19:32:11 +0200 diff --git a/debian/patches/901_xterm_manpage.diff b/debian/patches/901_xterm_manpage.diff index add85a5..7f12d81 100644 --- a/debian/patches/901_xterm_manpage.diff +++ b/debian/patches/901_xterm_manpage.diff @@ -5,11 +5,11 @@ Make Debian-specific tweaks to xterm manpage: This patch by Branden Robinson and David MartÃnez. -Index: xterm-242/xterm.man +Index: xterm/xterm.man =================================================================== ---- xterm-242.orig/xterm.man -+++ xterm-242/xterm.man -@@ -4899,10 +4899,10 @@ +--- xterm.orig/xterm.man ++++ xterm/xterm.man +@@ -5008,10 +5008,10 @@ .SH FILES The actual pathnames given may differ on your system. .TP 5 diff --git a/debian/patches/902_pointermode_never.diff b/debian/patches/902_pointermode_never.diff index d6440ea..8e1199d 100644 --- a/debian/patches/902_pointermode_never.diff +++ b/debian/patches/902_pointermode_never.diff @@ -1,11 +1,11 @@ Debian-specific tweak: the pointerMode resource is set to 0 (never) by default. -Index: xterm-242/xterm.man +Index: xterm/xterm.man =================================================================== ---- xterm-242.orig/xterm.man -+++ xterm-242/xterm.man -@@ -2642,11 +2642,11 @@ +--- xterm.orig/xterm.man ++++ xterm/xterm.man +@@ -2663,11 +2663,11 @@ .RS .TP 3 0 diff --git a/debian/patches/903_windowops.diff b/debian/patches/903_windowops.diff index 2cc3abb..de1e195 100644 --- a/debian/patches/903_windowops.diff +++ b/debian/patches/903_windowops.diff @@ -1,7 +1,7 @@ -Index: xterm-242/xterm.man +Index: xterm/xterm.man =================================================================== ---- xterm-242.orig/xterm.man -+++ xterm-242/xterm.man +--- xterm.orig/xterm.man ++++ xterm/xterm.man @@ -1516,7 +1516,7 @@ .B "allowWindowOps (\fPclass\fB AllowWindowOps)" Specifies whether extended window control sequences (as used in dtterm) @@ -11,16 +11,3 @@ Index: xterm-242/xterm.man .TP 8 .B "altIsNotMeta (\fPclass\fB AltIsNotMeta\fP)" If ``true'', treat the Alt-key as if it were the Meta-key. -Index: xterm-242/charproc.c -=================================================================== ---- xterm-242.orig/charproc.c -+++ xterm-242/charproc.c -@@ -398,7 +398,7 @@ - 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(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, False), - 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), diff --git a/debian/patches/904_fontops.diff b/debian/patches/904_fontops.diff index b4bf7f2..9d20e03 100644 --- a/debian/patches/904_fontops.diff +++ b/debian/patches/904_fontops.diff @@ -1,20 +1,7 @@ -Index: xterm-242/charproc.c +Index: xterm/xterm.man =================================================================== ---- xterm-242.orig/charproc.c -+++ xterm-242/charproc.c -@@ -395,7 +395,7 @@ - static XtResource resources[] = - { - Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False), -- Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, True), -+ Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, False), - Bres(XtNallowTcapOps, XtCAllowTcapOps, screen.allowTcapOp0, False), - Bres(XtNallowTitleOps, XtCAllowTitleOps, screen.allowTitleOp0, True), - Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, False), -Index: xterm-242/xterm.man -=================================================================== ---- xterm-242.orig/xterm.man -+++ xterm-242/xterm.man +--- xterm.orig/xterm.man ++++ xterm/xterm.man @@ -1474,7 +1474,7 @@ .TP .B "allowFontOps (\fPclass\fB AllowFontOps)" diff --git a/debian/rules b/debian/rules index 429293c..2df28a2 100755 --- a/debian/rules +++ b/debian/rules @@ -53,6 +53,11 @@ DESKTOP_FLAGS = --vendor debian \ # by default, never hide the cursor CFLAGS += -DDEF_POINTER_MODE=pNever +# disable some unsafe operations +CFLAGS += \ + -DDEF_ALLOW_WINDOW=False \ + -DDEF_ALLOW_FONT=False \ + -DDEF_ALLOW_TCAP=False # Set up the $(STAMP_DIR) directory. .PHONY: stampdir commit 40d73240a51b47e78a521017992fe85d5b769436 Author: Julien Cristau <jcris...@debian.org> Date: Mon May 25 19:39:21 2009 +0200 Update changelog diff --git a/debian/changelog b/debian/changelog index da9a45d..dba17f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +xterm (243-1) UNRELEASED; urgency=low + + * New upstream release (closes: #526334) + + fixes bell regression (closes: #520405) + + -- Julien Cristau <jcris...@debian.org> Mon, 25 May 2009 19:32:11 +0200 + xterm (242-1) unstable; urgency=low * New upstream release. commit 5cc6c9ac6341aa3b67f68c5980c6d0349b5cfef0 Author: Julien Cristau <jcris...@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, -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org