diff --git a/docs/changelog.rst b/docs/changelog.rst index 438c86bfd..f76dcd473 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -115,11 +115,11 @@ Detailed list of changes line (:iss:`8464`) - Fix a regression in 0.40.1 that caused copying to clipboard via OSC 52 from - applications that dont specify a destination in the escape code not working + applications that don't specify a destination in the escape code not working (:iss:`8459`) - Wayland: Fix a regression in the previous release that caused crashes on - compositors that dont support the xdg-toplevel-icon protocol and the user has + compositors that don't support the xdg-toplevel-icon protocol and the user has set a custom kitty icon (:iss:`8471`) 0.40.1 [2025-03-18] diff --git a/kitty/char-props.h b/kitty/char-props.h index 095d7668d..b333dd0d2 100644 --- a/kitty/char-props.h +++ b/kitty/char-props.h @@ -9,6 +9,30 @@ #include "data-types.h" +// CharPropsDeclaration +// Uses 23 bits +typedef union CharProps { + struct { + uint8_t shifted_width : 3; + uint8_t is_extended_pictographic : 1; + uint8_t grapheme_break : 4; + uint8_t indic_conjunct_break : 2; + uint8_t category : 5; + uint8_t is_emoji : 1; + uint8_t is_emoji_presentation_base : 1; + uint8_t is_invalid : 1; + uint8_t is_non_rendered : 1; + uint8_t is_symbol : 1; + uint8_t is_combining_char : 1; + uint8_t is_word_char : 1; + uint8_t is_punctuation : 1; + }; + uint32_t val; +} CharProps; +static_assert(sizeof(CharProps) == sizeof(uint32_t), "Fix the ordering of CharProps"); +// EndCharPropsDeclaration + + // UCBDeclaration typedef enum UnicodeCategory { UC_Cn, @@ -46,29 +70,6 @@ typedef enum UnicodeCategory { // EndUCBDeclaration -// CharPropsDeclaration -// Uses 23 bits -typedef union CharProps { - struct { - uint8_t shifted_width : 3; - uint8_t is_extended_pictographic : 1; - uint8_t grapheme_break : 4; - uint8_t indic_conjunct_break : 2; - uint8_t category : 5; - uint8_t is_emoji : 1; - uint8_t is_emoji_presentation_base : 1; - uint8_t is_invalid : 1; - uint8_t is_non_rendered : 1; - uint8_t is_symbol : 1; - uint8_t is_combining_char : 1; - uint8_t is_word_char : 1; - uint8_t is_punctuation : 1; - }; - uint32_t val; -} CharProps; -static_assert(sizeof(CharProps) == sizeof(uint32_t), "Fix the ordering of CharProps"); -// EndCharPropsDeclaration - typedef struct GraphemeSegmentationState { int last_char_prop; diff --git a/kitty/data-types.c b/kitty/data-types.c index 8b792bd11..d3713bf47 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -638,9 +638,9 @@ py_char_props_for(PyObject *self UNUSED, PyObject *ch) { char_type c = PyUnicode_READ_CHAR(ch, 0); CharProps cp = char_props_for(c); #define B(x) #x, cp.x ? Py_True : Py_False - return Py_BuildValue("{ si sO sB sB ss }", + return Py_BuildValue("{si sO sB sB ss sO sO}", "width", wcwidth_std(cp), B(is_extended_pictographic), "grapheme_break", cp.grapheme_break, - "indic_conjunct_break", cp.indic_conjunct_break, "category", char_category(cp) + "indic_conjunct_break", cp.indic_conjunct_break, "category", char_category(cp), B(is_emoji), B(is_emoji_presentation_base) ); #undef B } diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index 88700f3cc..1279da5c2 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -637,8 +637,8 @@ class TestDataTypes(BaseTest): self.ae(expected, actual, f'Failed for text: {q!r}') def test_split_into_graphemes(self): + self.assertEqual(char_props_for('\ue000')['category'], 'Co') for i, test in enumerate(json.loads(read_kitty_resource('GraphemeBreakTest.json', __name__.rpartition('.')[0]))): expected = test['data'] actual = split_into_graphemes(''.join(expected)) self.ae(expected, actual, f'Test #{i} failed: {test["comment"]}') - self.assertEqual(char_props_for('\ue000')['category'], 'Co')