From b0f19f9f296bed44ee2ca69b0cbff1b2b29902f0 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Fri, 20 Jan 2023 22:31:02 +0800 Subject: [PATCH] Do not be lazy, make amount of max text code points into a define --- include/notcurses/notcurses.h | 10 ++++++++-- src/lib/in.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index b148a7c88..3594b8c28 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1198,6 +1198,11 @@ typedef enum { NCTYPE_RELEASE, } ncintype_e; + +//Note: changing this also means adding kitty_cb_atxt functions in +//in.c otherwise extra codepoints won't be picked up. +#define NCINPUT_MAX_EFF_TEXT_CODEPOINTS 4 + // An input event. Cell coordinates are currently defined only for mouse // events. It is not guaranteed that we can set the modifiers for a given // ncinput. We encompass single Unicode codepoints, not complete EGCs. @@ -1214,8 +1219,9 @@ typedef struct ncinput { ncintype_e evtype; unsigned modifiers;// bitmask over NCKEY_MOD_* int ypx, xpx; // pixel offsets within cell, -1 for undefined - uint32_t eff_text[5]; // Effective utf32 representation, taking - // modifier keys into account. This can be multiple + uint32_t eff_text[NCINPUT_MAX_EFF_TEXT_CODEPOINTS]; // Effective + // utf32 representation, taking modifier + // keys into account. This can be multiple // codepoints. Array is zero-terminated. } ncinput; diff --git a/src/lib/in.c b/src/lib/in.c index 3be466db0..b6d4c79ef 100644 --- a/src/lib/in.c +++ b/src/lib/in.c @@ -832,7 +832,7 @@ kitty_kbd_txt(inputctx* ictx, int val, int mods, uint32_t *txt, int evtype){ } //note: if we don't set eff_text here, it will be set to .id later. if(txt && txt[0]!=0){ - for(int i=0 ; i<4 ; i++){ + for(int i=0 ; i