Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Dec 2010 10:53:16 +0300
From:      Eygene Ryabinkin <rea@freebsd.org>
To:        Eitan Adler <lists@eitanadler.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: questions relating to ncurses and dialog(1)
Message-ID:  <EAARFdbFSYRINO%2Bvmxn9Eev4rZc@QsmfhJNucgI88DfvPJdT1/nyboE>
In-Reply-To: <AANLkTi=EqukSOUOP0hvFHmR6=5%2BcNgiba5tQdmy-V8F-@mail.gmail.com>
References:  <AANLkTi=EqukSOUOP0hvFHmR6=5%2BcNgiba5tQdmy-V8F-@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--KZCIPwrNpw38UenM
Content-Type: multipart/mixed; boundary="+dH9khzwljbvYE07"
Content-Disposition: inline


--+dH9khzwljbvYE07
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Eitan, good day.

Thu, Dec 30, 2010 at 07:03:44PM -0500, Eitan Adler wrote:
> 1) When clicking the "View" button on the license window (using the
> withlicense.sh script) I fork() and then exec less. Less opens fine -
> but when I hit "q" it seems that any actions I took in less also took
> place in the ncurses program. If I use rfork(RFPROC|RFCFDG) then it
> never shows less on the screen. I suspect this is because in the
> former case they share the same stdin and stdout and in the latter
> case less doesn't get any std* streams.
> Is there a way to avoid this problem?

The attached patch should fix it.  The problem is that you should
leave the Ncurses mode before spawning external programs.  You seem
to be trying to do it in the child process (commented endwin()), but
it should be done inside the parent process, since it is the one who
does Ncurses.  And the most logical way is to
 - leave the curses mode;
 - invoke anything you like and wait() for it;
 - enter the curses mode again + refresh the windows.
--=20
Eygene Ryabinkin                                        ,,,^..^,,,
[ Life's unfair - but root password helps!           | codelabs.ru ]
[ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]

--+dH9khzwljbvYE07
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="0001-Save-restore-terminal-around-the-pager-invocation.patch"
Content-Transfer-Encoding: quoted-printable

=46rom 1c6ca9f805e965796e7321d04868c1278d4ec7a9 Mon Sep 17 00:00:00 2001
=46rom: Eygene Ryabinkin <rea@freebsd.org>
Date: Fri, 31 Dec 2010 10:47:46 +0300
Subject: [PATCH] Save/restore terminal around the pager invocation

We should leave Ncurses mode before the pager is spawned
and return to the saved mode once we're done with the pager.

Signed-off-by: Eygene Ryabinkin <rea@freebsd.org>
---
 dialog4ports.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/dialog4ports.c b/dialog4ports.c
index cdec074..026b0b9 100644
--- a/dialog4ports.c
+++ b/dialog4ports.c
@@ -888,6 +888,8 @@ main(int argc, char* argv[])
 					if (curItem =3D=3D licenceItems[licenceVIEW]) {
 						char const * const pager =3D getenv("PAGER");
 						//const int pid =3D rfork(RFPROC|RFCFDG);
+						def_prog_mode();
+						endwin();
 						const int pid =3D fork();
 						if (pid =3D=3D 0) {
 							//endwin();
@@ -903,6 +905,8 @@ main(int argc, char* argv[])
 						else {
 							wait(pid);
 						}
+						reset_prog_mode();
+						wrefresh(curscr);
 					}
 				}
 				else if (whichLocation =3D=3D EXIT) {
--=20
1.7.3.2


--+dH9khzwljbvYE07--

--KZCIPwrNpw38UenM
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (FreeBSD)

iF4EAREIAAYFAk0di+wACgkQFq+eroFS7PszuwD/Wvx+LZ5XSzT3itn8zI5vCP6Y
z7n65nmDutCJSmgpupYA/iJVB+Jh++jf4uSK9e4oRXE0QTH2nLFouRu8axnEbOST
=mWGS
-----END PGP SIGNATURE-----

--KZCIPwrNpw38UenM--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?EAARFdbFSYRINO%2Bvmxn9Eev4rZc>