]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.9 - patch 20141011
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 12 Oct 2014 01:08:25 +0000 (01:08 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 12 Oct 2014 01:08:25 +0000 (01:08 +0000)
+ add experimental support for xterm's 1005 mouse mode, to use in a
  demonstration of its limitations.
+ add experimental support for "%u" format to terminfo.
+ modify test/ncurses.c to also show position reports in 'a' test.
+ minor formatting fixes to _nc_trace_mmask_t, make this function
  exported to help with debugging mouse changes.
+ improve behavior of wheel-mice for xterm protocol, noting that there
  are only button-presses for buttons "4" and "5", so there is no need
  to wait to combine events into double-clicks (report/analysis by
  Greg Field).
+ provide examples xterm-1005 and xterm-1006 terminfo entries -TD
+ implement decoder for xterm SGR 1006 mouse mode.

19 files changed:
NEWS
dist.mk
man/curs_mouse.3x
misc/terminfo.src
ncurses/base/lib_mouse.c
ncurses/curses.priv.h
ncurses/tinfo/lib_tparm.c
ncurses/tinfo/obsolete.c
ncurses/trace/lib_tracemse.c
package/debian-mingw/changelog
package/debian-mingw64/changelog
package/debian/changelog
package/mingw-ncurses.nsi
package/mingw-ncurses.spec
package/ncurses.spec
test/demo_forms.c
test/demo_termcap.c
test/demo_terminfo.c
test/ncurses.c

diff --git a/NEWS b/NEWS
index 2c74afe833bdc8cddde6c974a494311008c0c101..f89cbee1658397dda3bf95056d9c1aa318af7936 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.2281 2014/09/27 22:15:56 tom Exp $
+-- $Id: NEWS,v 1.2287 2014/10/11 17:49:17 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,20 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20141011
+       + add experimental support for xterm's 1005 mouse mode, to use in a
+         demonstration of its limitations.
+       + add experimental support for "%u" format to terminfo.
+       + modify test/ncurses.c to also show position reports in 'a' test.
+       + minor formatting fixes to _nc_trace_mmask_t, make this function
+         exported to help with debugging mouse changes.
+       + improve behavior of wheel-mice for xterm protocol, noting that there
+         are only button-presses for buttons "4" and "5", so there is no need
+         to wait to combine events into double-clicks (report/analysis by
+         Greg Field).
+       + provide examples xterm-1005 and xterm-1006 terminfo entries -TD
+       + implement decoder for xterm SGR 1006 mouse mode.
+
 20140927
        + implement curs_set in win_driver.c
        + implement flash in win_driver.c
diff --git a/dist.mk b/dist.mk
index fbc886276d59666d7409c40e0edb78601516dd4d..edf97eb83c71ff98a15da81485142769c5d9d9c7 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.1008 2014/09/23 20:52:38 tom Exp $
+# $Id: dist.mk,v 1.1010 2014/10/09 01:02:28 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 9
-NCURSES_PATCH = 20140927
+NCURSES_PATCH = 20141011
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index 1de85e510851183c6b7a73a1108f5bcda8138687..5272de924b02ed9481643f830a632a643a4d29b7 100644 (file)
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2010,2013 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
 .\" copy of this software and associated documentation files (the            *
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_mouse.3x,v 1.39 2013/06/22 18:09:42 tom Exp $
+.\" $Id: curs_mouse.3x,v 1.40 2014/10/10 09:31:18 tom Exp $
 .TH curs_mouse 3X ""
 .na
 .hy 0
@@ -135,7 +135,7 @@ REPORT_MOUSE_POSITION       report mouse movement
 _
 .TE
 .PP
-Once a class of mouse events have been made visible in a window,
+Once a class of mouse events has been made visible in a window,
 calling the \fBwgetch\fR function on that window may return
 \fBKEY_MOUSE\fR as an indicator that a mouse event has been queued.
 To read the event data and pop the event off the queue, call
@@ -283,10 +283,17 @@ corresponds to private mode 1000 of xterm:
 .RS
 \\E[?1000%?%p1%{1}%=%th%el%;
 .RE
+.PP
 The z member in the event structure is not presently used.
 It is intended
 for use with touch screens (which may be pressure-sensitive) or with
 3D-mice/trackballs/power gloves.
+.PP
+The \fBALL_MOUSE_EVENTS\fP class does not include \fBREPORT_MOUSE_POSITION\fP.
+They are distinct.
+For example, in xterm,
+wheel/scrolling mice send position reports as a sequence of
+presses of buttons 4 or 5 without matching button-releases.
 .SH BUGS
 Mouse events under xterm will not in fact be ignored during cooked mode,
 if they have been enabled by \fBmousemask\fR.
index 8078639c796da75e3ecd91db12db9db2816041e1..903f24129a9f336726404893455c8b9e2e49f2b7 100644 (file)
@@ -6,8 +6,8 @@
 # Report bugs and new terminal descriptions to
 #      bug-ncurses@gnu.org
 #
-#      $Revision: 1.508 $
-#      $Date: 2014/06/14 21:16:34 $
+#      $Revision: 1.524 $
+#      $Date: 2014/10/11 23:02:12 $
 #
 # The original header is preserved below for reference.  It is noted that there
 # is a "newer" version which differs in some cosmetic details (but actually
@@ -4164,19 +4164,6 @@ xterm-256color|xterm with 256 colors,
 xterm-88color|xterm with 88 colors,
        use=xterm+88color, use=xterm-256color,
 
-# These two are used to demonstrate the any-event mouse support, i.e., by
-# using an extended name "XM" which tells ncurses to put the terminal into
-# a special mode when initializing the xterm mouse.
-xterm+sm+1002|testing xterm-mouse,
-       XM=\E[?1002%?%p1%{1}%=%th%el%;, use=xterm-new,
-xterm+sm+1003|testing xterm-mouse,
-       XM=\E[?1003%?%p1%{1}%=%th%el%;, use=xterm-new,
-
-xterm-1002|testing xterm-mouse,
-       use=xterm+sm+1002, use=xterm-new,
-xterm-1003|testing xterm-mouse,
-       use=xterm+sm+1003, use=xterm-new,
-
 # This chunk is based on suggestions by Ailin Nemui and Nicholas Marriott, who
 # asked for some of xterm's advanced features to be added to its terminfo
 # entry.  It defines extended capabilities not found in standard terminfo or
@@ -4378,6 +4365,132 @@ xterm-nic|xterm with ich/ich1 suppressed for non-curses programs,
 xterm1|xterm terminal emulator ignoring the alternate screen buffer,
        rmcup@, smcup@, use=xterm,
 
+#### XTERM Mouse
+# The xterm mouse protocol is used by other terminal emulators.
+# In this section, two extended capabilities are used to illustrate the mouse
+# protocol: XM and xm.  The "XM" capability is recognized by ncurses to allow
+# enabling/disabling other mouse protocols.  The "xm" capability describes the
+# mouse response; currently there is no interpreter which would use this
+# information to make the mouse support completely data-driven.
+
+# Here is the "original" xterm mouse protocol.
+#
+# First seen in X10.3, February 1986, this likely dates from 1985 based on the
+# copyright dates in the sources.  A comment in charproc.c notes "MIT bogus
+# sequence", referring to the fact that it does not correspond to a "real"
+# terminal.  The mouse responses for the X10 protocol are sent only for
+# button-presses.
+xterm+x10mouse|X10 xterm mouse protocol,
+       kmous=\E[M, XM=\E[?9%?%p1%{1}%=%th%el%;,
+       xm=\E[M%p3%' '%+%c%p2%'!'%+%c%p1%'!'%+%c,
+xterm-x10mouse|X10 xterm mouse,
+       use=xterm+x10mouse, use=xterm,
+
+# Here is the conventional xterm mouse protocol, introduced with X11R1 in
+# September 1987.
+#
+# The mouse responses for the X11 protocol covered button releases, as well as
+# modifiers:
+#  shift    4
+#  alt/meta 8 (technically the "mod1" mask, because X11 has no such keys)
+#  control 16
+#
+# The modifiers are not reflected in this description because as used in xterm
+# they are normally inaccessible because the translations resources assign
+# shift and control to other features.  However, they are important because
+# they take up space in the first byte of the response.  The other bits of this
+# byte are used to encode the button number for both presses and releases.
+# In the X11 protocol, any button-release is encoded with "3" (the lowest 2
+# bits in the byte).  Later work on XFree86 xterm used the remaining 3 bits to
+# provide additional features, e.g., wheel mouse.
+#
+# X11R1's xterm also supported an "emacs" mouse protocol, with final character
+# "t" or "T", which was activated by double-clicking.  The "t" response was
+# used when the starting/ending positions were the same.
+#
+# X11R3 (February 1988) added the highlight/tracking mode.
+#
+# X11R4 (December 1989) added the control sequences document, listing the
+# control sequences for the X10/X11 protocols without descriptions.  It also
+# mentioned the "emacs" ("T") response.  Comments in button.c referred to the
+# X11 protocol as "DEC vt200 compatible", although DEC offered no such terminal.
+#
+# X11R5 (November 1993) gave a description of the mouse protocol.
+#
+# X11R6 (January 1995) moved the control sequences document out of the xterm
+# source-directory to xc/doc/specs/xterm, polishing the formatting but adding
+# no new information.
+xterm+x11mouse|X11 xterm mouse protocol,
+       kmous=\E[M, XM=\E[?1000%?%p1%{1}%=%th%el%;,
+       xm=\E[M%?%p4%t3%e%p3%' '%+%c%;%p2%'!'%+%c%p1%'!'%+%c,
+xterm-x11mouse|X11 mouse,
+       use=xterm+x11mouse, use=xterm,
+
+# Here is a suggested description of the xterm highlighting protocol.
+# A more complicated example could be constructed to account for the "t"
+# response.
+xterm+x11hilite|X11 xterm mouse protocol with highlight,
+       kmous=\E[M, XM=\E[?1001%?%p1%{1}%=%th%el%;,
+       xm=\E[%p7%'!'%+%p6%'!'%+%c%p9%'!'%+%c%p8%'!'%+%c%p2%'!'%+%c%p1%'!'%+%cT,
+xterm-x11hilite|X11 mouse with highlight,
+       use=xterm+x11mouse, use=xterm,
+
+# The preceding were the sources from X Consortium.  Other sources (or patches)
+# were available.  Starting in mid-1995, XFree86 developers collected some of
+# those changes and began improvements, e.g., to support color.  This was, by
+# the way, around the same time that rxvt developers began implementing color,
+# though dates (and attributions) are not well documented.  I became interested
+# in xterm in late 1995, and involved in early 1996.  To complete the picture,
+# CDE's dtterm was introduced around the same time, with no mouse protocol -TD
+
+# xterm patch #83 (1998/10/7), added Jason Bacon's changes to provide an
+# "any-event" mouse mode. 
+xterm+sm+1002|xterm any-event mouse,
+       kmous=\E[M, XM=\E[?1002%?%p1%{1}%=%th%el%;,
+xterm-1002|xterm any-event mouse,
+       use=xterm+sm+1002, use=xterm,
+
+xterm+sm+1003|testing xterm-mouse,
+       kmous=\E[M, XM=\E[?1003%?%p1%{1}%=%th%el%;,
+
+xterm-1003|testing xterm-mouse,
+       use=xterm+sm+1003, use=xterm,
+
+# xterm patch #116 (1999/9/25) added Stephen P Wall's changes to support DEC
+# locator mode.
+
+# xterm patch #120 (1999/10/28) added my change to support wheel mouse, by
+# dropping support for the X11 mouse protocol's shift-modifier and using
+# available bits in the first byte of the response to encode buttons 4 and 5.
+# xterm patch #126 (2000/2/8) amended that change to avoid conflicting with
+# older configurations which might have used the obsolete modifiers.
+
+# xterm patch #262 (2010/8/30) added Ryan Johnson's changes to provide a mode
+# where the coordinates in the mouse response would be encoded in UTF-8,
+# thereby extending the range of coordinates past 222=(255-33).  This is the
+# "1005" mouse mode.
+xterm+sm+1005|xterm UTF-8 mouse,
+       kmous=\E[M, XM=\E[?1005;1000%?%p1%{1}%=%th%el%;,
+       xm=\E[M%?%p4%t3%e%p3%' '%+%c%;%p2%'!'%+%u%p1%'!'%+%u,
+xterm-1005|xterm UTF-8 mouse,
+       use=xterm+sm+1005, use=xterm,
+
+# xterm patch #277 (2012/1/7) provides a mode where the mouse response uses
+# SGR-style parameters.
+#
+# Someone stated that the 1005 mouse mode would not be handled properly in luit.
+# (By the way, this is a problem with the X11 protocol).  A more plausible
+# criticism is that the responses provided by the 1005 mode are not distinct
+# from the non-1005 responses.
+#
+# As an alternative (and fixing the longstanding limitation of X11 mouse
+# protocol regarding button-releases), I provided this:
+xterm+sm+1006|xterm SGR-mouse,
+       kmous=\E[<, XM=\E[?1006;1000%?%p1%{1}%=%th%el%;,
+       xm=\E[<%p1%d;%p2%d;%p3%d;%?%p4%tM%em%;,
+xterm-1006|xterm SGR-mouse,
+       use=xterm+sm+1006, use=xterm,
+
 #### KTERM
 # (kterm: this had extension capabilities ":KJ:TY=ascii:" -- esr)
 # (kterm should not invoke DEC Graphics as the alternate character set
@@ -5004,6 +5117,25 @@ rxvt+pcfkeys|fragment for PC-style fkeys,
        kLFT5=\EOd, kNXT5=\E[6\^, kNXT6=\E[6@, kPRV5=\E[5\^,
        kPRV6=\E[5@, kRIT5=\EOc, kUP=\E[a, kUP5=\EOa,
 
+# rxvt was originally "xvt", first announced in April 1993:
+#      http://www.informatica.co.cr/linux-desktops/research/1993/0416.html
+#
+# Though its change-log does not mention this, John Davis has stated that he
+# was the author of the changes to use the bce ("new color model") which was
+# incorporated into rxvt 2.11 (June 15, 1995).  The change-log does not give
+# dates, nor give developer's names.  Initial color support was added for rxvt
+# "2.0", which was sometime in 1994.
+#
+# rxvt had usable color support with 2.16 (April 2, 1996), with some help by my work on
+# vttest, as well as bug reports to Mark Olesen.  For instance, the fix
+# mentioned here
+#      http://web.archiveorange.com/archive/v/6ETvLb5wHtbbzCaS4S9J
+# was from one of my bug-reports -TD
+#
+# While the color model both for xterm and rxvt was based on Linux console,
+# Olesen (or possibly Davis) diverged in one respect from Linux's bce color
+# behavior: inserting/deleting characters does not fill the newly empty cell
+# with the default background color.
 rxvt|rxvt terminal emulator (X Window System),
        ncv@,
        hpa=\E[%i%p1%dG, kf0=\E[21~, sgr0=\E[m\017,
@@ -5033,6 +5165,23 @@ rxvt-16color|xterm with 16 colors like aixterm,
 #
 # mrxvt is based on rxvt 2.7.11, but has by default XTERM_FKEYS defined, which
 # makes its function-keys different from other flavors of rxvt -TD
+#
+# Testing with tack:
+# +    made custom description (below) to work, though it sets TERM=xterm.
+#
+# Testing with vttest:
+# +    While "based on" rxvt, some of the basic functionality is broken.  The
+#      window collapses to a single line when running several of the screens
+#      in vttest, e.g., the tests for cursor movement, screen features,
+#      double-sized characters.
+# +    The vt52 test works properly, but this is an exception.  Due to the
+#      other bug(s) most of vttest is untestable.
+# +    the color test using ECH shows a gap in the bce model, like rxvt.
+#
+# Testing with xterm "vttest" scripts:
+# +    resize.pl does not work because mrxvt does implement CSI 18 t
+#      (not in rxvt, but not documented by mrxvt) but not CSI 19 t.
+# +    none of the "dynamic colors" (OSC colors) scripts work.
 mrxvt|multitabbed rxvt,
        XT,
        kEND=\E[8;2~, kHOM=\E[7;2~, kcub1=\E[D, kcud1=\E[B,
@@ -21809,7 +21958,18 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # TS is a string capability which acts like "tsl", but uses no parameter and
 #    goes to the first column of the "status line".
 # XM is a string capability which overrides ncurses's built-in string which
-#    enables xterm mouse mode.
+#    enables/disables xterm mouse mode.
+# xm shows the format of the mouse responses.  Parameters are (from zero):
+#      p1 = y-ordinate
+#      p2 = x-ordinate
+#      p3 = button
+#      p4 = state, e.g., pressed or released
+#      p6 = y-ordinate starting region
+#      p7 = x-ordinate starting region
+#      p8 = y-ordinate ending region
+#      p9 = x-ordinate ending region
+# Other extensions, used in xm:
+#      %u = UTF-8
 #
 #### Miscellaneous extensions:
 #
@@ -23394,4 +23554,14 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 #      + add dim, invis capabilities to vte-2012 -TD
 #      + add sitm/ritm to konsole-base and mlterm3 -TD
 #
+# 2014-10-06
+#      + add xterm-1005 and xterm-1006 entries, with suggested extension
+#        capability "xm" -TD
+#
+# 2014-10-07
+#      + update test-report for mrxvt -TD
+#
+# 2014-10-11
+#      + add xterm-x10mouse, xterm-x11mouse, etc. -TD
+#
 ######## SHANTIH!  SHANTIH!  SHANTIH!
index 08af6a6867b5d83f4cc50a69a12f51b5cf692d93..cd46d0c9e21250db77404b061c7f9b2812341ee3 100644 (file)
@@ -84,7 +84,7 @@
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_mouse.c,v 1.143 2014/04/26 18:47:20 juergen Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.162 2014/10/12 00:03:37 tom Exp $")
 
 #include <tic.h>
 
@@ -376,9 +376,46 @@ static void
 init_xterm_mouse(SCREEN *sp)
 {
     sp->_mouse_type = M_XTERM;
+    sp->_mouse_format = MF_X10;
     sp->_mouse_xtermcap = tigetstr("XM");
-    if (!VALID_STRING(sp->_mouse_xtermcap))
+    if (VALID_STRING(sp->_mouse_xtermcap)) {
+       char *code = strstr(sp->_mouse_xtermcap, "[?");
+       if (code != 0) {
+           code += 2;
+           while ((*code >= '0') && (*code <= '9')) {
+               char *next = code;
+               while ((*next >= '0') && (*next <= '9')) {
+                   ++next;
+               }
+               if (!strncmp(code, "1006", (size_t) (next - code))) {
+                   sp->_mouse_format = MF_SGR1006;
+               }
+#ifdef EXP_XTERM_1005
+               if (!strncmp(code, "1005", (size_t) (next - code))) {
+                   sp->_mouse_format = MF_XTERM_1005;
+               }
+#endif
+               if (*next == ';') {
+                   while (*next == ';') {
+                       ++next;
+                   }
+                   code = next;
+               } else {
+                   break;
+               }
+           }
+       }
+    } else {
+       int code = tigetnum("XM");
+       switch (code) {
+       case 1006:
+           break;
+       default:
+           code = 1000;
+           break;
+       }
        sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
+    }
 }
 #endif
 
@@ -846,173 +883,415 @@ _nc_mouse_event(SCREEN *sp)
     return result;             /* true if we found an event */
 }
 
+#if USE_EMX_MOUSE
+#define PRESS_POSITION(n) \
+    do { \
+           eventp->bstate = MASK_PRESS(n); \
+           sp->_mouse_bstate |= MASK_PRESS(n); \
+           if (kbuf[0] & 0x40) { \
+                   eventp->bstate = MASK_RELEASE(n); \
+                   sp->_mouse_bstate &= ~MASK_PRESS(n); \
+           } \
+    } while (0)
+#else
+#define PRESS_POSITION(n) \
+    do { \
+           eventp->bstate = (mmask_t) (sp->_mouse_bstate & MASK_PRESS(n) \
+                                   ? REPORT_MOUSE_POSITION \
+                                   : MASK_PRESS(n)); \
+           sp->_mouse_bstate |= MASK_PRESS(n); \
+    } while (0)
+#endif
+
 static bool
-_nc_mouse_inline(SCREEN *sp)
-/* mouse report received in the keyboard stream -- parse its info */
+handle_wheel(SCREEN *sp, MEVENT * eventp, int button, int wheel)
 {
+    bool result = TRUE;
+
+    switch (button & 3) {
+    case 0:
+       if (wheel) {
+           eventp->bstate = MASK_PRESS(4);
+           /* Do not record in sp->_mouse_bstate; there will be no
+            * corresponding release event.
+            */
+       } else {
+           PRESS_POSITION(1);
+       }
+       break;
+    case 1:
+       if (wheel) {
+#if NCURSES_MOUSE_VERSION == 2
+           eventp->bstate = MASK_PRESS(5);
+           /* See comment above for button 4 */
+#else
+           /* Ignore this event as it is not a true press of the button */
+           eventp->bstate = REPORT_MOUSE_POSITION;
+#endif
+       } else {
+           PRESS_POSITION(2);
+       }
+       break;
+    case 2:
+       PRESS_POSITION(3);
+       break;
+    default:
+       result = FALSE;
+       break;
+    }
+    return result;
+}
+
+static bool
+decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro)
+{
+    bool result;
     int b;
-    bool result = FALSE;
-    MEVENT *eventp = sp->_mouse_eventp;
 
-    TR(MY_TRACE, ("_nc_mouse_inline() called"));
+    eventp->bstate = 0;
 
-    if (sp->_mouse_type == M_XTERM) {
-       unsigned char kbuf[4];
-       size_t grabbed;
-       int res;
-
-       /* This code requires that your xterm entry contain the kmous
-        * capability and that it be set to the \E[M documented in the
-        * Xterm Control Sequences reference.  This is how we
-        * arrange for mouse events to be reported via a KEY_MOUSE
-        * return value from wgetch().  After this value is received,
-        * _nc_mouse_inline() gets called and is immediately
-        * responsible for parsing the mouse status information
-        * following the prefix.
-        *
-        * The following quotes from the ctrlseqs.ms document in the
-        * X distribution, describing the X mouse tracking feature:
-        *
-        * Parameters for all mouse tracking escape sequences
-        * generated by xterm encode numeric parameters in a single
-        * character as value+040.  For example, !  is 1.
-        *
-        * On button press or release, xterm sends ESC [ M CbCxCy.
-        * The low two bits of Cb encode button information: 0=MB1
-        * pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release.  The
-        * upper bits encode what modifiers were down when the
-        * button was pressed and are added together.  4=Shift,
-        * 8=Meta, 16=Control.  Cx and Cy are the x and y coordinates
-        * of the mouse event.  The upper left corner is (1,1).
-        *
-        * (End quote)  By the time we get here, we've eaten the
-        * key prefix.  FYI, the loop below is necessary because
-        * mouse click info isn't guaranteed to present as a
-        * single clist item.
-        *
-        * Wheel mice may return buttons 4 and 5 when the wheel is turned.
-        * We encode those as button presses.
+    if (!handle_wheel(sp, eventp, (int) intro, (intro & 96) == 96)) {
+       /*
+        * Release events aren't reported for individual buttons, just for
+        * the button set as a whole.  However, because there are normally
+        * no mouse events under xterm that intervene between press and
+        * release, we can infer the button actually released by looking at
+        * the previous event.
         */
+       if (sp->_mouse_bstate & BUTTON_PRESSED) {
+           eventp->bstate = BUTTON_RELEASED;
+           for (b = 1; b <= MAX_BUTTONS; ++b) {
+               if (!(sp->_mouse_bstate & MASK_PRESS(b)))
+                   eventp->bstate &= ~MASK_RELEASE(b);
+           }
+           sp->_mouse_bstate = 0;
+       } else {
+           /*
+            * xterm will return a stream of release-events to let the
+            * application know where the mouse is going, if private mode
+            * 1002 or 1003 is enabled.
+            */
+           eventp->bstate = REPORT_MOUSE_POSITION;
+       }
+    }
+
+    if (intro & 4) {
+       eventp->bstate |= BUTTON_SHIFT;
+    }
+    if (intro & 8) {
+       eventp->bstate |= BUTTON_ALT;
+    }
+    if (intro & 16) {
+       eventp->bstate |= BUTTON_CTRL;
+    }
+    result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;
+    return result;
+}
+
+/* This code requires that your xterm entry contain the kmous capability and
+ * that it be set to the \E[M documented in the Xterm Control Sequences
+ * reference.  This is how we arrange for mouse events to be reported via a
+ * KEY_MOUSE return value from wgetch().  After this value is received,
+ * _nc_mouse_inline() gets called and is immediately responsible for parsing
+ * the mouse status information following the prefix.
+ *
+ * The following quotes from the ctlseqs.ms document in the XTerm distribution,
+ * describing the mouse tracking feature:
+ *
+ * Parameters for all mouse tracking escape sequences generated by xterm encode
+ * numeric parameters in a single character as value+040.  For example, ! is
+ * 1.
+ *
+ * On button press or release, xterm sends ESC [ M CbCxCy.  The low two bits of
+ * Cb encode button information:  0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed,
+ * 3=release.  The upper bits encode what modifiers were down when the button
+ * was pressed and are added together.  4=Shift, 8=Meta, 16=Control.  Cx and Cy
+ * are the x and y coordinates of the mouse event.  The upper left corner is
+ * (1,1).
+ *
+ * (End quote) By the time we get here, we've eaten the key prefix.  FYI, the
+ * loop below is necessary because mouse click info isn't guaranteed to present
+ * as a single clist item.
+ *
+ * Wheel mice may return buttons 4 and 5 when the wheel is turned.  We encode
+ * those as button presses.
+ */
+static bool
+decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
+{
+    unsigned char kbuf[4];
+    size_t grabbed;
+    int res;
+    bool result;
+
 # if USE_PTHREADS_EINTR
 #  if USE_WEAK_SYMBOLS
-       if ((pthread_self) && (pthread_kill) && (pthread_equal))
+    if ((pthread_self) && (pthread_kill) && (pthread_equal))
 #  endif
-           _nc_globals.read_thread = pthread_self();
+       _nc_globals.read_thread = pthread_self();
 # endif
-       for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) {
+    for (grabbed = 0; grabbed < 3; grabbed += (size_t) res) {
 
-           /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
+       /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
+       res = (int) read(
 #if USE_EMX_MOUSE
-           res = (int) read(M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
+                           (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd,
 #else
-           res = (int) read(sp->_ifd, kbuf + grabbed, 3 - grabbed);
+                           sp->_ifd,
 #endif
-           if (res == -1)
-               break;
-       }
+                           kbuf + grabbed, 3 - grabbed);
+       if (res == -1)
+           break;
+    }
 #if USE_PTHREADS_EINTR
-       _nc_globals.read_thread = 0;
+    _nc_globals.read_thread = 0;
 #endif
-       kbuf[3] = '\0';
+    kbuf[3] = '\0';
 
-       TR(TRACE_IEVENT,
-          ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+    TR(TRACE_IEVENT,
+       ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
 
-       /* there's only one mouse... */
-       eventp->id = NORMAL_EVENT;
+    /* there's only one mouse... */
+    eventp->id = NORMAL_EVENT;
 
-       /* processing code goes here */
-       eventp->bstate = 0;
+    result = decode_X10_bstate(sp, eventp, kbuf[0]);
 
+    eventp->x = (kbuf[1] - ' ') - 1;
+    eventp->y = (kbuf[2] - ' ') - 1;
+
+    return result;
+}
+
+#ifdef EXP_XTERM_1005
+/*
+ * This is identical to X10/X11 responses except that there are two UTF-8
+ * characters storing the ordinates instead of two bytes.
+ */
+static bool
+decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
+{
+    char kbuf[80];
+    size_t grabbed;
+    size_t limit = (sizeof(kbuf) - 1);
+    unsigned coords[2];
+    int res;
+    bool result;
+
+    coords[0] = 0;
+    coords[1] = 0;
+
+# if USE_PTHREADS_EINTR
+#  if USE_WEAK_SYMBOLS
+    if ((pthread_self) && (pthread_kill) && (pthread_equal))
+#  endif
+       _nc_globals.read_thread = pthread_self();
+# endif
+    for (grabbed = 0; grabbed < limit;) {
+
+       res = (int) read(
 #if USE_EMX_MOUSE
-#define PRESS_POSITION(n) \
-       do { \
-               eventp->bstate = MASK_PRESS(n); \
-               sp->_mouse_bstate |= MASK_PRESS(n); \
-               if (kbuf[0] & 0x40) { \
-                       eventp->bstate = MASK_RELEASE(n); \
-                       sp->_mouse_bstate &= ~MASK_PRESS(n); \
-               } \
-       } while (0)
+                           (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd,
 #else
-#define PRESS_POSITION(n) \
-       do { \
-               eventp->bstate = (mmask_t) (sp->_mouse_bstate & MASK_PRESS(n) \
-                                       ? REPORT_MOUSE_POSITION \
-                                       : MASK_PRESS(n)); \
-               sp->_mouse_bstate |= MASK_PRESS(n); \
-       } while (0)
+                           sp->_ifd,
 #endif
-
-       switch (kbuf[0] & 0x3) {
-       case 0x0:
-           if ((kbuf[0] & 96) == 96) {
-               eventp->bstate = MASK_PRESS(4);
-               /* Do not record in sp->_mouse_bstate; there will be no
-                * corresponding release event.
-                */
-           } else {
-               PRESS_POSITION(1);
-           }
+                           kbuf + grabbed, 1);
+       if (res == -1)
            break;
+       grabbed += res;
+       if (grabbed > 1) {
+           size_t check = 1;
+           int n;
+           int rc;
+           for (n = 0; n < 2; ++n) {
+               if (check >= grabbed)
+                   break;
+               rc = _nc_conv_to_utf32(&coords[n], kbuf + check, grabbed - check);
+               if (!rc)
+                   break;
+               check += rc;
+           }
+           if (n >= 2)
+               break;
+       }
+    }
+#if USE_PTHREADS_EINTR
+    _nc_globals.read_thread = 0;
+#endif
 
-       case 0x1:
-           if ((kbuf[0] & 96) == 96) {
-#if NCURSES_MOUSE_VERSION == 2
-               eventp->bstate = MASK_PRESS(5);
-               /* See comment above for button 4 */
+    TR(TRACE_IEVENT,
+       ("_nc_mouse_inline sees the following xterm data: %s",
+       _nc_visbufn(kbuf, (int) grabbed)));
+
+    /* there's only one mouse... */
+    eventp->id = NORMAL_EVENT;
+
+    result = decode_X10_bstate(sp, eventp, UChar(kbuf[0]));
+
+    eventp->x = (coords[0] - ' ') - 1;
+    eventp->y = (coords[1] - ' ') - 1;
+
+    return result;
+}
+#endif /* EXP_XTERM_1005 */
+
+/*
+ * ECMA-48 section 5.4
+ */
+#define isInter(c) ((c) >= 0x20 && (c) <= 0x2f)
+#define isParam(c) ((c) >= 0x30 && (c) <= 0x3f)
+#define isFinal(c) ((c) >= 0x40 && (c) <= 0x7e)
+
+#define MAX_PARAMS 9
+
+typedef struct {
+    int nerror;                        /* nonzero if there are unexpected chars */
+    int nparam;                        /* number of numeric parameters */
+    int params[MAX_PARAMS];
+    int final;                 /* the final-character */
+} SGR_DATA;
+
+static bool
+read_SGR(SCREEN *sp, SGR_DATA * result)
+{
+    char kbuf[80];             /* bigger than any possible mouse response */
+    int grabbed = 0;
+    int res;
+    int ch = 0;
+    int now = -1;
+    int marker = 1;
+
+    memset(result, 0, sizeof(*result));
+# if USE_PTHREADS_EINTR
+#  if USE_WEAK_SYMBOLS
+    if ((pthread_self) && (pthread_kill) && (pthread_equal))
+#  endif
+       _nc_globals.read_thread = pthread_self();
+# endif
+    do {
+       res = (int) read(
+#if USE_EMX_MOUSE
+                           (M_FD(sp) >= 0) ? M_FD(sp) : sp->_ifd,
 #else
-               /* Ignore this event as it is not a true press of the button */
-               eventp->bstate = REPORT_MOUSE_POSITION;
+                           sp->_ifd,
 #endif
+                           kbuf + grabbed, 1);
+       if (res == -1)
+           break;
+       if ((grabbed + 3) >= (int) sizeof(kbuf)) {
+           result->nerror++;
+           break;
+       }
+       ch = UChar(kbuf[grabbed]);
+       kbuf[grabbed + 1] = 0;
+       switch (ch) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+           if (marker) {
+               ++now;
+               result->nparam = (now + 1);
+           }
+           marker = 0;
+           result->params[now] = (result->params[now] * 10) + (ch - '0');
+           break;
+       case ';':
+           if (marker) {
+               ++now;
+               result->nparam = (now + 1);
+           }
+           marker = 1;
+           break;
+       default:
+           if (ch < 32 || ch > 126) {
+               /*
+                * Technically other characters could be interspersed in the
+                * response.  Ignore those for now.
+                */
+               result->nerror++;
+               continue;
+           } else if (isFinal(ch)) {
+               if (marker) {
+                   result->nparam++;
+               }
+               result->final = ch;
            } else {
-               PRESS_POSITION(2);
+               result->nerror++;
            }
            break;
+       }
+       ++grabbed;
+    } while (!isFinal(ch));
+#if USE_PTHREADS_EINTR
+    _nc_globals.read_thread = 0;
+#endif
 
-       case 0x2:
-           PRESS_POSITION(3);
-           break;
+    kbuf[++grabbed] = 0;
+    TR(TRACE_IEVENT,
+       ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+    return (grabbed > 0) && (result->nerror == 0);
+}
 
-       case 0x3:
-           /*
-            * Release events aren't reported for individual buttons, just for
-            * the button set as a whole.  However, because there are normally
-            * no mouse events under xterm that intervene between press and
-            * release, we can infer the button actually released by looking at
-            * the previous event.
-            */
-           if (sp->_mouse_bstate & BUTTON_PRESSED) {
-               eventp->bstate = BUTTON_RELEASED;
-               for (b = 1; b <= MAX_BUTTONS; ++b) {
-                   if (!(sp->_mouse_bstate & MASK_PRESS(b)))
-                       eventp->bstate &= ~MASK_RELEASE(b);
-               }
-               sp->_mouse_bstate = 0;
+static bool
+decode_xterm_SGR1006(SCREEN *sp, MEVENT * eventp)
+{
+    SGR_DATA data;
+    bool result = FALSE;
+    if (read_SGR(sp, &data)) {
+       int b = data.params[0];
+       int b3 = 1 + (b & 3);
+
+       result = TRUE;
+       eventp->id = NORMAL_EVENT;
+       if (data.final == 'M') {
+           (void) handle_wheel(sp, eventp, b, (b & 64) == 64);
+       } else {
+           mmask_t pressed = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_PRESSED);
+           mmask_t release = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_RELEASED);
+           if (sp->_mouse_bstate & pressed) {
+               eventp->bstate = release;
+               sp->_mouse_bstate &= ~pressed;
            } else {
-               /*
-                * XFree86 xterm will return a stream of release-events to
-                * let the application know where the mouse is going, if the
-                * private mode 1002 or 1003 is enabled.
-                */
                eventp->bstate = REPORT_MOUSE_POSITION;
            }
-           break;
        }
        result = (eventp->bstate & REPORT_MOUSE_POSITION) ? TRUE : FALSE;
+       eventp->x = (data.params[1] ? (data.params[1] - 1) : 0);
+       eventp->y = (data.params[2] ? (data.params[2] - 1) : 0);
+    }
+    return result;
+}
 
-       if (kbuf[0] & 4) {
-           eventp->bstate |= BUTTON_SHIFT;
-       }
-       if (kbuf[0] & 8) {
-           eventp->bstate |= BUTTON_ALT;
-       }
-       if (kbuf[0] & 16) {
-           eventp->bstate |= BUTTON_CTRL;
+static bool
+_nc_mouse_inline(SCREEN *sp)
+/* mouse report received in the keyboard stream -- parse its info */
+{
+    bool result = FALSE;
+    MEVENT *eventp = sp->_mouse_eventp;
+
+    TR(MY_TRACE, ("_nc_mouse_inline() called"));
+
+    if (sp->_mouse_type == M_XTERM) {
+       switch (sp->_mouse_format) {
+       case MF_X10:
+           result = decode_xterm_X10(sp, eventp);
+           break;
+       case MF_SGR1006:
+           result = decode_xterm_SGR1006(sp, eventp);
+           break;
+#ifdef EXP_XTERM_1005
+       case MF_XTERM_1005:
+           result = decode_xterm_1005(sp, eventp);
+           break;
+#endif
        }
 
-       eventp->x = (kbuf[1] - ' ') - 1;
-       eventp->y = (kbuf[2] - ' ') - 1;
        TR(MY_TRACE,
           ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
            _nc_tracemouse(sp, eventp),
@@ -1020,9 +1299,23 @@ _nc_mouse_inline(SCREEN *sp)
 
        /* bump the next-free pointer into the circular list */
        sp->_mouse_eventp = NEXT(eventp);
-#if 0                          /* this return would be needed for QNX's mods to lib_getch.c */
-       return (TRUE);
-#endif
+
+       if (!result) {
+           /* If this event is from a wheel-mouse, treat it like position
+            * reports and avoid waiting for the release-events which will
+            * never come.
+            */
+           if (eventp->bstate & BUTTON_PRESSED) {
+               int b;
+
+               for (b = 4; b <= MAX_BUTTONS; ++b) {
+                   if ((eventp->bstate & MASK_PRESS(b))) {
+                       result = TRUE;
+                       break;
+                   }
+               }
+           }
+       }
     }
 
     return (result);
index 2c3df406cd2e31c1940236fdb0c9cc9ba152203a..01539d8d62000530e05360f1a328c3d85a3f7782 100644 (file)
@@ -34,7 +34,7 @@
  ****************************************************************************/
 
 /*
- * $Id: curses.priv.h,v 1.540 2014/09/27 21:44:28 tom Exp $
+ * $Id: curses.priv.h,v 1.544 2014/10/11 19:30:58 tom Exp $
  *
  *     curses.priv.h
  *
@@ -676,6 +676,14 @@ typedef enum {
 #endif
 } MouseType;
 
+typedef enum {
+       MF_X10 = 0              /* conventional 3-byte format */
+       , MF_SGR1006            /* xterm private mode 1006, SGR-style */
+#ifdef EXP_XTERM_1005
+       , MF_XTERM_1005         /* xterm UTF-8 private mode 1005 */
+#endif
+} MouseFormat;
+
 /*
  * Structures for scrolling.
  */
@@ -1145,6 +1153,7 @@ struct screen {
        mmask_t         _mouse_mask;    /* set via mousemask() */
        mmask_t         _mouse_mask2;   /* OR's in press/release bits */
        mmask_t         _mouse_bstate;
+       MouseFormat     _mouse_format;  /* type of xterm mouse protocol */
        NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
        MEVENT          _mouse_events[EV_MAX];  /* hold the last mouse event seen */
        MEVENT          *_mouse_eventp; /* next free slot in event queue */
@@ -2004,6 +2013,7 @@ extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
 extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
 extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
 extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
+extern NCURSES_EXPORT(char *) _nc_trace_mmask_t (SCREEN *, mmask_t);
 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
 extern NCURSES_EXPORT(int) _nc_baudrate (int);
 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
@@ -2481,6 +2491,11 @@ extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
 
 #endif
 
+#ifdef EXP_XTERM_1005
+NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned);
+NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index bca90c8cbeb15dadcbbb5774cfa9d1a1d150e4e2..44a20611e37327a532a167fd7719b9aa5a78212a 100644 (file)
@@ -42,7 +42,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_tparm.c,v 1.92 2014/05/23 00:33:45 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.93 2014/10/11 03:04:31 tom Exp $")
 
 /*
  *     char *
@@ -253,6 +253,9 @@ parse_format(const char *s, char *format, int *len)
            case 'x':           /* FALLTHRU */
            case 'X':           /* FALLTHRU */
            case 's':
+#ifdef EXP_XTERM_1005
+           case 'u':
+#endif
                *format++ = *s;
                done = TRUE;
                break;
@@ -372,6 +375,9 @@ _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
            case 'x':           /* FALLTHRU */
            case 'X':           /* FALLTHRU */
            case 'c':           /* FALLTHRU */
+#ifdef EXP_XTERM_1005
+           case 'u':
+#endif
                if (lastpop <= 0)
                    number++;
                lastpop = -1;
@@ -567,6 +573,20 @@ tparam_internal(int use_TPARM_ARG, const char *string, va_list ap)
                save_char(npop());
                break;
 
+#ifdef EXP_XTERM_1005
+           case 'u':
+               {
+                   unsigned char target[10];
+                   unsigned source = (unsigned) npop();
+                   int rc = _nc_conv_to_utf8(target, source, (unsigned)
+                                             sizeof(target));
+                   int n;
+                   for (n = 0; n < rc; ++n) {
+                       save_char(target[n]);
+                   }
+               }
+               break;
+#endif
            case 'l':
                npush((int) strlen(spop()));
                break;
index 9b62917d7ccf8e9e6b804dc46d18fc871ec4cdd7..63476dc7987910db960fe37a7b6ea40c29fb5087 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2013 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2013,2014 Free Software Foundation, Inc.                   *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey                        2013                    *
+ *  Author: Thomas E. Dickey                        2013-on                 *
  ****************************************************************************/
 
 /*
-**     Support for obsolete features.
+**     Support for obsolete/unusual features.
 */
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: obsolete.c,v 1.1 2013/01/26 22:07:51 tom Exp $")
+MODULE_ID("$Id: obsolete.c,v 1.3 2014/10/11 02:39:35 tom Exp $")
 
 /*
  * Obsolete entrypoint retained for binary compatbility.
@@ -100,3 +100,140 @@ _nc_memmove(void *s1, const void *s2, size_t n)
     return s1;
 }
 #endif /* USE_MY_MEMMOVE */
+
+#ifdef EXP_XTERM_1005
+NCURSES_EXPORT(int)
+_nc_conv_to_utf8(unsigned char *target, unsigned source, unsigned limit)
+{
+#define CH(n) UChar((source) >> ((n) * 8))
+    int rc = 0;
+
+    if (source <= 0x0000007f)
+       rc = 1;
+    else if (source <= 0x000007ff)
+       rc = 2;
+    else if (source <= 0x0000ffff)
+       rc = 3;
+    else if (source <= 0x001fffff)
+       rc = 4;
+    else if (source <= 0x03ffffff)
+       rc = 5;
+    else                       /* (source <= 0x7fffffff) */
+       rc = 6;
+
+    if ((unsigned) rc > limit) {       /* whatever it is, we cannot decode it */
+       rc = 0;
+    }
+
+    if (target != 0) {
+       switch (rc) {
+       case 1:
+           target[0] = CH(0);
+           break;
+
+       case 2:
+           target[1] = UChar(0x80 | (CH(0) & 0x3f));
+           target[0] = UChar(0xc0 | (CH(0) >> 6) | ((CH(1) & 0x07) << 2));
+           break;
+
+       case 3:
+           target[2] = UChar(0x80 | (CH(0) & 0x3f));
+           target[1] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+           target[0] = UChar(0xe0 | ((int) (CH(1) & 0xf0) >> 4));
+           break;
+
+       case 4:
+           target[3] = UChar(0x80 | (CH(0) & 0x3f));
+           target[2] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+           target[1] = UChar(0x80 |
+                             ((int) (CH(1) & 0xf0) >> 4) |
+                             ((int) (CH(2) & 0x03) << 4));
+           target[0] = UChar(0xf0 | ((int) (CH(2) & 0x1f) >> 2));
+           break;
+
+       case 5:
+           target[4] = UChar(0x80 | (CH(0) & 0x3f));
+           target[3] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+           target[2] = UChar(0x80 |
+                             ((int) (CH(1) & 0xf0) >> 4) |
+                             ((int) (CH(2) & 0x03) << 4));
+           target[1] = UChar(0x80 | (CH(2) >> 2));
+           target[0] = UChar(0xf8 | (CH(3) & 0x03));
+           break;
+
+       case 6:
+           target[5] = UChar(0x80 | (CH(0) & 0x3f));
+           target[4] = UChar(0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+           target[3] = UChar(0x80 | (CH(1) >> 4) | ((CH(2) & 0x03) << 4));
+           target[2] = UChar(0x80 | (CH(2) >> 2));
+           target[1] = UChar(0x80 | (CH(3) & 0x3f));
+           target[0] = UChar(0xfc | ((int) (CH(3) & 0x40) >> 6));
+           break;
+       }
+    }
+
+    return rc;                 /* number of bytes needed in target */
+#undef CH
+}
+
+NCURSES_EXPORT(int)
+_nc_conv_to_utf32(unsigned *target, const char *source, unsigned limit)
+{
+#define CH(n) UChar((*target) >> ((n) * 8))
+    int rc = 0;
+    int j;
+    unsigned mask = 0;
+
+    /*
+     * Find the number of bytes we will need from the source.
+     */
+    if ((*source & 0x80) == 0) {
+       rc = 1;
+       mask = (unsigned) *source;
+    } else if ((*source & 0xe0) == 0xc0) {
+       rc = 2;
+       mask = (unsigned) (*source & 0x1f);
+    } else if ((*source & 0xf0) == 0xe0) {
+       rc = 3;
+       mask = (unsigned) (*source & 0x0f);
+    } else if ((*source & 0xf8) == 0xf0) {
+       rc = 4;
+       mask = (unsigned) (*source & 0x07);
+    } else if ((*source & 0xfc) == 0xf8) {
+       rc = 5;
+       mask = (unsigned) (*source & 0x03);
+    } else if ((*source & 0xfe) == 0xfc) {
+       rc = 6;
+       mask = (unsigned) (*source & 0x01);
+    }
+
+    if ((unsigned) rc > limit) {       /* whatever it is, we cannot decode it */
+       rc = 0;
+    }
+
+    /*
+     * sanity-check.
+     */
+    if (rc > 1) {
+       for (j = 1; j < rc; j++) {
+           if ((source[j] & 0xc0) != 0x80)
+               break;
+       }
+       if (j != rc) {
+           rc = 0;
+       }
+    }
+
+    if (target != 0) {
+       int shift = 0;
+       *target = 0;
+       for (j = 1; j < rc; j++) {
+           *target |= (unsigned) (source[rc - j] & 0x3f) << shift;
+           shift += 6;
+       }
+       *target |= mask << shift;
+    }
+    return rc;
+#undef CH
+}
+#endif /* EXP_XTERM_1005 */
index 51ffa2ef7634884bf02816032ddbbc548c09b301..c62b71a0658bbd9e64155cb0772f007c77828cc8 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracemse.c,v 1.21 2012/12/15 23:51:19 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.22 2014/10/10 09:06:26 tom Exp $")
 
 #ifdef TRACE
 
 #define my_buffer sp->tracemse_buf
 
-static char *
-_trace_mmask_t(SCREEN *sp, mmask_t code)
+NCURSES_EXPORT(char *)
+_nc_trace_mmask_t(SCREEN *sp, mmask_t code)
 {
 #define SHOW(m, s) \
     if ((code & m) == m) { \
-       _nc_STRCAT(my_buffer, s, sizeof(my_buffer)); \
+       size_t n = strlen(my_buffer); \
+       if (n && (my_buffer[n-1] != '{')) \
        _nc_STRCAT(my_buffer, ", ", sizeof(my_buffer)); \
+       _nc_STRCAT(my_buffer, s, sizeof(my_buffer)); \
     }
 
     SHOW(BUTTON1_RELEASED, "release-1");
@@ -125,7 +127,7 @@ _nc_tracemouse(SCREEN *sp, MEVENT const *ep)
                    ep->z,
                    (unsigned long) ep->bstate);
 
-       (void) _trace_mmask_t(sp, ep->bstate);
+       (void) _nc_trace_mmask_t(sp, ep->bstate);
        _nc_STRCAT(my_buffer, "}", sizeof(my_buffer));
        result = (my_buffer);
     }
@@ -137,7 +139,7 @@ _nc_retrace_mmask_t(SCREEN *sp, mmask_t code)
 {
     if (sp != 0) {
        *my_buffer = '\0';
-       T((T_RETURN("{%s}"), _trace_mmask_t(sp, code)));
+       T((T_RETURN("{%s}"), _nc_trace_mmask_t(sp, code)));
     } else {
        T((T_RETURN("{?}")));
     }
index f50b132a490785deaeecc3a7a45884eba25bc087..5f35b73d282c7b29a35a0e21962e6dbb4ef8dd8c 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20140927) unstable; urgency=low
+ncurses6 (5.9-20141011) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Tue, 23 Sep 2014 16:52:38 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Wed, 08 Oct 2014 21:02:28 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
index f50b132a490785deaeecc3a7a45884eba25bc087..5f35b73d282c7b29a35a0e21962e6dbb4ef8dd8c 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20140927) unstable; urgency=low
+ncurses6 (5.9-20141011) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Tue, 23 Sep 2014 16:52:38 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Wed, 08 Oct 2014 21:02:28 -0400
 
 ncurses6 (5.9-20131005) unstable; urgency=low
 
index 26e8499f7b3e05d36a2d58f1da682d014c023189..c3c8681379831c1900ea07110280189cfb18c453 100644 (file)
@@ -1,8 +1,8 @@
-ncurses6 (5.9-20140927) unstable; urgency=low
+ncurses6 (5.9-20141011) unstable; urgency=low
 
   * latest weekly patch
 
- -- Thomas E. Dickey <dickey@invisible-island.net>  Tue, 23 Sep 2014 16:52:38 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Wed, 08 Oct 2014 21:02:28 -0400
 
 ncurses6 (5.9-20120608) unstable; urgency=low
 
index 307d3d532bf2791eec9152409a535cc6203246ae..6843c40f761144f849d35916f44a706abaf186af 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: mingw-ncurses.nsi,v 1.63 2014/09/23 20:52:38 tom Exp $\r
+; $Id: mingw-ncurses.nsi,v 1.65 2014/10/09 01:02:28 tom Exp $\r
 \r
 ; TODO add examples\r
 ; TODO bump ABI to 6\r
@@ -10,7 +10,7 @@
 !define VERSION_MAJOR "5"\r
 !define VERSION_MINOR "9"\r
 !define VERSION_YYYY  "2014"\r
-!define VERSION_MMDD  "0927"\r
+!define VERSION_MMDD  "1011"\r
 !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}\r
 \r
 !define MY_ABI   "5"\r
index fe3a6b5ea8b32fe171a4976cb072efa32a82d9f5..21108cfce21b77c9c2f85ca8c469f39e9d9cb23c 100644 (file)
@@ -3,7 +3,7 @@
 Summary: shared libraries for terminal handling
 Name: mingw32-ncurses6
 Version: 5.9
-Release: 20140927
+Release: 20141011
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
index ae621d7152646280e04f64309b8df7c993eccced..83035483ce8af065129e2227c36a6c456df49e6a 100644 (file)
@@ -1,7 +1,7 @@
 Summary: shared libraries for terminal handling
 Name: ncurses6
 Version: 5.9
-Release: 20140927
+Release: 20141011
 License: X11
 Group: Development/Libraries
 Source: ncurses-%{version}-%{release}.tgz
index 7ba067c13a78d979c1ccb541d5930e899cfab502..97125e396e5fc0720069a08117ef9a6075588b32 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_forms.c,v 1.49 2014/08/02 23:11:57 tom Exp $
+ * $Id: demo_forms.c,v 1.50 2014/10/10 00:38:00 tom Exp $
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
@@ -172,6 +172,7 @@ read_data(const char *filename)
                failed("expected a colon");
            }
        }
+       fclose(fp);
     } else {
        failed(filename);
     }
index 30967cc0f4548d3d3b87f9568edb8704df9ace31..2a29266f6bb50ef3b6fe0eff0a4776e9a4c33243 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_termcap.c,v 1.45 2014/09/05 08:44:49 tom Exp $
+ * $Id: demo_termcap.c,v 1.46 2014/10/10 00:35:43 tom Exp $
  *
  * A simple demo of the termcap interface.
  */
@@ -405,6 +405,7 @@ parse_description(const char *input_name)
     if ((fp = fopen(input_name, "r")) == 0)
        failed("cannot open input-file");
     len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+    my_blob[sb.st_size] = '\0';
     fclose(fp);
 
     /*
index b4466168fa6dc0710f354608bbd6fb0e0c8ae408..3b44a0bbcff445018a4f344ada172e4a1a138481 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_terminfo.c,v 1.37 2014/09/05 08:44:49 tom Exp $
+ * $Id: demo_terminfo.c,v 1.38 2014/10/10 00:35:28 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
@@ -453,6 +453,7 @@ parse_description(const char *input_name)
     if ((fp = fopen(input_name, "r")) == 0)
        failed("cannot open input-file");
     len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+    my_blob[sb.st_size] = '\0';
     fclose(fp);
 
     /*
index ef75b42587780cc6894b427f86aaeeb35af25d6c..e6aa8fa6e6b6152e4046a7aab62bc5d9676d2444 100644 (file)
@@ -40,7 +40,7 @@ AUTHOR
    Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.416 2014/08/16 23:30:20 tom Exp $
+$Id: ncurses.c,v 1.417 2014/10/10 09:09:41 tom Exp $
 
 ***************************************************************************/
 
@@ -943,7 +943,7 @@ begin_getch_test(void)
     refresh();
 
 #ifdef NCURSES_MOUSE_VERSION
-    mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
+    mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, (mmask_t *) 0);
 #endif
 
     (void) printw("Delay in 10ths of a second (<CR> for blocking input)? ");