💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Vgmi › files › e2eae60aa2335115c00711b40af47… captured on 2023-12-28 at 15:44:32. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Go Back

0 /*

1 * ISC License

2 * Copyright (c) 2023 RMF <rawmonk@firemail.cc>

3 */

4 #include <stdlib.h>

5 #include <stdint.h>

6 #include "macro.h"

7 #include "wcwidth.h"

8 #include "termbox.h"

9 #define PAGE_INTERNAL

10 #include "page.h"

11 #include "request.h"

12 #define PARSER_INTERNAL

13 #include "parser.h"

14

15 int parse_plain(int in, size_t length, int width, int out) {

16

17 size_t i, cells;

18 struct termwriter termwriter = {0};

19

20 if (width < 10) width = 10;

21

22 termwriter.width = width - OFFSETX;

23 termwriter.fd = out;

24 termwriter.pos = 0;

25 cells = 0;

26

27 for (i = 0; i < length;) {

28 uint32_t ch;

29 struct page_cell cell = {0};

30

31 readnext(in, &ch, &i);

32 if (ch == '\n') {

33 cell.special = PAGE_NEWLINE;

34 } else {

35 cell.codepoint = ch;

36 cell.width = mk_wcwidth(ch);

37 cell.color = TB_DEFAULT;

38 }

39 cells++;

40 writecell(&termwriter, cell, i);

41 }

42

43 {

44 struct page_cell cell = {0};

45 cell.special = PAGE_EOF;

46 writecell(&termwriter, cell, i);

47 }

48 return 0;

49 }

50