Add a script to generate wcwidth as well

Generated function is more efficient than the implementation from
wcwidth9 and also makes it easy to update when the unicode standard
changes.
This commit is contained in:
Kovid Goyal
2017-12-20 16:06:58 +05:30
parent 11ee317884
commit d1282b9f55
8 changed files with 2653 additions and 1405 deletions

18
kitty/emoji.h generated
View File

@@ -1,9 +1,17 @@
// unicode data, built from the unicode standard on: 2017-12-20
// see gen-wcwidth.py
#pragma once
#include "data-types.h"
START_ALLOW_CASE_RANGE
static inline bool is_emoji(uint32_t code) {
static inline bool
is_emoji(char_type code) {
switch(code) {
case 0x2194 ... 0x2199:
return true;
case 0x21a9 ... 0x21aa:
return true;
case 0x231a ... 0x231b:
return true;
case 0x2328:
@@ -274,14 +282,16 @@ static inline bool is_emoji(uint32_t code) {
return true;
default: return false;
}
return false;
return false;
}
static inline bool is_emoji_modifier(uint32_t code) {
static inline bool
is_emoji_modifier(char_type code) {
switch(code) {
case 0x1f3fb ... 0x1f3ff:
return true;
default: return false;
}
return false;
return false;
}
END_ALLOW_CASE_RANGE

View File

@@ -18,7 +18,7 @@
#include <fcntl.h>
#include "unicode-data.h"
#include "modes.h"
#include "wcwidth9.h"
#include "wcwidth-std.h"
#include "control-codes.h"
static const ScreenModes empty_modes = {0, .mDECAWM=true, .mDECTCEM=true, .mDECARM=true};
@@ -275,8 +275,8 @@ safe_wcwidth(uint32_t ch) {
}
void
change_wcwidth(bool use9) {
wcwidth_impl = (use9) ? wcwidth9 : wcwidth;
change_wcwidth(bool use_std) {
wcwidth_impl = use_std ? wcwidth_std : wcwidth;
}

2435
kitty/wcwidth-std.h generated Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff