]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
changes to use readline variables for the color and background used to highlight...
authorChet Ramey <chet.ramey@case.edu>
Fri, 11 Feb 2022 14:21:26 +0000 (09:21 -0500)
committerChet Ramey <chet.ramey@case.edu>
Fri, 11 Feb 2022 14:21:26 +0000 (09:21 -0500)
18 files changed:
.gitignore
.gitignore~ [new file with mode: 0644]
bind.c
display.c
doc/history.texi
doc/hstech.texi
doc/hsuser.texi
doc/readline.3
doc/rlman.texi
doc/rltech.texi
doc/rluser.texi
doc/rluserman.texi
doc/version.texi
history.h
readline.h
rlprivate.h
rltty.c
terminal.c

index be107bbad478f4873b9fdf03092ab3410eecabf7..4f4df66baeced8c3cd8548ee6ee7fe2ff04a8cee 100644 (file)
@@ -33,5 +33,6 @@ libreadline.so.*
 *.dylib
 
 readline.pc
+history.pc
 
 stamp-h
diff --git a/.gitignore~ b/.gitignore~
new file mode 100644 (file)
index 0000000..be107bb
--- /dev/null
@@ -0,0 +1,37 @@
+Makefile
+
+*.o
+*.a
+*.so
+*.sl
+*.dll
+
+config.cache
+config.h
+config.log
+config.status
+
+doc/Makefile
+examples/Makefile
+shlib/Makefile
+
+examples/fileman
+examples/hist_erasedups
+examples/hist_purgecmd
+examples/histexamp
+examples/rl
+examples/rl-callbacktest
+examples/rlbasic
+examples/rlcat
+examples/rlevent
+examples/rltest
+examples/rlversion
+
+libhistory.so.*
+libreadline.so.*
+
+*.dylib
+
+readline.pc
+
+stamp-h
diff --git a/bind.c b/bind.c
index b8a5deb9fc76d5f1fd280de908db8dcc64cfe54c..971116a90c58ef1ad5d27b4718f6db89fc7b6026 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -1,6 +1,6 @@
 /* bind.c -- key binding and startup file support for the readline library. */
 
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -1983,6 +1983,8 @@ typedef int _rl_sv_func_t (const char *);
 #define V_INT          2
 
 /* Forward declarations */
+static int sv_region_start_color (const char *);
+static int sv_region_end_color (const char *);
 static int sv_bell_style (const char *);
 static int sv_combegin (const char *);
 static int sv_dispprefix (const char *);
@@ -2002,6 +2004,8 @@ static const struct {
   int flags;
   _rl_sv_func_t *set_func;
 } string_varlist[] = {
+  { "active-region-end-color", V_STRING, sv_region_end_color },
+  { "active-region-start-color", V_STRING, sv_region_start_color },
   { "bell-style",      V_STRING,       sv_bell_style },
   { "comment-begin",   V_STRING,       sv_combegin },
   { "completion-display-width", V_INT, sv_compwidth },
@@ -2220,6 +2224,18 @@ sv_seqtimeout (const char *value)
   return 0;
 }
 
+static int
+sv_region_start_color (const char *value)
+{
+  return (_rl_reset_region_color (0, value));
+}
+
+static int
+sv_region_end_color (const char *value)
+{
+  return (_rl_reset_region_color (1, value));
+}
+
 static int
 sv_bell_style (const char *value)
 {
index e38bfce73c4415967446eb97b16f57fe8b749dc4..fe1e4cc9c96516695c6931e8d070eea379d89b35 100644 (file)
--- a/display.c
+++ b/display.c
@@ -1,6 +1,6 @@
 /* display.c -- readline redisplay facility. */
 
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library    
    for reading lines of text with interactive input and history editing.
@@ -1595,9 +1595,9 @@ putc_face (int c, int face, char *cur_face)
       if (face != FACE_NORMAL && face != FACE_STANDOUT)
        return;
       if (face == FACE_STANDOUT && cf == FACE_NORMAL)
-        _rl_standout_on ();
+       _rl_region_color_on ();
       if (face == FACE_NORMAL && cf == FACE_STANDOUT)
-        _rl_standout_off ();
+       _rl_region_color_off ();
       *cur_face = face;
     }
   if (c != EOF)
index 7a3a4767e7a591ded5f14e0b4879cd4a28358e37..721118bce1e8bfb9a9bbf75da627c22fb5ef458e 100644 (file)
@@ -12,7 +12,7 @@ This document describes the GNU History library
 a programming tool that provides a consistent user interface for
 recalling lines of previously typed input.
 
-Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 7ac11953df304255a3f64424ab073656ab731e84..da6417b48fda487e24853fab3d7176912ba89e10 100644 (file)
@@ -1,7 +1,7 @@
 @ignore
 This file documents the user interface to the GNU History library.
 
-Copyright (C) 1988-2020 Free Software Foundation, Inc.
+Copyright (C) 1988-2022 Free Software Foundation, Inc.
 Authored by Brian Fox and Chet Ramey.
 
 Permission is granted to make and distribute verbatim copies of this manual
index 0a81c46e932f1821187948487064a8fe343d742a..99351e32b67fd02f1f95ce3e340feeb6b5c115ee 100644 (file)
@@ -1,7 +1,7 @@
 @ignore
 This file documents the user interface to the GNU History library.
 
-Copyright (C) 1988--2020 Free Software Foundation, Inc.
+Copyright (C) 1988--2022 Free Software Foundation, Inc.
 Authored by Brian Fox and Chet Ramey.
 
 Permission is granted to make and distribute verbatim copies of this manual
index 92ee63d132148ccd8d587791ef6497f409cad507..a3d26220710a3e20a7062f26640f9f2ef3c435e4 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Mon Nov 15 17:06:54 EST 2021
+.\"    Last Change: Thu Feb 10 10:58:32 EST 2022
 .\"
-.TH READLINE 3 "2021 November 15" "GNU Readline 8.1"
+.TH READLINE 3 "2022 February 10" "GNU Readline 8.2"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
@@ -339,6 +339,30 @@ The variables and their default values are:
 .PP
 .PD 0
 .TP
+.B active\-region\-start\-color
+A string variable that controls the text color and background when displaying
+the text in the active region (see the description of
+\fBenable\-active\-region\fP below).
+This string must not take up any physical character positions on the display,
+so it should consist only of terminal escape sequences.
+It is output to the terminal before displaying the text in the active region.
+This variable is reset to the default value whenever the terminal type changes.
+The default value is the string that puts the terminal in standout mode,
+as obtained from the terminal's terminfo description.
+A sample value might be \f(CW"\ee[01;33m"\fP.
+.TP
+.B active\-region\-end\-color
+A string variable that "undoes" the effects of \fBactive\-region\-start\-color\fP
+and restores "normal" terminal display appearance after displaying text
+in the active region.
+This string must not take up any physical character positions on the display,
+so it should consist only of terminal escape sequences.
+It is output to the terminal after displaying the text in the active region.
+This variable is reset to the default value whenever the terminal type changes.
+The default value is the string that restores the terminal from standout mode,
+as obtained from the terminal's terminfo description.
+A sample value might be \f(CW"\ee[0m\fP".
+.TP
 .B bell\-style (audible)
 Controls what happens when readline wants to ring the terminal bell.
 If set to \fBnone\fP, readline never rings the bell.  If set to
@@ -458,6 +482,8 @@ The text between the point and mark is referred to as the \fIregion\fP.
 When this variable is set to \fIOn\fP, readline allows certain commands
 to designate the region as \fIactive\fP.
 When the region is active, readline highlights the text in the region using
+the value of the \fBactive\-region\-start\-color\fP, which defaults to the
+string that enables
 the terminal's standout mode.
 The active region shows the text inserted by bracketed-paste and any
 matching text found by incremental and non-incremental history searches.
index ec7487b7a78812f10d236078f88fd1b431aa03c5..d046b87d1fbdfa5bcfe15cd8f64979104b56cadb 100644 (file)
@@ -13,7 +13,7 @@ This manual describes the GNU Readline Library
 consistency of user interface across discrete programs which provide
 a command line interface.
 
-Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 8c4814ecfaf2bee4ff06cc9bd35972fbf69e938b..01343edc88aaa1491ae40a917e8838bc9032a91e 100644 (file)
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
 in the consistency of user interface across discrete programs that need
 to provide a command line interface.
 
-Copyright (C) 1988--2020 Free Software Foundation, Inc.
+Copyright (C) 1988--2022 Free Software Foundation, Inc.
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -1184,10 +1184,13 @@ Returns 0 if the timeout is set successfully.
 
 @deftypefun int rl_timeout_remaining (unsigned int *secs, unsigned int *usecs)
 Return the number of seconds and microseconds remaining in the current
-timeout duration in @code{*secs} and @code{*usecs}, respectively.
-Returns -1 on error or when there is no timeout set, 0 when the timeout has
-expired (leaving @code{*secs} and @code{*usecs} unchanged), and 1 if the
-timeout has not expired. If @code{secs} and @code{usecs} are @code{NULL},
+timeout duration in @var{*secs} and @var{*usecs}, respectively.
+Both @var{*secs} and @var{*usecs} must be non-NULL to return any values.
+The return value is -1 on error or when there is no timeout set,
+0 when the timeout has expired (leaving @var{*secs} and @var{*usecs}
+unchanged),
+and 1 if the timeout has not expired.
+If either of @var{secs} and @var{usecs} is @code{NULL},
 the return value indicates whether the timeout has expired.
 @end deftypefun
 
index 505225b9807631d065896eba222e77599943c99d..63e2c75dd619aa8bf23e79d24fba085eea365b67 100644 (file)
@@ -9,7 +9,7 @@ use these features.  There is a document entitled "readline.texinfo"
 which contains both end-user and programmer documentation for the
 GNU Readline Library.
 
-Copyright (C) 1988--2020 Free Software Foundation, Inc.
+Copyright (C) 1988--2022 Free Software Foundation, Inc.
 
 Authored by Brian Fox and Chet Ramey.
 
@@ -419,6 +419,32 @@ variables.
 @cindex variables, readline
 @table @code
 
+@item active-region-start-color
+@vindex active-region-start-color
+A string variable that controls the text color and background when displaying
+the text in the active region (see the description of
+@code{enable-active-region} below).
+This string must not take up any physical character positions on the display,
+so it should consist only of terminal escape sequences.
+It is output to the terminal before displaying the text in the active region.
+This variable is reset to the default value whenever the terminal type changes.
+The default value is the string that puts the terminal in standout mode,
+as obtained from the terminal's terminfo description.
+A sample value might be @samp{\e[01;33m}.
+
+@item active-region-end-color
+@vindex active-region-end-color
+A string variable that "undoes" the effects of @code{active-region-start-color}
+and restores "normal" terminal display appearance after displaying text
+in the active region.
+This string must not take up any physical character positions on the display,
+so it should consist only of terminal escape sequences.
+It is output to the terminal after displaying the text in the active region.
+This variable is reset to the default value whenever the terminal type changes.
+The default value is the string that restores the terminal from standout mode,
+as obtained from the terminal's terminfo description.
+A sample value might be @samp{\e[0m}.
+
 @item bell-style
 @vindex bell-style
 Controls what happens when Readline wants to ring the terminal bell.
@@ -553,6 +579,8 @@ The text between the point and mark is referred to as the @dfn{region}.
 When this variable is set to @samp{On}, Readline allows certain commands
 to designate the region as @dfn{active}.
 When the region is active, Readline highlights the text in the region using
+the value of the @code{active-region-start-color}, which defaults to the
+string that enables
 the terminal's standout mode.
 The active region shows the text inserted by bracketed-paste and any
 matching text found by incremental and non-incremental history searches.
index 6e8e848b6e5ae993259eb3a964e8573fe3a73fc5..ae9ec6eb4f8f267d80202adccfe193aa622b7fd1 100644 (file)
@@ -12,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
 consistency of user interface across discrete programs which provide
 a command line interface.
 
-Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
index 0d5883fb6530f63d76b16ce919891abd0c3f21cc..46c88bdb0a48e607b6907fbc481bf9182004d6b8 100644 (file)
@@ -1,10 +1,11 @@
 @ignore
-Copyright (C) 1988-2021 Free Software Foundation, Inc. 
+Copyright (C) 1988-2022 Free Software Foundation, Inc. 
 @end ignore
 
-@set EDITION 8.1
-@set VERSION 8.1
-@set UPDATED 15 November 2021
-@set UPDATED-MONTH November 2021
+@set EDITION 8.2
+@set VERSION 8.2
 
-@set LASTCHANGE Mon Nov 15 17:05:28 EST 2021
+@set UPDATED Thu Feb 10 10:56:04 EST 2022
+@set UPDATED-MONTH February 2022
+
+@set LASTCHANGE Thu Feb 10 10:56:20 EST 2022
index fc98eeeaa4d7cf7402617d2de6d14a0eca337354..ad2ce70a179e9e16a0e04f94273c871eb0e866c6 100644 (file)
--- a/history.h
+++ b/history.h
@@ -44,7 +44,7 @@ typedef char *histdata_t;
 
 /* Let's not step on anyone else's define for now, since we don't use this yet. */
 #ifndef HS_HISTORY_VERSION
-#  define HS_HISTORY_VERSION 0x0801    /* History 8.1 */
+#  define HS_HISTORY_VERSION 0x0802    /* History 8.2 */
 #endif
 
 /* The structure used to store a history entry. */
index 5f17dfd7b95c6e53cf7abb410df75ecf3ec0a330..7cf1fcf58a42972f1a9fe42b4fac09c3be05cd2b 100644 (file)
@@ -39,9 +39,9 @@ extern "C" {
 #endif
 
 /* Hex-encoded Readline version number. */
-#define RL_READLINE_VERSION    0x0801          /* Readline 8.1 */
+#define RL_READLINE_VERSION    0x0802          /* Readline 8.2 */
 #define RL_VERSION_MAJOR       8
-#define RL_VERSION_MINOR       1
+#define RL_VERSION_MINOR       2
 
 /* Readline data structures. */
 
index bda34119ef1086ee8c5343b19b718ff84b47364e..db20b92c9b6f48f0326839ab37fad195b96e33fe 100644 (file)
@@ -1,7 +1,7 @@
 /* rlprivate.h -- functions and variables global to the readline library,
                  but not intended for use by applications. */
 
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -415,6 +415,9 @@ extern void _rl_control_keypad (int);
 extern void _rl_set_cursor (int, int);
 extern void _rl_standout_on (void);
 extern void _rl_standout_off (void);
+extern int _rl_reset_region_color (int, const char *);
+extern void _rl_region_color_on (void);
+extern void _rl_region_color_off (void);
 
 /* text.c */
 extern void _rl_fix_point (int);
@@ -551,6 +554,8 @@ extern int _rl_echo_control_chars;
 extern int _rl_show_mode_in_prompt;
 extern int _rl_enable_bracketed_paste;
 extern int _rl_enable_active_region;
+extern char *_rl_active_region_start_color;
+extern char *_rl_active_region_end_color;
 extern char *_rl_comment_begin;
 extern unsigned char _rl_parsing_conditionalized_out;
 extern Keymap _rl_keymap;
diff --git a/rltty.c b/rltty.c
index dd10933153f286b701e6f4d576d8ed5ff5a2d075..b34de2a49619b8522e9ba34fdc320d6f5323cde4 100644 (file)
--- a/rltty.c
+++ b/rltty.c
@@ -692,6 +692,8 @@ rl_deprep_terminal (void)
   if (terminal_prepped & TPX_BRACKPASTE)
     {
       fprintf (rl_outstream, BRACK_PASTE_FINI);
+      /* Since the last character in BRACK_PASTE_FINI is \r */
+      _rl_last_c_pos = 0;
       if (_rl_eof_found && (RL_ISSTATE (RL_STATE_TIMEOUT) == 0))
        fprintf (rl_outstream, "\n");
       else if (_rl_echoing_p == 0)
index 5b4ef1bd505c660d70b5a957f6e8210231b9c38e..bddf1ed42078e38e8a1ad7200ac423305dc8c296 100644 (file)
@@ -1,6 +1,6 @@
 /* terminal.c -- controlling the terminal with termcap. */
 
-/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
@@ -185,6 +185,11 @@ static char *_rl_term_kN;
 static char *_rl_term_vs;      /* very visible */
 static char *_rl_term_ve;      /* normal */
 
+/* User-settable color sequences to begin and end the active region. Defaults
+   are rl_term_so and rl_term_se on non-dumb terminals. */
+char *_rl_active_region_start_color = NULL;
+char *_rl_active_region_end_color = NULL;
+
 /* It's not clear how HPUX is so broken here. */
 #ifdef TGETENT_BROKEN
 #  define TGETENT_SUCCESS 0
@@ -466,7 +471,7 @@ _rl_init_terminal_io (const char *terminal_name)
 {
   const char *term;
   char *buffer;
-  int tty, tgetent_ret, dumbterm;
+  int tty, tgetent_ret, dumbterm, reset_region_colors;
 
   term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
   _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = _rl_term_clrscroll = (char *)NULL;
@@ -477,6 +482,8 @@ _rl_init_terminal_io (const char *terminal_name)
 
   dumbterm = STREQ (term, "dumb");
 
+  reset_region_colors = 1;
+
 #ifdef __MSDOS__
   _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
   _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
@@ -562,6 +569,11 @@ _rl_init_terminal_io (const char *terminal_name)
         escape sequences */
       _rl_enable_bracketed_paste = 0;
 
+      /* No terminal so/se capabilities. */
+      _rl_enable_active_region = 0;
+      _rl_reset_region_color (0, NULL);
+      _rl_reset_region_color (1, NULL);
+    
       /* Reasonable defaults for tgoto().  Readline currently only uses
          tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
          change that later... */
@@ -616,8 +628,14 @@ _rl_init_terminal_io (const char *terminal_name)
   /* There's no way to determine whether or not a given terminal supports
      bracketed paste mode, so we assume a terminal named "dumb" does not. */
   if (dumbterm)
-    _rl_enable_bracketed_paste = 0;
-    
+    _rl_enable_bracketed_paste = _rl_enable_active_region = 0;
+
+  if (reset_region_colors)
+    {
+      _rl_reset_region_color (0, _rl_term_so);
+      _rl_reset_region_color (1, _rl_term_se);
+    }
+
   return 0;
 }
 
@@ -789,6 +807,67 @@ _rl_standout_off (void)
 #endif
 }
 
+/* **************************************************************** */
+/*                                                                 */
+/*          Controlling color for a portion of the line            */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Reset the region color variables to VALUE depending on WHICH (0 == start,
+   1 == end). This is where all the memory allocation for the color variable
+   strings is performed. We might want to pass a flag saying whether or not
+   to translate VALUE like a key sequence, but it doesn't really matter. */
+int
+_rl_reset_region_color (int which, const char *value)
+{
+  int len;
+
+  if (which == 0)
+    {
+      free (_rl_active_region_start_color);
+      if (value && *value)
+       {
+         _rl_active_region_start_color = (char *)xmalloc (2 * strlen (value) + 1);
+         rl_translate_keyseq (value, _rl_active_region_start_color, &len);
+         _rl_active_region_start_color[len] = '\0';
+       }
+      else
+       _rl_active_region_start_color = NULL;
+    }
+  else
+    {
+      free (_rl_active_region_end_color);
+      if (value && *value)
+       {
+         _rl_active_region_end_color = (char *)xmalloc (2 * strlen (value) + 1);
+         rl_translate_keyseq (value, _rl_active_region_end_color, &len);
+         _rl_active_region_end_color[len] = '\0';
+       }
+      else
+       _rl_active_region_end_color = NULL;
+    }
+
+  return 0;
+}
+
+void
+_rl_region_color_on (void)
+{
+#ifndef __MSDOS__
+  if (_rl_active_region_start_color && _rl_active_region_end_color)
+    tputs (_rl_active_region_start_color, 1, _rl_output_character_function);
+#endif
+}
+
+void
+_rl_region_color_off (void)
+{
+#ifndef __MSDOS__
+  if (_rl_active_region_start_color && _rl_active_region_end_color)
+    tputs (_rl_active_region_end_color, 1, _rl_output_character_function);
+#endif
+}
+
 /* **************************************************************** */
 /*                                                                 */
 /*             Controlling the Meta Key and Keypad                 */