zsh-workers
 help / color / mirror / code / Atom feed
* %<< and %{%}
@ 2000-02-29 15:26 Tanaka Akira
  2000-02-29 17:32 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Tanaka Akira @ 2000-02-29 15:26 UTC (permalink / raw)
  To: zsh-workers

I heard that the combination of %<< and %{%} in prompt doesn't work well.

Z(2):akr@is27e1u11% Src/zsh -f
is27e1u11% cd /usr/local/bin
is27e1u11% PS1=$'[%20<..<%/]'
[/usr/local/bin]PS1=$'[%20<..<%/]%{\e[33m%}'
[../local/bin]

Hm.  The string in %{..%} is affected to truncation.  It is wrong.

zsh-3.0.7 works well.

Z(2):akr@is27e1u11% zsh-3.0.7 -f
is27e1u11% cd /usr/local/bin
is27e1u11% PS1='[%20<..<%/]' 
[/usr/local/bin]PS1='[%20<..<%/]%{^[[33m%}'
[/usr/local/bin]
-- 
Tanaka Akira


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

* Re: %<< and %{%}
  2000-02-29 15:26 %<< and %{%} Tanaka Akira
@ 2000-02-29 17:32 ` Bart Schaefer
  2000-02-29 18:12   ` PATCH: (partially) " Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2000-02-29 17:32 UTC (permalink / raw)
  To: zsh-workers

On Mar 1, 12:26am, Tanaka Akira wrote:
} Subject: %<< and %{%}
}
} I heard that the combination of %<< and %{%} in prompt doesn't work well.
} 
} Z(2):akr@is27e1u11% Src/zsh -f
} is27e1u11% cd /usr/local/bin
} is27e1u11% PS1=$'[%20<..<%/]'
} [/usr/local/bin]PS1=$'[%20<..<%/]%{\e[33m%}'
} [../local/bin]
} 
} Hm.  The string in %{..%} is affected to truncation.  It is wrong.

Maybe, but (I think) so is your usage of %<..<, since zsh-workers/4601.
I believe you want something like

PS1=$'[%20<..<%/%<<]%{\e[33m%}'

There does seem to be a bug with handling of turncations inside the %()
conditional construct; if the truncation is in the "true" branch, then
the false branch and the trailing `)' are left as part of the prompt.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* PATCH: (partially) Re: %<< and %{%}
  2000-02-29 17:32 ` Bart Schaefer
@ 2000-02-29 18:12   ` Bart Schaefer
  2000-02-29 18:36     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2000-02-29 18:12 UTC (permalink / raw)
  To: zsh-workers

On Feb 29,  5:32pm, Bart Schaefer wrote:
} Subject: Re: %<< and %{%}
}
} On Mar 1, 12:26am, Tanaka Akira wrote:
} } Subject: %<< and %{%}
} }
} } I heard that the combination of %<< and %{%} in prompt doesn't work well.
} } 
} } Hm.  The string in %{..%} is affected to truncation.  It is wrong.

Had a quick look at this ... unfortunately, the way prompt truncation
is now calculated, the knowledge of what strings were contained inside
%{...%} has been lost by the time we start computing the truncation.
That means that we might even truncate into the middle of a %{...%}.

Prior to 4601 (and in the 3.0 series), prompt truncation applied to
exactly one following %-escape, which made it very difficult to specify
the total length of the prompt.  4601 introduced the idea of truncating
the entire remainder of the prompt, unless truncation were explicitly
limited by either enclosing it in %(...) or by an empty truncation, as
I suggested here:

} PS1=$'[%20<..<%/%<<]%{\e[33m%}'

Unfortunately this has the unwanted side-effect that the prompt is fully
generated before its size is counted for truncation -- and hence the
trouble with %{...%}.

Fixing this is going to require another rethinking of putpromptchar().

} There does seem to be a bug with handling of turncations inside the %()
} conditional construct; if the truncation is in the "true" branch, then
} the false branch and the trailing `)' are left as part of the prompt.

That, however, is easily fixed.

Index: Src/prompt.c
===================================================================
@@ -815,9 +815,9 @@
 	     */
 	    if (!putpromptchar(doprint, endchar))
 		return 0;
-	    /* Now we have to trick it into matching endchar again */
-	    fm--;
 	}
+	/* Now we have to trick it into matching endchar again */
+	fm--;
     } else {
 	if (*fm != ']')
 	    fm++;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: (partially) Re: %<< and %{%}
  2000-02-29 18:12   ` PATCH: (partially) " Bart Schaefer
@ 2000-02-29 18:36     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2000-02-29 18:36 UTC (permalink / raw)
  To: zsh-workers

On Feb 29,  6:12pm, Bart Schaefer wrote:
} Subject: PATCH: (partially) Re: %<< and %{%}
}
} Had a quick look at this ... unfortunately, the way prompt truncation
} is now calculated, the knowledge of what strings were contained inside
} %{...%} has been lost by the time we start computing the truncation.

Minor correction:  It hasn't been lost -- it's represented by Inpar and
Outpar tokens in the prompt string, but prompttruncate() doesn't look
for them -- it just does pointer arithmetic and memmove().  It's going
to be only a little bit tricky to fix it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~2000-02-29 18:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-29 15:26 %<< and %{%} Tanaka Akira
2000-02-29 17:32 ` Bart Schaefer
2000-02-29 18:12   ` PATCH: (partially) " Bart Schaefer
2000-02-29 18:36     ` Bart Schaefer

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