zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: prompts with newlines get printed twice
Date: Sun, 25 Sep 2011 14:44:16 -0700	[thread overview]
Message-ID: <110925144416.ZM19577@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3QcrD6gVcGRrVX=n2bL5ZW9F93f39-BYq1a1iyQeZyB1g@mail.gmail.com>

[>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.


       reply	other threads:[~2011-09-25 21:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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     ` Bart Schaefer [this message]
2011-10-01 19:14       ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=110925144416.ZM19577@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).