Thread: invisible characters in readline

invisible characters in readline

From
Reece Hart
Date:
# characters, as for fancy colorized prompts.  This was nearly a direct
# lift from bash-2.05b's lib/readline/display.c, per guidance from Chet Ramey.
#
# Is pset.useReadline used anywhere? It's set to 0 by default, even when
# readline really is in use, and therefore I ignored it.
--- postgresql-7.4.1/src/bin/psql/prompt.c-orig 2004-01-15 10:47:05.000000000 -0800
+++ postgresql-7.4.1/src/bin/psql/prompt.c 2004-01-15 14:21:27.000000000 -0800
@@ -14,4 +14,5 @@
#include "common.h"
#include "variables.h"
+#include "input.h"

#ifdef WIN32
@@ -242,4 +243,17 @@
break;

+     case '[':
+     case ']':
+#if defined (USE_READLINE)
+   buf[0] = '\001';
+   buf[1] = (*p == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+   buf[2] = '\0';
+#else
+   /* Should we remove text between %[ and %] ?
+ e.g., for fancy prompts on dumb terminals??
+       If so, under what conditions? */
+#endif /* USE_READLINE */
+   break;
+ /* end case [ or ] */
+
/* execute command */
case '`':

Re: invisible characters in readline

From
Reece Hart
Date:
I have no idea what happened to the first lines of the patch. Here goes
again, with a prompt example.

# fancy readline prompt patch for psql
#
# This is a patch to support readline prompts which contain non-printing
# characters, as for fancy colorized prompts.  This was nearly a direct
# lift from bash-2.05b's lib/readline/display.c, per guidance from Chet
# Ramey.
#
# Usage:
# Invisible characters within the prompt must be quoted with %[ and %].
# example: \set PROMPT1 '%[%033[1;33m%]%n@%/%R%[%033[0m%]%# '
#
# Is pset.useReadline used anywhere? It's set to 0 by default, even when
# readline is in use, and therefore I ignored it below.
#
# 2004/01/15 (Thu) 14:27 Reece Hart <reece@in-machina.com>


--- postgresql-7.4.1/src/bin/psql/prompt.c-orig    2004-01-15
10:47:05.000000000 -0800
+++ postgresql-7.4.1/src/bin/psql/prompt.c    2004-01-15 14:21:27.000000000
-0800
@@ -14,4 +14,5 @@
 #include "common.h"
 #include "variables.h"
+#include "input.h"

 #ifdef WIN32
@@ -242,4 +243,17 @@
                     break;

+                case '[':
+                case ']':
+#if defined (USE_READLINE)
+                  buf[0] = '\001';
+                  buf[1] = (*p == '[') ? RL_PROMPT_START_IGNORE :
RL_PROMPT_END_IGNORE;
+                  buf[2] = '\0';
+#else
+                      /* Should we remove text between %[ and %]
+                         e.g., for fancy prompts on dumb terminals ?
+                         If so, under what conditions? */
+#endif /* USE_READLINE */
+                  break;
+                /* end case [ or ] */
+
                     /* execute command */
                 case '`':


Re: invisible characters in readline

From
Tom Lane
Date:
Reece Hart <reece@in-machina.com> writes:
> [ unintelligible patch with no documentation component ]

Uh, what is this supposed to do exactly?

            regards, tom lane