Re: Invisible PROMPT2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, ilmari(at)ilmari(dot)org, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Invisible PROMPT2
Date: 2019-11-18 17:21:53
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> On Mon, Nov 18, 2019 at 1:49 PM Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
>> On 2019-Nov-18, Thomas Munro wrote:
>>> Nice idea. Here's one like that, that just does the counting at the
>>> end and looks out for readline control codes. It's pretty naive about
>>> what "width" means though: you'll get two spaces for UTF-8 encoded é,
>>> and I suppose a complete implementation would know about the half
>>> width/full width thing for Chinese and Japanese etc.

> Yeah. Maybe pg_wcswidth() would be OK though, and it's available in
> psql, though I guess you'd have to make a copy with the escaped bits
> stripped out.

Right, you should use pg_wcswidth() or the underlying PQdsplen() function
to compute display width. The latter might be more convenient since
you could apply it character by character rather than making a copy
of the string.

regards, tom lane

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2019-11-18 17:42:04 Re: [PATCH][BUG FIX] Unsafe access pointers.
Previous Message Laurenz Albe 2019-11-18 14:40:51 Re: Role membership and DROP