mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 17:27:39 +02:00
Use the new multi-stage unicode table for wcwidth
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#include "wcwidth-std.h"
|
||||
#include "char-props.h"
|
||||
#include "wcswidth.h"
|
||||
#include "unicode-data.h"
|
||||
|
||||
@@ -19,6 +19,11 @@ is_flag_pair(char_type a, char_type b) {
|
||||
return is_flag_codepoint(a) && is_flag_codepoint(b);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_emoji_presentation_base(char_type ch) {
|
||||
return char_props_for(ch).is_emoji_presentation_base == 1;
|
||||
}
|
||||
|
||||
int
|
||||
wcswidth_step(WCSState *state, const char_type ch) {
|
||||
int ans = 0;
|
||||
@@ -59,7 +64,7 @@ wcswidth_step(WCSState *state, const char_type ch) {
|
||||
|
||||
default: {
|
||||
if (is_flag_codepoint(ch)) state->parser_state = FLAG_PAIR_STARTED;
|
||||
int w = wcwidth_std(ch);
|
||||
int w = wcwidth_std(char_props_for(ch));
|
||||
switch(w) {
|
||||
case -1:
|
||||
case 0:
|
||||
@@ -142,8 +147,3 @@ wcswidth_std(PyObject UNUSED *self, PyObject *str) {
|
||||
}
|
||||
return PyLong_FromSize_t(ans);
|
||||
}
|
||||
|
||||
PyObject*
|
||||
unicode_database_version(PyObject *self UNUSED, PyObject *args UNUSED) {
|
||||
return Py_BuildValue("iii", UNICODE_MAJOR_VERSION, UNICODE_MINOR_VERSION, UNICODE_PATCH_VERSION);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user