diff options
author | Bruce Momjian | 2002-11-08 19:12:21 +0000 |
---|---|---|
committer | Bruce Momjian | 2002-11-08 19:12:21 +0000 |
commit | 1588b70a8991a329f1ab52a8377bb9bb800e30cb (patch) | |
tree | 969f3d9836a97421f398f75036fa9680fca2b18e | |
parent | 6e2cf74466d5556e5d12aa26ee3c434480bed979 (diff) |
Here is a patch that does just that, while maintaining the
"traditional" behavior, so the change should be transparent. Use the
command "\pset pager always" to turn it on. Anything else does the
normal toggle between "on" and "off"
Greg Sabino Mullane
-rw-r--r-- | doc/src/sgml/ref/psql-ref.sgml | 22 | ||||
-rw-r--r-- | src/bin/psql/command.c | 11 | ||||
-rw-r--r-- | src/bin/psql/common.c | 2 | ||||
-rw-r--r-- | src/bin/psql/help.c | 2 | ||||
-rw-r--r-- | src/bin/psql/help.h | 2 | ||||
-rw-r--r-- | src/bin/psql/print.h | 5 | ||||
-rw-r--r-- | src/bin/psql/startup.c | 2 |
7 files changed, 27 insertions, 19 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 553b3b8293..46e77de01e 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1456,21 +1456,21 @@ lo_import 152801 <term><literal>pager</literal></term> <listitem> <para> - Toggles the use of a pager for query and <application>psql</> help output. If the - environment variable <envar>PAGER</envar> is set, the output - is piped to the specified program. Otherwise a platform-dependent default (such as + Controls use of a pager for query and <application>psql</> + help output. If the environment variable <envar>PAGER</envar> + is set, the output is piped to the specified program. + Otherwise a platform-dependent default (such as <filename>more</filename>) is used. </para> <para> - In any case, <application>psql</application> only uses the - pager if it seems appropriate. That means among other things - that the output is to a terminal and that the table would - normally not fit on the screen. Because of the modular nature - of the printing routines it is not always possible to predict - the number of lines that will actually be printed. For that - reason <application>psql</application> might not appear very - discriminating about when to use the pager. + When the pager is off, the pager is not used. When the pager + is on, the pager is used only when appropriate, i.e. the + output is to a terminal and will not fit on the screen. + (<application>psql</> does not do a perfect job of estimating + when to use the pager.) <literal>\pset pager</> turns the + pager on and off. Pager can also be set to <literal>always</>, + which causes the pager to be always used. </para> </listitem> </varlistentry> diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 8cf8a7dbe5..ff42d2b27a 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1873,11 +1873,18 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet) /* toggle use of pager */ else if (strcmp(param, "pager") == 0) { - popt->topt.pager = !popt->topt.pager; + if (value && strcasecmp(value, "always") == 0) + popt->topt.pager = 2; + else if (popt->topt.pager == 1) + popt->topt.pager = 0; + else + popt->topt.pager = 1; if (!quiet) { - if (popt->topt.pager) + if (popt->topt.pager == 1) puts(gettext("Using pager is on.")); + else if (popt->topt.pager == 2) + puts(gettext("Using pager is always.")); else puts(gettext("Using pager is off.")); } diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index a5ab9ecabe..b800fbeb4f 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -548,7 +548,7 @@ PageOutput(int lines, bool pager) struct winsize screen_size; result = ioctl(fileno(stdout), TIOCGWINSZ, &screen_size); - if (result == -1 || lines > screen_size.ws_row) + if (result == -1 || lines > screen_size.ws_row || pager > 1) { #endif pagerprog = getenv("PAGER"); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 9468af0939..4c94772d55 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -159,7 +159,7 @@ struct winsize #endif void -slashUsage(bool pager) +slashUsage(unsigned short int pager) { FILE *output; diff --git a/src/bin/psql/help.h b/src/bin/psql/help.h index 5c14f36be7..39bd0ebe4f 100644 --- a/src/bin/psql/help.h +++ b/src/bin/psql/help.h @@ -10,7 +10,7 @@ void usage(void); -void slashUsage(bool pager); +void slashUsage(unsigned short int pager); void helpSQL(const char *topic, bool pager); diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h index 593361b15c..09033c7bbb 100644 --- a/src/bin/psql/print.h +++ b/src/bin/psql/print.h @@ -26,8 +26,9 @@ typedef struct _printTableOpt enum printFormat format; /* one of the above */ bool expanded; /* expanded/vertical output (if supported * by output format) */ - bool pager; /* use pager for output (if to stdout and - * stdout is a tty) */ + unsigned short int pager; /* use pager for output (if to stdout and + * stdout is a tty) + * 0=off 1=on 2=always */ bool tuples_only; /* don't output headers, row counts, etc. */ unsigned short int border; /* Print a border around the table. * 0=none, 1=dividing lines, 2=full */ diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 82d8b6bbe4..89decb4a97 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -137,7 +137,7 @@ main(int argc, char *argv[]) pset.popt.topt.format = PRINT_ALIGNED; pset.queryFout = stdout; pset.popt.topt.border = 1; - pset.popt.topt.pager = true; + pset.popt.topt.pager = 1; pset.popt.default_footer = true; SetVariable(pset.vars, "VERSION", PG_VERSION_STR); |