zsh-workers
 help / color / mirror / code / Atom feed
* Re: prompts with newlines get printed twice
       [not found]   ` <CAHYJk3QcrD6gVcGRrVX=n2bL5ZW9F93f39-BYq1a1iyQeZyB1g@mail.gmail.com>
@ 2011-09-25 21:44     ` Bart Schaefer
  2011-10-01 19:14       ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2011-09-25 21:44 UTC (permalink / raw)
  To: zsh-workers

[>workers]

On Sep 24,  8:31pm, Mikael Magnusson wrote:
}
} I'm seeing some strange behaviour here, when I resize after setting
} PS1='%D{%s} hello
} there '
} I do get the first line twice, but subsequent resizes properly redraws
} both lines in place, updating the time too. Pressing enter then causes
} the next resize to double the first line and then subsequent ones work
} again.

Hmm.

I've traced this to adjustwinsize() called from zhandler().  It makes
these two calls:

1694            zleentry(ZLE_CMD_REFRESH);
1695            zleentry(ZLE_CMD_RESET_PROMPT);

The first one calls zrefresh() which erases the current line and then
prints the prompt (lines 1126 - 1129 of zle_refresh.c) and calls
fflush(shout).  The second then goes through redisplay(), which moves
up one line to the beginning of the just-printed prompt and sets
resetneeded, but the prompt is never printed nor is shout flushed.

On subsequent calls to the handler, when the prompt is printed the
up-line from the previous call is finally flushed BEFORE the prompt
is printed by zrefresh(), so the prompt is accidentally displayed in
the right place.  But I can't believe that it's useful to leave that
up-line lingering in the shout buffer.  I'm still not sure why that
doesn't cause a problem when resizing is done and editing resumes;
it must be because resetneeded is also left hanging.

Can anyone think of a reason not to swap the order of those calls in
adjustwinsize()?  That seems to completely resolve the problem with
vertical resizing.  There's still an issue with horizontal resize
where, if the number of lines in the prompt increases due to the
window becoming too narrow, redisplay() uses the new prompt size and
moves up too far, which may cover up some of the previous command's
output.  Fixing that would seem to be a more significant change, to
keep the old lines/columns around until after lprompth is computed
or some such.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: prompts with newlines get printed twice
  2011-09-25 21:44     ` prompts with newlines get printed twice Bart Schaefer
@ 2011-10-01 19:14       ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2011-10-01 19:14 UTC (permalink / raw)
  To: zsh-workers

On Sun, 25 Sep 2011 14:44:16 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> I've traced this to adjustwinsize() called from zhandler().  It makes
> these two calls:
> 
> 1694            zleentry(ZLE_CMD_REFRESH);
> 1695            zleentry(ZLE_CMD_RESET_PROMPT);
> 
> The first one calls zrefresh() which erases the current line and then
> prints the prompt (lines 1126 - 1129 of zle_refresh.c) and calls
> fflush(shout).  The second then goes through redisplay(), which moves
> up one line to the beginning of the just-printed prompt and sets
> resetneeded, but the prompt is never printed nor is shout flushed.
> 
> Can anyone think of a reason not to swap the order of those calls in
> adjustwinsize()?

It does seem a strange order.  You'd have thought that at the least it
should ensure the prompt is output.  That rather confusing "redisplay"
call in zle_resetprompt, which I don't think does actually redisplay
anything, isn't helping clarify matters.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-01 19:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAF3NQe_arDSLBRUEKRfZyDx-2QhsfP63xFYktxKK45a1iA6Eow@mail.gmail.com>
     [not found] ` <110924112412.ZM24918@torch.brasslantern.com>
     [not found]   ` <CAHYJk3QcrD6gVcGRrVX=n2bL5ZW9F93f39-BYq1a1iyQeZyB1g@mail.gmail.com>
2011-09-25 21:44     ` prompts with newlines get printed twice Bart Schaefer
2011-10-01 19:14       ` 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).