zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: zle reset-prompt with prompt that is COLUMNS wide eats line above prompt's first line
Date: Fri, 10 Dec 2010 23:57:48 -0800	[thread overview]
Message-ID: <101210235748.ZM11748@torch.brasslantern.com> (raw)
In-Reply-To: =?iso-8859-1?Q?=3CAANLkTikHzGZGnhCma+wsDPhYhMwK4TaL3AASNOvfXi?= =?iso-8859-1?Q?sn=40mail=2Egmail=2Ecom=3E?= =?iso-8859-1?Q?Comments=3A_In_reply_to_Nikolai_Weibull_=3Cnow=40bitwi=2Es?= =?iso-8859-1?Q?e=3E?= =?iso-8859-1?Q?________=22=28_Text_in_unknown_character_set_UTF-8_not_sho?= =?iso-8859-1?Q?wn_=29_ts_line_above_prompt=E2=80=99s_first_line=22_=28Dec?= =?iso-8859-1?Q?_10=2C_11=3A40am=29?=

On Dec 10, 11:40am, Nikolai Weibull wrote:
}
} Running zle reset-prompt with a prompt that is COLUMNS wide eats the
} line above prompt's first line.  Here's a set-up to try it with:
} 
} PS1=${(l:COLUMNS:)}$'\n'
} bindkey '^^' reset-prompt

The problem here isn't the width of the prompt, it's the newline.
(OK, it's sort of the combination of the two, but more the latter.)

} Each time you press CTRL-^ you'll be eating the line above the first
} line of the prompt.  If you change PS1 to ${(l:COLUMNS-1)}$'\n' this
} doesn't happen.
} 
} Would it be possible to have prompt that is COLUMNS wide and have this
} not happen?

This is a problem with terminals and terminfo or termcap descriptions.
Some terminals silently discard a newline when one is output at the
right margin, others don't, and still others discard it only when it
is output at the right margin of the very last line of the screen.
Some terminals cause the cursor to wrap onto the next line right
away when the right margin is reached, others leave the cursor on
top of the last character that was output until at least one more
character appears.

Terminal description databases aren't very good at differentiating
these cases.  ZLE decides in this case that the terminal both wraps
the line and does not discard the newline, so it believes it needs
to move up one line before redrawing the prompt.  Your terminal
wraps at the margin but does discard the newline, so ZLE's internal
idea of what the screen looks like does not match reality.

You can get around this by replacing $'\n' with $'%1(l.\n.)' which
means to emit the newline only if ZLE believes that at least one
character has been output since the last (implicit) newline.  If
the line is exactly $COLUMNS wide, ZLE will think that the terminal
has wrapped and that zero characters have been output since, so it
won't fool itself by emitting a newline that the terminal discards.

On a different terminal, though, you might need to go back to $'\n'
unconditionally.


  reply	other threads:[~2010-12-11  7:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-10 10:40 zle reset-prompt with prompt that is COLUMNS wide eats line above prompt’s " Nikolai Weibull
2010-12-11  7:57 ` Bart Schaefer [this message]
2011-01-25 13:23   ` zle reset-prompt with prompt that is COLUMNS wide eats line above prompt's " Nikolai Weibull

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=101210235748.ZM11748@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).