flexablelib-speedups 3.3.0__tar.gz → 3.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/MANIFEST.in +1 -0
- {flexablelib_speedups-3.3.0/flexablelib_speedups.egg-info → flexablelib_speedups-3.4.0}/PKG-INFO +1 -1
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups/__init__.py +1 -1
- flexablelib_speedups-3.4.0/flexablelib_speedups/_ascii_table.h +342 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups/_frames.c +224 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0/flexablelib_speedups.egg-info}/PKG-INFO +1 -1
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups.egg-info/SOURCES.txt +1 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/setup.py +2 -1
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/LICENSE +0 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/README.md +0 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups/_width_tables.h +0 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups.egg-info/dependency_links.txt +0 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups.egg-info/top_level.txt +0 -0
- {flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/setup.cfg +0 -0
{flexablelib_speedups-3.3.0/flexablelib_speedups.egg-info → flexablelib_speedups-3.4.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib-speedups
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Optional C acceleration of terminal frame drawing for flexablelib (cut, pad, borders, frame diffs).
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/* Generated by tools/gen_ascii_table.py from
|
|
2
|
+
* flexablelib._frames.ASCII_FOLD. Do not edit. */
|
|
3
|
+
|
|
4
|
+
struct ascii_fold_entry { Py_UCS4 cp; char ch; };
|
|
5
|
+
|
|
6
|
+
static const struct ascii_fold_entry ascii_fold_table[] = {
|
|
7
|
+
{0x00A0, ' '},
|
|
8
|
+
{0x00A6, '|'},
|
|
9
|
+
{0x00AB, '<'},
|
|
10
|
+
{0x00AC, '-'},
|
|
11
|
+
{0x00B0, 'o'},
|
|
12
|
+
{0x00B1, '+'},
|
|
13
|
+
{0x00B7, '.'},
|
|
14
|
+
{0x00BB, '>'},
|
|
15
|
+
{0x00D7, 'x'},
|
|
16
|
+
{0x00F7, '/'},
|
|
17
|
+
{0x2010, '-'},
|
|
18
|
+
{0x2011, '-'},
|
|
19
|
+
{0x2012, '-'},
|
|
20
|
+
{0x2013, '-'},
|
|
21
|
+
{0x2014, '-'},
|
|
22
|
+
{0x2015, '-'},
|
|
23
|
+
{0x2018, '\''},
|
|
24
|
+
{0x2019, '\''},
|
|
25
|
+
{0x201A, '\''},
|
|
26
|
+
{0x201C, '"'},
|
|
27
|
+
{0x201D, '"'},
|
|
28
|
+
{0x201E, '"'},
|
|
29
|
+
{0x2022, '.'},
|
|
30
|
+
{0x2023, '>'},
|
|
31
|
+
{0x2026, '.'},
|
|
32
|
+
{0x2032, '\''},
|
|
33
|
+
{0x2033, '"'},
|
|
34
|
+
{0x2039, '<'},
|
|
35
|
+
{0x203A, '>'},
|
|
36
|
+
{0x2043, '-'},
|
|
37
|
+
{0x20AC, 'E'},
|
|
38
|
+
{0x2139, 'i'},
|
|
39
|
+
{0x2190, '<'},
|
|
40
|
+
{0x2191, '^'},
|
|
41
|
+
{0x2192, '>'},
|
|
42
|
+
{0x2193, 'v'},
|
|
43
|
+
{0x2194, '-'},
|
|
44
|
+
{0x2195, '|'},
|
|
45
|
+
{0x219E, '<'},
|
|
46
|
+
{0x21A0, '>'},
|
|
47
|
+
{0x21A4, '<'},
|
|
48
|
+
{0x21A6, '>'},
|
|
49
|
+
{0x21A9, '<'},
|
|
50
|
+
{0x21B5, '<'},
|
|
51
|
+
{0x21D0, '<'},
|
|
52
|
+
{0x21D1, '^'},
|
|
53
|
+
{0x21D2, '>'},
|
|
54
|
+
{0x21D3, 'v'},
|
|
55
|
+
{0x21D4, '-'},
|
|
56
|
+
{0x21D5, '|'},
|
|
57
|
+
{0x2205, '0'},
|
|
58
|
+
{0x2212, '-'},
|
|
59
|
+
{0x2219, '.'},
|
|
60
|
+
{0x221A, '+'},
|
|
61
|
+
{0x221E, '8'},
|
|
62
|
+
{0x223C, '~'},
|
|
63
|
+
{0x2248, '~'},
|
|
64
|
+
{0x2260, '#'},
|
|
65
|
+
{0x2264, '<'},
|
|
66
|
+
{0x2265, '>'},
|
|
67
|
+
{0x22EF, '.'},
|
|
68
|
+
{0x23CE, '<'},
|
|
69
|
+
{0x2423, '_'},
|
|
70
|
+
{0x2500, '-'},
|
|
71
|
+
{0x2501, '-'},
|
|
72
|
+
{0x2502, '|'},
|
|
73
|
+
{0x2503, '|'},
|
|
74
|
+
{0x2504, '-'},
|
|
75
|
+
{0x2505, '-'},
|
|
76
|
+
{0x2506, '|'},
|
|
77
|
+
{0x2507, '|'},
|
|
78
|
+
{0x2508, '-'},
|
|
79
|
+
{0x2509, '-'},
|
|
80
|
+
{0x250A, '|'},
|
|
81
|
+
{0x250B, '|'},
|
|
82
|
+
{0x250C, '+'},
|
|
83
|
+
{0x250D, '+'},
|
|
84
|
+
{0x250E, '+'},
|
|
85
|
+
{0x250F, '+'},
|
|
86
|
+
{0x2510, '+'},
|
|
87
|
+
{0x2511, '+'},
|
|
88
|
+
{0x2512, '+'},
|
|
89
|
+
{0x2513, '+'},
|
|
90
|
+
{0x2514, '+'},
|
|
91
|
+
{0x2515, '+'},
|
|
92
|
+
{0x2516, '+'},
|
|
93
|
+
{0x2517, '+'},
|
|
94
|
+
{0x2518, '+'},
|
|
95
|
+
{0x2519, '+'},
|
|
96
|
+
{0x251A, '+'},
|
|
97
|
+
{0x251B, '+'},
|
|
98
|
+
{0x251C, '+'},
|
|
99
|
+
{0x251D, '+'},
|
|
100
|
+
{0x251E, '+'},
|
|
101
|
+
{0x251F, '+'},
|
|
102
|
+
{0x2520, '+'},
|
|
103
|
+
{0x2521, '+'},
|
|
104
|
+
{0x2522, '+'},
|
|
105
|
+
{0x2523, '+'},
|
|
106
|
+
{0x2524, '+'},
|
|
107
|
+
{0x2525, '+'},
|
|
108
|
+
{0x2526, '+'},
|
|
109
|
+
{0x2527, '+'},
|
|
110
|
+
{0x2528, '+'},
|
|
111
|
+
{0x2529, '+'},
|
|
112
|
+
{0x252A, '+'},
|
|
113
|
+
{0x252B, '+'},
|
|
114
|
+
{0x252C, '+'},
|
|
115
|
+
{0x252D, '+'},
|
|
116
|
+
{0x252E, '+'},
|
|
117
|
+
{0x252F, '+'},
|
|
118
|
+
{0x2530, '+'},
|
|
119
|
+
{0x2531, '+'},
|
|
120
|
+
{0x2532, '+'},
|
|
121
|
+
{0x2533, '+'},
|
|
122
|
+
{0x2534, '+'},
|
|
123
|
+
{0x2535, '+'},
|
|
124
|
+
{0x2536, '+'},
|
|
125
|
+
{0x2537, '+'},
|
|
126
|
+
{0x2538, '+'},
|
|
127
|
+
{0x2539, '+'},
|
|
128
|
+
{0x253A, '+'},
|
|
129
|
+
{0x253B, '+'},
|
|
130
|
+
{0x253C, '+'},
|
|
131
|
+
{0x253D, '+'},
|
|
132
|
+
{0x253E, '+'},
|
|
133
|
+
{0x253F, '+'},
|
|
134
|
+
{0x2540, '+'},
|
|
135
|
+
{0x2541, '+'},
|
|
136
|
+
{0x2542, '+'},
|
|
137
|
+
{0x2543, '+'},
|
|
138
|
+
{0x2544, '+'},
|
|
139
|
+
{0x2545, '+'},
|
|
140
|
+
{0x2546, '+'},
|
|
141
|
+
{0x2547, '+'},
|
|
142
|
+
{0x2548, '+'},
|
|
143
|
+
{0x2549, '+'},
|
|
144
|
+
{0x254A, '+'},
|
|
145
|
+
{0x254B, '+'},
|
|
146
|
+
{0x254C, '-'},
|
|
147
|
+
{0x254D, '-'},
|
|
148
|
+
{0x254E, '|'},
|
|
149
|
+
{0x254F, '|'},
|
|
150
|
+
{0x2550, '='},
|
|
151
|
+
{0x2551, '|'},
|
|
152
|
+
{0x2552, '+'},
|
|
153
|
+
{0x2553, '+'},
|
|
154
|
+
{0x2554, '+'},
|
|
155
|
+
{0x2555, '+'},
|
|
156
|
+
{0x2556, '+'},
|
|
157
|
+
{0x2557, '+'},
|
|
158
|
+
{0x2558, '+'},
|
|
159
|
+
{0x2559, '+'},
|
|
160
|
+
{0x255A, '+'},
|
|
161
|
+
{0x255B, '+'},
|
|
162
|
+
{0x255C, '+'},
|
|
163
|
+
{0x255D, '+'},
|
|
164
|
+
{0x255E, '+'},
|
|
165
|
+
{0x255F, '+'},
|
|
166
|
+
{0x2560, '+'},
|
|
167
|
+
{0x2561, '+'},
|
|
168
|
+
{0x2562, '+'},
|
|
169
|
+
{0x2563, '+'},
|
|
170
|
+
{0x2564, '+'},
|
|
171
|
+
{0x2565, '+'},
|
|
172
|
+
{0x2566, '+'},
|
|
173
|
+
{0x2567, '+'},
|
|
174
|
+
{0x2568, '+'},
|
|
175
|
+
{0x2569, '+'},
|
|
176
|
+
{0x256A, '+'},
|
|
177
|
+
{0x256B, '+'},
|
|
178
|
+
{0x256C, '+'},
|
|
179
|
+
{0x256D, '+'},
|
|
180
|
+
{0x256E, '+'},
|
|
181
|
+
{0x256F, '+'},
|
|
182
|
+
{0x2570, '+'},
|
|
183
|
+
{0x2571, '/'},
|
|
184
|
+
{0x2572, '\\'},
|
|
185
|
+
{0x2573, 'X'},
|
|
186
|
+
{0x2574, '-'},
|
|
187
|
+
{0x2575, '|'},
|
|
188
|
+
{0x2576, '-'},
|
|
189
|
+
{0x2577, '|'},
|
|
190
|
+
{0x2578, '-'},
|
|
191
|
+
{0x2579, '|'},
|
|
192
|
+
{0x257A, '-'},
|
|
193
|
+
{0x257B, '|'},
|
|
194
|
+
{0x257C, '-'},
|
|
195
|
+
{0x257D, '|'},
|
|
196
|
+
{0x257E, '-'},
|
|
197
|
+
{0x257F, '|'},
|
|
198
|
+
{0x2580, '-'},
|
|
199
|
+
{0x2581, '_'},
|
|
200
|
+
{0x2582, '_'},
|
|
201
|
+
{0x2583, '.'},
|
|
202
|
+
{0x2584, '-'},
|
|
203
|
+
{0x2585, '='},
|
|
204
|
+
{0x2586, '='},
|
|
205
|
+
{0x2587, '#'},
|
|
206
|
+
{0x2588, '#'},
|
|
207
|
+
{0x2589, '#'},
|
|
208
|
+
{0x258A, '#'},
|
|
209
|
+
{0x258B, '='},
|
|
210
|
+
{0x258C, '='},
|
|
211
|
+
{0x258D, '-'},
|
|
212
|
+
{0x258E, '-'},
|
|
213
|
+
{0x258F, '|'},
|
|
214
|
+
{0x2590, '='},
|
|
215
|
+
{0x2591, '.'},
|
|
216
|
+
{0x2592, ':'},
|
|
217
|
+
{0x2593, '#'},
|
|
218
|
+
{0x2594, '-'},
|
|
219
|
+
{0x2595, '|'},
|
|
220
|
+
{0x2596, '#'},
|
|
221
|
+
{0x2597, '#'},
|
|
222
|
+
{0x2598, '#'},
|
|
223
|
+
{0x2599, '#'},
|
|
224
|
+
{0x259A, '#'},
|
|
225
|
+
{0x259B, '#'},
|
|
226
|
+
{0x259C, '#'},
|
|
227
|
+
{0x259D, '#'},
|
|
228
|
+
{0x259E, '#'},
|
|
229
|
+
{0x259F, '#'},
|
|
230
|
+
{0x25A0, '#'},
|
|
231
|
+
{0x25A1, 'o'},
|
|
232
|
+
{0x25A2, '*'},
|
|
233
|
+
{0x25A3, '*'},
|
|
234
|
+
{0x25A4, '*'},
|
|
235
|
+
{0x25A5, '*'},
|
|
236
|
+
{0x25A6, '*'},
|
|
237
|
+
{0x25A7, '*'},
|
|
238
|
+
{0x25A8, '*'},
|
|
239
|
+
{0x25A9, '*'},
|
|
240
|
+
{0x25AA, '#'},
|
|
241
|
+
{0x25AB, 'o'},
|
|
242
|
+
{0x25AC, '#'},
|
|
243
|
+
{0x25AD, 'o'},
|
|
244
|
+
{0x25AE, '#'},
|
|
245
|
+
{0x25AF, 'o'},
|
|
246
|
+
{0x25B0, '*'},
|
|
247
|
+
{0x25B1, '*'},
|
|
248
|
+
{0x25B2, '^'},
|
|
249
|
+
{0x25B3, '^'},
|
|
250
|
+
{0x25B4, '^'},
|
|
251
|
+
{0x25B5, '^'},
|
|
252
|
+
{0x25B6, '>'},
|
|
253
|
+
{0x25B7, '>'},
|
|
254
|
+
{0x25B8, '>'},
|
|
255
|
+
{0x25B9, '>'},
|
|
256
|
+
{0x25BA, '>'},
|
|
257
|
+
{0x25BB, '>'},
|
|
258
|
+
{0x25BC, 'v'},
|
|
259
|
+
{0x25BD, 'v'},
|
|
260
|
+
{0x25BE, 'v'},
|
|
261
|
+
{0x25BF, 'v'},
|
|
262
|
+
{0x25C0, '<'},
|
|
263
|
+
{0x25C1, '<'},
|
|
264
|
+
{0x25C2, '<'},
|
|
265
|
+
{0x25C3, '<'},
|
|
266
|
+
{0x25C4, '<'},
|
|
267
|
+
{0x25C5, '<'},
|
|
268
|
+
{0x25C6, '*'},
|
|
269
|
+
{0x25C7, '*'},
|
|
270
|
+
{0x25C8, '*'},
|
|
271
|
+
{0x25C9, '*'},
|
|
272
|
+
{0x25CA, '*'},
|
|
273
|
+
{0x25CB, 'o'},
|
|
274
|
+
{0x25CC, 'o'},
|
|
275
|
+
{0x25CD, '*'},
|
|
276
|
+
{0x25CE, '*'},
|
|
277
|
+
{0x25CF, '*'},
|
|
278
|
+
{0x25D0, 'o'},
|
|
279
|
+
{0x25D1, 'o'},
|
|
280
|
+
{0x25D2, 'o'},
|
|
281
|
+
{0x25D3, 'o'},
|
|
282
|
+
{0x25D4, '*'},
|
|
283
|
+
{0x25D5, '*'},
|
|
284
|
+
{0x25D6, '*'},
|
|
285
|
+
{0x25D7, '*'},
|
|
286
|
+
{0x25D8, '*'},
|
|
287
|
+
{0x25D9, '*'},
|
|
288
|
+
{0x25DA, '*'},
|
|
289
|
+
{0x25DB, '*'},
|
|
290
|
+
{0x25DC, '*'},
|
|
291
|
+
{0x25DD, '*'},
|
|
292
|
+
{0x25DE, '*'},
|
|
293
|
+
{0x25DF, '*'},
|
|
294
|
+
{0x25E0, '*'},
|
|
295
|
+
{0x25E1, '*'},
|
|
296
|
+
{0x25E2, '*'},
|
|
297
|
+
{0x25E3, '*'},
|
|
298
|
+
{0x25E4, '*'},
|
|
299
|
+
{0x25E5, '*'},
|
|
300
|
+
{0x25E6, 'o'},
|
|
301
|
+
{0x25E7, '*'},
|
|
302
|
+
{0x25E8, '*'},
|
|
303
|
+
{0x25E9, '*'},
|
|
304
|
+
{0x25EA, '*'},
|
|
305
|
+
{0x25EB, '*'},
|
|
306
|
+
{0x25EC, '*'},
|
|
307
|
+
{0x25ED, '*'},
|
|
308
|
+
{0x25EE, '*'},
|
|
309
|
+
{0x25EF, 'o'},
|
|
310
|
+
{0x25F0, '*'},
|
|
311
|
+
{0x25F1, '*'},
|
|
312
|
+
{0x25F2, '*'},
|
|
313
|
+
{0x25F3, '*'},
|
|
314
|
+
{0x25F4, '*'},
|
|
315
|
+
{0x25F5, '*'},
|
|
316
|
+
{0x25F6, '*'},
|
|
317
|
+
{0x25F7, '*'},
|
|
318
|
+
{0x25F8, '*'},
|
|
319
|
+
{0x25F9, '*'},
|
|
320
|
+
{0x25FA, '*'},
|
|
321
|
+
{0x25FB, '*'},
|
|
322
|
+
{0x25FC, '*'},
|
|
323
|
+
{0x25FF, '*'},
|
|
324
|
+
{0x2605, '*'},
|
|
325
|
+
{0x2606, '*'},
|
|
326
|
+
{0x2610, '.'},
|
|
327
|
+
{0x2611, 'x'},
|
|
328
|
+
{0x2612, 'x'},
|
|
329
|
+
{0x26A0, '!'},
|
|
330
|
+
{0x2713, '+'},
|
|
331
|
+
{0x2714, '+'},
|
|
332
|
+
{0x2716, 'x'},
|
|
333
|
+
{0x2717, 'x'},
|
|
334
|
+
{0x2718, 'x'},
|
|
335
|
+
{0x2726, '*'},
|
|
336
|
+
{0x2727, '*'},
|
|
337
|
+
{0x27F5, '<'},
|
|
338
|
+
{0x27F6, '>'},
|
|
339
|
+
{0x2B51, '*'},
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
#define ASCII_FOLD_COUNT 333
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include <string.h>
|
|
20
20
|
|
|
21
21
|
#include "_width_tables.h"
|
|
22
|
+
#include "_ascii_table.h"
|
|
22
23
|
|
|
23
24
|
#define ESC 0x1B
|
|
24
25
|
#define BEL 0x07
|
|
@@ -682,6 +683,226 @@ fail:
|
|
|
682
683
|
return NULL;
|
|
683
684
|
}
|
|
684
685
|
|
|
686
|
+
/* ------------------------------------------------------------------------
|
|
687
|
+
* ascii_fold(text) -> str
|
|
688
|
+
*
|
|
689
|
+
* Every symbol of flexablelib._frames.ASCII_FOLD replaced by its one-column
|
|
690
|
+
* ASCII stand-in; braille cells become ' ', '.', ':' or '#' by dot count.
|
|
691
|
+
*/
|
|
692
|
+
static int
|
|
693
|
+
fold_cp(Py_UCS4 cp)
|
|
694
|
+
{
|
|
695
|
+
size_t low = 0, high = ASCII_FOLD_COUNT;
|
|
696
|
+
if (cp < 0x80) return 0;
|
|
697
|
+
if (cp >= 0x2800 && cp <= 0x28FF) {
|
|
698
|
+
unsigned bits = (unsigned)(cp - 0x2800);
|
|
699
|
+
int dots = 0;
|
|
700
|
+
while (bits) { dots += (int)(bits & 1u); bits >>= 1; }
|
|
701
|
+
return dots == 0 ? ' ' : dots <= 2 ? '.' : dots <= 5 ? ':' : '#';
|
|
702
|
+
}
|
|
703
|
+
while (low < high) {
|
|
704
|
+
size_t mid = low + (high - low) / 2;
|
|
705
|
+
if (cp < ascii_fold_table[mid].cp) high = mid;
|
|
706
|
+
else if (cp > ascii_fold_table[mid].cp) low = mid + 1;
|
|
707
|
+
else return (unsigned char)ascii_fold_table[mid].ch;
|
|
708
|
+
}
|
|
709
|
+
return 0;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
static PyObject *
|
|
713
|
+
py_ascii_fold(PyObject *m, PyObject *text)
|
|
714
|
+
{
|
|
715
|
+
int kind, okind;
|
|
716
|
+
const void *data;
|
|
717
|
+
void *odata;
|
|
718
|
+
Py_ssize_t length, i;
|
|
719
|
+
Py_UCS4 maxchar = 0;
|
|
720
|
+
int changed = 0;
|
|
721
|
+
PyObject *out;
|
|
722
|
+
(void)m;
|
|
723
|
+
if (unpack(text, &kind, &data, &length) < 0) return NULL;
|
|
724
|
+
if (PyUnicode_IS_ASCII(text)) return Py_NewRef(text);
|
|
725
|
+
for (i = 0; i < length; i++) {
|
|
726
|
+
Py_UCS4 cp = PyUnicode_READ(kind, data, i);
|
|
727
|
+
int c = fold_cp(cp);
|
|
728
|
+
if (c) { changed = 1; cp = (Py_UCS4)c; }
|
|
729
|
+
if (cp > maxchar) maxchar = cp;
|
|
730
|
+
}
|
|
731
|
+
if (!changed) return Py_NewRef(text);
|
|
732
|
+
out = PyUnicode_New(length, maxchar);
|
|
733
|
+
if (!out) return NULL;
|
|
734
|
+
okind = PyUnicode_KIND(out);
|
|
735
|
+
odata = PyUnicode_DATA(out);
|
|
736
|
+
for (i = 0; i < length; i++) {
|
|
737
|
+
Py_UCS4 cp = PyUnicode_READ(kind, data, i);
|
|
738
|
+
int c = fold_cp(cp);
|
|
739
|
+
PyUnicode_WRITE(okind, odata, i, c ? (Py_UCS4)c : cp);
|
|
740
|
+
}
|
|
741
|
+
return out;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/* ------------------------------------------------------------------------
|
|
745
|
+
* extract_marks(lines) -> (clean_lines, regions)
|
|
746
|
+
*
|
|
747
|
+
* Removes the zero-width hit-region marks (ESC ] 8970 ; id BEL opens,
|
|
748
|
+
* ESC ] 8970 ; BEL closes) and reports (id, row, x0, x1, depth) per span.
|
|
749
|
+
*/
|
|
750
|
+
static Py_ssize_t
|
|
751
|
+
measure_range(int kind, const void *data, Py_ssize_t start, Py_ssize_t end)
|
|
752
|
+
{
|
|
753
|
+
Py_ssize_t total = 0, pos = start;
|
|
754
|
+
int prev = 0;
|
|
755
|
+
while (pos < end) {
|
|
756
|
+
Py_UCS4 cp = PyUnicode_READ(kind, data, pos);
|
|
757
|
+
int w;
|
|
758
|
+
if (cp == ESC) {
|
|
759
|
+
Py_ssize_t skip = seq_len(kind, data, end, pos);
|
|
760
|
+
if (skip > 0) { pos += skip; continue; }
|
|
761
|
+
}
|
|
762
|
+
if (cp == VS16) {
|
|
763
|
+
if (prev == 1) { total += 1; prev = 2; }
|
|
764
|
+
pos++;
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
w = cp_width(cp);
|
|
768
|
+
total += w;
|
|
769
|
+
prev = w;
|
|
770
|
+
pos++;
|
|
771
|
+
}
|
|
772
|
+
return total;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
static int
|
|
776
|
+
is_mark(int kind, const void *data, Py_ssize_t length, Py_ssize_t pos)
|
|
777
|
+
{
|
|
778
|
+
static const char tag[] = "\x1b]8970;";
|
|
779
|
+
Py_ssize_t k;
|
|
780
|
+
if (pos + 7 > length) return 0;
|
|
781
|
+
for (k = 0; k < 7; k++)
|
|
782
|
+
if (PyUnicode_READ(kind, data, pos + k) != (Py_UCS4)(unsigned char)tag[k])
|
|
783
|
+
return 0;
|
|
784
|
+
return 1;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
#define MARK_DEPTH 64
|
|
788
|
+
|
|
789
|
+
static int
|
|
790
|
+
add_region(PyObject *regions, long ident, Py_ssize_t row, Py_ssize_t x0,
|
|
791
|
+
Py_ssize_t x1, Py_ssize_t depth)
|
|
792
|
+
{
|
|
793
|
+
PyObject *t = Py_BuildValue("(lnnnn)", ident, row, x0, x1, depth);
|
|
794
|
+
int rc;
|
|
795
|
+
if (!t) return -1;
|
|
796
|
+
rc = PyList_Append(regions, t);
|
|
797
|
+
Py_DECREF(t);
|
|
798
|
+
return rc;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
static PyObject *
|
|
802
|
+
py_extract_marks(PyObject *m, PyObject *arg)
|
|
803
|
+
{
|
|
804
|
+
PyObject *seq, *out = NULL, *regions = NULL, *result = NULL;
|
|
805
|
+
Py_ssize_t n, row;
|
|
806
|
+
long ids[MARK_DEPTH];
|
|
807
|
+
Py_ssize_t starts[MARK_DEPTH];
|
|
808
|
+
(void)m;
|
|
809
|
+
seq = PySequence_Fast(arg, "lines must be a sequence of str");
|
|
810
|
+
if (!seq) return NULL;
|
|
811
|
+
n = PySequence_Fast_GET_SIZE(seq);
|
|
812
|
+
out = PyList_New(n);
|
|
813
|
+
regions = PyList_New(0);
|
|
814
|
+
if (!out || !regions) goto done;
|
|
815
|
+
for (row = 0; row < n; row++) {
|
|
816
|
+
PyObject *line = PySequence_Fast_GET_ITEM(seq, row);
|
|
817
|
+
PyObject *parts = NULL, *joined, *empty;
|
|
818
|
+
int kind;
|
|
819
|
+
const void *data;
|
|
820
|
+
Py_ssize_t length, pos = 0, k, col = 0, depth = 0, overflow = 0;
|
|
821
|
+
int found = 0;
|
|
822
|
+
if (unpack(line, &kind, &data, &length) < 0) goto done;
|
|
823
|
+
for (k = 0; k < length; k++) {
|
|
824
|
+
if (PyUnicode_READ(kind, data, k) == ESC &&
|
|
825
|
+
is_mark(kind, data, length, k)) { found = 1; break; }
|
|
826
|
+
}
|
|
827
|
+
if (!found) {
|
|
828
|
+
PyList_SET_ITEM(out, row, Py_NewRef(line));
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
parts = PyList_New(0);
|
|
832
|
+
if (!parts) goto done;
|
|
833
|
+
for (;;) {
|
|
834
|
+
Py_ssize_t mk = -1, end = -1, q;
|
|
835
|
+
PyObject *seg;
|
|
836
|
+
for (k = pos; k < length; k++) {
|
|
837
|
+
if (PyUnicode_READ(kind, data, k) == ESC &&
|
|
838
|
+
is_mark(kind, data, length, k)) { mk = k; break; }
|
|
839
|
+
}
|
|
840
|
+
q = mk < 0 ? length : mk;
|
|
841
|
+
seg = PyUnicode_Substring(line, pos, q);
|
|
842
|
+
if (!seg || PyList_Append(parts, seg) < 0) {
|
|
843
|
+
Py_XDECREF(seg); Py_DECREF(parts); goto done;
|
|
844
|
+
}
|
|
845
|
+
Py_DECREF(seg);
|
|
846
|
+
col += measure_range(kind, data, pos, q);
|
|
847
|
+
if (mk < 0) break;
|
|
848
|
+
for (k = mk; k < length; k++) {
|
|
849
|
+
if (PyUnicode_READ(kind, data, k) == BEL) { end = k; break; }
|
|
850
|
+
}
|
|
851
|
+
if (end < 0) break;
|
|
852
|
+
{
|
|
853
|
+
Py_ssize_t a = mk + 7, len = end - a;
|
|
854
|
+
int digits = len > 0 && len <= 9;
|
|
855
|
+
long ident = 0;
|
|
856
|
+
for (k = a; digits && k < end; k++) {
|
|
857
|
+
Py_UCS4 c = PyUnicode_READ(kind, data, k);
|
|
858
|
+
if (c < '0' || c > '9') digits = 0;
|
|
859
|
+
else ident = ident * 10 + (long)(c - '0');
|
|
860
|
+
}
|
|
861
|
+
if (digits) {
|
|
862
|
+
if (depth < MARK_DEPTH) {
|
|
863
|
+
ids[depth] = ident;
|
|
864
|
+
starts[depth] = col;
|
|
865
|
+
depth++;
|
|
866
|
+
} else {
|
|
867
|
+
overflow++;
|
|
868
|
+
}
|
|
869
|
+
} else if (len == 0) {
|
|
870
|
+
if (overflow) {
|
|
871
|
+
overflow--;
|
|
872
|
+
} else if (depth > 0) {
|
|
873
|
+
depth--;
|
|
874
|
+
if (add_region(regions, ids[depth], row, starts[depth],
|
|
875
|
+
col, depth) < 0) {
|
|
876
|
+
Py_DECREF(parts); goto done;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
pos = end + 1;
|
|
882
|
+
}
|
|
883
|
+
while (depth > 0) {
|
|
884
|
+
depth--;
|
|
885
|
+
if (add_region(regions, ids[depth], row, starts[depth], col,
|
|
886
|
+
depth) < 0) {
|
|
887
|
+
Py_DECREF(parts); goto done;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
empty = PyUnicode_New(0, 0);
|
|
891
|
+
if (!empty) { Py_DECREF(parts); goto done; }
|
|
892
|
+
joined = PyUnicode_Join(empty, parts);
|
|
893
|
+
Py_DECREF(empty);
|
|
894
|
+
Py_DECREF(parts);
|
|
895
|
+
if (!joined) goto done;
|
|
896
|
+
PyList_SET_ITEM(out, row, joined);
|
|
897
|
+
}
|
|
898
|
+
result = PyTuple_Pack(2, out, regions);
|
|
899
|
+
done:
|
|
900
|
+
Py_XDECREF(out);
|
|
901
|
+
Py_XDECREF(regions);
|
|
902
|
+
Py_DECREF(seq);
|
|
903
|
+
return result;
|
|
904
|
+
}
|
|
905
|
+
|
|
685
906
|
static PyMethodDef methods[] = {
|
|
686
907
|
{"visible_width", py_visible_width, METH_O, "Visible terminal columns of a string."},
|
|
687
908
|
{"strip_ansi", py_strip_ansi, METH_O, "The string without ANSI escapes."},
|
|
@@ -695,6 +916,9 @@ static PyMethodDef methods[] = {
|
|
|
695
916
|
"border_grid(width, height, horiz, vert, glyphs) -> list of str"},
|
|
696
917
|
{"changed_lines", py_changed_lines, METH_VARARGS, "changed_lines(old, new)"},
|
|
697
918
|
{"render_diff", py_render_diff, METH_VARARGS, "render_diff(old, new) -> str"},
|
|
919
|
+
{"ascii_fold", py_ascii_fold, METH_O, "ascii_fold(text) -> str"},
|
|
920
|
+
{"extract_marks", py_extract_marks, METH_O,
|
|
921
|
+
"extract_marks(lines) -> (clean_lines, regions)"},
|
|
698
922
|
{NULL, NULL, 0, NULL}
|
|
699
923
|
};
|
|
700
924
|
|
{flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0/flexablelib_speedups.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib-speedups
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Optional C acceleration of terminal frame drawing for flexablelib (cut, pad, borders, frame diffs).
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -30,7 +30,8 @@ setup(
|
|
|
30
30
|
packages=['flexablelib_speedups'],
|
|
31
31
|
ext_modules=[Extension('flexablelib_speedups._frames',
|
|
32
32
|
sources=['flexablelib_speedups/_frames.c'],
|
|
33
|
-
depends=['flexablelib_speedups/_width_tables.h'
|
|
33
|
+
depends=['flexablelib_speedups/_width_tables.h',
|
|
34
|
+
'flexablelib_speedups/_ascii_table.h'],
|
|
34
35
|
# No compiler: the install still succeeds and
|
|
35
36
|
# flexablelib keeps its pure-Python frame code.
|
|
36
37
|
optional=True)],
|
|
File without changes
|
|
File without changes
|
{flexablelib_speedups-3.3.0 → flexablelib_speedups-3.4.0}/flexablelib_speedups/_width_tables.h
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|