summaryrefslogtreecommitdiff
path: root/src/bin/psql/print.h
diff options
context:
space:
mode:
authorTom Lane2009-10-13 21:04:01 +0000
committerTom Lane2009-10-13 21:04:01 +0000
commit42ec8ad6286be046d86fc9f09bb4cdeefc395bfe (patch)
treebc2de6234cbc40060ba81d71222d593b0c680efe /src/bin/psql/print.h
parentb14071164366e7efee9dc3a017eb7cb4cfac3428 (diff)
Add "\pset linestyle ascii/unicode" option to psql, allowing our traditional
ASCII-art style of table output to be upgraded to use Unicode box drawing characters if desired. By default, psql will use the Unicode characters whenever client_encoding is UTF8. The patch forces linestyle=ascii in pg_regress usage, ensuring we don't break the regression tests in Unicode locales. Roger Leigh
Diffstat (limited to 'src/bin/psql/print.h')
-rw-r--r--src/bin/psql/print.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index 13e53e0dad0..b09aac90f77 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.40 2009/06/11 14:49:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.41 2009/10/13 21:04:01 tgl Exp $
*/
#ifndef PRINT_H
#define PRINT_H
@@ -23,10 +23,37 @@ enum printFormat
/* add your favourite output format here ... */
};
+typedef struct printTextLineFormat
+{
+ /* Line drawing characters to be used in various contexts */
+ const char *hrule; /* horizontal line character */
+ const char *leftvrule; /* left vertical line (+horizontal) */
+ const char *midvrule; /* intra-column vertical line (+horizontal) */
+ const char *rightvrule; /* right vertical line (+horizontal) */
+} printTextLineFormat;
+
+typedef enum printTextRule
+{
+ /* Additional context for selecting line drawing characters */
+ PRINT_RULE_TOP, /* top horizontal line */
+ PRINT_RULE_MIDDLE, /* intra-data horizontal line */
+ PRINT_RULE_BOTTOM, /* bottom horizontal line */
+ PRINT_RULE_DATA /* data line (hrule is unused here) */
+} printTextRule;
+
+typedef struct printTextFormat
+{
+ /* A complete line style */
+ const char *name; /* for display purposes */
+ printTextLineFormat lrule[4]; /* indexed by enum printTextRule */
+ const char *midvrule_cont; /* vertical line for continue after newline */
+ const char *midvrule_wrap; /* vertical line for wrapped data */
+ const char *midvrule_blank; /* vertical line for blank data */
+} printTextFormat;
typedef struct printTableOpt
{
- enum printFormat format; /* one of the above */
+ enum printFormat format; /* see enum above */
bool expanded; /* expanded/vertical output (if supported by
* output format) */
unsigned short int border; /* Print a border around the table. 0=none,
@@ -37,6 +64,7 @@ typedef struct printTableOpt
bool start_table; /* print start decoration, eg <table> */
bool stop_table; /* print stop decoration, eg </table> */
unsigned long prior_records; /* start offset for record counters */
+ const printTextFormat *line_style; /* line style (NULL for default) */
char *fieldSep; /* field separator for unaligned text mode */
char *recordSep; /* record separator for unaligned text mode */
bool numericLocale; /* locale-aware numeric units separator and
@@ -96,6 +124,10 @@ typedef struct printQueryOpt
} printQueryOpt;
+extern const printTextFormat pg_asciiformat;
+extern const printTextFormat pg_utf8format;
+
+
extern FILE *PageOutput(int lines, unsigned short int pager);
extern void ClosePager(FILE *pagerpipe);
@@ -118,6 +150,7 @@ extern void printQuery(const PGresult *result, const printQueryOpt *opt,
FILE *fout, FILE *flog);
extern void setDecimalLocale(void);
+extern const printTextFormat *get_line_style(const printTableOpt *opt);
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"