-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexrich.c
More file actions
53 lines (41 loc) · 1.44 KB
/
Copy pathexrich.c
File metadata and controls
53 lines (41 loc) · 1.44 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: MIT
#define AMP_BUF_SIZE 1024 // Let's use the integrated buffer for convenience.
#include "../../amp.h"
#include <stdio.h>
int main(int, char **) {
struct amp_type amp;
if (amp_init(&, 40, 1, nullptr, 0) > sizeof(amp.buffer)) {
static const char message[] = "amp_init: not enough memory provided\n";
write(2, message, strlen(message));
return EXIT_FAILURE;
}
constexpr size_t rows = (
sizeof(amp_inline_style_table) / sizeof(amp_inline_style_table[0])
);
char buf[64];
for (size_t i = 0, n = 0; i < rows; ++i) {
auto const row = amp_inline_style_table[i];
if (row.glyph == nullptr || row.glyph[0] == '\0') {
continue;
}
ssize_t written = amp_snprint_rich_textf(
&, 0, 0, 0, 0, AMP_ALIGN_LEFT, buf, sizeof(buf),
" {{%s → {%ssample{X (%s)", row.glyph, row.glyph, row.name
);
if (written < (ssize_t) sizeof(buf) && written >= 0) {
amp_to_ans(&, nullptr, 0); // Write to stdout.
amp_clear(&);
if (n++ % 2) {
amp_stdout("\n", 1);
}
}
}
amp_stdout("\n", 1);
amp_print_rich_text(
&, 0, 0, 0, 0, AMP_ALIGN_LEFT,
"{rA{mN{lS{gI {bc{no{al{to{fr{ps {ya{or{we {sf{cu{xn{*!"
);
amp_to_ans(&, nullptr, 0); // Write to stdout.
amp_stdout("\n", 1);
return EXIT_SUCCESS;
}