# patch for fancy (e.g., colored) prompts in psql, take III
#
# 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%]%# '
#
diff -r --exclude='*.rej' --exclude='*.log' --exclude='*.so' --exclude='*.o' --exclude='*.orig' -c postgresql-7.4.1-orig/doc/src/sgml/ref/psql-ref.sgml postgresql-7.4.1/doc/src/sgml/ref/psql-ref.sgml
*** postgresql-7.4.1-orig/doc/src/sgml/ref/psql-ref.sgml 2003-10-31 17:56:29.000000000 -0800
--- postgresql-7.4.1/doc/src/sgml/ref/psql-ref.sgml 2004-01-16 09:56:54.000000000 -0800
***************
*** 2236,2241 ****
--- 2236,2265 ----
+ %[ ... %]
+
+
+ Prompts may contain terminal control characters which, for
+ example, change the color, background, or style of the prompt
+ text, or change the title of the terminal window. In order for
+ the line editing features of readline to work properly, these
+ non-printing control characters must be designated as invisible
+ by surrounding them with %[ and
+ %]. Multiple pairs of these may occur within
+ the prompt. For example,
+
+ testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] '
+
+ results in a boldfaced (1;) yellow-on-black
+ 33;40 prompt (within color-capable terminals).
+ See http://www.termsys.demon.co.uk/vtansi.htm
+ for an example of allowable codes.
+
+
+
+
+
%R
diff -r --exclude='*.rej' --exclude='*.log' --exclude='*.so' --exclude='*.o' --exclude='*.orig' -c postgresql-7.4.1-orig/src/bin/psql/prompt.c postgresql-7.4.1/src/bin/psql/prompt.c
*** postgresql-7.4.1-orig/src/bin/psql/prompt.c 2003-10-03 18:04:46.000000000 -0700
--- postgresql-7.4.1/src/bin/psql/prompt.c 2004-01-20 09:33:23.000000000 -0800
***************
*** 13,18 ****
--- 13,19 ----
#include "settings.h"
#include "common.h"
#include "variables.h"
+ #include "input.h"
#ifdef WIN32
#include
***************
*** 241,246 ****
--- 242,259 ----
buf[0] = '>';
break;
+ case '[':
+ case ']':
+ #if defined (USE_READLINE) && defined (RL_PROMPT_START_IGNORE)
+ /* readline >=4.0 undocumented feature: non-printing
+ characters in prompt strings must be quoted in order
+ to properly display the line during editing.
+ */
+ buf[0] = '\001';
+ buf[1] = (*p == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+ #endif /* USE_READLINE */
+ break;
+
/* execute command */
case '`':
{