commit 828b14926efd83e2a4ad1557974e98d87b16e733 from: Omar Polo date: Fri Sep 24 15:59:57 2021 UTC proposal: use ^L as page separator in text/gemini commit - 798e1c954749cdd5b3042212050c8ddae75a9c52 commit + 828b14926efd83e2a4ad1557974e98d87b16e733 blob - bfe716e2534422cfd54bc88659797c8e652bc61f blob + 7a36c3ef643b5e552ca5cdcc39c2b27453be7be4 --- defaults.c +++ defaults.c @@ -52,6 +52,7 @@ struct lineprefix line_prefixes[] = { [LINE_PRE_START] = { "─── ", " " }, [LINE_PRE_CONTENT] = { "", "" }, [LINE_PRE_END] = { "─── ", "" }, + [LINE_BREAK] = { "", "" }, [LINE_PATCH] = {"", ""}, [LINE_PATCH_HDR] = {"", ""}, @@ -121,6 +122,11 @@ struct line_face line_faces[] = { .pair = PPEND, .trail_pair = PPEND_TRAIL, }, + [LINE_BREAK] = { + .prfx_pair = PB_PRFX, + .pair = PB, + .trail_pair = PB_TRAIL, + }, /* text/x-patch */ [LINE_PATCH] = { @@ -217,6 +223,7 @@ struct mapping { {"pre.start", LINE_PRE_START}, {"pre", LINE_PRE_CONTENT}, {"pre.end", LINE_PRE_END}, + {"break", LINE_BREAK}, /* text/x-patch */ {"patch", LINE_PATCH}, blob - 3677a37fdf65203a8209a0bbff32432245163cda blob + 94fd896ef22984ed7ca602e84655c00c896fe2e7 --- parser.c +++ parser.c @@ -156,7 +156,7 @@ parser_foreach_line(struct parser *p, const char *buf, /* drop every "funny" ASCII character */ for (i = 0; i < len; ) { ch = b[i]; - if ((ch >= ' ' || ch == '\n' || ch == '\t') + if ((ch >= ' ' || ch == '\n' || ch == '\t' || ch == '\f') && ch != 127) { /* del */ ++i; continue; blob - 18b733769b1ae829dc232a0a9e2258a91cec3b2b blob + d97ef8a406db8176d013dc5e6b7e1618d1859a4e --- parser_gemtext.c +++ parser_gemtext.c @@ -44,6 +44,7 @@ static int parse_quote(struct parser*, enum line_type, static int parse_pre_start(struct parser*, enum line_type, const char*, size_t); static int parse_pre_cnt(struct parser*, enum line_type, const char*, size_t); static int parse_pre_end(struct parser*, enum line_type, const char*, size_t); +static int parse_linebreak(struct parser *, enum line_type, const char *, size_t); static void search_title(struct parser*, enum line_type); typedef int (parselinefn)(struct parser*, enum line_type, const char*, size_t); @@ -59,6 +60,7 @@ static parselinefn *parsers[] = { [LINE_PRE_START] = parse_pre_start, [LINE_PRE_CONTENT] = parse_pre_cnt, [LINE_PRE_END] = parse_pre_end, + [LINE_BREAK] = parse_linebreak, }; void @@ -356,6 +358,8 @@ detect_line_type(const char *buf, size_t len, int in_p if (buf[0] == '`' && buf[1] == '`' && buf[2] == '`') return LINE_PRE_START; break; + case 0xC: /* form feed */ + return LINE_BREAK; } return LINE_TEXT; @@ -407,6 +411,12 @@ gemtext_free(struct parser *p) search_title(p, LINE_TITLE_3); return 1; +} + +static int +parse_linebreak(struct parser *p, enum line_type t, const char *buf, size_t len) +{ + return emit_line(p, t, NULL, NULL); } static void blob - ef98398b3626a915b01006ff3723470452943613 blob + c5c6b126335d09991a5ee82f85cd08cca4a2f029 --- telescope.h +++ telescope.h @@ -80,6 +80,7 @@ enum line_type { LINE_PRE_START, LINE_PRE_CONTENT, LINE_PRE_END, + LINE_BREAK, /* text/x-patch */ LINE_PATCH, blob - a622e686532715c9ae3e445390ff8fc7cdead884 blob + e075cab3a5e524546611f19eb261070470a9202f --- ui.c +++ ui.c @@ -437,6 +437,15 @@ print_vline_descr(int width, WINDOW *window, struct vl wprintw(window, "%s", vl->parent->alt); } +static inline void +print_line_break(int width, WINDOW *window) +{ + int x, y; + + getyx(window, y, x); + mvwprintw(window, y, width/2 - 4, "-*-*-"); +} + /* * Core part of the rendering. It prints a vline starting from the * current cursor position. Printing a vline consists of skipping @@ -469,9 +478,13 @@ print_vline(int off, int width, WINDOW *window, struct waddch(window, ' '); wattr_off(window, body_face.left, NULL); - wattr_on(window, f->prefix, NULL); - wprintw(window, "%s", prfx); - wattr_off(window, f->prefix, NULL); + if (vl->parent->type == LINE_BREAK) { + print_line_break(width, window); + } else { + wattr_on(window, f->prefix, NULL); + wprintw(window, "%s", prfx); + wattr_off(window, f->prefix, NULL); + } wattr_on(window, f->text, NULL); wprintw(window, "%s", text); blob - 5b6289bc91bb36beeca2eb44c323fde71555bba1 blob + 48a4d5fc3422bb38f14bfe1cd87ff03085ff5182 --- ui.h +++ ui.h @@ -71,6 +71,9 @@ enum pairs { PPEND, PPEND_PRFX, PPEND_TRAIL, + PB, + PB_PRFX, + PB_TRAIL, PPATCH, PPATCH_PRFX, blob - 6fd7a38bb0ef087bbca6a041f93fb5abbdefc022 blob + 56fea6a26b20d7263d471337f4138eb5a94f1bbf --- wrap.c +++ wrap.c @@ -267,6 +267,9 @@ wrap_page(struct buffer *buffer, int width) case LINE_PRE_END: wrap_text(buffer, prfx, l, MIN(fill_column, width)); break; + case LINE_BREAK: + push_line(buffer, l, NULL, 0, 0); + break; case LINE_PRE_CONTENT: case LINE_PATCH: case LINE_PATCH_HDR: