This source file includes following definitions.
- u16_width_linebreaks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <config.h>
27
28
29 #include "unilbrk.h"
30
31 #include "unistr.h"
32 #include "uniwidth.h"
33
34 int
35 u16_width_linebreaks (const uint16_t *s, size_t n,
36 int width, int start_column, int at_end_columns,
37 const char *o, const char *encoding,
38 char *p)
39 {
40 const uint16_t *s_end;
41 char *last_p;
42 int last_column;
43 int piece_width;
44
45 u16_possible_linebreaks (s, n, encoding, p);
46
47 s_end = s + n;
48 last_p = NULL;
49 last_column = start_column;
50 piece_width = 0;
51 while (s < s_end)
52 {
53 ucs4_t uc;
54 int count = u16_mbtouc_unsafe (&uc, s, s_end - s);
55
56
57 if (o != NULL && *o != UC_BREAK_UNDEFINED)
58 *p = *o;
59
60 if (*p == UC_BREAK_POSSIBLE || *p == UC_BREAK_MANDATORY)
61 {
62
63 if (last_p != NULL && last_column + piece_width > width)
64 {
65
66 *last_p = UC_BREAK_POSSIBLE;
67 last_column = 0;
68 }
69 }
70
71 if (*p == UC_BREAK_MANDATORY)
72 {
73
74
75 last_p = NULL;
76 last_column = 0;
77 piece_width = 0;
78 }
79 else
80 {
81
82 int w;
83
84 if (*p == UC_BREAK_POSSIBLE)
85 {
86
87 last_p = p;
88 last_column += piece_width;
89 piece_width = 0;
90
91
92 }
93
94 *p = UC_BREAK_PROHIBITED;
95
96 w = uc_width (uc, encoding);
97 if (w >= 0)
98 piece_width += w;
99 }
100
101 s += count;
102 p += count;
103 if (o != NULL)
104 o += count;
105 }
106
107
108 if (last_p != NULL && last_column + piece_width + at_end_columns > width)
109 {
110
111 *last_p = UC_BREAK_POSSIBLE;
112 last_column = 0;
113 }
114
115 return last_column + piece_width;
116 }