💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Vgmi › files › 3363051fbcccda6517b9a9169cfd9… captured on 2023-12-28 at 15:44:00. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
0 /*
1 * ISC License
2 * Copyright (c) 2023 RMF <rawmonk@firemail.cc>
3 */
4 struct page_line;
5 struct page_search;
6
7 struct rect {
8 int x;
9 int y;
10 int w;
11 int h;
12 };
13
14 struct page {
15 char title[1024];
16 struct page_line *lines;
17 struct page_search *results;
18 size_t length;
19 size_t links_count;
20 char **links;
21 int width;
22 int mime;
23 int offset;
24 unsigned int selected;
25 unsigned int occurrences;
26 int img_tried;
27 int img_w;
28 int img_h;
29 void *img;
30 };
31
32 #define TAB_SIZE 4
33 #define PARSER_CHUNK 2048 /* send reset cell every 2048 bytes */
34
35 #define PAGE_NEWLINE (uint8_t)1
36 #define PAGE_EOF (uint8_t)2
37 #define PAGE_BLANK (uint8_t)3
38 #define PAGE_RESET (uint8_t)4
39 #define BLOCK_SIZE 4096
40
41 #ifdef PAGE_INTERNAL
42 #define OFFSETX 2
43
44 struct page_cell {
45 uint32_t codepoint;
46 uint32_t link;
47 uint32_t selected;
48 uint16_t color;
49 unsigned width:4;
50 unsigned special:4;
51 };
52
53 struct page_line {
54 struct page_cell *cells;
55 size_t length;
56 };
57
58 struct page_search {
59 size_t line;
60 struct page_search *next;
61 };
62
63 struct termwriter {
64 struct page_cell cells[512]; /* maximum cells for a line */
65 size_t pos;
66 size_t sent;
67 size_t width;
68 size_t last_reset;
69 size_t last_x;
70 int fd;
71 };
72
73 int writecell(struct termwriter *termwriter, struct page_cell cell,
74 size_t pos);
75 int writenewline(struct termwriter *termwriter, size_t pos);
76 int writeto(struct termwriter *termwriter, const char *str,
77 int color, int link, size_t pos);
78 #endif
79
80 int page_display(struct page text, int from, struct rect rect, int selected);
81 int page_update(int in, int out, const char *data, size_t length,
82 struct page *page);
83 int page_free(struct page page);
84 void page_search(struct page *page, const char *search);
85 int page_selection_line(struct page page);
86