Re: Invisible PROMPT2

2020-02-09 Thread Thomas Munro
On Mon, Dec 23, 2019 at 5:43 AM Maxence Ahlouche wrote: > On Wed, 27 Nov 2019 at 17:09, Tom Lane wrote: >> Good idea, but I think you need to account for "visible" (ie, if the >> newline is inside RL_PROMPT_START_IGNORE, it shouldn't change the width). >> It might be best to add logic inside the

Re: Invisible PROMPT2

2019-12-22 Thread Maxence Ahlouche
but I'm not sure it's worth the effort. commit 491cf173aad247299622796775feea580a8f9b13 (HEAD -> refs/heads/patch_psql_prompt) Author: Maxence Ahlouche Date: Wed Nov 27 16:21:35 2019 +0100 Fix %w length in PROMPT2 when PROMPT1 contains a newline, in psql. The width of the invisible PROMPT2 must take i

Re: Invisible PROMPT2

2019-11-27 Thread Tom Lane
Maxence Ahlouche writes: > The length of %w should probably be computed starting from the last newline > in PROMPT1. Good idea, but I think you need to account for "visible" (ie, if the newline is inside RL_PROMPT_START_IGNORE, it shouldn't change the width). It might be best to add logic inside

Re: Invisible PROMPT2

2019-11-27 Thread Maxence Ahlouche
ise, nice feature, I like it! Regards, Maxence commit 7fca5709d3ada8cf0b4219c707562cd841c997d2 (HEAD -> refs/heads/psql_prompt) Author: Maxence Ahlouche Date: Wed Nov 27 16:21:35 2019 +0100 Fix %w length in PROMPT2 when PROMPT1 contains a newline, in psql. The width of the inv

Re: Invisible PROMPT2

2019-11-19 Thread David Fetter
On Tue, Nov 19, 2019 at 04:02:48PM +1300, Thomas Munro wrote: > On Tue, Nov 19, 2019 at 12:09 PM Tom Lane 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(). > >

Re: Invisible PROMPT2

2019-11-18 Thread Thomas Munro
On Tue, Nov 19, 2019 at 12:09 PM Tom Lane 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(),

Re: Invisible PROMPT2

2019-11-18 Thread Tom Lane
Thomas Munro writes: > Right, a PQdsplen()/PQmblen() loop works nicely, as attached. > I spotted a potential problem: I suppose I could write a PROMPT1 that > includes an invalid multibyte sequence at the end of the buffer and > trick PQmblen() or PQdsplen() into reading a few bytes past the

Re: Invisible PROMPT2

2019-11-18 Thread Thomas Munro
_length() to make sure you can't get close enough to the end of the buffer, but neither of those functions are available to psql. v2-0001-Allow-invisible-PROMPT2-in-psql.patch Description: Binary data

Re: Invisible PROMPT2

2019-11-18 Thread Tom Lane
Thomas Munro writes: > On Mon, Nov 18, 2019 at 1:49 PM Alvaro Herrera > 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

Re: Invisible PROMPT2

2019-11-17 Thread Thomas Munro
On Mon, Nov 18, 2019 at 1:49 PM Alvaro Herrera 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

Re: Invisible PROMPT2

2019-11-17 Thread Alvaro Herrera
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

Re: Invisible PROMPT2

2019-11-17 Thread Thomas Munro
line 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. 0001-Allow-invisible-PROMPT2-in-psql.patch Description: Binary data

Re: Invisible PROMPT2

2019-11-14 Thread Tom Lane
Kyotaro Horiguchi writes: > This seems assuming %x are a kind of stable (until semicolon) > function. But at least %`..` can be volatile. So, I think the %w > thing in PROMPT2 should be able to refer the actual prompt string > resulted from PROMPT1. Oh, that's a good point. But it actually

Re: Invisible PROMPT2

2019-11-13 Thread Kyotaro Horiguchi
At Wed, 13 Nov 2019 20:57:04 +0100, David Fetter wrote in > On Wed, Nov 13, 2019 at 03:58:38PM -0300, Alvaro Herrera wrote: > > On 2019-Nov-13, David Fetter wrote: > > > > > On Wed, Nov 13, 2019 at 03:06:08PM -0300, Alvaro Herrera wrote: > > > > On 2019-Nov-13, David Fetter wrote: > > > > > >

Re: Invisible PROMPT2

2019-11-13 Thread David Fetter
On Wed, Nov 13, 2019 at 03:58:38PM -0300, Alvaro Herrera wrote: > On 2019-Nov-13, David Fetter wrote: > > > On Wed, Nov 13, 2019 at 03:06:08PM -0300, Alvaro Herrera wrote: > > > On 2019-Nov-13, David Fetter wrote: > > > > > > > On Wed, Nov 13, 2019 at 09:47:01AM -0500, Tom Lane wrote: > > > > >

Re: Invisible PROMPT2

2019-11-13 Thread Alvaro Herrera
On 2019-Nov-13, David Fetter wrote: > On Wed, Nov 13, 2019 at 03:06:08PM -0300, Alvaro Herrera wrote: > > On 2019-Nov-13, David Fetter wrote: > > > > > On Wed, Nov 13, 2019 at 09:47:01AM -0500, Tom Lane wrote: > > > > > > > How about a circumfix directive (like the existing %[ ... %]) > > > > >

Re: Invisible PROMPT2

2019-11-13 Thread David Fetter
On Wed, Nov 13, 2019 at 03:06:08PM -0300, Alvaro Herrera wrote: > On 2019-Nov-13, David Fetter wrote: > > > On Wed, Nov 13, 2019 at 09:47:01AM -0500, Tom Lane wrote: > > > > > How about a circumfix directive (like the existing %[ ... %]) > > > > that replaces everything inside with whitespace,

Re: Invisible PROMPT2

2019-11-13 Thread Alvaro Herrera
On 2019-Nov-13, David Fetter wrote: > On Wed, Nov 13, 2019 at 09:47:01AM -0500, Tom Lane wrote: > > > How about a circumfix directive (like the existing %[ ... %]) > > > that replaces everything inside with whitespace, but keeps the width? > > > > Or just define %w as meaning "whitespace of the

Re: Invisible PROMPT2

2019-11-13 Thread Chapman Flack
On 11/13/19 12:49 PM, David Fetter wrote: >> Or just define %w as meaning "whitespace of the same width as >> PROMPT1". You couldn't use it *in* PROMPT1, then, but I see >> no use-case for that anyway. > > +1 for doing it this way. Would it make more sense to error out if > somebody tried to

Re: Invisible PROMPT2

2019-11-13 Thread David Fetter
On Wed, Nov 13, 2019 at 09:47:01AM -0500, Tom Lane wrote: > ilm...@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes: > > Thomas Munro writes: > >> From the advanced bikeshedding department: I'd like my psql > >> transcripts to have the usual alignment, but be easier to copy and > >>

Re: Invisible PROMPT2

2019-11-13 Thread Tom Lane
ilm...@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes: > Thomas Munro writes: >> From the advanced bikeshedding department: I'd like my psql >> transcripts to have the usual alignment, but be easier to copy and >> paste later without having weird prompt stuff in the middle. How >>

Re: Invisible PROMPT2

2019-11-13 Thread Dagfinn Ilmari Mannsåker
Thomas Munro writes: > Hello hackers, > > From the advanced bikeshedding department: I'd like my psql > transcripts to have the usual alignment, but be easier to copy and > paste later without having weird prompt stuff in the middle. How > about a prompt format directive %w that means

Re: Invisible PROMPT2

2019-11-12 Thread Pavel Stehule
st 13. 11. 2019 v 4:15 odesílatel Thomas Munro napsal: > Hello hackers, > > From the advanced bikeshedding department: I'd like my psql > transcripts to have the usual alignment, but be easier to copy and > paste later without having weird prompt stuff in the middle. How > about a prompt format

Invisible PROMPT2

2019-11-12 Thread Thomas Munro
Hello hackers, >From the advanced bikeshedding department: I'd like my psql transcripts to have the usual alignment, but be easier to copy and paste later without having weird prompt stuff in the middle. How about a prompt format directive %w that means "whitespace of the same width as %/"?