Add two new values for the destroy-unattached option to destroy sessions
[tmux.git] / utf8-combined.c
blob05958d47c08f3e98012c125b686ebc5fb2409657
1 /* $OpenBSD$ */
3 /*
4 * Copyright (c) 2023 Nicholas Marriott <nicholas.marriott@gmail.com>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <wchar.h>
25 #include "tmux.h"
27 static const wchar_t utf8_modifier_table[] = {
28 0x1F1E6,
29 0x1F1E7,
30 0x1F1E8,
31 0x1F1E9,
32 0x1F1EA,
33 0x1F1EB,
34 0x1F1EC,
35 0x1F1ED,
36 0x1F1EE,
37 0x1F1EF,
38 0x1F1F0,
39 0x1F1F1,
40 0x1F1F2,
41 0x1F1F3,
42 0x1F1F4,
43 0x1F1F5,
44 0x1F1F6,
45 0x1F1F7,
46 0x1F1F8,
47 0x1F1F9,
48 0x1F1FA,
49 0x1F1FB,
50 0x1F1FC,
51 0x1F1FD,
52 0x1F1FE,
53 0x1F1FF,
54 0x1F3FB,
55 0x1F3FC,
56 0x1F3FD,
57 0x1F3FE,
58 0x1F3FF
61 /* Has this got a zero width joiner at the end? */
62 int
63 utf8_has_zwj(const struct utf8_data *ud)
65 if (ud->size < 3)
66 return (0);
67 return (memcmp(ud->data + ud->size - 3, "\342\200\215", 3) == 0);
70 /* Is this a zero width joiner? */
71 int
72 utf8_is_zwj(const struct utf8_data *ud)
74 if (ud->size != 3)
75 return (0);
76 return (memcmp(ud->data, "\342\200\215", 3) == 0);
79 /* Is this a variation selector? */
80 int
81 utf8_is_vs(const struct utf8_data *ud)
83 if (ud->size != 3)
84 return (0);
85 return (memcmp(ud->data, "\357\270\217", 3) == 0);
88 /* Is this in the modifier table? */
89 int
90 utf8_is_modifier(const struct utf8_data *ud)
92 wchar_t wc;
94 if (utf8_towc(ud, &wc) != UTF8_DONE)
95 return (0);
96 if (!utf8_in_table(wc, utf8_modifier_table,
97 nitems(utf8_modifier_table)))
98 return (0);
99 return (1);