mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Add a pager_min_lines setting to psql
If set, the pager will not be used unless this many lines are to be displayed, even if that is more than the screen depth. Default is zero, meaning it's disabled. There is probably more work to be done in giving the user control over when the pager is used, particularly when wide output forces use of the pager regardless of how many lines there are, but this is a start.
This commit is contained in:
@ -1071,7 +1071,8 @@ exec_command(const char *cmd,
|
||||
static const char *const my_list[] = {
|
||||
"border", "columns", "expanded", "fieldsep", "fieldsep_zero",
|
||||
"footer", "format", "linestyle", "null",
|
||||
"numericlocale", "pager", "recordsep", "recordsep_zero",
|
||||
"numericlocale", "pager", "pager_min_lines",
|
||||
"recordsep", "recordsep_zero",
|
||||
"tableattr", "title", "tuples_only",
|
||||
"unicode_border_linestyle",
|
||||
"unicode_column_linestyle",
|
||||
@ -1265,7 +1266,7 @@ exec_command(const char *cmd,
|
||||
lines++;
|
||||
}
|
||||
|
||||
output = PageOutput(lineno, pset.popt.topt.pager);
|
||||
output = PageOutput(lineno, &(pset.popt.topt));
|
||||
is_pager = true;
|
||||
}
|
||||
else
|
||||
@ -2519,6 +2520,13 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
|
||||
popt->topt.pager = 1;
|
||||
}
|
||||
|
||||
/* set minimum lines for pager use */
|
||||
else if (strcmp(param, "pager_min_lines") == 0)
|
||||
{
|
||||
if (value)
|
||||
popt->topt.pager_min_lines = atoi(value);
|
||||
}
|
||||
|
||||
/* disable "(x rows)" footer */
|
||||
else if (strcmp(param, "footer") == 0)
|
||||
{
|
||||
@ -2640,6 +2648,13 @@ printPsetInfo(const char *param, struct printQueryOpt *popt)
|
||||
printf(_("Pager usage is off.\n"));
|
||||
}
|
||||
|
||||
/* show minimum lines for pager use */
|
||||
else if (strcmp(param, "pager_min_lines") == 0)
|
||||
{
|
||||
printf(_("Pager won't be used for less than %d lines\n"),
|
||||
popt->topt.pager_min_lines);
|
||||
}
|
||||
|
||||
/* show record separator for unaligned text */
|
||||
else if (strcmp(param, "recordsep") == 0)
|
||||
{
|
||||
@ -2792,6 +2807,8 @@ pset_value_string(const char *param, struct printQueryOpt *popt)
|
||||
return pstrdup(pset_bool_string(popt->topt.numericLocale));
|
||||
else if (strcmp(param, "pager") == 0)
|
||||
return psprintf("%d", popt->topt.pager);
|
||||
else if (strcmp(param, "pager_min_lines") == 0)
|
||||
return psprintf("%d", popt->topt.pager_min_lines);
|
||||
else if (strcmp(param, "recordsep") == 0)
|
||||
return pset_quoted_string(popt->topt.recordSep.separator
|
||||
? popt->topt.recordSep.separator
|
||||
|
Reference in New Issue
Block a user