Обсуждение: Re: Ascii Elephant for text based protocols - Final function proposal
Re: Ascii Elephant for text based protocols - Final function proposal
От
"Charles Clavadetscher"
Дата:
Hello all > -----Original Message----- > From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Karsten Hilbert > Sent: Dienstag, 17. Mai 2016 09:23 > To: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Ascii Elephant for text based protocols - Final > > On Tue, May 17, 2016 at 06:58:14AM +0200, Charles Clavadetscher wrote: > > > A question to the naming. I find pg_logo() also a good name, but is > > the prefix pg_* not reserved for system functions? Of course I could > > use the name I want, but was wondering if there is a policy or a best > > practice in this area. > > pg_logo would only be suitable if it got blessing from "higher up". Well. This question will be addressed when the body of the function is complete. Now I have a proposal which is in the attachment. The function accepts a set of arguments, all having default values: p_frame BOOLEAN DEFAULT false: values true or false. p_text TEXT[] DEFAULT NULL: Free text as array of text. Each element of the array is a line of text. Maximum of 8 lines.What is above is ignored. p_position TEXT DEFAULT 'bottom': position of the text in relation to the pic. bottom or right. p_align TEXT DEFAULT 'center': Alignment of pic AND text, when p_position is bottom, only of the text otherwise. Values:left, center, right. p_valign TEXT DEFAULT 'center': Vertical alignement of the text. Only applies if p_position is right. Values: top, center,bottom. Below I add a set of sample outputs. Feel free to test it and all feedbacks are as usual very much appreciated. Regards, Charles Sample outputs: No arguments (all defaults): select pg_logo(); pg_logo ----------------------- ____ ______ ___ / )/ \/ \ ( / __ _\ ) \ (/ o) ( o) ) \_ (_ ) \ ) _/ \ /\_/ \)/ \/ <//| |\\> _| | \|_/ (9 rows) Add frame: select pg_logo(true); pg_logo --------------------------- +-----------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) | | \ (/ o) ( o) ) | | \_ (_ ) \ ) _/ | | \ /\_/ \)/ | | \/ <//| |\\> | | _| | | | \|_/ | | | +-----------------------+ (12 rows) Add text using default positioning and alignments: select pg_logo(true,ARRAY['Swiss PGDay 2016','24.06.2016 - HSR Rapperswil','Switzerland','http://www.pgday.ch']); pg_logo --------------------------------- +-----------------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) | | \ (/ o) ( o) ) | | \_ (_ ) \ ) _/ | | \ /\_/ \)/ | | \/ <//| |\\> | | _| | | | \|_/ | | | | Swiss PGDay 2016 | | 24.06.2016 - HSR Rapperswil | | Switzerland | | http://www.pgday.ch | | | +-----------------------------+ (17 rows) Position text on the right hand side of the pic: select pg_logo(true,ARRAY['Swiss PGDay 2016','24.06.2016 - HSR Rapperswil','Switzerland','http://www.pgday.ch'],'right'); pg_logo ------------------------------------------------------- +---------------------------------------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) Swiss PGDay 2016 | | \ (/ o) ( o) ) 24.06.2016 - HSR Rapperswil | | \_ (_ ) \ ) _/ Switzerland | | \ /\_/ \)/ http://www.pgday.ch | | \/ <//| |\\> | | _| | | | \|_/ | | | +---------------------------------------------------+ (12 rows) Change text alignment to left: select pg_logo(true,ARRAY['Swiss PGDay 2016','24.06.2016 - HSR Rapperswil','Switzerland','http://www.pgday.ch'],'right','left'); pg_logo ------------------------------------------------------- +---------------------------------------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) Swiss PGDay 2016 | | \ (/ o) ( o) ) 24.06.2016 - HSR Rapperswil | | \_ (_ ) \ ) _/ Switzerland | | \ /\_/ \)/ http://www.pgday.ch | | \/ <//| |\\> | | _| | | | \|_/ | | | +---------------------------------------------------+ (12 rows) Change vertical alignment of text to bottom: select pg_logo(true,ARRAY['Swiss PGDay 2016','24.06.2016 - HSR Rapperswil','Switzerland','http://www.pgday.ch'],'right','left','bottom'); pg_logo ------------------------------------------------------- +---------------------------------------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) | | \ (/ o) ( o) ) | | \_ (_ ) \ ) _/ | | \ /\_/ \)/ Swiss PGDay 2016 | | \/ <//| |\\> 24.06.2016 - HSR Rapperswil | | _| | Switzerland | | \|_/ http://www.pgday.ch | | | +---------------------------------------------------+ (12 rows) And all other combinations, e.g. Put text below the pic and left aligned without frame: select pg_logo(false,ARRAY['Swiss PGDay 2016','24.06.2016 - HSR Rapperswil','Switzerland','http://www.pgday.ch'],'bottom','left'); pg_logo ----------------------------- ____ ______ ___ / )/ \/ \ ( / __ _\ ) \ (/ o) ( o) ) \_ (_ ) \ ) _/ \ /\_/ \)/ \/ <//| |\\> _| | \|_/ Swiss PGDay 2016 24.06.2016 - HSR Rapperswil Switzerland http://www.pgday.ch (14 rows) > > Karsten > -- > GPG key ID E4071346 @ eu.pool.sks-keyservers.net > E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346 > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general
Вложения
Re: Ascii Elephant for text based protocols - Final function proposal
От
"Charles Clavadetscher"
Дата:
Hello again > -----Original Message----- > From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Charles > Clavadetscher > Sent: Dienstag, 17. Mai 2016 14:50 > To: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Ascii Elephant for text based protocols - Final function proposal > > Hello all > > > -----Original Message----- > > From: pgsql-general-owner@postgresql.org > > [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Karsten > > Hilbert > > Sent: Dienstag, 17. Mai 2016 09:23 > > To: pgsql-general@postgresql.org > > Subject: Re: [GENERAL] Ascii Elephant for text based protocols - Final > > > > On Tue, May 17, 2016 at 06:58:14AM +0200, Charles Clavadetscher wrote: > > > > > A question to the naming. I find pg_logo() also a good name, but is > > > the prefix pg_* not reserved for system functions? Of course I could > > > use the name I want, but was wondering if there is a policy or a > > > best practice in this area. > > > > pg_logo would only be suitable if it got blessing from "higher up". > > Well. This question will be addressed when the body of the function is complete. Now I have a proposal which is in > the attachment. In my function there was a problem with casting of values to real instead of numeric to compute the number of spaces requiredon the right side of a string to be centered. In some specific string lengths the rounding was not correct. Sorry. This should now be ok. In the attachment the corrected version. Bye Charles