term: turn ‘box-drawings’ array into three dynamically allocated arrays

The box_drawings array is now quite large, and uses up ~4K
when *empty*.

This patch splits it up into three separate, dynamically allocated
arrays; one for the traditional box+line drawing and block elements
glyphs, one for braille, and one for the legacy computing symbols.

When we need to render a glyph, the *entire* array (that it belongs
to) is allocated.

I.e this is one step closer to a dynamic glyph cache (like the one
fcft uses), but doesn’t go all the way.

This is especially nice for people with
‘box-drawings-uses-font-glyphs=yes’; for them, the custom glyphs now
uses 3*8 bytes (for the three array pointers), instead of 4K.
This commit is contained in:
Daniel Eklöf 2021-09-14 09:50:49 +02:00
parent ac2091f107
commit 37b15adcd8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 87 additions and 42 deletions

View file

@ -333,13 +333,26 @@ struct terminal {
int16_t font_y_ofs;
enum fcft_subpixel font_subpixel;
/*
* 0-159: U+02500+0259F
* 160-415: U+02800-028FF
* 416-555: U+1FB00-1FB8B
* 556-557: U+1FB9A-1FB9B
*/
struct fcft_glyph *box_drawing[558];
struct {
struct fcft_glyph **box_drawing;
struct fcft_glyph **braille;
struct fcft_glyph **legacy;
#define GLYPH_BOX_DRAWING_FIRST 0x2500
#define GLYPH_BOX_DRAWING_LAST 0x259F
#define GLYPH_BOX_DRAWING_COUNT \
(GLYPH_BOX_DRAWING_LAST - GLYPH_BOX_DRAWING_FIRST + 1)
#define GLYPH_BRAILLE_FIRST 0x2800
#define GLYPH_BRAILLE_LAST 0x28FF
#define GLYPH_BRAILLE_COUNT \
(GLYPH_BRAILLE_LAST - GLYPH_BRAILLE_FIRST + 1)
#define GLYPH_LEGACY_FIRST 0x1FB00
#define GLYPH_LEGACY_LAST 0x1FB9B
#define GLYPH_LEGACY_COUNT \
(GLYPH_LEGACY_LAST - GLYPH_LEGACY_FIRST + 1)
} custom_glyphs;
bool is_sending_paste_data;
ptmx_buffer_list_t ptmx_buffers;