fix for readline terminal size problems when window is resized with open pager - Mailing list pgsql-hackers

From Merlin Moncure
Subject fix for readline terminal size problems when window is resized with open pager
Date
Msg-id CAHyXU0wv-bVMX8WO6-SUOE1GEiQG9NFA3nCKaRr_enmDntid+w@mail.gmail.com
Whole thread Raw
Responses Re: fix for readline terminal size problems when window is resized with open pager  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello,

The following patch deals with a long standing gripe of mine that the
terminal frequently gets garbled so that when typing.  I guess this
problem is entirely dependent on pager settings and your interaction
patterns with the window (in particular, if you tend to resize the
window when the pager is open).  Experimenting with the problem, it
became pretty clear: libreadline for whatever reason does not get the
signal from the kernal telling it that the bounds have changed.  This
problem does not manifest 100% of the time, you may have to get the
pager to open, resize the window, close the pager, and recall a
previous long line (or type a new one) several times to get the
problem to occur.  Nevertheless, the attached seems to end the
problem.

This adds a dependency to print.c on input.h for the readline macro
and the readline header.

merlin

diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 655850b..ede736e 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 +2248,13 @@ ClosePager(FILE *pagerpipe)#ifndef WIN32       pqsignal(SIGPIPE, SIG_DFL);#endif
+#ifdef USE_READLINE
+       /*
+        * Force libreadline to recheck the terminal size in case pager may
+        * have handled any terminal resize events.
+        */
+       rl_resize_terminal();
+#endif   }}



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Include ppc64le build type for back branches
Next
From: Tom Lane
Date:
Subject: Re: Include ppc64le build type for back branches