Re: Unicode UTF-8 table formatting for psql text output - Mailing list pgsql-hackers

From Roger Leigh
Subject Re: Unicode UTF-8 table formatting for psql text output
Date
Msg-id 20090828002807.GA13948@codelibre.net
Whole thread Raw
In response to Re: Unicode UTF-8 table formatting for psql text output  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Unicode UTF-8 table formatting for psql text output  (Selena Deckelmann <selenamarie@gmail.com>)
List pgsql-hackers
On Thu, Aug 27, 2009 at 10:17:32AM -0400, Alvaro Herrera wrote:
> Alvaro Herrera escribió:
>
> > > I initially left these exactly the same as for ASCII (the ':' and ';'
> > > usage).  However, it's quite possible to make it use other characters.
> > > We could use the same lines, or two, three or four dashed lines
> > > ('╎' and '╏', or ┆' and '┇' or '┊' and '┋').
> >
> > This works for me (say ╎ for newline-separated strings and ┊ for wrapped
> > output).
>
> So it'd look like this:
>
> alvherre=# select * from foo;
>  a │                                     b
> ━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
>  1 │ En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho
>    ┊ tiempo que vivía un hidalgo de los de lanza en astillero, adarga antigua,
>    ┊ rocín flaco y galgo corredor. Una olla de algo más vaca que carnero, salpi
>    ┊ cón las más noches, duelos y quebrantos los sábados, lantejas los viernes,
>    ┊  algún palomino de añadidura los domingos, consumían las tres partes de su
>    ┊  hacienda. El resto della concluían sayo de velarte, calzas de velludo par
>    ┊ a las fiestas, con sus pantuflos de lo mesmo, y los días de entresemana se
>    ┊  honraba con su vellorí de lo más fino.  Tenía en su casa una ama que pasa
>    ┊ ba de los cuarenta, y una sobrina que no llegaba a los veinte, y un mozo d
>    ┊ e campo y plaza, que así ensillaba el rocín como tomaba la podadera.
>  2 │ —«Nunca fuera caballero de
>    ╎ damas tan bien servido
>    ╎ como fuera don Quijote
>    ╎ cuando de su aldea vino:
>    ╎ doncellas curaban dél;
>    ╎ princesas, del su rocino»
> (2 filas)

The attached patch adds support for the above output in wrapped mode.
It also uses single dashes (half lines) to represent lines which
contain no data, just vertical padding.  Output is unchanged for
ASCII output.

The last bit I'm missing is how to handle column wrapping for aligned
text output.  This is was introduced on 8th May 2008 by Bryce Nesbitt,
committed by Bruce Momjian (git commit f92f424d).  This patch
introduced the wrapped format, but I have not been able to activate
the codepaths that wrap column names in the table header (adding '+').

The logic in print_aligned_text goes like this:

col_count = cont->ncolumns;
...
more_col_wrapping = col_count;
curr_nl_line = 0;
while (more_col_wrapping)
{
  for (i = 0; i < cont->ncolumns; i++)
    if (!(this_line + 1)->ptr)   // Surely only true once at end of columns?
      more_col_wrapping--;
  curr_nl_line++;
}

I'm not convinced looking at the code that more_col_wrapping is ever
true except for the first time through the loop, and it's reached
zero after completion of the inner loop, so all of the code used when
curr_nl_line is > 0 is never called.  I'm sure I'm interpreting this
incorrectly, but I can't see under what circumstances I would get the
column name header line wrapped over multiple lines.

It may be that I just haven't got a table with column names of the
correct number and lengths to trigger it?


Regards,
Roger

--
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.

Attachment

pgsql-hackers by date:

Previous
From: Paul Matthews
Date:
Subject: Re: Patches for static check on geo_ops.c
Next
From: Robert Haas
Date:
Subject: Re: 8.5 release timetable, again