INSTALL                  |    7 
 Imakefile                |    7 
 MANIFEST                 |    2 
 Tekproc.c                |    8 
 VTPrsTbl.c               |   22 
 VTparse.def              |   10 
 VTparse.h                |   10 
 aclocal.m4               |  162 +-
 button.c                 |  832 ++++++++++
 charproc.c               |  497 ++++--
 configure                | 3631 +++++++++++++++++++++++++++--------------------
 configure.in             |   26 
 ctlseqs.ms               |   89 +
 ctlseqs.txt              |   99 -
 fontutils.c              |   20 
 input.c                  |   23 
 main.c                   |  467 ++----
 main.h                   |    8 
 menu.c                   |    4 
 misc.c                   |  381 +++-
 os2main.c                |   43 
 package/debian/changelog |    6 
 package/xterm.spec       |    4 
 ptyx.h                   |   62 
 screen.c                 |    4 
 trace.c                  |    4 
 util.c                   |   81 -
 version.h                |    4 
 vttests/16colors.sh      |    6 
 vttests/8colors.sh       |    6 
 vttests/acolors.sh       |    6 
 vttests/doublechars.sh   |    6 
 vttests/dynamic.sh       |    6 
 vttests/dynamic2.sh      |    6 
 vttests/fonts.sh         |    6 
 vttests/resize.sh        |    6 
 vttests/title.sh         |    6 
 xcharmouse.h             |    7 
 xterm.h                  |   25 
 xterm.log.html           |  107 +
 xterm.man                |  457 +++--
 xterm_io.h               |    4 
 xtermcfg.hin             |    9 
 43 files changed, 4713 insertions(+), 2463 deletions(-)

New commits:
commit 4e01e5971e45b9d39ac1531f9b84f5058e362400
Author: Julien Cristau <jcris...@debian.org>
Date:   Sun Jan 8 13:21:43 2012 +0100

    Imported Upstream version 277

diff --git a/INSTALL b/INSTALL
index c8f28eb..0d0a4de 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
--- $XTermId: INSTALL,v 1.126 2011/08/30 09:51:01 tom Exp $
+-- $XTermId: INSTALL,v 1.127 2011/12/22 01:59:16 tom Exp $
 -------------------------------------------------------------------------------
 -- Copyright 1997-2010,2011 by Thomas E. Dickey
 --
@@ -281,6 +281,11 @@ The options (in alphabetic order):
        Do not compile-in code that suppresses redundant updates to the
        titlebar when the text has not changed.
 
+  --disable-selection-ops disable selection operations
+
+       Do not compile-in code to support the actions which allow users
+       to bind keys that use the selection or extract data from the screen.
+
   --disable-session-mgt   enable support for session management
 
        Do not compile-in code which adds simple session management hooks
diff --git a/Imakefile b/Imakefile
index f65c300..fcfaced 100644
--- a/Imakefile
+++ b/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XTermId: Imakefile,v 1.104 2011/07/02 00:48:49 tom Exp $
+XCOMM $XTermId: Imakefile,v 1.105 2011/11/29 10:19:20 Thorsten.Glaser Exp $
 XCOMM
 XCOMM                         Attention xterm porters
 XCOMM
@@ -253,6 +253,11 @@ SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) 
XkbClientLibs XawClien
 NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs 
XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB))
 #endif
 
+#if defined(OpenBSDArchitecture) || defined(MirBSDArchitecture)
+/* On OpenBSD xterm is now setgid utmp */
+INSTUIDFLAGS= -m 2555 -g utmp
+#endif
+
 #if InstallXtermSetUID && defined(SunArchitecture) && HasSharedLibraries && 
(OSMajorVersion < 5)
 #if AlternateUsrLibDir
 #if ((OSMajorVersion == 4) && (OSMinorVersion >= 1))
diff --git a/MANIFEST b/MANIFEST
index b17561b..36647ff 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST for xterm-276, version xterm-276
+MANIFEST for xterm-277, version xterm-277
 
--------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
diff --git a/Tekproc.c b/Tekproc.c
index 1aa9282..6a7f668 100644
--- a/Tekproc.c
+++ b/Tekproc.c
@@ -1,4 +1,4 @@
-/* $XTermId: Tekproc.c,v 1.190 2011/09/03 12:13:42 tom Exp $ */
+/* $XTermId: Tekproc.c,v 1.191 2011/12/27 10:19:51 tom Exp $ */
 
 /*
  * Copyright 2001-2010,2011 by Thomas E. Dickey
@@ -397,7 +397,7 @@ TekPtyData(void)
     if (Tpushb == 0) {
        if ((Tpushb = TypeMallocN(Char, 10)) == NULL
            || (Tline = TypeMallocN(XSegment, MAX_VTX)) == NULL) {
-           fprintf(stderr, "%s: Not enough core for Tek mode\n", ProgramName);
+           xtermWarning("Not enough core for Tek mode\n");
            if (Tpushb)
                free(Tpushb);
            Tfailed = True;
@@ -1571,8 +1571,8 @@ TekRealize(Widget gw,
     else if (TestGIN(GIN_TERM_EOT_STR) == 0)
        tekscr->gin_terminator = GIN_TERM_EOT;
     else
-       fprintf(stderr, "%s: illegal GIN terminator setting \"%s\"\n",
-               ProgramName, tw->tek.gin_terminator_str);
+       xtermWarning("illegal GIN terminator setting \"%s\"\n",
+                    tw->tek.gin_terminator_str);
 
     gcv.graphics_exposures = True;     /* default */
     gcv.font = tw->tek.Tfont[tekscr->cur.fontsize]->fid;
diff --git a/VTPrsTbl.c b/VTPrsTbl.c
index 9c2cfdf..35e0bc7 100644
--- a/VTPrsTbl.c
+++ b/VTPrsTbl.c
@@ -1,4 +1,4 @@
-/* $XTermId: VTPrsTbl.c,v 1.60 2011/09/11 15:00:46 tom Exp $ */
+/* $XTermId: VTPrsTbl.c,v 1.63 2011/12/04 19:46:52 tom Exp $ */
 
 /*
  * Copyright 1999-2010,2011 by Thomas E. Dickey
@@ -1786,8 +1786,8 @@ CASE_CSI_IGNORE,
 CASE_CSI_IGNORE,
 CASE_CSI_IGNORE,
 /*     @               A               B               C       */
-CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_SL,
+CASE_SR,
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
 /*     D               E               F               G       */
@@ -2188,8 +2188,8 @@ CASE_DECELR,
 CASE_DECSLE,
 /*     |               }               ~               DEL     */
 CASE_DECRQLP,
-CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_DECIC,
+CASE_DECDC,
 CASE_IGNORE,
 /*      0x80            0x81            0x82            0x83    */
 CASE_GROUND_STATE,
@@ -2348,8 +2348,8 @@ CASE_DECELR,
 CASE_DECSLE,
 /*     udiaeresis      yacute          thorn           ydiaeresis      */
 CASE_DECRQLP,
-CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_DECIC,
+CASE_DECDC,
 CASE_IGNORE,
 };
 #endif /* OPT_DEC_LOCATOR */
@@ -5020,11 +5020,11 @@ CASE_GROUND_STATE,
 /*     4               5               6               7       */
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_DECBI,
 CASE_DECSC,
 /*     8               9               :               ;       */
 CASE_DECRC,
-CASE_GROUND_STATE,
+CASE_DECFI,
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
 /*     <               =               >               ?       */
@@ -5180,11 +5180,11 @@ CASE_GROUND_STATE,
 /*      acute           mu              paragraph       periodcentered  */
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_DECBI,
 CASE_DECSC,
 /*      cedilla         onesuperior     masculine       guillemotright  */
 CASE_DECRC,
-CASE_GROUND_STATE,
+CASE_DECFI,
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
 /*      onequarter      onehalf         threequarters   questiondown    */
diff --git a/VTparse.def b/VTparse.def
index da9b5c7..67254d1 100644
--- a/VTparse.def
+++ b/VTparse.def
@@ -1,10 +1,10 @@
-# $XTermId: VTparse.def,v 1.40 2010/08/24 21:26:42 tom Exp $
+# $XTermId: VTparse.def,v 1.42 2011/12/04 18:29:33 tom Exp $
 #
 # vile:confmode rs=lf
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
-# Copyright 1996-2009,2010 by Thomas E. Dickey
+# Copyright 1996-2010,2011 by Thomas E. Dickey
 # 
 #                         All Rights Reserved
 # 
@@ -185,3 +185,9 @@ CASE_DECLL
 CASE_DECRQM
 CASE_RQM
 CASE_CSI_DEC_DOLLAR_STATE
+CASE_SL
+CASE_SR
+CASE_DECDC
+CASE_DECIC
+CASE_DECBI
+CASE_DECFI
diff --git a/VTparse.h b/VTparse.h
index cafbbe3..bf9350f 100644
--- a/VTparse.h
+++ b/VTparse.h
@@ -1,7 +1,7 @@
-/* $XTermId: VTparse.h,v 1.53 2010/08/24 21:27:13 tom Exp $ */
+/* $XTermId: VTparse.h,v 1.55 2011/12/04 18:30:20 tom Exp $ */
 
 /*
- * Copyright 2002-2009,2010 by Thomas E. Dickey
+ * Copyright 2002-2010,2011 by Thomas E. Dickey
  *
  *                         All Rights Reserved
  *
@@ -266,5 +266,11 @@ extern Const PARSE_T esc_pct_table[];
 #define CASE_DECRQM 144
 #define CASE_RQM 145
 #define CASE_CSI_DEC_DOLLAR_STATE 146
+#define CASE_SL 147
+#define CASE_SR 148
+#define CASE_DECDC 149
+#define CASE_DECIC 150
+#define CASE_DECBI 151
+#define CASE_DECFI 152
 
 #endif /* included_VTparse_h */
diff --git a/aclocal.m4 b/aclocal.m4
index f77b1d7..ea0d846 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl $XTermId: aclocal.m4,v 1.313 2011/09/04 21:20:20 tom Exp $
+dnl $XTermId: aclocal.m4,v 1.319 2012/01/07 13:29:08 tom Exp $
 dnl
 dnl ---------------------------------------------------------------------------
 dnl
@@ -543,6 +543,32 @@ AC_DEFUN([CF_ERRNO],
 CF_CHECK_ERRNO(errno)
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_GRANTPT version: 2 updated: 2011/11/28 20:14:06
+dnl ---------------
+dnl Check for grantpt versus openpty, as well as functions that "should" be
+dnl available if grantpt is available.
+AC_DEFUN([CF_FUNC_GRANTPT],[
+
+AC_CHECK_FUNCS(\
+grantpt \
+posix_openpt \
+ptsname \
+)
+
+if test "x$ac_cv_func_grantpt" != "xyes" ; then
+       AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
+       if test "$cf_have_openpty" = yes ; then
+               LIBS="-lutil $LIBS"
+               AC_DEFINE(HAVE_OPENPTY)
+               AC_CHECK_HEADERS( \ 
+                       util.h \
+                       libutil.h \
+                       pty.h \
+               )
+       fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
 dnl ---------------
 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
@@ -2219,6 +2245,45 @@ else
 fi
 ])
 dnl ---------------------------------------------------------------------------
+dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
+dnl -------------------
+dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
+dnl can define it successfully.
+AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
+AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
+       AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_cv_xopen_source=no],
+       [cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+        AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+],[
+#ifdef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_cv_xopen_source=no],
+       [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+       CPPFLAGS="$cf_save"
+       ])
+])
+
+if test "$cf_cv_xopen_source" != no ; then
+       CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
+       CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
+       cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+       CF_ADD_CFLAGS($cf_temp_xopen_source)
+fi
+])
+dnl ---------------------------------------------------------------------------
 dnl CF_TTY_GROUP version: 7 updated: 2007/03/14 16:43:59
 dnl ------------
 dnl Check if the system has a tty-group defined.  This is used in xterm when
@@ -2338,6 +2403,30 @@ else
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_TYPE_CC_T version: 1 updated: 2011/12/12 20:54:48
+dnl ------------
+dnl    Check for cc_t type, used in termio.
+AC_DEFUN([CF_TYPE_CC_T],
+[
+AC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
+AC_CACHE_VAL(cf_cv_type_cc_t,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#if defined(HAVE_TERMIOS_H)
+#include <termios.h>
+#else
+#include <termio.h>
+#include <sys/ioctl.h>
+#endif
+],
+               [cc_t x],
+               [cf_cv_type_cc_t=yes],
+               [cf_cv_type_cc_t=no])
+       ])
+AC_MSG_RESULT($cf_cv_type_cc_t)
+test $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char)
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_TYPE_FD_MASK version: 2 updated: 2008/03/25 20:59:57
 dnl ---------------
 dnl Check for the declaration of fd_mask, which is like fd_set, associated
@@ -3021,7 +3110,7 @@ AC_TRY_LINK([
 test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT)
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_SOURCE version: 37 updated: 2011/08/06 20:32:05
+dnl CF_XOPEN_SOURCE version: 42 updated: 2012/01/07 08:26:49
 dnl ---------------
 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
 dnl or adapt to the vendor's definitions to get equivalent functionality,
@@ -3048,6 +3137,7 @@ darwin[[0-8]].*) #(vi
        ;;
 darwin*) #(vi
        cf_xopen_source="-D_DARWIN_C_SOURCE"
+       cf_XOPEN_SOURCE=
        ;;
 freebsd*|dragonfly*) #(vi
        # 5.x headers associate
@@ -3065,16 +3155,24 @@ hpux*) #(vi
        ;;
 irix[[56]].*) #(vi
        cf_xopen_source="-D_SGI_SOURCE"
+       cf_XOPEN_SOURCE=
        ;;
 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
        CF_GNU_SOURCE
        ;;
 mirbsd*) #(vi
-       # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+       # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and 
other headers which use u_int / u_short types
+       cf_XOPEN_SOURCE=
+       CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
        ;;
 netbsd*) #(vi
        cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 
for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
        ;;
+openbsd[[4-9]]*) #(vi
+       # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, 
needed for ncursesw
+       cf_xopen_source="-D_BSD_SOURCE"
+       cf_XOPEN_SOURCE=600
+       ;;
 openbsd*) #(vi
        # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for 
ncursesw
        ;;
@@ -3087,36 +3185,11 @@ nto-qnx*) #(vi
 sco*) #(vi
        # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
        ;;
-solaris2.1[[0-9]]) #(vi
-       cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
-       ;;
-solaris2.[[1-9]]) #(vi
+solaris2.*) #(vi
        cf_xopen_source="-D__EXTENSIONS__"
        ;;
 *)
-       AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
-       AC_TRY_COMPILE([#include <sys/types.h>],[
-#ifndef _XOPEN_SOURCE
-make an error
-#endif],
-       [cf_cv_xopen_source=no],
-       [cf_save="$CPPFLAGS"
-        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
-        AC_TRY_COMPILE([#include <sys/types.h>],[
-#ifdef _XOPEN_SOURCE
-make an error
-#endif],
-       [cf_cv_xopen_source=no],
-       [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
-       CPPFLAGS="$cf_save"
-       ])
-])
-       if test "$cf_cv_xopen_source" != no ; then
-               CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
-               CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
-               cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
-               CF_ADD_CFLAGS($cf_temp_xopen_source)
-       fi
+       CF_TRY_XOPEN_SOURCE
        CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
        ;;
 esac
@@ -3124,6 +3197,35 @@ esac
 if test -n "$cf_xopen_source" ; then
        CF_ADD_CFLAGS($cf_xopen_source)
 fi
+
+dnl In anything but the default case, we may have system-specific setting
+dnl which is still not guaranteed to provide all of the entrypoints that
+dnl _XOPEN_SOURCE would yield.
+if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
+       AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
+       AC_TRY_COMPILE([#include <stdlib.h>],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_XOPEN_SOURCE_set=yes],
+       [cf_XOPEN_SOURCE_set=no])
+       AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
+       if test $cf_XOPEN_SOURCE_set = yes
+       then
+               AC_TRY_COMPILE([#include <stdlib.h>],[
+#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
+make an error
+#endif],
+               [cf_XOPEN_SOURCE_set_ok=yes],
+               [cf_XOPEN_SOURCE_set_ok=no])
+               if test $cf_XOPEN_SOURCE_set_ok = no
+               then
+                       AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
+               fi
+       else
+               CF_TRY_XOPEN_SOURCE
+       fi
+fi
 ])
 dnl ---------------------------------------------------------------------------
 dnl CF_X_ATHENA version: 20 updated: 2010/11/09 05:18:02
diff --git a/button.c b/button.c
index c8678d0..d3c44e4 100644
--- a/button.c
+++ b/button.c
@@ -1,4 +1,4 @@
-/* $XTermId: button.c,v 1.399 2011/08/19 00:09:26 Marco.Peereboom Exp $ */
+/* $XTermId: button.c,v 1.430 2012/01/07 02:00:35 tom Exp $ */
 
 /*
  * Copyright 1999-2010,2011 by Thomas E. Dickey
@@ -62,6 +62,7 @@ button.c      Handles button events in the terminal emulator.
 #include <xterm.h>
 
 #include <stdio.h>
+#include <ctype.h>
 #include <assert.h>
 
 #include <X11/Xatom.h>
@@ -119,6 +120,7 @@ button.c    Handles button events in the terminal emulator.
 #define KeyModifiers(event) (event->xbutton.state & OurModifiers)
 
 #define IsBtnEvent(event) ((event)->type == ButtonPress || (event)->type == 
ButtonRelease)
+#define IsKeyEvent(event) ((event)->type == KeyPress    || (event)->type == 
KeyRelease)
 
 #define KeyState(x) (((int) ((x) & (ShiftMask|ControlMask))) \
                          + (((x) & Mod1Mask) ? 2 : 0))
@@ -156,8 +158,7 @@ static void EndExtend(XtermWidget w, XEvent * event, String 
* params, Cardinal
 static void ExtendExtend(XtermWidget xw, const CELL * cell);
 static void PointToCELL(TScreen * screen, int y, int x, CELL * cell);
 static void ReHiliteText(XtermWidget xw, CELL * first, CELL * last);
-static void SaltTextAway(XtermWidget xw, CELL * cellc, CELL * cell,
-                        String * params, Cardinal num_params);
+static void SaltTextAway(XtermWidget xw, CELL * cellc, CELL * cell);
 static void SelectSet(XtermWidget xw, XEvent * event, String * params, 
Cardinal num_params);
 static void SelectionReceived PROTO_XT_SEL_CB_ARGS;
 static void StartSelect(XtermWidget xw, const CELL * cell);
@@ -173,12 +174,30 @@ static void do_select_end(XtermWidget xw, XEvent * event, 
String * params,
 #define EXT_MOUSE_LIMIT (2047 - 32)
 #define EXT_MOUSE_START (127 - 32)
 
+static int
+MouseLimit(TScreen * screen)
+{
+    int mouse_limit;
+
+    switch (screen->extend_coords) {
+    default:
+       mouse_limit = MOUSE_LIMIT;
+       break;
+    case SET_EXT_MODE_MOUSE:
+       mouse_limit = EXT_MOUSE_LIMIT;
+       break;
+    case SET_SGR_EXT_MODE_MOUSE:
+    case SET_URXVT_EXT_MODE_MOUSE:
+       mouse_limit = -1;
+       break;
+    }
+    return mouse_limit;
+}
+
 static unsigned
 EmitMousePosition(TScreen * screen, Char line[], unsigned count, int value)
 {
-    int mouse_limit = (screen->ext_mode_mouse
-                      ? EXT_MOUSE_LIMIT
-                      : MOUSE_LIMIT);
+    int mouse_limit = MouseLimit(screen);
 
     /*
      * Add pointer position to key sequence
@@ -190,14 +209,42 @@ EmitMousePosition(TScreen * screen, Char line[], unsigned 
count, int value)
      * it's also somewhat useful as a past-end marker. We preserve
      * this behavior for both normal and extended mouse modes.
      */
-    if (value == mouse_limit) {
-       line[count++] = CharOf(0);
-    } else if (!screen->ext_mode_mouse || value < EXT_MOUSE_START) {
-       line[count++] = CharOf(' ' + value + 1);
-    } else {
-       value += ' ' + 1;
-       line[count++] = CharOf(0xC0 + (value >> 6));
-       line[count++] = CharOf(0x80 + (value & 0x3F));
+    switch (screen->extend_coords) {
+    default:
+       if (value == mouse_limit) {
+           line[count++] = CharOf(0);
+       } else {
+           line[count++] = CharOf(' ' + value + 1);
+       }
+       break;
+    case SET_EXT_MODE_MOUSE:
+       if (value == mouse_limit) {
+           line[count++] = CharOf(0);
+       } else if (value < EXT_MOUSE_START) {
+           line[count++] = CharOf(' ' + value + 1);
+       } else {
+           value += ' ' + 1;
+           line[count++] = CharOf(0xC0 + (value >> 6));
+           line[count++] = CharOf(0x80 + (value & 0x3F));
+       }
+       break;
+    case SET_SGR_EXT_MODE_MOUSE:
+       /* FALLTHRU */
+    case SET_URXVT_EXT_MODE_MOUSE:
+       count += (unsigned) sprintf((char *) line + count, "%d", value + 1);
+       break;
+    }
+    return count;
+}
+
+static unsigned
+EmitMousePositionSeparator(TScreen * screen, Char line[], unsigned count)
+{
+    switch (screen->extend_coords) {
+    case SET_SGR_EXT_MODE_MOUSE:
+    case SET_URXVT_EXT_MODE_MOUSE:
+       line[count++] = ';';
+       break;
     }
     return count;
 }
@@ -1030,6 +1077,8 @@ HandleSelectExtend(Widget w,
        TScreen *screen = TScreenOf(xw);
        CELL cell;
 
+       TRACE(("HandleSelectExtend\n"));
+
        screen->selection_time = event->xmotion.time;
        switch (screen->eventMode) {
            /* If not in one of the DEC mouse-reporting modes */
@@ -1062,6 +1111,8 @@ HandleKeyboardSelectExtend(Widget w,
 
     if ((xw = getXtermWidget(w)) != 0) {
        TScreen *screen = TScreenOf(xw);
+
+       TRACE(("HandleKeyboardSelectExtend\n"));
        ExtendExtend(xw, &screen->cursorp);
     }
 }
@@ -1099,6 +1150,7 @@ HandleSelectEnd(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleSelectEnd\n"));
        do_select_end(xw, event, params, num_params, False);
     }
 }
@@ -1112,6 +1164,7 @@ HandleKeyboardSelectEnd(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleKeyboardSelectEnd\n"));
        do_select_end(xw, event, params, num_params, True);
     }
 }
@@ -1128,6 +1181,7 @@ HandleCopySelection(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleCopySelection\n"));
        SelectSet(xw, event, params, *num_params);
     }
 }
@@ -1996,7 +2050,19 @@ SelectionReceived(Widget w,
 #endif
        for (i = 0; i < text_list_count; i++) {
            size_t len = strlen(text_list[i]);
-           _WriteSelectionData(screen, (Char *) text_list[i], len);
+           if (screen->selectToBuffer) {
+               size_t have = (screen->internal_select
+                              ? strlen(screen->internal_select)
+                              : 0);
+               size_t need = have + len + 1;
+               char *buffer = realloc(screen->internal_select, need);
+               if (buffer != 0) {
+                   strcpy(buffer + have, text_list[i]);
+                   screen->internal_select = buffer;
+               }
+           } else {
+               _WriteSelectionData(screen, (Char *) text_list[i], len);
+           }
        }
 #if OPT_PASTE64
        if (screen->base64_paste) {
@@ -2042,6 +2108,7 @@ HandleInsertSelection(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleInsertSelection\n"));
        if (!SendMousePosition(xw, event)) {
 #if OPT_READLINE
            int ldelta;
@@ -2129,6 +2196,7 @@ HandleSelectStart(Widget w,
        TScreen *screen = TScreenOf(xw);
        CELL cell;
 
+       TRACE(("HandleSelectStart\n"));
        screen->firstValidRow = 0;
        screen->lastValidRow = screen->max_row;
        PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
@@ -2152,6 +2220,8 @@ HandleKeyboardSelectStart(Widget w,
 
     if ((xw = getXtermWidget(w)) != 0) {
        TScreen *screen = TScreenOf(xw);
+
+       TRACE(("HandleKeyboardSelectStart\n"));
        do_select_start(xw, event, &screen->cursorp);
     }
 }
@@ -2242,7 +2312,7 @@ EndExtend(XtermWidget xw,
     CELL cell;
     unsigned count;
     TScreen *screen = TScreenOf(xw);
-    Char line[20];
+    Char line[64];
 
     if (use_cursor_loc) {
        cell = screen->cursorp;
@@ -2264,18 +2334,58 @@ EndExtend(XtermWidget xw,
            if (isSameCELL(&(screen->rawPos), &(screen->startSel))
                && isSameCELL(&cell, &(screen->endSel))) {
                /* Use short-form emacs select */
-               line[count++] = 't';
+
+               switch (screen->extend_coords) {
+               case 0:
+               case SET_EXT_MODE_MOUSE:
+                   line[count++] = 't';
+                   break;
+               case SET_SGR_EXT_MODE_MOUSE:
+                   line[count++] = '<';
+                   break;
+               }
+
                count = EmitMousePosition(screen, line, count, 
screen->endSel.col);
+               count = EmitMousePositionSeparator(screen, line, count);
                count = EmitMousePosition(screen, line, count, 
screen->endSel.row);
+
+               switch (screen->extend_coords) {
+               case SET_SGR_EXT_MODE_MOUSE:
+               case SET_URXVT_EXT_MODE_MOUSE:
+                   line[count++] = 't';
+                   break;
+               }
            } else {
                /* long-form, specify everything */
-               line[count++] = 'T';
+
+               switch (screen->extend_coords) {
+               case 0:
+               case SET_EXT_MODE_MOUSE:
+                   line[count++] = 'T';
+                   break;
+               case SET_SGR_EXT_MODE_MOUSE:
+                   line[count++] = '<';
+                   break;
+               }
+
                count = EmitMousePosition(screen, line, count, 
screen->startSel.col);
+               count = EmitMousePositionSeparator(screen, line, count);
                count = EmitMousePosition(screen, line, count, 
screen->startSel.row);
+               count = EmitMousePositionSeparator(screen, line, count);
                count = EmitMousePosition(screen, line, count, 
screen->endSel.col);
+               count = EmitMousePositionSeparator(screen, line, count);
                count = EmitMousePosition(screen, line, count, 
screen->endSel.row);
+               count = EmitMousePositionSeparator(screen, line, count);
                count = EmitMousePosition(screen, line, count, cell.col);
+               count = EmitMousePositionSeparator(screen, line, count);
                count = EmitMousePosition(screen, line, count, cell.row);
+
+               switch (screen->extend_coords) {
+               case SET_SGR_EXT_MODE_MOUSE:
+               case SET_URXVT_EXT_MODE_MOUSE:
+                   line[count++] = 'T';
+                   break;
+               }
            }
            v_write(screen->respond, line, count);
            TrackText(xw, &zeroCELL, &zeroCELL);
@@ -2294,6 +2404,7 @@ HandleSelectSet(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleSelectSet\n"));
        SelectSet(xw, event, params, *num_params);
     }
 }
@@ -2310,7 +2421,8 @@ SelectSet(XtermWidget xw,
     TRACE(("SelectSet\n"));
     /* Only do select stuff if non-null select */
     if (!isSameCELL(&(screen->startSel), &(screen->endSel))) {
-       SaltTextAway(xw, &(screen->startSel), &(screen->endSel), params, 
num_params);
+       SaltTextAway(xw, &(screen->startSel), &(screen->endSel));
+       _OwnSelection(xw, params, num_params);
     } else {
        ScrnDisownSelection(xw);
     }
@@ -2429,6 +2541,7 @@ HandleStartExtend(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleStartExtend\n"));
        do_start_extend(xw, event, params, num_params, False);
     }
 }
@@ -2442,6 +2555,7 @@ HandleKeyboardStartExtend(Widget w,
     XtermWidget xw;
 
     if ((xw = getXtermWidget(w)) != 0) {
+       TRACE(("HandleKeyboardStartExtend\n"));
        do_start_extend(xw, event, params, num_params, True);
     }
 }
@@ -2707,7 +2821,7 @@ class_of(LineData * ld, CELL * cell)
     }
 #endif
 
-    assert(temp.col < ld->lineSize);
+    assert(temp.col < (int) ld->lineSize);
     return CharacterClass((int) (ld->charData[temp.col]));
 }
 
@@ -2842,7 +2956,7 @@ make_indexed_text(TScreen * screen, int row, unsigned 
length, int *indexed)
                Char *next = last;
                unsigned data = ld->charData[col];
 
-               assert(col < ld->lineSize);
+               assert(col < (int) ld->lineSize);
                /* some internal points may not be drawn */
                if (data == 0)
                    data = ' ';
@@ -3281,9 +3395,14 @@ TrackText(XtermWidget xw,
 
     old_start = screen->startH;
     old_end = screen->endH;
+    TRACE(("...previous(first=%d,%d, last=%d,%d)\n",
+          old_start.row, old_start.col,
+          old_end.row, old_end.col));
     if (isSameCELL(&first, &old_start) &&
-       isSameCELL(&last, &old_end))
+       isSameCELL(&last, &old_end)) {
        return;
+    }
+
     screen->startH = first;
     screen->endH = last;
     from = Coordinate(screen, &screen->startH);
@@ -3362,9 +3481,7 @@ ReHiliteText(XtermWidget xw,
 static void
 SaltTextAway(XtermWidget xw,
             CELL * cellc,
-            CELL * cell,
-            String * params,   /* selections */
-            Cardinal num_params)
+            CELL * cell)
 {
     TScreen *screen = TScreenOf(xw);
     int i, j = 0;
@@ -3435,7 +3552,6 @@ SaltTextAway(XtermWidget xw,
           visibleChars(line, (unsigned) (lp - line))));
 
     screen->selection_length = (unsigned long) (lp - line);
-    _OwnSelection(xw, params, num_params);
 }
 
 #if OPT_PASTE64
@@ -3836,9 +3952,8 @@ _OwnSelection(XtermWidget xw,
            if (screen->selection_length > limit) {
                TRACE(("selection too big (%lu bytes), not storing in 
CUT_BUFFER%d\n",
                       screen->selection_length, cutbuffer));
-               fprintf(stderr,
-                       "%s: selection too big (%lu bytes), not storing in 
CUT_BUFFER%d\n",
-                       ProgramName, screen->selection_length, cutbuffer);
+               xtermWarning("selection too big (%lu bytes), not storing in 
CUT_BUFFER%d\n",
+                            screen->selection_length, cutbuffer);
            } else {
                /* This used to just use the UTF-8 data, which was totally
                 * broken as not even the corresponding paste code in Xterm
@@ -3974,7 +4089,7 @@ SaveText(TScreen * screen,
 #endif
     *eol = !LineTstWrapped(ld);
     for (i = scol; i < ecol; i++) {
-       assert(i < ld->lineSize);
+       assert(i < (int) ld->lineSize);
        c = E2A(ld->charData[i]);
 #if OPT_WIDE_CHARS
        /* We want to strip out every occurrence of HIDDEN_CHAR AFTER a
@@ -4066,26 +4181,52 @@ BtnCode(XButtonEvent * event, int button)
 }
 
 static unsigned
-EmitButtonCode(TScreen * screen, Char * line, unsigned count, XButtonEvent * 
event)
+EmitButtonCode(TScreen * screen,
+              Char * line,
+              unsigned count,
+              XButtonEvent * event,
+              int button)
 {
-    int value = BtnCode(event, screen->mouse_button);
+    int value;
 
-    if (!screen->ext_mode_mouse || value < 128) {
-       line[count++] = CharOf(value);
+    if (screen->send_mouse_pos == X10_MOUSE) {
+       value = CharOf(' ' + button);
     } else {
-       line[count++] = CharOf(0xC0 + (value >> 6));
-       line[count++] = CharOf(0x80 + (value & 0x3F));
+       value = BtnCode(event, button);
+    }
+
+    switch (screen->extend_coords) {
+    default:
+       line[count++] = CharOf(value);
+       break;
+    case SET_SGR_EXT_MODE_MOUSE:
+       value -= 32;            /* encoding starts at zero */
+       /* FALLTHRU */
+    case SET_URXVT_EXT_MODE_MOUSE:
+       count += (unsigned) sprintf((char *) line + count, "%d", value);
+       break;
+    case SET_EXT_MODE_MOUSE:
+       if (value < 128) {
+           line[count++] = CharOf(value);
+       } else {
+           line[count++] = CharOf(0xC0 + (value >> 6));
+           line[count++] = CharOf(0x80 + (value & 0x3F));
+       }
+       break;
     }
     return count;
 }
 
+#define EMIT_BUTTON(button) EmitButtonCode(screen, line, count, event, button)
+
 static void
 EditorButton(XtermWidget xw, XButtonEvent * event)
 {
     TScreen *screen = TScreenOf(xw);
     int pty = screen->respond;
-    int mouse_limit = screen->ext_mode_mouse ? EXT_MOUSE_LIMIT : MOUSE_LIMIT;
-    Char line[10];
+    int mouse_limit = MouseLimit(screen);
+    Char line[32];
+    Char final = 'M';
     int row, col;
     int button;
     unsigned count = 0;
@@ -4111,11 +4252,13 @@ EditorButton(XtermWidget xw, XButtonEvent * event)
     else if (col > screen->max_col)
        col = screen->max_col;
 
-    /* Limit to representable mouse dimensions */
-    if (row > mouse_limit)
-       row = mouse_limit;
-    if (col > mouse_limit)
-       col = mouse_limit;
+    if (mouse_limit > 0) {
+       /* Limit to representable mouse dimensions */
+       if (row > mouse_limit)
+           row = mouse_limit;
+       if (col > mouse_limit)
+           col = mouse_limit;
+    }
 
     /* Build key sequence starting with \E[M */
     if (screen->control_eight_bits) {
@@ -4124,37 +4267,54 @@ EditorButton(XtermWidget xw, XButtonEvent * event)
        line[count++] = ANSI_ESC;
        line[count++] = '[';
     }
+    switch (screen->extend_coords) {
+    case 0:
+    case SET_EXT_MODE_MOUSE:
 #if OPT_SCO_FUNC_KEYS
-    if (xw->keyboard.type == keyboardIsSCO) {
-       /*
-        * SCO function key F1 is \E[M, which would conflict with xterm's
-        * normal kmous.
-        */
-       line[count++] = '>';
-    }
+       if (xw->keyboard.type == keyboardIsSCO) {
+           /*
+            * SCO function key F1 is \E[M, which would conflict with xterm's
+            * normal kmous.
+            */
+           line[count++] = '>';
+       }
 #endif
-    line[count++] = 'M';
+       line[count++] = final;
+       break;
+    case SET_SGR_EXT_MODE_MOUSE:
+       line[count++] = '<';
+       break;
+    }
 
     /* Add event code to key sequence */
     if (screen->send_mouse_pos == X10_MOUSE) {
-       line[count++] = CharOf(' ' + button);
+       count = EMIT_BUTTON(button);


-- 
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/e1rjs55-0002ic...@vasks.debian.org

Reply via email to