Render any flag pair in two cells not just known ones
This commit is contained in:
parent
6357f7b811
commit
0b9a37139e
@ -10,7 +10,7 @@ from contextlib import contextmanager
|
||||
from datetime import date
|
||||
from functools import partial
|
||||
from html.entities import html5
|
||||
from itertools import groupby, repeat
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
from typing import (
|
||||
Callable, DefaultDict, Dict, FrozenSet, Generator, Iterable, List,
|
||||
@ -266,22 +266,6 @@ def gen_emoji() -> None:
|
||||
p('\t}')
|
||||
p('\treturn false;\n}')
|
||||
|
||||
p('static inline bool is_flag_pair(char_type a, char_type b) {')
|
||||
p('static const unsigned char flag_combinations[26][26] = {')
|
||||
for i in range(26):
|
||||
q = 0x1F1E6 + i
|
||||
vals = flags.get(q, [])
|
||||
arr = list(repeat(0, 26))
|
||||
for x in vals:
|
||||
idx = x - 0x1F1E6
|
||||
arr[idx] = 1
|
||||
comma = '' if i == 0 else ','
|
||||
p(comma, '{', ', '.join(map(str, arr)), '}')
|
||||
p('};')
|
||||
p('if (a < 0x1F1E6 || b < 0x1F1E6 || a >= 0x1F1E6 + 26 || b >= 0x1F1E6 + 26) return false;')
|
||||
p('return flag_combinations[a - 0x1F1E6][b - 0x1F1E6];')
|
||||
p('};')
|
||||
|
||||
|
||||
def category_test(
|
||||
name: str,
|
||||
|
||||
32
kitty/emoji.h
generated
32
kitty/emoji.h
generated
@ -781,37 +781,5 @@ is_symbol(char_type code) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static inline bool is_flag_pair(char_type a, char_type b) {
|
||||
static const unsigned char flag_combinations[26][26] = {
|
||||
{ 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1 }
|
||||
, { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1 }
|
||||
, { 1, 0, 1, 1, 0, 1, 1, 1, 1, 0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0 }
|
||||
};
|
||||
if (a < 0x1F1E6 || b < 0x1F1E6 || a >= 0x1F1E6 + 26 || b >= 0x1F1E6 + 26) return false;
|
||||
return flag_combinations[a - 0x1F1E6][b - 0x1F1E6];
|
||||
};
|
||||
|
||||
END_ALLOW_CASE_RANGE
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include "fonts.h"
|
||||
#include "lineops.h"
|
||||
#include "screen.h"
|
||||
#include "emoji.h"
|
||||
#include <structmember.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
@ -358,6 +357,10 @@ selection_has_screen_line(Selection *s, int y) {
|
||||
return top <= y && y <= bottom;
|
||||
}
|
||||
|
||||
static inline bool is_flag_pair(char_type a, char_type b) {
|
||||
return is_flag_codepoint(a) && is_flag_codepoint(b);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
draw_second_flag_codepoint(Screen *self, char_type ch) {
|
||||
index_type xpos = 0, ypos = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user