This source file includes following definitions.
- u32_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 "uniwidth.h"
32
33 int
34 u32_width_linebreaks (const uint32_t *s, size_t n,
35 int width, int start_column, int at_end_columns,
36 const char *o, const char *encoding,
37 char *p)
38 {
39 const uint32_t *s_end;
40 char *last_p;
41 int last_column;
42 int piece_width;
43
44 u32_possible_linebreaks (s, n, encoding, p);
45
46 s_end = s + n;
47 last_p = NULL;
48 last_column = start_column;
49 piece_width = 0;
50 while (s < s_end)
51 {
52 ucs4_t uc = *s;
53
54
55 if (o != NULL && *o != UC_BREAK_UNDEFINED)
56 *p = *o;
57
58 if (*p == UC_BREAK_POSSIBLE || *p == UC_BREAK_MANDATORY)
59 {
60
61 if (last_p != NULL && last_column + piece_width > width)
62 {
63
64 *last_p = UC_BREAK_POSSIBLE;
65 last_column = 0;
66 }
67 }
68
69 if (*p == UC_BREAK_MANDATORY)
70 {
71
72
73 last_p = NULL;
74 last_column = 0;
75 piece_width = 0;
76 }
77 else
78 {
79
80 int w;
81
82 if (*p == UC_BREAK_POSSIBLE)
83 {
84
85 last_p = p;
86 last_column += piece_width;
87 piece_width = 0;
88
89
90 }
91
92 *p = UC_BREAK_PROHIBITED;
93
94 w = uc_width (uc, encoding);
95 if (w >= 0)
96 piece_width += w;
97 }
98
99 s++;
100 p++;
101 if (o != NULL)
102 o++;
103 }
104
105
106 if (last_p != NULL && last_column + piece_width + at_end_columns > width)
107 {
108
109 *last_p = UC_BREAK_POSSIBLE;
110 last_column = 0;
111 }
112
113 return last_column + piece_width;
114 }