st

Suckless' st with my personal patches
git clone https://git.instinctive.eu/st.git
Log | Files | Refs | README | LICENSE

boxdraw_data.h (6212B)


      1 /*
      2  * Copyright 2018 Avi Halachmi (:avih) avihpit@yahoo.com https://github.com/avih
      3  * MIT/X Consortium License
      4  */
      5 
      6 /*
      7  * U+25XX codepoints data
      8  *
      9  * References:
     10  *   http://www.unicode.org/charts/PDF/U2500.pdf
     11  *   http://www.unicode.org/charts/PDF/U2580.pdf
     12  *
     13  * Test page:
     14  *   https://github.com/GNOME/vte/blob/master/doc/boxes.txt
     15  */
     16 
     17 /* Each shape is encoded as 16-bits. Higher bits are category, lower are data */
     18 /* Categories (mutually exclusive except BDB): */
     19 /* For convenience, BDL/BDA/BBS/BDB are 1 bit each, the rest are enums */
     20 #define BDL (1<<8)   /* Box Draw Lines (light/double/heavy) */
     21 #define BDA (1<<9)   /* Box Draw Arc (light) */
     22 
     23 #define BBD (1<<10)  /* Box Block Down (lower) X/8 */
     24 #define BBL (2<<10)  /* Box Block Left X/8 */
     25 #define BBU (3<<10)  /* Box Block Upper X/8 */
     26 #define BBR (4<<10)  /* Box Block Right X/8 */
     27 #define BBQ (5<<10)  /* Box Block Quadrants */
     28 #define BRL (6<<10)  /* Box Braille (data is lower byte of U28XX) */
     29 
     30 #define BBS (1<<14)  /* Box Block Shades */
     31 #define BDB (1<<15)  /* Box Draw is Bold */
     32 
     33 /* (BDL/BDA) Light/Double/Heavy x Left/Up/Right/Down/Horizontal/Vertical      */
     34 /* Heavy is light+double (literally drawing light+double align to form heavy) */
     35 #define LL (1<<0)
     36 #define LU (1<<1)
     37 #define LR (1<<2)
     38 #define LD (1<<3)
     39 #define LH (LL+LR)
     40 #define LV (LU+LD)
     41 
     42 #define DL (1<<4)
     43 #define DU (1<<5)
     44 #define DR (1<<6)
     45 #define DD (1<<7)
     46 #define DH (DL+DR)
     47 #define DV (DU+DD)
     48 
     49 #define HL (LL+DL)
     50 #define HU (LU+DU)
     51 #define HR (LR+DR)
     52 #define HD (LD+DD)
     53 #define HH (HL+HR)
     54 #define HV (HU+HD)
     55 
     56 /* (BBQ) Quadrants Top/Bottom x Left/Right */
     57 #define TL (1<<0)
     58 #define TR (1<<1)
     59 #define BL (1<<2)
     60 #define BR (1<<3)
     61 
     62 /* Data for U+2500 - U+259F except dashes/diagonals */
     63 static const unsigned short boxdata[256] = {
     64 	/* light lines */
     65 	[0x00] = BDL + LH,       /* light horizontal */
     66 	[0x02] = BDL + LV,       /* light vertical */
     67 	[0x0c] = BDL + LD + LR,  /* light down and right */
     68 	[0x10] = BDL + LD + LL,  /* light down and left */
     69 	[0x14] = BDL + LU + LR,  /* light up and right */
     70 	[0x18] = BDL + LU + LL,  /* light up and left */
     71 	[0x1c] = BDL + LV + LR,  /* light vertical and right */
     72 	[0x24] = BDL + LV + LL,  /* light vertical and left */
     73 	[0x2c] = BDL + LH + LD,  /* light horizontal and down */
     74 	[0x34] = BDL + LH + LU,  /* light horizontal and up */
     75 	[0x3c] = BDL + LV + LH,  /* light vertical and horizontal */
     76 	[0x74] = BDL + LL,       /* light left */
     77 	[0x75] = BDL + LU,       /* light up */
     78 	[0x76] = BDL + LR,       /* light right */
     79 	[0x77] = BDL + LD,       /* light down */
     80 
     81 	/* heavy [+light] lines */
     82 	[0x01] = BDL + HH,
     83 	[0x03] = BDL + HV,
     84 	[0x0d] = BDL + HR + LD,
     85 	[0x0e] = BDL + HD + LR,
     86 	[0x0f] = BDL + HD + HR,
     87 	[0x11] = BDL + HL + LD,
     88 	[0x12] = BDL + HD + LL,
     89 	[0x13] = BDL + HD + HL,
     90 	[0x15] = BDL + HR + LU,
     91 	[0x16] = BDL + HU + LR,
     92 	[0x17] = BDL + HU + HR,
     93 	[0x19] = BDL + HL + LU,
     94 	[0x1a] = BDL + HU + LL,
     95 	[0x1b] = BDL + HU + HL,
     96 	[0x1d] = BDL + HR + LV,
     97 	[0x1e] = BDL + HU + LD + LR,
     98 	[0x1f] = BDL + HD + LR + LU,
     99 	[0x20] = BDL + HV + LR,
    100 	[0x21] = BDL + HU + HR + LD,
    101 	[0x22] = BDL + HD + HR + LU,
    102 	[0x23] = BDL + HV + HR,
    103 	[0x25] = BDL + HL + LV,
    104 	[0x26] = BDL + HU + LD + LL,
    105 	[0x27] = BDL + HD + LU + LL,
    106 	[0x28] = BDL + HV + LL,
    107 	[0x29] = BDL + HU + HL + LD,
    108 	[0x2a] = BDL + HD + HL + LU,
    109 	[0x2b] = BDL + HV + HL,
    110 	[0x2d] = BDL + HL + LD + LR,
    111 	[0x2e] = BDL + HR + LL + LD,
    112 	[0x2f] = BDL + HH + LD,
    113 	[0x30] = BDL + HD + LH,
    114 	[0x31] = BDL + HD + HL + LR,
    115 	[0x32] = BDL + HR + HD + LL,
    116 	[0x33] = BDL + HH + HD,
    117 	[0x35] = BDL + HL + LU + LR,
    118 	[0x36] = BDL + HR + LU + LL,
    119 	[0x37] = BDL + HH + LU,
    120 	[0x38] = BDL + HU + LH,
    121 	[0x39] = BDL + HU + HL + LR,
    122 	[0x3a] = BDL + HU + HR + LL,
    123 	[0x3b] = BDL + HH + HU,
    124 	[0x3d] = BDL + HL + LV + LR,
    125 	[0x3e] = BDL + HR + LV + LL,
    126 	[0x3f] = BDL + HH + LV,
    127 	[0x40] = BDL + HU + LH + LD,
    128 	[0x41] = BDL + HD + LH + LU,
    129 	[0x42] = BDL + HV + LH,
    130 	[0x43] = BDL + HU + HL + LD + LR,
    131 	[0x44] = BDL + HU + HR + LD + LL,
    132 	[0x45] = BDL + HD + HL + LU + LR,
    133 	[0x46] = BDL + HD + HR + LU + LL,
    134 	[0x47] = BDL + HH + HU + LD,
    135 	[0x48] = BDL + HH + HD + LU,
    136 	[0x49] = BDL + HV + HL + LR,
    137 	[0x4a] = BDL + HV + HR + LL,
    138 	[0x4b] = BDL + HV + HH,
    139 	[0x78] = BDL + HL,
    140 	[0x79] = BDL + HU,
    141 	[0x7a] = BDL + HR,
    142 	[0x7b] = BDL + HD,
    143 	[0x7c] = BDL + HR + LL,
    144 	[0x7d] = BDL + HD + LU,
    145 	[0x7e] = BDL + HL + LR,
    146 	[0x7f] = BDL + HU + LD,
    147 
    148 	/* double [+light] lines */
    149 	[0x50] = BDL + DH,
    150 	[0x51] = BDL + DV,
    151 	[0x52] = BDL + DR + LD,
    152 	[0x53] = BDL + DD + LR,
    153 	[0x54] = BDL + DR + DD,
    154 	[0x55] = BDL + DL + LD,
    155 	[0x56] = BDL + DD + LL,
    156 	[0x57] = BDL + DL + DD,
    157 	[0x58] = BDL + DR + LU,
    158 	[0x59] = BDL + DU + LR,
    159 	[0x5a] = BDL + DU + DR,
    160 	[0x5b] = BDL + DL + LU,
    161 	[0x5c] = BDL + DU + LL,
    162 	[0x5d] = BDL + DL + DU,
    163 	[0x5e] = BDL + DR + LV,
    164 	[0x5f] = BDL + DV + LR,
    165 	[0x60] = BDL + DV + DR,
    166 	[0x61] = BDL + DL + LV,
    167 	[0x62] = BDL + DV + LL,
    168 	[0x63] = BDL + DV + DL,
    169 	[0x64] = BDL + DH + LD,
    170 	[0x65] = BDL + DD + LH,
    171 	[0x66] = BDL + DD + DH,
    172 	[0x67] = BDL + DH + LU,
    173 	[0x68] = BDL + DU + LH,
    174 	[0x69] = BDL + DH + DU,
    175 	[0x6a] = BDL + DH + LV,
    176 	[0x6b] = BDL + DV + LH,
    177 	[0x6c] = BDL + DH + DV,
    178 
    179 	/* (light) arcs */
    180 	[0x6d] = BDA + LD + LR,
    181 	[0x6e] = BDA + LD + LL,
    182 	[0x6f] = BDA + LU + LL,
    183 	[0x70] = BDA + LU + LR,
    184 
    185 	/* Lower (Down) X/8 block (data is 8 - X) */
    186 	[0x81] = BBD + 7, [0x82] = BBD + 6, [0x83] = BBD + 5, [0x84] = BBD + 4,
    187 	[0x85] = BBD + 3, [0x86] = BBD + 2, [0x87] = BBD + 1, [0x88] = BBD + 0,
    188 
    189 	/* Left X/8 block (data is X) */
    190 	[0x89] = BBL + 7, [0x8a] = BBL + 6, [0x8b] = BBL + 5, [0x8c] = BBL + 4,
    191 	[0x8d] = BBL + 3, [0x8e] = BBL + 2, [0x8f] = BBL + 1,
    192 
    193 	/* upper 1/2 (4/8), 1/8 block (X), right 1/2, 1/8 block (8-X) */
    194 	[0x80] = BBU + 4, [0x94] = BBU + 1,
    195 	[0x90] = BBR + 4, [0x95] = BBR + 7,
    196 
    197 	/* Quadrants */
    198 	[0x96] = BBQ + BL,
    199 	[0x97] = BBQ + BR,
    200 	[0x98] = BBQ + TL,
    201 	[0x99] = BBQ + TL + BL + BR,
    202 	[0x9a] = BBQ + TL + BR,
    203 	[0x9b] = BBQ + TL + TR + BL,
    204 	[0x9c] = BBQ + TL + TR + BR,
    205 	[0x9d] = BBQ + TR,
    206 	[0x9e] = BBQ + BL + TR,
    207 	[0x9f] = BBQ + BL + TR + BR,
    208 
    209 	/* Shades, data is an alpha value in 25% units (1/4, 1/2, 3/4) */
    210 	[0x91] = BBS + 1, [0x92] = BBS + 2, [0x93] = BBS + 3,
    211 
    212 	/* U+2504 - U+250B, U+254C - U+254F: unsupported (dashes) */
    213 	/* U+2571 - U+2573: unsupported (diagonals) */
    214 };