+----------------------------------------+
|Awk - Layout Functions                  |
|Written by Wim Stockman - on 06 Oct 2020|
+----------------------------------------+

Awk is by far my favourite tool: So here is some need trick:

Some Useful Awk Layout Function to line out your Plain Text
for your gopher page for instance

1.      The first function left fills with a paddingchar:

'''CodeSnippet

               function leftfill(text,width,paddingchar){
                       if(!paddingchar){paddingchar=" ";}
                       size=length(text)+1;
                       out="";
                       for(i=size;i<=width;i++){ out = out paddingchar;}
                       out = out text;
                       paddingchar=" " ;
                       print(out);
               }
'''
       Which fills up the left side of your text with a paddinchar.
       Default Paddingchar is <space>

       Usage: leftfill(Text,75,"-");
Example:
-----------------------------------------------------------------Left Fill

2.      The centertext function centers the text in your giving width

'''CodeSnippet
               function centertext(text,width,paddingchar) {
                       size=length(text);
                       out="";
                       insertpos=int((width-size)/2);
                       if(!paddingchar){paddingchar=" ";}
                       for(i=0;i<=width;i++)
                               {
                               if(i==insertpos) {out= out text; i=i+size}
                               else { out = out paddingchar; }
                               }
                       print(out);
               }
'''
       and you can add a paddingchar to fill up both left and rigt side
       Default Paddingchar is <space>

       Usage: centertex(text,width,"-")
Example:

-------------------------------Center Text--------------------------------
3.      Rightfill with a paddingchar:

'''CodeSnippet
               function rightfill(text,width,paddingchar) {
                       if(!paddingchar){paddingchar=" ";}
                       size=length(text)+1;
                       out=text;
                       for(i=size;i<=width;i++){ out = out paddingchar;}
                       paddingchar=" " ;
                       print(out);
               }
'''
       Which fills up the right side of your text with a paddinchar.
       Default Paddingchar is <space>

       Usage: rightfill(Text,75,"-");

Right Fill----------------------------------------------------------------

To Use these awk function inside your awk scripts you can copy and paste them
or save them to a file:e.g. layout_func.awk
and include them with the:
               @include layout_func.awk

To use it on the command line for example creating a cool gopher page Title
you can use it:
               awk -f layout_func.awk '{centertext($0,75,"-")}'
+--------------------------------------------------+
|Suggestions? [email protected]                |
+--------------------------------------------------+