zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh users mailing list <zsh-users@sunsite.auc.dk>
Subject: Re: non-greedy matching?
Date: Wed, 21 Mar 2001 16:01:16 +0000	[thread overview]
Message-ID: <1010321160116.ZM17613@candle.brasslantern.com> (raw)
In-Reply-To: <20010321151448.4320.qmail@web9301.mail.yahoo.com>

On Mar 21,  2:23pm, Adam Spiers wrote:
} Subject: non-greedy matching?
}
}   ..... | perl -pe 's/%{.*?%}//g'
} 
} They are done in order to strip control characters from a prompt so
} that its display width can be determined.

I had to do something similar in prompt_bart_setup, and ended up with
this:

	${#${(%%f)${PS1//[%]\{[^%]#%\}/}}[1]}

The (f) and [1] are because of the multi-line PS1, where it computes the
length only of the first line.  The above works as long as you don't
have other prompt escapes inside the %{ %}.  Hmm.  Perhaps this:

	${#${(%%)${prompt_line_1a//[%]\{([^%]|%[^\}])#%\}/}}}

Looking at prompt_adam2_precmd, it does exactly what prompt_bart_precmd
does: compute a padding width by subtracting from $COLUMNS.  With the
above expression you can get rid of prompt_line_1[ab]_no_color entirely:

	prompt_padding_size=$(( COLUMNS
		- ${#${(%%)${prompt_line_1a//[%]\{([^%]|%[^\}])#%\}/}}}
		- ${#${(%%)${prompt_line_1b//[%]\{([^%]|%[^\}])#%\}/}}} ))

Which also, as Sven mentioned, gets rid of $(print -P ...).

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


  reply	other threads:[~2001-03-21 16:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-21 14:23 Adam Spiers
2001-03-21 15:14 ` Oliver Kiddle
2001-03-21 16:01   ` Bart Schaefer [this message]
2001-03-21 15:47 ` Oliver Kiddle
2001-03-21 14:57 Sven Wischnowsky

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=1010321160116.ZM17613@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-users@sunsite.auc.dk \
    /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).