Drop the dependency on libunistring
This commit is contained in:
parent
2ddc7e8c80
commit
5faa649452
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3,6 +3,7 @@ kitty/emoji.h linguist-generated=true
|
|||||||
kitty/keys.h linguist-generated=true
|
kitty/keys.h linguist-generated=true
|
||||||
kitty/charsets.c linguist-generated=true
|
kitty/charsets.c linguist-generated=true
|
||||||
kitty/key_encoding.py linguist-generated=true
|
kitty/key_encoding.py linguist-generated=true
|
||||||
|
kitty/unicode-data.c
|
||||||
kitty/rgb.py linguist-generated=true
|
kitty/rgb.py linguist-generated=true
|
||||||
kitty/gl-wrapper.* linguist-generated=true
|
kitty/gl-wrapper.* linguist-generated=true
|
||||||
kitty/khrplatform.h linguist-generated=true
|
kitty/khrplatform.h linguist-generated=true
|
||||||
|
|||||||
@ -36,6 +36,8 @@ version 0.7.0 [future]
|
|||||||
|
|
||||||
- Fix incorrect handling of some unicode combining marks that are not re-ordered
|
- Fix incorrect handling of some unicode combining marks that are not re-ordered
|
||||||
|
|
||||||
|
- Drop the dependency on libunistring
|
||||||
|
|
||||||
|
|
||||||
version 0.6.1 [2017-12-28]
|
version 0.6.1 [2017-12-28]
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|||||||
@ -90,7 +90,6 @@ the following dependencies are installed first.
|
|||||||
|
|
||||||
* python >= 3.5
|
* python >= 3.5
|
||||||
* harfbuzz >= 1.5.0
|
* harfbuzz >= 1.5.0
|
||||||
* libunistring
|
|
||||||
* zlib
|
* zlib
|
||||||
* libpng
|
* libpng
|
||||||
* freetype (not needed on macOS)
|
* freetype (not needed on macOS)
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cloc --exclude-list-file <(echo -e 'kitty/wcwidth-std.h\nkitty/glfw.c\nkitty/keys.h\nkitty/charsets.c\nkitty/key_encoding.py\nkitty/rgb.py\nkitty/gl.h\nkitty/gl-wrapper.h\nkitty/gl-wrapper.c\nkitty/khrplatform.h\nkitty/glfw-wrapper.h\nkitty/glfw-wrapper.c\nkitty/emoji.h') kitty
|
cloc --exclude-list-file <(echo -e 'kitty/wcwidth-std.h\nkitty/glfw.c\nkitty/keys.h\nkitty/charsets.c\nkitty/unicode-data.c\nkitty/key_encoding.py\nkitty/rgb.py\nkitty/gl.h\nkitty/gl-wrapper.h\nkitty/gl-wrapper.c\nkitty/khrplatform.h\nkitty/glfw-wrapper.h\nkitty/glfw-wrapper.c\nkitty/emoji.h') kitty
|
||||||
|
|||||||
@ -130,6 +130,7 @@ def create_header(path):
|
|||||||
p = partial(print, file=f)
|
p = partial(print, file=f)
|
||||||
p('// unicode data, built from the unicode standard on:', date.today())
|
p('// unicode data, built from the unicode standard on:', date.today())
|
||||||
p('// see gen-wcwidth.py')
|
p('// see gen-wcwidth.py')
|
||||||
|
if path.endswith('.h'):
|
||||||
p('#pragma once')
|
p('#pragma once')
|
||||||
p('#include "data-types.h"\n')
|
p('#include "data-types.h"\n')
|
||||||
p('START_ALLOW_CASE_RANGE')
|
p('START_ALLOW_CASE_RANGE')
|
||||||
@ -160,13 +161,38 @@ def gen_emoji():
|
|||||||
p('\treturn false;\n}')
|
p('\treturn false;\n}')
|
||||||
|
|
||||||
|
|
||||||
|
def category_test(name, p, classes, comment, static=False):
|
||||||
|
static = 'static inline ' if static else ''
|
||||||
|
chars = set()
|
||||||
|
for c in classes:
|
||||||
|
chars |= class_maps[c]
|
||||||
|
p(f'{static}bool\n{name}(char_type code) {{')
|
||||||
|
p(f'\t// {comment} ({len(chars)} codepoints)' + ' {{' '{')
|
||||||
|
p('\tswitch(code) {')
|
||||||
|
for spec in get_ranges(list(chars)):
|
||||||
|
write_case(spec, p)
|
||||||
|
p(f'\t\t\treturn true;')
|
||||||
|
p('\t} // }}}\n')
|
||||||
|
p('\treturn false;\n}\n')
|
||||||
|
|
||||||
|
|
||||||
|
def gen_ucd():
|
||||||
|
with create_header('kitty/unicode-data.c') as p:
|
||||||
|
p('#include "unicode-data.h"')
|
||||||
|
category_test('is_combining_char', p, {c for c in class_maps if c.startswith('M')}, 'M category (marks)')
|
||||||
|
category_test('is_ignored_char', p, 'Cc Cf Cs'.split(), 'Control characters (Cc Cf Cs)')
|
||||||
|
category_test('is_word_char', p, {c for c in class_maps if c[0] in 'LN'}, 'L and N categories')
|
||||||
|
category_test('is_CZ_category', p, {c for c in class_maps if c[0] in 'CZ'}, 'C and Z categories')
|
||||||
|
category_test('is_P_category', p, {c for c in class_maps if c[0] == 'P'}, 'P category (punctuation)')
|
||||||
|
|
||||||
|
|
||||||
def gen_wcwidth():
|
def gen_wcwidth():
|
||||||
seen = set()
|
seen = set()
|
||||||
|
|
||||||
def add(p, comment, chars_, ret):
|
def add(p, comment, chars_, ret):
|
||||||
chars = chars_ - seen
|
chars = chars_ - seen
|
||||||
seen.update(chars)
|
seen.update(chars)
|
||||||
p(f'\t\t// {comment} ({len(chars)} codepoints)' + ' {{{')
|
p(f'\t\t// {comment} ({len(chars)} codepoints)' + ' {{' '{')
|
||||||
for spec in get_ranges(list(chars)):
|
for spec in get_ranges(list(chars)):
|
||||||
write_case(spec, p)
|
write_case(spec, p)
|
||||||
p(f'\t\t\treturn {ret};')
|
p(f'\t\t\treturn {ret};')
|
||||||
@ -194,5 +220,6 @@ def gen_wcwidth():
|
|||||||
parse_ucd()
|
parse_ucd()
|
||||||
parse_emoji()
|
parse_emoji()
|
||||||
parse_eaw()
|
parse_eaw()
|
||||||
|
gen_ucd()
|
||||||
gen_wcwidth()
|
gen_wcwidth()
|
||||||
gen_emoji()
|
gen_emoji()
|
||||||
|
|||||||
2
kitty/emoji.h
generated
2
kitty/emoji.h
generated
@ -1,4 +1,4 @@
|
|||||||
// unicode data, built from the unicode standard on: 2018-01-17
|
// unicode data, built from the unicode standard on: 2018-01-18
|
||||||
// see gen-wcwidth.py
|
// see gen-wcwidth.py
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
|||||||
@ -42,9 +42,7 @@ line_text_at(char_type ch, combining_type cc) {
|
|||||||
} else {
|
} else {
|
||||||
Py_UCS4 buf[3];
|
Py_UCS4 buf[3];
|
||||||
buf[0] = ch; buf[1] = cc & CC_MASK; buf[2] = cc >> 16;
|
buf[0] = ch; buf[1] = cc & CC_MASK; buf[2] = cc >> 16;
|
||||||
Py_UCS4 normalized = normalize(ch, buf[1], buf[2]);
|
ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buf, buf[2] ? 3 : 2);
|
||||||
if (normalized) ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, &normalized, 1);
|
|
||||||
else ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buf, buf[2] ? 3 : 2);
|
|
||||||
}
|
}
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|||||||
2330
kitty/unicode-data.c
Normal file
2330
kitty/unicode-data.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,41 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "data-types.h"
|
||||||
|
|
||||||
#include <unictype.h>
|
bool is_combining_char(char_type ch);
|
||||||
#include <uninorm.h>
|
bool is_ignored_char(char_type ch);
|
||||||
|
bool is_word_char(char_type ch);
|
||||||
static inline bool
|
bool is_CZ_category(char_type);
|
||||||
is_combining_char(uint32_t ch) {
|
bool is_P_category(char_type);
|
||||||
return uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_M);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_ignored_char(uint32_t ch) {
|
|
||||||
return uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_Cc | UC_CATEGORY_MASK_Cf | UC_CATEGORY_MASK_Cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_word_char(uint32_t ch) {
|
|
||||||
return uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_L | UC_CATEGORY_MASK_N);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
is_url_char(uint32_t ch) {
|
is_url_char(uint32_t ch) {
|
||||||
return ch && !uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_C | UC_CATEGORY_MASK_Z);
|
return ch && !is_CZ_category(ch);
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
normalize(uint32_t ch, uint32_t cc1, uint32_t cc2) {
|
|
||||||
uint32_t ans = uc_composition(ch, cc1);
|
|
||||||
if (ans && cc2) ans = uc_composition(ans, cc2);
|
|
||||||
return ans;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
can_strip_from_end_of_url(uint32_t ch) {
|
can_strip_from_end_of_url(uint32_t ch) {
|
||||||
// remove trailing punctuation
|
// remove trailing punctuation
|
||||||
return (
|
return (
|
||||||
(uc_is_general_category_withtable(ch, UC_CATEGORY_MASK_P) && ch != '/') ||
|
(is_P_category(ch) && ch != '/') ||
|
||||||
ch == '>'
|
ch == '>'
|
||||||
) ? true : false;
|
) ? true : false;
|
||||||
}
|
}
|
||||||
|
|||||||
2
kitty/wcwidth-std.h
generated
2
kitty/wcwidth-std.h
generated
@ -1,4 +1,4 @@
|
|||||||
// unicode data, built from the unicode standard on: 2018-01-17
|
// unicode data, built from the unicode standard on: 2018-01-18
|
||||||
// see gen-wcwidth.py
|
// see gen-wcwidth.py
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
|||||||
4
setup.py
4
setup.py
@ -220,9 +220,7 @@ def kitty_env():
|
|||||||
pylib = get_python_flags(cflags)
|
pylib = get_python_flags(cflags)
|
||||||
gl_libs = ['-framework', 'OpenGL'] if is_macos else pkg_config('gl', '--libs')
|
gl_libs = ['-framework', 'OpenGL'] if is_macos else pkg_config('gl', '--libs')
|
||||||
libpng = pkg_config('libpng', '--libs')
|
libpng = pkg_config('libpng', '--libs')
|
||||||
ans.ldpaths += pylib + font_libs + gl_libs + libpng + [
|
ans.ldpaths += pylib + font_libs + gl_libs + libpng
|
||||||
'-lunistring'
|
|
||||||
]
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
ans.ldpaths.extend('-framework Cocoa'.split())
|
ans.ldpaths.extend('-framework Cocoa'.split())
|
||||||
if is_travis and 'SW' in os.environ:
|
if is_travis and 'SW' in os.environ:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user