mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 14:34:52 +02:00
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:
18
kitty/emoji.h
generated
18
kitty/emoji.h
generated
@@ -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
|
||||
|
||||
@@ -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
2435
kitty/wcwidth-std.h
generated
Normal file
File diff suppressed because it is too large
Load Diff
1321
kitty/wcwidth9.h
1321
kitty/wcwidth9.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user