banner.c

     
   1  //! @file banner.c
   2  //! @author J. Marcel van der Veer
   3  //
   4  //! @section Copyright
   5  //
   6  // This file is part of VIF - vintage FORTRAN compiler.
   7  // Copyright 2020-2024 J. Marcel van der Veer <algol68g@xs4all.nl>.
   8  //
   9  //! @section License
  10  //
  11  // This program is free software; you can redistribute it and/or modify it 
  12  // under the terms of the GNU General Public License as published by the 
  13  // Free Software Foundation; either version 3 of the License, or 
  14  // (at your option) any later version.
  15  //
  16  // This program is distributed in the hope that it will be useful, but 
  17  // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  18  // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
  19  // more details. You should have received a copy of the GNU General Public 
  20  // License along with this program. If not, see <http://www.gnu.org/licenses/>.
  21  
  22  //! @section Synopsis
  23  //!
  24  //! Banner for listing files.
  25  
  26  // Loosely based on the public domain SYSV banner source code by Brian Wallis.
  27  
  28  #include <vif.h>
  29  
  30  char *glyphs[] = {
  31    "         ***  *** ***  * *   ***** ***   *  **     ***  ",
  32    "         ***  *** ***  * *  *  *  ** *  *  *  *    ***   ",
  33    "         ***   *   * ********  *   *** *    **      *   ",
  34    "          *            * *   *****    *    ***     *    ",
  35    "                     *******   *  *  * ****   * *       ",
  36    "         ***           * *  *  *  * *  * **    *        ",
  37    "         ***           * *   ***** *   *** **** *       ",
  38  
  39    "   **    **                                            *",
  40    "  *        *   *   *    *                             * ",
  41    " *          *   * *     *                            *  ",
  42    " *          * ******* *****   ***   *****           *   ",
  43    " *          *   * *     *     ***           ***    *    ",
  44    "  *        *   *   *    *      *            ***   *     ",
  45    "   **    **                   *             ***  *      ",
  46  
  47    "  000     1    22222  33333 4      5555555 66666 7777777",
  48    " 0   0   11   2     23     34    4 5      6     67    7 ",
  49    "0     0 1 1         2      34    4 5      6          7  ",
  50    "0     0   1    22222  33333 4444444 55555 666666    7   ",
  51    "0     0   1   2            3     4       56     6  7    ",
  52    " 0   0    1   2      3     3     4 5     56     6  7    ",
  53    "  000   11111 2222222 33333      4  55555  66666   7    ",
  54  
  55    " 88888  99999    *     ***      *           *     ***** ",
  56    "8     89     9  * *    ***     *             *   *     *",
  57    "8     89     9   *            *     *****     *        *",
  58    " 88888  999999         ***   *                 *     ** ",
  59    "8     8      9   *     ***    *     *****     *     *   ",
  60    "8     89     9  * *     *      *             *          ",
  61    " 88888  99999    *     *        *           *       *   ",
  62  
  63    " *****    A   BBBBBB  CCCCC DDDDDD EEEEEEEFFFFFFF GGGGG ",
  64    "*     *  A A  B     BC     CD     DE      F      G     G",
  65    "* *** * A   A B     BC      D     DE      F      G      ",
  66    "* * * *A     ABBBBBB C      D     DEEEEE  FFFFF  G  GGGG",
  67    "* **** AAAAAAAB     BC      D     DE      F      G     G",
  68    "*     *A     AB     BC     CD     DE      F      G     G",
  69    " ***** A     ABBBBBB  CCCCC DDDDDD EEEEEEEF       GGGGG ",
  70  
  71    "H     H  III        JK    K L      M     MN     N OOOOO ",
  72    "H     H   I         JK   K  L      MM   MMNN    NO     O",
  73    "H     H   I         JK  K   L      M M M MN N   NO     O",
  74    "HHHHHHH   I         JKKK    L      M  M  MN  N  NO     O",
  75    "H     H   I   J     JK  K   L      M     MN   N NO     O",
  76    "H     H   I   J     JK   K  L      M     MN    NNO     O",
  77    "H     H  III   JJJJJ K    K LLLLLLLM     MN     N OOOOO ",
  78  
  79    "PPPPPP  QQQQQ RRRRRR  SSSSS TTTTTTTU     UV     VW     W",
  80    "P     PQ     QR     RS     S   T   U     UV     VW     W",
  81    "P     PQ     QR     RS         T   U     UV     VW     W",
  82    "PPPPPP Q     QRRRRRR  SSSSS    T   U     UV     VW  W  W",
  83    "P      Q   Q QR   R        S   T   U     U V   V W  W  W",
  84    "P      Q    Q R    R S     S   T   U     U  V V  W  W  W",
  85    "P       QQQQ QR     R SSSSS    T    UUUUU    V    WW WW ",
  86  
  87    "X     XY     YZZZZZZZ ***** *       *****    *          ",
  88    " X   X  Y   Y      Z  *      *          *   * *         ",
  89    "  X X    Y Y      Z   *       *         *  *   *        ",
  90    "   X      Y      Z    *        *        *               ",
  91    "  X X     Y     Z     *         *       *               ",
  92    " X   X    Y    *      *          *      *               ",
  93    "X     X   Y   ZZZZZZZ *****       * *****        *******",
  94  
  95    "  ***                                                   ",
  96    "  ***     AA   BBBBB   CCCC  DDDDD  EEEEEE FFFFFF  GGGG ",
  97    "   *     A  A  B    B C    C D    D E      F      G    G",
  98    "    *   A    A BBBBB  C      D    D EEEEE  FFFFF  G     ",
  99    "        AAAAAA B    B C      D    D E      F      G  GGG",
 100    "        A    A B    B C    C D    D E      F      G    G",
 101    "        A    A BBBBB   CCCC  DDDDD  EEEEEE F       GGGG ",
 102  
 103    "                                                        ",
 104    " H    H    I        J K    K L      M    M N    N  OOOO ",
 105    " H    H    I        J K   K  L      MM  MM NN   N O    O",
 106    " HHHHHH    I        J KKKK   L      M MM M N N  N O    O",
 107    " H    H    I        J K  K   L      M    M N  N N O    O",
 108    " H    H    I   J    J K   K  L      M    M N   NN O    O",
 109    " H    H    I    JJJJ  K    K LLLLLL M    M N    N  OOOO ",
 110  
 111    "                                                        ",
 112    " PPPPP   QQQQ  RRRRR   SSSS   TTTTT U    U V    V W    W",
 113    " P    P Q    Q R    R S         T   U    U V    V W    W",
 114    " P    P Q    Q R    R  SSSS     T   U    U V    V W    W",
 115    " PPPPP  Q  Q Q RRRRR       S    T   U    U V    V W WW W",
 116    " P      Q   Q  R   R  S    S    T   U    U  V  V  WW  WW",
 117    " P       QQQ Q R    R  SSSS     T    UUUU    VV   W    W",
 118  
 119    "                       ***     *     ***   **    * * * *",
 120    " X    X  Y   Y ZZZZZZ *        *        * *  *  * * * * ",
 121    "  X  X    Y Y      Z  *        *        *     ** * * * *",
 122    "   XX      Y      Z  **                 **        * * * ",
 123    "   XX      Y     Z    *        *        *        * * * *",
 124    "  X  X     Y    Z     *        *        *         * * * ",
 125    " X    X    Y   ZZZZZZ  ***     *     ***         * * * *"
 126  };
 127  
 128  void banner (int_4 proc, int_4 phase, char *arg)
 129  {
 130    int_4 len = strlen (arg);
 131    if (len > 12) {
 132      len = 12;
 133    }
 134    int_4 max = 0;
 135    for (int_4 cyc = 0; cyc < 2; cyc++) {
 136      char str[RECLN], lin[RECLN];
 137      for (int_4 a = 0; a < 7; a++) {
 138        for (int_4 b = 0; b < len; b++) {
 139          int_4 ind;
 140          if ((ind = (arg)[b] - ' ') < 0) {
 141            ind = 0;
 142          }
 143          for (int_4 c = 0; c < 7; c++) {
 144            lin[b * 8 + c] = glyphs[(ind / 8 * 7) + a][(ind % 8 * 7) + c];
 145          }
 146          lin[b * 8 + 7] = ' ';
 147        }
 148        for (int_4 b = len * 8 - 1; b >= 0; b--) {
 149          if (lin[b] != ' ') {
 150            break;
 151          }
 152          lin[b] = '\0';
 153        }
 154        if (cyc == 0) {
 155          if ((int_4) strlen (lin) > max) {
 156            max = strlen (lin);
 157          }
 158        } else {
 159          strcpy (str, "// ");
 160          for (int_4 k = 0; k < (LINE_WIDTH - max) / 2 - 3; k++) {
 161           bufcat (str, " ", LINE_WIDTH);
 162          }
 163         bufcat (str, lin, LINE_WIDTH);
 164         bufcat (str, "\n", LINE_WIDTH);
 165          code (proc, phase, str);
 166        }
 167      }
 168    }
 169  }
     


© 2002-2024 J.M. van der Veer (jmvdveer@xs4all.nl)