zsh-users
 help / color / mirror / code / Atom feed
* terminal resizing and prompt problem
@ 2004-07-10 21:25 Nathan Sommer
  2004-07-11  3:41 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Sommer @ 2004-07-10 21:25 UTC (permalink / raw)
  To: zsh-users

Hello,
I have a problem with my zsh prompt.  It's 2 lines long and looks like so:

[/home/nate]
[17:02]% 

The code looks like this:
PS1=$'%{\e[1;32m%}[%d]\n%{\e[1;34m%}[%T]%{\e[1;32m%}%%%{\e[0m%} '

It works just fine, until I try to resize my terminal.  For each character height I resize vertically, or each character width I resize horizontally, the top line of my prompt is repeated.  For example, if I resize my terminal to make it 6 lines taller, I end up with this:

[/home/nate]
[/home/nate]
[/home/nate]
[/home/nate]
[/home/nate]
[/home/nate]
[/home/nate]
[17:14]%

This is terribly annoying, since it means I can't resize my terminal to see more output, since any additional visibility I would have gained is taken up by the additional lines of my prompt.  This happens in both xterm and rxvt.  Is this a bug?  Or is there an easy fix to this that I haven't found?

Thanks,
Nate

-- 
sommena@cs.earlham.edu
http://cs.earlham.edu/~sommena


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

* Re: terminal resizing and prompt problem
  2004-07-10 21:25 terminal resizing and prompt problem Nathan Sommer
@ 2004-07-11  3:41 ` Bart Schaefer
  2004-07-11  4:20   ` Nathan Sommer
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2004-07-11  3:41 UTC (permalink / raw)
  To: zsh-users

On Sat, 10 Jul 2004, Nathan Sommer wrote:

> For each character height I resize vertically, or each character width I 
> resize horizontally, the top line of my prompt is repeated.
[...]
> This is terribly annoying, since it means I can't resize my terminal to 
> see more output, since any additional visibility I would have gained is 
> taken up by the additional lines of my prompt.

Precisely how are you resizing the terminal?

Zsh reprints the prompt each time it gets a SIGWINCH signal.  Normally,
e.g. when dragging the window borders with the mouse, there would be only
a one such signal delivered at the time the mouse was released.

It sounds as though you -- or your window manager -- is performing e.g. 
six resizes of one line each rather than one resize of six lines, causing 
zsh to receive a stream of SIGWINCH signals.  This is not a bug in zsh.

When zsh reprints the prompt, it moves the cursor to the beginning of the 
line (prints a carriage return without a line feed) and then displays the 
prompt.  The line editor only keeps track of where it is on the current 
line, not what may have gone on before it got there, so it doesn't try to 
move up to wherever it was when the prompt began printing.  This could be 
considered a misfeature, but printing the prompt is entirely a separate 
action from editing the command line (the prompt is printed the same way 
whether ZLE is enabled or not).

However, you wouldn't notice (or at least it wouldn't be so annoying) if
your resizing signals weren't behaving so oddly.


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

* Re: terminal resizing and prompt problem
  2004-07-11  3:41 ` Bart Schaefer
@ 2004-07-11  4:20   ` Nathan Sommer
  2004-07-11  5:56     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Sommer @ 2004-07-11  4:20 UTC (permalink / raw)
  To: zsh-users

On Sat, 10 Jul 2004 20:41:40 -0700 (PDT)
Bart Schaefer <schaefer@brasslantern.com> wrote:

> On Sat, 10 Jul 2004, Nathan Sommer wrote:
> 
> > For each character height I resize vertically, or each character width I 
> > resize horizontally, the top line of my prompt is repeated.
> [...]
> > This is terribly annoying, since it means I can't resize my terminal to 
> > see more output, since any additional visibility I would have gained is 
> > taken up by the additional lines of my prompt.
> 
> Precisely how are you resizing the terminal?
> 
> Zsh reprints the prompt each time it gets a SIGWINCH signal.  Normally,
> e.g. when dragging the window borders with the mouse, there would be only
> a one such signal delivered at the time the mouse was released.
> 
> It sounds as though you -- or your window manager -- is performing e.g. 
> six resizes of one line each rather than one resize of six lines, causing 
> zsh to receive a stream of SIGWINCH signals.  This is not a bug in zsh.

It looks like the problem is due to the way fvwm (my window manager of choice)
does opaque resizing.  It is doing exactly what you say, six resizes of one
line each.  I happen to enjoy opaque resizing quite a bit, but maybe I'll turn
it off for my xterms.  That's kind of an annoying work-around though, and I'll
still get an extra line every time I resize.  I just may end up doing more
resizing with opaque resize off as well, since I'm not exactly sure what I'm
going to be seeing when I release the mouse button, and this will contribute
more annoying lines.  

Am I correct in concluding from your reply that it is impossible to have a
multi-line zsh prompt and not get any extra lines after resizing a terminal?


Thanks,
Nate

-- 
sommena@cs.earlham.edu
http://cs.earlham.edu/~sommena


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

* Re: terminal resizing and prompt problem
  2004-07-11  4:20   ` Nathan Sommer
@ 2004-07-11  5:56     ` Bart Schaefer
  2004-07-11 19:59       ` Nathan Sommer
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2004-07-11  5:56 UTC (permalink / raw)
  To: zsh-users

On Sun, 11 Jul 2004, Nathan Sommer wrote:

> Am I correct in concluding from your reply that it is impossible to have 
> a multi-line zsh prompt and not get any extra lines after resizing a 
> terminal?

It's impossible to have a multi-line value of $PS1 withoug getting extra
lines after resizing.

However, it occurs to me that you can make it look pretty much the same by 
printing the first line yourself in the precmd function and having the 
second line as the value of $PS1.

E.g.

 precmd() { print -rP $'\e[1;32m[%d]\e[0m' }
 PS1=$'%{\e[1;34m%}[%T]%{\e[1;32m%}%%%{\e[0m%} '

Incidentally, I also use fvwm, but I almost never resize a window by 
dragging.  I have a title-bar button using a function for "Maximize 0 100" 
and simply toggle back and forth between having the window be the full 
height of the display, and whatever height it started at.  What's the 
point of mucking around with anything in between?


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

* Re: terminal resizing and prompt problem
  2004-07-11  5:56     ` Bart Schaefer
@ 2004-07-11 19:59       ` Nathan Sommer
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Sommer @ 2004-07-11 19:59 UTC (permalink / raw)
  To: zsh-users

On Sat, 10 Jul 2004 22:56:13 -0700 (PDT)
Bart Schaefer <schaefer@brasslantern.com> wrote:

> However, it occurs to me that you can make it look pretty much the same by 
> printing the first line yourself in the precmd function and having the 
> second line as the value of $PS1.
> 
> E.g.
> 
>  precmd() { print -rP $'\e[1;32m[%d]\e[0m' }
>  PS1=$'%{\e[1;34m%}[%T]%{\e[1;32m%}%%%{\e[0m%} '
 
That works like a charm.  I'm pretty new to zsh, so I hadn't played around
with the precmd function yet.  Pretty cool.

> Incidentally, I also use fvwm, but I almost never resize a window by 
> dragging.  I have a title-bar button using a function for "Maximize 0 100" 
> and simply toggle back and forth between having the window be the full 
> height of the display, and whatever height it started at.  What's the 
> point of mucking around with anything in between?

That's what I do too, most of the time.  But sometimes I want my windows just
so.

Thanks a lot for your responses.

Nate

-- 
sommena@cs.earlham.edu
http://cs.earlham.edu/~sommena


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

end of thread, other threads:[~2004-07-11 20:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-10 21:25 terminal resizing and prompt problem Nathan Sommer
2004-07-11  3:41 ` Bart Schaefer
2004-07-11  4:20   ` Nathan Sommer
2004-07-11  5:56     ` Bart Schaefer
2004-07-11 19:59       ` Nathan Sommer

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