zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: don't redraw when not printing job info
@ 2007-01-30 19:00 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2007-01-30 19:00 UTC (permalink / raw)
  To: Zsh hackers list

It turns out that zrefresh() can be triggered by the job handler when it
thinks some information has been printed, even though it hasn't.
This redraws the ZLE line including the prompt.  Usually this goes
unnoticed.  I spotted it because at the point in question there was a
function running under sched, and the last status was 1, which appeared
on the display because of the redraw (since my prompt outputs non-zero
statuses).

This patch doesn't force the redraw when there's nothing printed.  This
is a simple and safe thing to do which fixes this symptom.  However, it
would presumably be sensible for prompts to be insensitive to contextual
information from functions not explicitly run by the user.  (This is
more than just the status: suppose we were at a PS2 which output the
parse status, for example.)  That's messier and a rather special case
you don't normally see, so I haven't attempted it.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.53
diff -u -r1.53 jobs.c
--- Src/jobs.c	21 Jan 2007 22:47:41 -0000	1.53
+++ Src/jobs.c	30 Jan 2007 18:52:18 -0000
@@ -448,8 +448,8 @@
 	curjob = job;
     }
     if ((isset(NOTIFY) || job == thisjob) && (jn->stat & STAT_LOCKED)) {
-	printjob(jn, !!isset(LONGLISTJOBS), 0);
-	if (zleactive)
+	if (printjob(jn, !!isset(LONGLISTJOBS), 0) &&
+	    zleactive)
 	    zrefreshptr();
     }
     if (sigtrapped[SIGCHLD] && job != thisjob)
@@ -804,19 +804,22 @@
  * synch = 0 means asynchronous
  * synch = 1 means synchronous
  * synch = 2 means called synchronously from jobs
+ *
+ * Returns 1 if some output was done.
 */
 
 /**/
-void
+int
 printjob(Job jn, int lng, int synch)
 {
     Process pn;
     int job, len = 9, sig, sflag = 0, llen;
     int conted = 0, lineleng = columns, skip = 0, doputnl = 0;
+    int doneprint = 0;
     FILE *fout = (synch == 2) ? stdout : shout;
 
     if (jn->stat & STAT_NOPRINT)
-	return;
+	return 0;
 
     /*
      * Wow, what a hack.  Did I really write this? --- pws
@@ -874,8 +877,10 @@
 
 	if (!synch)
 	    trashzleptr();
-	if (doputnl && !synch)
+	if (doputnl && !synch) {
+	    doneprint = 1;
 	    putc('\n', fout);
+	}
 	for (pn = jn->procs; pn;) {
 	    len2 = (thisfmt ? 5 : 10) + len;	/* 2 spaces */
 	    if (lng & 3)
@@ -888,6 +893,7 @@
 			break;
 		    len2 += strlen(qn->text) + 2;
 		}
+	    doneprint = 1;
 	    if (!thisfmt || lng) {
 		if (fline)
 		    fprintf(fout, "[%ld]  %c ",
@@ -944,6 +950,7 @@
 	}
 	fflush(fout);
     } else if (doputnl && interact && !synch) {
+	doneprint = 1;
 	putc('\n', fout);
 	fflush(fout);
     }
@@ -954,6 +961,7 @@
 
     if ((lng & 4) || (interact && job == thisjob &&
 		      jn->pwd && strcmp(jn->pwd, pwd))) {
+	doneprint = 1;
 	fprintf(fout, "(pwd %s: ", (lng & 4) ? "" : "now");
 	fprintdir(((lng & 4) && jn->pwd) ? jn->pwd : pwd, fout);
 	fprintf(fout, ")\n");
@@ -973,6 +981,8 @@
 	    setprevjob();
     } else
 	jn->stat &= ~STAT_CHANGED;
+
+    return doneprint;
 }
 
 /**/

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-01-30 19:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-30 19:00 PATCH: don't redraw when not printing job info Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).