zsh-users
 help / color / mirror / code / Atom feed
* problem with bold prompt
@ 1997-01-30 23:13 Will Day
  1997-01-31  0:08 ` Zefram
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Will Day @ 1997-01-30 23:13 UTC (permalink / raw)
  To: zsh users mailing list

-----BEGIN PGP SIGNED MESSAGE-----

This is a problem I've been fighting with for a long time, and which I only
recently began to grasp, when it got worse after I upgraded from 2.5.03 to
3.0.2. :) 

My prompt is defined as:
	export PS1="^[[1m${HOSTNAME}:^[[m%d) "
so that it appears as:
	rom:/home/willday)
where the "rom" is bold.

It looks like zsh is counting the formatting characters as printable
characters on the command-line.  Under 2.5.03, this would screw up
command-recall, and ctrl-U line clearing.  

For instance, at the prompt (where # indicates the location of the cursor):
   rom:/home/willday/src/done/zsh-2.5.03) #
hitting "ESC /" would move the cursor over seven characters:
   rom:/home/willday/src/done/zsh-2.5.03)        #
   /
which corresponds to the seven non-printable characters in my prompt
(^[,[,1,m,^[,[,m).  

Lines recalled with "/" would be printed at the 7-char offset:
   rom:/home/willday/src/done/zsh-2.5.03)        ls -dlF INSTALL README doc etc 
   examples help src

Lines recalled with just "ESC -" would not be offset, but command-line editing
would be screwed up.  For instance, "ESC - b b b b" should bring up the line,
and go back 4 words, placing the cursor at "etc".  Instead, it ends up 7
chars off, in the middle of "example":
   rom:/home/willday/src/done/zsh-2.5.03) ls -dlF INSTALL README doc etc exa#ple
   s help src

Under 3.0.2, it now also clears the line and starts overwriting when I reach
the right margin.  For instance, a line that should look like this:
   rom:/home/willday/src/done/zsh-3.0.2) ls -dlF INSTALL README Doc Etc Misc Src
    Util
ends up looking like this:
   isc Src Util
which makes it most unusable.

It doesn't seem to matter what terminal type I'm using (xterm, mac vt100,
linux console), nor which formatting codes I use (^[[34m for blue, etc), 
but the offset does always correspond to the number of non-printable
characters in the prompt.

I managed to hack 3.0.2's zle_refresh.c to behave like 2.0.5 did in this
regard (that is, not to clear the line), so at least it's now usable again.
:)  But I don't know enough about the code to go in and fix the problem.  

______________________________________________________________________________
Will Day       <PGP mail preferred>      OIT, Georgia Tech, Atlanta 30332-0715
willday@rom.oit.gatech.edu               http://rom.oit.gatech.edu/~willday/
     =-> Opinions expressed are mine alone and do not reflect OIT policy <-=
Those who would give up essential Liberty, to purchase a little temporary 
Safety, deserve neither Liberty nor Safety.
    Benjamin Franklin, Pennsylvania Assembly, Nov. 11, 1755

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3a
Charset: noconv
Comment: http://rom.oit.gatech.edu/~willday/pubkey.asc

iQCVAwUBMvEq+BDHlOdPw2ZdAQFTKgP/eQUjR/8aqE9jXpZrIAeAaZIqy23IFlOO
iflYxFPgIyLxTLiccxDeI2cYvzOwElMLXyfzhe11rydSpTUvhAtxyrf2b0YKy2Lu
YPFAqKAgZ5oH7oRCHNHqepDDfHWKMakWIHSoLxfpJgm2j2JstGsdIPEEBEahFhly
T9T+r0CCMjc=
=O+wh
-----END PGP SIGNATURE-----


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

* Re: problem with bold prompt
  1997-01-30 23:13 problem with bold prompt Will Day
@ 1997-01-31  0:08 ` Zefram
  1997-01-31  0:14 ` Aaron Schrab
  1997-01-31  4:23 ` Vidiot
  2 siblings, 0 replies; 4+ messages in thread
From: Zefram @ 1997-01-31  0:08 UTC (permalink / raw)
  To: willday; +Cc: zsh-users

Will Day wrote:
>My prompt is defined as:
>	export PS1="^[[1m${HOSTNAME}:^[[m%d) "
...
>It looks like zsh is counting the formatting characters as printable
>characters on the command-line.

This is exactly what it is doing; you have done nothing to tell it that
the escape sequences are not printable.  You can do that directly by
surrounding them in %{ and %}:

PS1='%{^[[1m%}${HOSTNAME}:%{^[[m%}%d) '

However, this still suffers one of the same basic problems as your
first attempt -- it will only work on a vt100-compatible terminal.  You
can solve this by using the sequences %B and %b to mark the bold text:

PS1='%B${HOSTNAME}:%b%d) '

This is more readable.  zsh will substitute the correct sequences for
whichever terminal you are using, and knows that they don't take up any
screen space (or, on a few odd terminals, that they do).

-zefram


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

* Re: problem with bold prompt
  1997-01-30 23:13 problem with bold prompt Will Day
  1997-01-31  0:08 ` Zefram
@ 1997-01-31  0:14 ` Aaron Schrab
  1997-01-31  4:23 ` Vidiot
  2 siblings, 0 replies; 4+ messages in thread
From: Aaron Schrab @ 1997-01-31  0:14 UTC (permalink / raw)
  To: zsh users mailing list

On 30 Jan 1997, willday@rom.oit.gatech.edu (Will Day) wrote:
> This is a problem I've been fighting with for a long time, and which I only
> recently began to grasp, when it got worse after I upgraded from 2.5.03 to
> 3.0.2. :) 
> 
> My prompt is defined as:
> 	export PS1="^[[1m${HOSTNAME}:^[[m%d) "
> so that it appears as:
> 	rom:/home/willday)
> where the "rom" is bold.
> 
> It looks like zsh is counting the formatting characters as printable
> characters on the command-line.  Under 2.5.03, this would screw up
> command-recall, and ctrl-U line clearing.  

Put the formatting characters inside %{ %} pairs:
  export PS1="%{^[[1m%}${HOSTNAME}:%{^[[mi%}%d) "
this tells zsh not to count them.
-- 
Aaron Schrab    <mailto:aarons@execpc.com>    <http://www.execpc.com/~aarons/>
Exec-PC Internet Systems Administration <mailto:info@execpc.com> for auto info


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

* Re: problem with bold prompt
  1997-01-30 23:13 problem with bold prompt Will Day
  1997-01-31  0:08 ` Zefram
  1997-01-31  0:14 ` Aaron Schrab
@ 1997-01-31  4:23 ` Vidiot
  2 siblings, 0 replies; 4+ messages in thread
From: Vidiot @ 1997-01-31  4:23 UTC (permalink / raw)
  To: ZSH Mailing List

<This is a problem I've been fighting with for a long time, and which I only
<recently began to grasp, when it got worse after I upgraded from 2.5.03 to
<3.0.2. :) 
<
<My prompt is defined as:
<	export PS1="^[[1m${HOSTNAME}:^[[m%d) "
<so that it appears as:
<	rom:/home/willday)
<where the "rom" is bold.

Interesting.  This is the string that I use to set all of the line to bold:

if [[ vt102 = $TERM ]]
then export PROMPT="%{^[[1m%}$HOST.BRN <%h> %{^[[0m%}"
else export PROMPT="$HOST.BRN <%h> "
fi


I have no problem on the old zsh and zsh 3.1.  So far the cursor has ended
up where it belongs.

BTW, the ^[ is a real ESC character in the file.

MB
-- 
System Administrator - Finnigan FT/MS - Madison WI. <URL:http://www.ftms.com/>
e-mail: brown@ftms.com
phone: (608) 273-8262 ext: 612  fax: (608) 273-8719
Visit - <URL:http://www.cdsnet.net/vidiot/>  (Your link to Star Trek and UPN)


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

end of thread, other threads:[~1997-01-31  4:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-30 23:13 problem with bold prompt Will Day
1997-01-31  0:08 ` Zefram
1997-01-31  0:14 ` Aaron Schrab
1997-01-31  4:23 ` Vidiot

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