On Mon, Dec 14, 2015 at 2:50 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > Alvaro Herrera <alvhe...@2ndquadrant.com> writes: >> Tom Lane wrote: >>> Quick followup: rl_resize_terminal() exists in GNU readline at least as >>> far back as 4.0 (released Feb 1999). However, it doesn't seem to be there >>> at all in libedit; I don't see it in OS X Yosemite's headers, anyway. >>> So we'd need a configure test for this. > >> In libedit (NetBSD's at least) there is el_resize() which seems to do >> the same thing. > > Hmm. I see this in OS X's histedit.h: > > void el_resize(EditLine *); > > but it appears that this is part of a completely separate API with > essentially nothing in common with GNU readline. Not sure if we have > the motivation to try to support that API in parallel with readline's. > I sure don't.
This may be moot; some testing demonstrated that libedit was not impacted so it really comes down to having the right readline api call available. Looking at the code ISTM that libedit resets the terminal on every prompt. Also, after some experimentation I had better luck with rl_reset_screen_size() (vs rl_resize_terminal()) that seemed to give more regular behavior with the prompt. So the consolidated patch with the configure check is attached. I'll leave it to the powers that be in terms of how and when to apply this. My gut is that it could probably be patched in now but I'd feel comfortable with more testing then my own perfunctory probing. merlin
diff --git a/configure b/configure index 660aa57..2f0fee6 100755 --- a/configure +++ b/configure @@ -12415,7 +12415,7 @@ if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then $as_echo "#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1" >>confdefs.h fi - for ac_func in rl_completion_matches rl_filename_completion_function + for ac_func in rl_completion_matches rl_filename_completion_function rl_reset_screen_size do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index 419e3d3..f3d926d 100644 --- a/configure.in +++ b/configure.in @@ -1545,7 +1545,7 @@ LIBS="$LIBS_including_readline" if test "$with_readline" = yes; then PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER - AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function]) + AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function rl_reset_screen_size]) AC_CHECK_FUNCS([append_history history_truncate_file]) fi diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 655850b..0f17826 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -27,6 +27,7 @@ #include "common.h" #include "mbprint.h" #include "print.h" +#include "input.h" /* * We define the cancel_pressed flag in this file, rather than common.c where @@ -2247,6 +2251,13 @@ ClosePager(FILE *pagerpipe) #ifndef WIN32 pqsignal(SIGPIPE, SIG_DFL); #endif +#ifdef HAVE_RL_RESET_SCREEN_SIZE + /* + * Force libreadline to recheck the terminal size in case the pager + * may have handled any terminal resize events. + */ + rl_reset_screen_size(); +#endif } } diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 6ce5907..8aa182c 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -406,6 +406,9 @@ /* Define to 1 if you have the `rl_filename_completion_function' function. */ #undef HAVE_RL_FILENAME_COMPLETION_FUNCTION +/* Define to 1 if you have the `rl_reset_screen_size' function. */ +#undef HAVE_RL_RESET_SCREEN_SIZE + /* Define to 1 if you have the <security/pam_appl.h> header file. */ #undef HAVE_SECURITY_PAM_APPL_H
-- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers