INSTALL                  |   71 
 MANIFEST                 |    3 
 Makefile.in              |    4 
 NEWS                     |  149 +
 VTPrsTbl.c               |   12 
 aclocal.m4               |  107 +
 button.c                 |   14 
 charproc.c               |  251 ++-
 charsets.c               |   50 
 config.guess             |  101 -
 config.sub               |   46 
 configure                | 3884 +++++++++++++++++++++++++----------------------
 configure.in             |   87 -
 ctlseqs.ms               |  109 -
 ctlseqs.txt              |  268 +--
 data.c                   |   11 
 data.h                   |    4 
 error.h                  |   30 
 fontutils.c              |  414 ++++-
 fontutils.h              |    3 
 graphics_regis.c         |   27 
 html.c                   |   38 
 linedata.c               |   95 -
 main.c                   |  328 +--
 menu.c                   |   45 
 misc.c                   |  318 ++-
 package/debian/changelog |    6 
 package/debian/copyright |   24 
 package/debian/rules     |    3 
 package/debian/watch     |    2 
 package/freebsd/Makefile |    8 
 package/xterm.spec       |    9 
 print.c                  |   69 
 ptyx.h                   |  145 +
 resize.man               |    7 
 screen.c                 |   22 
 scrollbar.c              |   34 
 svg.c                    |   41 
 termcap                  |   11 
 terminfo                 |  108 +
 trace.c                  |   29 
 trace.h                  |    8 
 util.c                   |   99 -
 version.h                |    6 
 vttests/query-status.pl  |   18 
 xcharmouse.h             |    3 
 xstrings.c               |    4 
 xterm.h                  |   38 
 xterm.log.html           |  243 ++
 xterm.man                |  564 ++++--
 xtermcfg.hin             |    5 
 51 files changed, 4961 insertions(+), 3014 deletions(-)

New commits:
commit 3349eff7f9c4b029ffd0d46ed750d6391fe20a61
Author: Sven Joachim <svenj...@gmx.de>
Date:   Sun Dec 31 09:14:42 2017 +0100

    Imported Upstream version 331

diff --git a/INSTALL b/INSTALL
index 188bac3..0a768b2 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
--- $XTermId: INSTALL,v 1.163 2017/05/30 08:32:35 tom Exp $
+-- $XTermId: INSTALL,v 1.176 2017/12/25 12:48:26 tom Exp $
 -------------------------------------------------------------------------------
 -- Copyright 1997-2016,2017 by Thomas E. Dickey
 --
@@ -49,6 +49,16 @@ the sense of the default behavior.
 
 The options (in alphabetic order):
 
+  --disable-256-color     disable 256-color support
+
+       Do not compile-in code that interprets SGR 38 and 48 for 256-colors.
+       If this feature is disabled, the 88-color feature will be used.
+
+  --disable-88-color      disable 88-color support
+
+       Do not compile-in code that interprets SGR 38 and 48 for 88-colors.
+       The 256-color option overrides this.
+
   --disable-16-color      disable 16-color support
 
        Do not compile-in code to recognize aixterm-style control sequences
@@ -137,6 +147,11 @@ The options (in alphabetic order):
 
        Note: If desktop-utils is not found they will not be installed anyway.
 
+  --disable-direct-color  disable direct color support
+
+       Do not compile-in code that interprets SGR 38 and 48 for direct colors.
+       This feature extends the 256-color feature.
+
   --disable-doublechars   disable support for double-size chars
 
        Do not compile-in code that supports font-manipulation needed to
@@ -156,7 +171,7 @@ The options (in alphabetic order):
 
   --disable-freetype      disable freetype library-support
 
-       Do not use freetype libraries if they are found.  Normally they will
+       Do not use freetype libraries if they are found.  Normally they will
        be used automatically.
 
   --disable-full-tgetent  disable check for termcap library
@@ -285,6 +300,10 @@ The options (in alphabetic order):
        Do not compile-in code that suppresses redundant updates to the
        titlebar when the text has not changed.
 
+  --disable-screen-dumps  disable XHTML and SVG screen dumps
+
+       Do not compile-in code that provides XHTML and SVG screen dumps.
+
   --disable-selection-ops disable selection operations
 
        Do not compile-in code to support the actions which allow users
@@ -345,7 +364,7 @@ The options (in alphabetic order):
        ISO 6429 defines a few more which historically have found little use.
        Some people find these amusing.
 
-       This is normally enabled.
+       This is normally enabled.  The direct-colors feature relies upon it.
 
   --disable-wide-chars    disable wide-character support
 
@@ -365,14 +384,6 @@ The options (in alphabetic order):
        This uses less memory, but is less complete.  However, most languages
        are covered by the 16-bit encoding.
 
-  --enable-256-color      enable 256-color support
-
-       Compile-in code that interprets SGR 38 and 48 for 256-colors.
-
-  --enable-88-color       enable 88-color support
-
-       Compile-in code that interprets SGR 38 and 48 for 88-colors.
-
   --enable-alt-sends-esc  set default altSendsEscape resource (default: no)
 
        This sets the default resource value, which is shown in the manpage.
@@ -522,10 +533,6 @@ The options (in alphabetic order):
 
        Compile-in code to support experimental sixel-graphics
 
-  --enable-sun-fkeys      enable support for Sun-style function keys
-
-       Compile-in code to support Sun-style function keys.
-
   --enable-toolbar        enable pulldown menus on toolbar
 
        Compile-in code that builds a toolbar with pulldown menus.  The
@@ -613,9 +620,10 @@ The options (in alphabetic order):
 
        Check for and link with dbmalloc.
 
-  --with-desktop-category=XXX  one or more desktop catgories or auto
+  --with-desktop-category=XXX  one or more desktop categories or auto
        This is a list of names.  The configure script maps blanks and commas
-       to semicolons (";") which are used by the desktop utils as a separator.
+       to semicolons (";") which are used by the desktop utilities as a
+       separator.
 
        The default value "auto" tells the configure script to look
        at existing ".desktop" files for xterm and common terminal
@@ -625,7 +633,7 @@ The options (in alphabetic order):
 
   --with-freetype-config  configure script to use for FreeType
 
-       Use a specific option value to tell the configure script to try
+       Use a specific option value to tell the configure script to try
        just one of the variations:
 
        "pkg*", e.g., pkg-config or pkgconfig uses whatever pkg-config
@@ -703,14 +711,18 @@ The options (in alphabetic order):
   --with-man2html[=XXX]   use XXX rather than groff
 
        Specify an alternative program to use for converting manpages and
-       control sequences document to html.  If the option is given, its
-       default value is "man2html", otherwise it is "groff" with groff's
-       special options.  The "man2html" script reads formatted nroff output
-       from its standard input, and writes html to its standard output.  Other
-       input/output conventions are not currently supported.
+       control sequences document to html.  The default value for the option
+       is "man2html".  If the "man2html" script is not found, then "groff" is
+       used with groff's special options.
+       
+       The "man2html" script reads formatted nroff output from its standard
+       input, and writes html to its standard output.  Other input/output
+       conventions are not currently supported.
 
        See
                http://invisible-island.net/scripts
+               http://invisible-island.net/scripts/man2html.html
+
        for an up-to-date version of "man2html".
 
   --with-neXtaw           link with neXT Athena library
@@ -733,9 +745,18 @@ The options (in alphabetic order):
        directed to other variations (such as nxterm) which do not
        support the background-color erase capability.
 
+  --with-pixmapdir=DIR    directory in which to install pixmaps 
(DATADIR/pixmaps)
+
+       Specify directory in which to install ".xpm" files.
+
   --with-pcre             use PCRE for regular-expressions
 
-       If regular expressions are not disable (--disable-regex), use PCRE
+       If regular expressions are not disabled (--disable-regex), use PCRE
+       rather than the POSIX regular expressions.
+
+  --with-pcre2            use PCRE2 for regular-expressions
+
+       If regular expressions are not disabled (--disable-regex), use PCRE2
        rather than the POSIX regular expressions.
 
   --with-pkg-config{=path} enable/disable use of pkg-config
@@ -794,7 +815,7 @@ The options (in alphabetic order):
 
   --with-xpm=DIR          use Xpm library for colored icon, may specify path
 
-       Use Xpm library to show colored icon in window decoration, e.g.,
+       Use Xpm library to show colored icon in window decoration, e.g.,
        title area.
 
        Use --without-xpm to suppress this feature.
diff --git a/MANIFEST b/MANIFEST
index d4d4430..cd7b264 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST for xterm-330, version xterm-330
+MANIFEST for xterm-331, version xterm-331
 
--------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
@@ -202,3 +202,4 @@ vttests/resize.pl               translated resize.sh to 
perl since it is easy to
 vttests/resize.sh               script to demonstrate resizing
 vttests/tcapquery.pl            script to test tcap-query option
 vttests/title.sh                test-script to show title of xterm in action
+vttests/true-color.pl          test script for true color
diff --git a/Makefile.in b/Makefile.in
index 5b4f67f..3341d45 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-## $XTermId: Makefile.in,v 1.239 2017/01/14 00:15:11 tom Exp $
+## $XTermId: Makefile.in,v 1.240 2017/11/06 00:21:44 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
@@ -513,7 +513,7 @@ uninstall-full ::
 @desktop_utils@                done'
 
################################################################################
 mostlyclean :
-       -$(RM) *$o *.[is] XtermLog.* .pure core *~ *.bak *.BAK *.out *.tmp
+       -$(RM) *$o *.[is] XTerm[1-9]*.* Xterm.log.* XtermLog.* .pure core *~ 
*.bak *.BAK *.out *.tmp
 
 clean : mostlyclean
        -$(RM) $(PROGRAMS) builtin_icons.h *.cin *parse.hin
diff --git a/NEWS b/NEWS
index 7022694..d83323b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,38 +1,121 @@
 The NEWS file was generated from xterm.log.html, which serves as the changelog
 for xterm.
 
--------------------------------------------------------------------------------
-                            Patch #330 - 2017/06/20
+                            Patch #331 - 2017/12/30
 
-     * updates for ReGIS (Ross Combs):
-          + remove redundant text command error check which broke T(B) and
-            T(E).
-          + retain  the  loading  alphabet  number across multiple “L”
-            commands.
-          + add S(T) delay handler.
-          + fix some color handling error messages.
-          + add stubbed-out macrograph handling.
-          + use  fragment_remaining()  and  fragment_consumed() instead of
-            manually checking position / length in various places.
-          + rename  some  local  variables  in  string  /  extent / option
-            parsing
-          + wrap some long lines.
-          + move macrograph command handling out of the top-level.
-     * add a summary of the italic fonts loaded to -report-fonts option.
-     * modify the font-lookup for italics to allow for “-i-” if no match
-       is found with slant “-o-” (prompted by patch by Ben Wong).
-     * change  default values for mkSamplePass and mkSampleSize to reflect
-       generally-improved  locale  support  in  various  operating systems
-       (FreeBSD #219800).
-     * modify  wcwidth.c to return -1 for non-Unicode values, and adjust a
-       couple  of blocks to better match assumptions about ambiguous-width
-       characters  in  other  implementations.  Also  modify  wcwidth.c to
-       support  configurable soft-hyphen, so there is no drawback to using
-       this version rather than a system wcwidth.
-     * amend  change  made  in  patch #328 for cursor-visibility to handle
-       case  where  an  application  is  updating  the reverse-video state
-       (FreeBSD #219800).
-     * update  tables  of  combining  and  ambiguous-width  characters  in
-       wcwidth.c based on Unicode 10.0.0.
-     * build-fix         for        --enable-sixel-graphics        without
-       --enable-regis-graphics (reports by Sven Joachim, FreeBSD #219945).
+     * add  workaround for improper grayscale adjustments made in FreeType
+       library, exposed by changes to rounding in 2.8.1, which shows up as
+       a gap in line-drawing characters (Debian #880407).
+     * improve  a  special  case  where  a non-Unicode font's line-drawing
+       characters  were  not  used,  when  specifying it via the utf8Fonts
+       resource, e.g.,
+
+        -fs 15 \
+        -xrm '*VT100.font:12x24' \
+        -xrm '*VT100.boldFont:12x24' \
+        -xrm '*VT100.utf8Fonts.font: 12x24' \
+        -xrm '*VT100.utf8Fonts.boldFont: 12x24' \
+
+     * replace  constant  10msec  delay for next X event with new resource
+       nextEventDelay,  and  reduce  that  to  1msec to accommodate faster
+       machines  than  used  when  -hold  was  implemented in 1999 (Debian
+       #877628).
+     * add  scroll-to  action, which simplifies binding a key to scroll to
+       the beginning or end of the saved-lines (Debian #880120).
+     * add   building  blocks  for  alternate  screen  and/or  title-stack
+       features in the terminfo file.
+     * improve calculations for cell-data size.
+     * change  configure  script  to  enable  XHTML/SVG  screen  dumps  by
+       default.
+     * change configure script to enable 256-colors by default.
+     * update config.guess, config.sub
+     * change  configure script option for --with-man2html to use improved
+       script by default.
+     * add   case   for  private  mode  1044  in  DECRQM,  to  report  the
+       keepClipboard resource setting and corresponding menu entry.
+     * fix  an  inconsistency between private mode 12 (the AT&T 610 cursor
+       blink)  and  DECSCUSR:  the former relied on having the cursorBlink
+       resource  set  initially  to  enable the escape sequence, while the
+       latter does not.
+     * add  private modes 13 and 14, as well as resource cursorBlinkXOR to
+       allow  better  control  over  the cursor-blinking state (discussion
+       with Bram Moolenaar).
+     * modify the html and svg screen dumps to support direct color
+     * modify  media  copy (screen-printing) to support the same SGR codes
+       as DECRQSS, including 88/256 indexed color as well as direct color.
+     * improve options-parsing for query-status.pl script.
+     * modify  parsing  of  SGR  direct-color  control  making color space
+       identitier optional. The corresponding DECRQSS reply always returns
+       an empty (default) field for the identifier.
+     * add wide-attributes to DECRQSS reply for SGR.
+     * add private mode 1046 to help with scripting applications.
+     * correct  expression  used for readline-flags in DECRQM; to test the
+       current  flag  rather  than  information  stacked  within  the same
+       variable.
+     * correct  typo  in ctlseqs.ms reference to ISO-8613-6 (patch by Mike
+       Frysinger).
+     * fix lintian warning for test-package.
+     * fix  typo in DECRQSS for SGR 48, which printed the foreground value
+       for  colors  past  15.  Also use colon delimiter for codes 38/48 in
+       response (report by Paul LeoNerd Evans).
+     * improve  workaround  for Debian #542434 by using the font's maximum
+       width when no ISO-8859-1 glyphs are provided (Debian #879936).
+     * work  around  a  special  case of Xft's mismanagement of its cached
+       data  by  adding  a check before the -report-fonts option to ensure
+       that it does not use an XftPattern which may have been freed during
+       a call to XftFontOpenPattern.
+     * improve  manual  page  description  of  regex  option for onXClicks
+       resources (report by Lukas Mai).
+     * add directColor resource.
+     * additional   manpage   macro   cleanup  (Brandon  Robinson,  Debian
+       #880551).
+     * add  optional  support  for  direct-colors  (adapted  from patch by
+       anonymous “Nibby Nebbulous”).
+     * improve legacy/NRC character set mapping (patch by Thomas Wolff):
+          + enable  alternate  NRC  set  designators for French and French
+            Canadian, ‘9’ and ‘f’ respectively, as documented in ctlseqs.
+            (‘9’ is documented for VT510, ‘f’ is a Kermit feature).
+          + correct  the  Unicode value in the DEC Technical table to show
+            capital delta.
+          + referring to
+
+     http://vt100.net/docs/vt220-rm/table2-3b.html
+     http://vt100.net/docs/vt320-uu/appendixe.html
+            add entries for the DEC Supplemental Graphics table to display
+            0x28/0xa8 as ¤ and 0x5d/0xdd as Ÿ.
+          + referring to
+
+     http://www.vt100.net/charsets/technical.html
+            alter  the  Unicode  values  used for 0x2b through 0x2c to use
+            curly braces to work with the “middle” parts displayed with
+            0x2f and 0x30.
+          + modify the VT220 “Supplemental” table, giving a hint that it
+            was probably meant to be “Supplemental Graphics” and is the
+            same as VT320's table.
+     * quiet a few font-warnings when a derived fontname cannot be opened,
+       overlooked   in   refactoring  of  font  resources  in  patch  #328
+       (initially reported on Cygwin mailing list, with followup).
+     * correct  error  response  for DECRQSS broken in cleanup of Coverity
+       reports  in  patch  #288  (reports  by  Bram  Moolenaar and IWAMOTO
+       Kouichi).
+     * improve DECRPM responses by returning mode not recognized for modes
+       which  may  not  be  settable  due  to  the  selected decTerminalID
+       resource (report by IWAMOTO Kouichi).
+     * correct  logic for print-immediate action, and enable corresponding
+       menu entry (patch by Lauri Tirkkonen).
+     * add configure option --with-pcre2 (patch by David Michael).
+     * fix  a  misspelled  subsection  title  in ctlseqs.ms and add a note
+       regarding  blink which was rendered as bold in X11R6. Blinking text
+       was implemented in Patch #60.
+     * fix typos in xterm.man (patches by Sven Joachim, Larry Hynes).
+     * fix  typography in xterm.man (patch by Bjarni Ingi Gislason, Debian
+       #869248).
+     * fix typo in INSTALL (Larry Hynes).
+     * add  xterm-direct  terminal description based on changes introduced
+       in patch #277, and relying upon ncurses RGB extension.
+     * modify   xterm-new   terminal   description  to  use  ECMA-48  REP,
+       reflecting its use in xterm since patch #32 (1996).
+     * clarify  comment in ctlseqs.ms regarding blink: it has been part of
+       xterm since patch #60 (1998).
+     * update ftp URLs in documentation.
 
diff --git a/VTPrsTbl.c b/VTPrsTbl.c
index f9868c4..3368320 100644
--- a/VTPrsTbl.c
+++ b/VTPrsTbl.c
@@ -1,7 +1,7 @@
-/* $XTermId: VTPrsTbl.c,v 1.81 2015/02/16 01:51:51 tom Exp $ */
+/* $XTermId: VTPrsTbl.c,v 1.82 2017/11/07 23:03:12 Thomas.Wolff Exp $ */
 
 /*
- * Copyright 1999-2014,2015 by Thomas E. Dickey
+ * Copyright 1999-2015,2017 by Thomas E. Dickey
  *
  *                         All Rights Reserved
  *
@@ -6000,7 +6000,7 @@ CASE_GSETS,
 CASE_GSETS,
 /*     8               9               :               ;       */
 CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_GSETS,
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
 /*     <               =               >               ?       */
@@ -6056,7 +6056,7 @@ CASE_GROUND_STATE,
 /*     d               e               f               g       */
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_GSETS,
 CASE_GROUND_STATE,
 /*     h               i               j               k       */
 CASE_GROUND_STATE,
@@ -6160,7 +6160,7 @@ CASE_GSETS,
 CASE_GSETS,
 /*      cedilla         onesuperior     masculine       guillemotright  */
 CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_GSETS,
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
 /*      onequarter      onehalf         threequarters   questiondown    */
@@ -6216,7 +6216,7 @@ CASE_GROUND_STATE,
 /*      adiaeresis      aring           ae              ccedilla        */
 CASE_GROUND_STATE,
 CASE_GROUND_STATE,
-CASE_GROUND_STATE,
+CASE_GSETS,
 CASE_GROUND_STATE,
 /*      egrave          eacute          ecircumflex     ediaeresis      */
 CASE_GROUND_STATE,
diff --git a/aclocal.m4 b/aclocal.m4
index dc963b0..85d8fbe 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl $XTermId: aclocal.m4,v 1.413 2017/05/02 23:45:28 tom Exp $
+dnl $XTermId: aclocal.m4,v 1.417 2017/12/24 22:48:59 tom Exp $
 dnl
 dnl ---------------------------------------------------------------------------
 dnl
@@ -264,7 +264,7 @@ ifelse([$3],,[    :]dnl
 ])dnl
 ])])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CC_ENV_FLAGS version: 7 updated: 2017/02/25 18:57:40
+dnl CF_CC_ENV_FLAGS version: 8 updated: 2017/09/23 08:50:24
 dnl ---------------
 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
 dnl into CC.  This will not help with broken scripts that wrap the compiler
@@ -288,7 +288,7 @@ case "$CC" in
        AC_MSG_WARN(your environment misuses the CC variable to hold 
CFLAGS/CPPFLAGS options)
        # humor him...
        cf_prog=`echo "$CC" | sed -e 's/        / /g' -e 's/[[ ]]* / /g' -e 
's/[[ ]]*[[ ]]-[[^ ]].*//'`
-       cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", 
substr([$]0,1+length(prog))); }'`
+       cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", 
[substr]([$]0,1+length(prog))); }'`
        CC="$cf_prog"
        for cf_arg in $cf_flags
        do
@@ -3597,9 +3597,13 @@ else
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36
+dnl CF_WITH_MAN2HTML version: 6 updated: 2017/12/24 17:45:28
 dnl ----------------
-dnl Check for man2html and groff.  Optionally prefer man2html over groff.
+dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
+dnl as a fallback.  See
+dnl
+dnl            http://invisible-island.net/scripts/man2html.html
+dnl
 dnl Generate a shell script which hides the differences between the two.
 dnl
 dnl We name that "man2html.tmp".
@@ -3608,11 +3612,35 @@ dnl The shell script can be removed later, e.g., using 
"make distclean".
 AC_DEFUN([CF_WITH_MAN2HTML],[
 AC_REQUIRE([CF_PROG_GROFF])
 
+case "x${with_man2html}" in
+(xno)
+       cf_man2html=no
+       ;;
+(x|xyes)
+       AC_PATH_PROG(cf_man2html,man2html,no)
+       case "x$cf_man2html" in
+       (x/*)
+               AC_MSG_CHECKING(for the modified Earl Hood script)
+               if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers 
at the end' >/dev/null )
+               then
+                       cf_man2html_ok=yes
+               else
+                       cf_man2html=no
+                       cf_man2html_ok=no
+               fi
+               AC_MSG_RESULT($cf_man2html_ok)
+               ;;
+       (*)
+               cf_man2html=no
+               ;;
+       esac
+esac
+
 AC_MSG_CHECKING(for program to convert manpage to html)
 AC_ARG_WITH(man2html,
        [  --with-man2html=XXX     use XXX rather than groff],
        [cf_man2html=$withval],
-       [cf_man2html=$GROFF_PATH])
+       [cf_man2html=$cf_man2html])
 
 cf_with_groff=no
 
@@ -3732,7 +3760,7 @@ AC_SUBST(MAN2HTML_PATH)
 AC_SUBST(MAN2HTML_TEMP)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_PCRE version: 11 updated: 2015/04/12 15:39:00
+dnl CF_WITH_PCRE version: 12 updated: 2017/07/29 22:57:34
 dnl ------------
 dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
 dnl available and the user requests it.  Assume the application will otherwise
@@ -3754,21 +3782,58 @@ if test "$with_pcre" != no ; then
                AC_CHECK_LIB(pcre,pcre_compile,,
                        AC_MSG_ERROR(Cannot find PCRE library))])
 
-               AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile 
with the PCRE library])
+       AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with 
the PCRE library])
 
-               case $LIBS in
-               (*pcreposix*)
-                       ;;
-               (*)
-                       AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
-                               [AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if 
we should include pcreposix.h])
-                                CF_ADD_LIB(pcreposix)],
-                               [AC_CHECK_LIB(pcreposix,regcomp,[
-                                       AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 
1 if we should include pcreposix.h])
-                                       CF_ADD_LIB(pcreposix)],
-                                       AC_MSG_ERROR(Cannot find PCRE POSIX 
library)]))
-                       ;;
-               esac
+       case $LIBS in
+       (*pcreposix*)
+               ;;
+       (*)
+               AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
+                       [AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should 
include pcreposix.h])
+                               CF_ADD_LIB(pcreposix)],
+                       [AC_CHECK_LIB(pcreposix,regcomp,[
+                               AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we 
should include pcreposix.h])
+                               CF_ADD_LIB(pcreposix)],
+                               AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
+               ;;
+       esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_PCRE2 version: 1 updated: 2017/07/29 22:57:34
+dnl -------------
+dnl Add PCRE2 (Perl-compatible regular expressions v2) to the build if it is
+dnl available and the user requests it.  Assume the application will otherwise
+dnl use the POSIX interface.
+dnl
+dnl TODO allow $withval to specify package location
+AC_DEFUN([CF_WITH_PCRE2],
+[
+AC_REQUIRE([CF_PKG_CONFIG])
+
+AC_MSG_CHECKING(if you want to use PCRE2 for regular-expressions)
+AC_ARG_WITH(pcre2,
+       [  --with-pcre2            use PCRE2 for regular-expressions])
+test -z "$with_pcre2" && with_pcre2=no
+AC_MSG_RESULT($with_pcre2)
+
+if test "$with_pcre2" != no ; then
+       CF_TRY_PKG_CONFIG(libpcre2,,[
+               AC_CHECK_LIB(pcre2-8,pcre2_compile_8,,
+                       AC_MSG_ERROR(Cannot find PCRE2 library))])
+
+       AC_DEFINE(HAVE_LIB_PCRE2,1,[Define to 1 if we can/should compile with 
the PCRE2 library])
+
+       case $LIBS in
+       (*pcre2-posix*)
+               ;;
+       (*)
+               AC_CHECK_LIB(pcre2-posix,regcomp,[
+                       AC_DEFINE(HAVE_PCRE2POSIX_H,1,[Define to 1 if we should 
include pcre2posix.h])
+                       CF_ADD_LIB(pcre2-posix)],
+                       AC_MSG_ERROR(Cannot find PCRE2 POSIX library))
+               ;;
+       esac
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
diff --git a/button.c b/button.c
index 43ef7b0..ac1f742 100644
--- a/button.c
+++ b/button.c
@@ -1,4 +1,4 @@
-/* $XTermId: button.c,v 1.524 2017/05/30 08:58:29 tom Exp $ */
+/* $XTermId: button.c,v 1.526 2017/12/01 00:47:35 tom Exp $ */
 
 /*
  * Copyright 1999-2016,2017 by Thomas E. Dickey
@@ -79,6 +79,9 @@ button.c      Handles button events in the terminal emulator.
 #include <xstrings.h>
 
 #if OPT_SELECT_REGEX
+#ifdef HAVE_PCRE2POSIX_H
+#include <pcre2posix.h>
+#else
 #ifdef HAVE_PCREPOSIX_H
 #include <pcreposix.h>
 #else /* POSIX regex.h */
@@ -86,6 +89,7 @@ button.c      Handles button events in the terminal emulator.
 #include <regex.h>
 #endif
 #endif
+#endif
 
 #if OPT_WIDE_CHARS
 #include <ctype.h>
@@ -5142,7 +5146,7 @@ formatVideoAttrs(XtermWidget xw, char *buffer, CELL *cell)
        }
 #if OPT_ISO_COLORS
        if (attribs & FG_COLOR) {
-           unsigned fg = extract_fg(xw, ld->color[cell->col], attribs);
+           Pixel fg = extract_fg(xw, ld->color[cell->col], attribs);
            if (fg < 8) {
                fg += 30;
            } else if (fg < 16) {
@@ -5151,11 +5155,11 @@ formatVideoAttrs(XtermWidget xw, char *buffer, CELL 
*cell)
                buffer += sprintf(buffer, "%s38;5", delim);
                delim = ";";
            }
-           buffer += sprintf(buffer, "%s%u", delim, fg);
+           buffer += sprintf(buffer, "%s%lu", delim, fg);
            delim = ";";
        }
        if (attribs & BG_COLOR) {
-           unsigned bg = extract_bg(xw, ld->color[cell->col], attribs);
+           Pixel bg = extract_bg(xw, ld->color[cell->col], attribs);
            if (bg < 8) {
                bg += 40;
            } else if (bg < 16) {
@@ -5164,7 +5168,7 @@ formatVideoAttrs(XtermWidget xw, char *buffer, CELL *cell)
                buffer += sprintf(buffer, "%s48;5", delim);
                delim = ";";
            }
-           (void) sprintf(buffer, "%s%u", delim, bg);
+           (void) sprintf(buffer, "%s%lu", delim, bg);
        }
 #endif
     }
diff --git a/charproc.c b/charproc.c
index 31cd8bc..91c10b7 100644
--- a/charproc.c
+++ b/charproc.c
@@ -1,4 +1,4 @@
-/* $XTermId: charproc.c,v 1.1492 2017/06/19 08:34:54 tom Exp $ */
+/* $XTermId: charproc.c,v 1.1517 2017/12/28 18:43:58 tom Exp $ */
 
 /*
  * Copyright 1999-2016,2017 by Thomas E. Dickey
@@ -168,12 +168,14 @@ static void restoremodes(XtermWidget /* xw */ );
 static void savemodes(XtermWidget /* xw */ );
 static void window_ops(XtermWidget /* xw */ );
 
-#define DoStartBlinking(s) ((s)->cursor_blink ^ (s)->cursor_blink_esc)
-
 #if OPT_BLINK_CURS || OPT_BLINK_TEXT
-#define UpdateCursorBlink(screen) SetCursorBlink(screen, screen->cursor_blink)
+#define SettableCursorBlink(screen) \
+       (((screen)->cursor_blink != cbAlways) && \
+        ((screen)->cursor_blink != cbNever))
+#define UpdateCursorBlink(screen) \
+        SetCursorBlink(screen, screen->cursor_blink)
 static void SetCursorBlink(TScreen * /* screen */ ,
-                          Bool /* enable */ );
+                          BlinkOps /* enable */ );
 static void HandleBlinking(XtPointer /* closure */ ,
                           XtIntervalId * /* id */ );
 static void StartBlinking(TScreen * /* screen */ );
@@ -260,6 +262,7 @@ static XtActionsRec actionsList[] = {
     { "redraw",                        HandleRedraw },
     { "scroll-back",           HandleScrollBack },
     { "scroll-forw",           HandleScrollForward },
+    { "scroll-to",             HandleScrollTo },
     { "secure",                        HandleSecure },
     { "select-cursor-end",     HandleKeyboardSelectEnd },
     { "select-cursor-extend",   HandleKeyboardSelectExtend },
@@ -491,6 +494,7 @@ static XtResource xterm_resources[] =
     Ires(XtNprinterControlMode, XtCPrinterControlMode,
         SPS.printer_controlmode, 0),
     Ires(XtNtitleModes, XtCTitleModes, screen.title_modes, DEF_TITLE_MODES),
+    Ires(XtNnextEventDelay, XtCNextEventDelay, screen.nextEventDelay, 1),
     Ires(XtNvisualBellDelay, XtCVisualBellDelay, screen.visualBellDelay, 100),
     Ires(XtNsaveLines, XtCSaveLines, screen.savelines, SAVELINES),
     Ires(XtNscrollBarBorder, XtCScrollBarBorder, screen.scrollBarBorder, 1),
@@ -556,7 +560,8 @@ static XtResource xterm_resources[] =
 #endif                         /* NO_ACTIVE_ICON */
 
 #if OPT_BLINK_CURS
-    Bres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink, False),
+    Bres(XtNcursorBlinkXOR, XtCCursorBlinkXOR, screen.cursor_blink_xor, True),
+    Sres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink_s, "false"),
 #endif
     Bres(XtNcursorUnderLine, XtCCursorUnderLine, screen.cursor_underline, 
False),
 
@@ -626,6 +631,9 @@ static XtResource xterm_resources[] =
 #if OPT_WIDE_ATTRS
     Bres(XtNcolorITMode, XtCColorAttrMode, screen.colorITMode, False),
 #endif
+#if OPT_DIRECT_COLOR
+    Bres(XtNdirectColor, XtCDirectColor, screen.direct_color, True),
+#endif
 
     COLOR_RES("0", screen.Acolors[COLOR_0], DFT_COLOR("black")),
     COLOR_RES("1", screen.Acolors[COLOR_1], DFT_COLOR("red3")),
@@ -889,6 +897,7 @@ xtermAddInput(Widget w)
        { "string",                 HandleStringEvent },
        { "scroll-back",            HandleScrollBack },
        { "scroll-forw",            HandleScrollForward },
+       { "scroll-to",              HandleScrollTo },
        { "select-cursor-end",      HandleKeyboardSelectEnd },
        { "select-cursor-extend",   HandleKeyboardSelectExtend },
        { "select-cursor-start",    HandleKeyboardSelectStart },
@@ -990,7 +999,7 @@ SGR_Foreground(XtermWidget xw, int color)
     } else {
        UIntClr(xw->flags, FG_COLOR);
     }
-    fg = getXtermForeground(xw, xw->flags, color);
+    fg = getXtermFG(xw, xw->flags, color);
     xw->cur_foreground = color;
 
     setCgsFore(xw, WhichVWin(screen), gcNorm, fg);
@@ -1035,7 +1044,7 @@ SGR_Background(XtermWidget xw, int color)
     } else {
        UIntClr(xw->flags, BG_COLOR);
     }
-    bg = getXtermBackground(xw, xw->flags, color);
+    bg = getXtermBG(xw, xw->flags, color);
     xw->cur_background = color;
 
     setCgsBack(xw, WhichVWin(screen), gcNorm, bg);
@@ -1065,7 +1074,7 @@ setExtendedFG(XtermWidget xw)
      */
 #if OPT_PC_COLORS              /* XXXJTL should be settable at runtime 
(resource or OSC?) */
     if (TScreenOf(xw)->boldColors
-       && (!xw->sgr_extended)
+       && (!hasDirectFG(xw->flags))
        && (fg >= 0)
        && (fg < 8)
        && (xw->flags & BOLD))
@@ -1096,7 +1105,7 @@ static void
 reset_SGR_Foreground(XtermWidget xw)
 {
     xw->sgr_foreground = -1;
-    xw->sgr_extended = False;
+    clrDirectFG(xw->flags);
     setExtendedFG(xw);
 }
 
@@ -1104,6 +1113,7 @@ static void
 reset_SGR_Background(XtermWidget xw)
 {
     xw->sgr_background = -1;
+    clrDirectBG(xw->flags);
     setExtendedBG(xw);
 }
 
@@ -1657,7 +1667,7 @@ param_has_subparams(int item)
     if (parms.has_subparams) {
        int n = subparam_index(item, 0);
        if (n >= 0 && parms.is_sub[n]) {
-           while (n++ < nparam && parms.is_sub[n - 1] < parms.is_sub[n]) {
+           while (++n < nparam && parms.is_sub[n - 1] < parms.is_sub[n]) {
                result++;
            }
        }
@@ -1666,7 +1676,7 @@ param_has_subparams(int item)
     return result;
 }
 
-#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
+#if OPT_DIRECT_COLOR || OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
 /*
  * Given an index into the parameter array, return the corresponding parameter
  * number (starting from zero).
@@ -1731,13 +1741,28 @@ get_subparam(int p, int s)
  * This function accepts either format (per request by Paul Leonerd Evans).
  * It also accepts
  *     CSI 38 : 5 : 1 m
- * according to Lars' original assumption.
+ * according to Lars' original assumption.  While implementing that, I added
+ * support for Konsole's interpretation of "CSI 38 : 2" as a 24-bit RGB value.
+ * ISO-8613-6 documents that as "direct color".
  *
- * By the way - all of the parameters are decimal integers.
+ * At the time in 2012, no one noticed (or commented) regarding ISO-8613-6's
+ * quirk in the description of direct color:  it mentions a color space
+ * identifier parameter which should follow the "2" (as parameter 1).  In the
+ * same section, ISO-8613-6 mentions a parameter 6 which can be ignored, as
+ * well as parameters 7 and 8.  Like parameter 1, parameters 7 and 8 are not
+ * defined clearly in the standard, and a close reading indicates they are
+ * optional, saying they "may be used".  This implementation ignores parameters
+ * 6 (and above), and provides for the color space identifier by checking the
+ * number of parameters:
+ *     3 after "2" (no color space identifier)
+ *     4 or more after "2" (color space identifier)
+ *
+ * By the way - all of the parameters are decimal integers, and missing
+ * parameters represent a default value.  ISO-8613-6 is clear about that.
  */
 #define extended_colors_limit(n) ((n) == 5 ? 1 : ((n) == 2 ? 3 : 0))
 static Boolean
-parse_extended_colors(XtermWidget xw, int *colorp, int *itemp)
+parse_extended_colors(XtermWidget xw, int *colorp, int *itemp, Boolean 
*extended)
 {
     Boolean result = False;
     int item = *itemp;
@@ -1761,7 +1786,7 @@ parse_extended_colors(XtermWidget xw, int *colorp, int 
*itemp)
        need = extended_colors_limit(code);
        next = item + have;
        for (n = 0; n < need && n < 3; ++n) {
-           values[n] = get_subparam(base, 2 + n);
+           values[n] = get_subparam(base, 2 + n + (have > 4));
        }
     } else if (++item < nparam) {
        ++base;
@@ -1772,7 +1797,7 @@ parse_extended_colors(XtermWidget xw, int *colorp, int 
*itemp)
            need = extended_colors_limit(code);
            next = base + have;
            for (n = 0; n < need && n < 3; ++n) {
-               values[n] = get_subparam(base, 1 + n);
+               values[n] = get_subparam(base, 1 + n + (have > 3));
            }
        } else {
            /* accept CSI 38 ; 5 ; 1 m */
@@ -1787,13 +1812,24 @@ parse_extended_colors(XtermWidget xw, int *colorp, int 
*itemp)
     }
     item = next;
 
+    *extended = False;
     switch (code) {
     case 2:
        /* direct color in rgb space */
        if ((values[0] >= 0 && values[0] < 256) &&
            (values[1] >= 0 && values[1] < 256) &&
            (values[2] >= 0 && values[2] < 256)) {
-           *colorp = xtermClosestColor(xw, values[0], values[1], values[2]);
+#if OPT_DIRECT_COLOR
+           if (TScreenOf(xw)->direct_color && xw->has_rgb) {
+               *colorp = getDirectColor(xw, values[0], values[1], values[2]);
+               result = True;
+               *extended = True;
+           } else
+#endif
+           {
+               *colorp = xtermClosestColor(xw, values[0], values[1], 
values[2]);
+               result = okIndexedColor(*colorp);
+           }
        } else {
            *colorp = -1;
        }
@@ -1801,13 +1837,13 @@ parse_extended_colors(XtermWidget xw, int *colorp, int 
*itemp)
     case 5:
        /* indexed color */
        *colorp = values[0];
+       result = okIndexedColor(*colorp);
        break;
     default:
        *colorp = -1;
        break;
     }
 
-    result = (*colorp >= 0 && *colorp < NUM_ANSI_COLORS);
     TRACE(("...resulting color %d/%d %s\n",
           *colorp, NUM_ANSI_COLORS,
           result ? "OK" : "ERR"));
@@ -1929,6 +1965,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
     int laststate;
     int thischar = -1;
     XTermRect myRect;
+    Boolean extended;
 
     do {
 #if OPT_WIDE_CHARS
@@ -3013,7 +3050,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
                case 37:
                    if_OPT_ISO_COLORS(screen, {
                        xw->sgr_foreground = (op - 30);
-                       xw->sgr_extended = False;
+                       clrDirectFG(xw->flags);
                        setExtendedFG(xw);
                    });
                    break;
@@ -3022,9 +3059,10 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
                     * properly eat all the parameters for unsupported modes.
                     */
                    if_OPT_ISO_COLORS(screen, {
-                       if (parse_extended_colors(xw, &value, &item)) {
+                       if (parse_extended_colors(xw, &value, &item,
+                                                 &extended)) {
                            xw->sgr_foreground = value;
-                           xw->sgr_extended = True;
+                           setDirectFG(xw->flags, extended);
                            setExtendedFG(xw);
                        }
                    });
@@ -3051,13 +3089,16 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
                case 47:
                    if_OPT_ISO_COLORS(screen, {
                        xw->sgr_background = (op - 40);
+                       clrDirectBG(xw->flags);
                        setExtendedBG(xw);
                    });
                    break;
                case 48:
                    if_OPT_ISO_COLORS(screen, {
-                       if (parse_extended_colors(xw, &value, &item)) {
+                       if (parse_extended_colors(xw, &value, &item,
+                                                 &extended)) {
                            xw->sgr_background = value;
+                           setDirectBG(xw->flags, extended);
                            setExtendedBG(xw);
                        }
                    });
@@ -3084,7 +3125,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
                case 97:
                    if_OPT_AIX_COLORS(screen, {
                        xw->sgr_foreground = (op - 90 + 8);
-                       xw->sgr_extended = False;
+                       clrDirectFG(xw->flags);
                        setExtendedFG(xw);
                    });
                    break;
@@ -3111,6 +3152,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
                case 107:
                    if_OPT_AIX_COLORS(screen, {
                        xw->sgr_background = (op - 100 + 8);
+                       clrDirectBG(xw->flags);
                        setExtendedBG(xw);
                    });
                    break;
@@ -3438,7 +3480,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
            TRACE(("CASE_DECSCUSR\n"));
            {
                Boolean change = True;
-               Boolean blinks = screen->cursor_blink_esc;
+               int blinks = screen->cursor_blink_esc;
 
                HideCursor();
 
@@ -4132,13 +4174,13 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState 
*sp)
 
        case CASE_RQM:
            TRACE(("CASE_RQM\n"));
-           do_rpm(xw, ParamPair(0));

Reply via email to