sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-boxdraw-legacycomputing-0.9.3.diff (7199B)


      1 From bff436a7aed5509ad9f03c19933e0bc870f742f7 Mon Sep 17 00:00:00 2001
      2 From: =?UTF-8?q?Milo=C5=A1=20Stojanovi=C4=87?= <mc.cm.mail@gmail.com>
      3 Date: Wed, 19 Aug 2026 01:35:39 +0200
      4 Subject: [PATCH] [st][patch][boxdraw-legacycomputing] add Legacy Computing symbols (sextants, eighths)
      5 
      6 Extends the Boxdraw patch with Unicode Symbols for Legacy Computing
      7 (U+1FB00-U+1FB8B): sextants, eighth-column/row stripes, and mixed-axis
      8 edge stripes.
      9 ---
     10  boxdraw.c      | 46 +++++++++++++++++++++++++++++++
     11  boxdraw_data.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
     12  2 files changed, 120 insertions(+)
     13 
     14 diff --git a/boxdraw.c b/boxdraw.c
     15 index 28a92d0..dbae2d1 100644
     16 --- a/boxdraw.c
     17 +++ b/boxdraw.c
     18 @@ -31,6 +31,8 @@ isboxdraw(Rune u)
     19  {
     20  	Rune block = u & ~0xff;
     21  	return (boxdraw && block == 0x2500 && boxdata[(uint8_t)u]) ||
     22 +	       (boxdraw && block == 0x1fb00 && (uint8_t)u < LEN(boxdata_1fb) &&
     23 +	        boxdata_1fb[(uint8_t)u]) ||
     24  	       (boxdraw_braille && block == 0x2800);
     25  }
     26  
     27 @@ -40,6 +42,8 @@ boxdrawindex(const Glyph *g)
     28  {
     29  	if (boxdraw_braille && (g->u & ~0xff) == 0x2800)
     30  		return BRL | (uint8_t)g->u;
     31 +	if ((g->u & ~0xff) == 0x1fb00)
     32 +		return (uint8_t)g->u < LEN(boxdata_1fb) ? boxdata_1fb[(uint8_t)g->u] : 0;
     33  	if (boxdraw_bold && (g->mode & ATTR_BOLD))
     34  		return BDB | boxdata[(uint8_t)g->u];
     35  	return boxdata[(uint8_t)g->u];
     36 @@ -107,6 +111,48 @@ drawbox(int x, int y, int w, int h, XftColor *fg, XftColor *bg, ushort bd)
     37  		XftDrawRect(xd, &xfc, x, y, w, h);
     38  		XftColorFree(xdpy, xvis, xcmap, &xfc);
     39  
     40 +	} else if (cat == BSX) {
     41 +		/* sextants: 2 columns x 3 rows, data bit0..5 = positions 1..6 */
     42 +		int cb[3] = { 0, DIV(w, 2), w };
     43 +		int rb[4] = { 0, DIV(h, 3), DIV(2 * h, 3), h };
     44 +		int i;
     45 +		for (i = 0; i < 6; i++) {
     46 +			int col = i % 2, row = i / 2;
     47 +			if (bd & (1 << i))
     48 +				XftDrawRect(xd, fg, x + cb[col], y + rb[row],
     49 +				            cb[col + 1] - cb[col], rb[row + 1] - rb[row]);
     50 +		}
     51 +
     52 +	} else if (cat == BVS || cat == BHS) {
     53 +		/* single (non-cumulative) eighth-column or eighth-row stripes */
     54 +		int eb[9], i;
     55 +		for (i = 0; i <= 8; i++)
     56 +			eb[i] = DIV(i * (cat == BVS ? w : h), 8);
     57 +		for (i = 0; i < 8; i++) {
     58 +			if (!((uint8_t)bd & (1 << i)))
     59 +				continue;
     60 +			if (cat == BVS)
     61 +				XftDrawRect(xd, fg, x + eb[i], y, eb[i + 1] - eb[i], h);
     62 +			else
     63 +				XftDrawRect(xd, fg, x, y + eb[i], w, eb[i + 1] - eb[i]);
     64 +		}
     65 +
     66 +	} else if (cat == BES) {
     67 +		/* mixed-axis eighth edge stripes: left/right column, top/bottom row */
     68 +		int cb[9], rb[9], i;
     69 +		for (i = 0; i <= 8; i++) {
     70 +			cb[i] = DIV(i * w, 8);
     71 +			rb[i] = DIV(i * h, 8);
     72 +		}
     73 +		if (bd & SL)
     74 +			XftDrawRect(xd, fg, x, y, cb[1], h);
     75 +		if (bd & SR)
     76 +			XftDrawRect(xd, fg, x + cb[7], y, w - cb[7], h);
     77 +		if (bd & ST)
     78 +			XftDrawRect(xd, fg, x, y, w, rb[1]);
     79 +		if (bd & SB)
     80 +			XftDrawRect(xd, fg, x, y + rb[7], w, h - rb[7]);
     81 +
     82  	} else if (cat == BRL) {
     83  		/* braille, each data bit corresponds to one dot at 2x4 grid */
     84  		int w1 = DIV(w, 2);
     85 diff --git a/boxdraw_data.h b/boxdraw_data.h
     86 index 31a6f24..4f3ebaf 100644
     87 --- a/boxdraw_data.h
     88 +++ b/boxdraw_data.h
     89 @@ -26,6 +26,10 @@
     90  #define BBR (4<<10)  /* Box Block Right X/8 */
     91  #define BBQ (5<<10)  /* Box Block Quadrants */
     92  #define BRL (6<<10)  /* Box Braille (data is lower byte of U28XX) */
     93 +#define BSX (7<<10)  /* Box Sextant (6-bit mask) */
     94 +#define BVS (8<<10)  /* Box Vertical eighth-column Stripe (8-bit mask) */
     95 +#define BHS (9<<10)  /* Box Horizontal eighth-row Stripe (8-bit mask) */
     96 +#define BES (10<<10) /* Box Edge Stripes (SL/SR/ST/SB mask) */
     97  
     98  #define BBS (1<<14)  /* Box Block Shades */
     99  #define BDB (1<<15)  /* Box Draw is Bold */
    100 @@ -59,6 +63,12 @@
    101  #define BL (1<<2)
    102  #define BR (1<<3)
    103  
    104 +/* (BES) Eighth Edge Stripes Top/Bottom x Left/Right */
    105 +#define SL (1<<0)
    106 +#define SR (1<<1)
    107 +#define ST (1<<2)
    108 +#define SB (1<<3)
    109 +
    110  /* Data for U+2500 - U+259F except dashes/diagonals */
    111  static const unsigned short boxdata[256] = {
    112  	/* light lines */
    113 @@ -212,3 +222,67 @@ static const unsigned short boxdata[256] = {
    114  	/* U+2504 - U+250B, U+254C - U+254F: unsupported (dashes) */
    115  	/* U+2571 - U+2573: unsupported (diagonals) */
    116  };
    117 +
    118 +/* Data for U+1FB00 - U+1FB8B (Legacy Computing: sextants, eighths) */
    119 +/* Wedges, shades, diagonals and pictographic symbols (U+1FB3C+, U+1FB8C+)
    120 + * are unsupported - left to font fallback. */
    121 +static const unsigned short boxdata_1fb[0x8c] = {
    122 +	/* sextants: data is a 6-bit mask, bit0..5 = positions 1..6            */
    123 +	/* (1=UL 2=UR 3=ML 4=MR 5=LL 6=LR, per the Unicode SEXTANT-N name)     */
    124 +	[0x00] = BSX + 0x01, [0x01] = BSX + 0x02, [0x02] = BSX + 0x03,
    125 +	[0x03] = BSX + 0x04, [0x04] = BSX + 0x05, [0x05] = BSX + 0x06,
    126 +	[0x06] = BSX + 0x07, [0x07] = BSX + 0x08, [0x08] = BSX + 0x09,
    127 +	[0x09] = BSX + 0x0a, [0x0a] = BSX + 0x0b, [0x0b] = BSX + 0x0c,
    128 +	[0x0c] = BSX + 0x0d, [0x0d] = BSX + 0x0e, [0x0e] = BSX + 0x0f,
    129 +	[0x0f] = BSX + 0x10, [0x10] = BSX + 0x11, [0x11] = BSX + 0x12,
    130 +	[0x12] = BSX + 0x13, [0x13] = BSX + 0x14, [0x14] = BSX + 0x16,
    131 +	[0x15] = BSX + 0x17, [0x16] = BSX + 0x18, [0x17] = BSX + 0x19,
    132 +	[0x18] = BSX + 0x1a, [0x19] = BSX + 0x1b, [0x1a] = BSX + 0x1c,
    133 +	[0x1b] = BSX + 0x1d, [0x1c] = BSX + 0x1e, [0x1d] = BSX + 0x1f,
    134 +	[0x1e] = BSX + 0x20, [0x1f] = BSX + 0x21, [0x20] = BSX + 0x22,
    135 +	[0x21] = BSX + 0x23, [0x22] = BSX + 0x24, [0x23] = BSX + 0x25,
    136 +	[0x24] = BSX + 0x26, [0x25] = BSX + 0x27, [0x26] = BSX + 0x28,
    137 +	[0x27] = BSX + 0x29, [0x28] = BSX + 0x2b, [0x29] = BSX + 0x2c,
    138 +	[0x2a] = BSX + 0x2d, [0x2b] = BSX + 0x2e, [0x2c] = BSX + 0x2f,
    139 +	[0x2d] = BSX + 0x30, [0x2e] = BSX + 0x31, [0x2f] = BSX + 0x32,
    140 +	[0x30] = BSX + 0x33, [0x31] = BSX + 0x34, [0x32] = BSX + 0x35,
    141 +	[0x33] = BSX + 0x36, [0x34] = BSX + 0x37, [0x35] = BSX + 0x38,
    142 +	[0x36] = BSX + 0x39, [0x37] = BSX + 0x3a, [0x38] = BSX + 0x3b,
    143 +	[0x39] = BSX + 0x3c, [0x3a] = BSX + 0x3d, [0x3b] = BSX + 0x3e,
    144 +
    145 +	/* single eighth-column / eighth-row stripes (not edge-cumulative) */
    146 +	[0x70] = BVS + 0x02, /* vertical eighth stripe, column 2 */
    147 +	[0x71] = BVS + 0x04, /* vertical eighth stripe, column 3 */
    148 +	[0x72] = BVS + 0x08, /* vertical eighth stripe, column 4 */
    149 +	[0x73] = BVS + 0x10, /* vertical eighth stripe, column 5 */
    150 +	[0x74] = BVS + 0x20, /* vertical eighth stripe, column 6 */
    151 +	[0x75] = BVS + 0x40, /* vertical eighth stripe, column 7 */
    152 +	[0x76] = BHS + 0x02, /* horizontal eighth stripe, row 2 */
    153 +	[0x77] = BHS + 0x04, /* horizontal eighth stripe, row 3 */
    154 +	[0x78] = BHS + 0x08, /* horizontal eighth stripe, row 4 */
    155 +	[0x79] = BHS + 0x10, /* horizontal eighth stripe, row 5 */
    156 +	[0x7a] = BHS + 0x20, /* horizontal eighth stripe, row 6 */
    157 +	[0x7b] = BHS + 0x40, /* horizontal eighth stripe, row 7 */
    158 +
    159 +	/* mixed-axis edge stripe pairs */
    160 +	[0x7c] = BES + SL + SB,
    161 +	[0x7d] = BES + SL + ST,
    162 +	[0x7e] = BES + SR + ST,
    163 +	[0x7f] = BES + SR + SB,
    164 +	[0x80] = BES + ST + SB,
    165 +
    166 +	/* horizontal eighth stripe, rows 1/3/5/8 (placed here for codepoint order) */
    167 +	[0x81] = BHS + 0x95,
    168 +
    169 +	/* cumulative eighths, filling gaps left by U+2500's halves/full-eighths */
    170 +	[0x82] = BBU + 2,
    171 +	[0x83] = BBU + 3,
    172 +	[0x84] = BBU + 5,
    173 +	[0x85] = BBU + 6,
    174 +	[0x86] = BBU + 7,
    175 +	[0x87] = BBR + 6,
    176 +	[0x88] = BBR + 5,
    177 +	[0x89] = BBR + 3,
    178 +	[0x8a] = BBR + 2,
    179 +	[0x8b] = BBR + 1,
    180 +};
    181 -- 
    182 2.55.0
    183