Re: Invisible PROMPT2

David Fetter <david@fetter.org>

From: David Fetter <david@fetter.org>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Alvaro Herrera <alvherre@2ndquadrant.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, ilmari@ilmari.org, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-11-19T21:37:26Z
Lists: pgsql-hackers

Attachments

On Tue, Nov 19, 2019 at 04:02:48PM +1300, Thomas Munro wrote:
> On Tue, Nov 19, 2019 at 12:09 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > You should follow the logic in pg_wcswidth: compute PQmblen() first,
> > and bail out if it's more than the remaining string length, otherwise
> > it's ok to apply PQdsplen().
> 
> Got it.  I was worried that it wasn't safe to call even PQmblen(),
> because I didn't know a fact about all encodings: as described in the
> comment of pg_gb18030_mblen(), all implementations read only the first
> byte to determine the length, except for GB18030 which reads the
> second byte too, and that's OK because there's always a null
> terminator.
> 
> > It might be a good idea to explicitly initialize last_prompt1_width to
> > zero, for clarity.
> >
> > Should the user docs explicitly say "of the same width as the most recent
> > output of PROMPT1", as you have in the comments?  That seems a more
> > precise specification, and it will eliminate some questions people will
> > otherwise ask.
> >
> > LGTM otherwise.
> 
> Done, and pushed.  I also skipped negative results from PQdsplen like
> pg_wcswidth() does (that oversight explained why a non-readline build
> showed the correct alignment for PROMPT1 '%[%033[1m%]%M
> %n@%/%R%[%033[0m%]%# ' by strange concindence).
> 
> Thanks all for the feedback.  I think the new bikeshed colour looks good.

Please find attached some polka dots for the bike shed :)

Best,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Commits

  1. psql: Fix %w length in PROMPT2 when PROMPT1 contains a newline.

  2. Allow invisible PROMPT2 in psql.