File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.102 2003/12/23 23:13:14 momjian Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.103 2004/01/20 19:49:34 tgl Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -2315,6 +2315,28 @@ testdb=> <userinput>\set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
2315
2315
</listitem>
2316
2316
</varlistentry>
2317
2317
2318
+ <varlistentry>
2319
+ <term><literal>%[</literal> ... <literal>%]</literal></term>
2320
+ <listitem>
2321
+ <para>
2322
+ Prompts may contain terminal control characters which, for
2323
+ example, change the color, background, or style of the prompt
2324
+ text, or change the title of the terminal window. In order for
2325
+ the line editing features of readline to work properly, these
2326
+ non-printing control characters must be designated as invisible
2327
+ by surrounding them with <literal>%[</literal> and
2328
+ <literal>%]</literal>. Multiple pairs of these may occur within
2329
+ the prompt. For example,
2330
+ <programlisting>
2331
+ testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%#%] '
2332
+ </programlisting>
2333
+ results in a boldfaced (<literal>1;</literal>) yellow-on-black
2334
+ (<literal>33;40</literal>) prompt on VT100-compatible, color-capable
2335
+ terminals.
2336
+ </para>
2337
+ </listitem>
2338
+ </varlistentry>
2339
+
2318
2340
</variablelist>
2319
2341
2320
2342
To insert a percent sign into your prompt, write
Original file line number Diff line number Diff line change 3
3
*
4
4
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.31 2003/11/29 19:52:07 pgsql Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.32 2004/01/20 19:49:34 tgl Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "prompt.h"
12
12
13
13
#include "settings.h"
14
14
#include "common.h"
15
+ #include "input.h"
15
16
#include "variables.h"
16
17
17
18
#ifdef WIN32
57
58
* %:name: - The value of the psql variable 'name'
58
59
* (those will not be rescanned for more escape sequences!)
59
60
*
60
- * If the application-wide prompts became NULL somehow, the returned string
61
+ * %[ ... %] - tell readline that the contained text is invisible
62
+ *
63
+ * If the application-wide prompts become NULL somehow, the returned string
61
64
* will be empty (not NULL!).
62
65
*--------------------------
63
66
*/
@@ -282,10 +285,23 @@ get_prompt(promptStatus_t status)
282
285
break ;
283
286
}
284
287
288
+ case '[' :
289
+ case ']' :
290
+ #if defined(USE_READLINE ) && defined(RL_PROMPT_START_IGNORE )
291
+ /*
292
+ * readline >=4.0 undocumented feature: non-printing
293
+ * characters in prompt strings must be marked as such,
294
+ * in order to properly display the line during editing.
295
+ */
296
+ buf [0 ] = '\001' ;
297
+ buf [1 ] = (* p == '[' ) ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE ;
298
+ #endif /* USE_READLINE */
299
+ break ;
285
300
286
301
default :
287
302
buf [0 ] = * p ;
288
303
buf [1 ] = '\0' ;
304
+ break ;
289
305
290
306
}
291
307
esc = false;
You can’t perform that action at this time.
0 commit comments