commit 963c680c7051d662f760a610687bb45acdbb632e from: Omar Polo date: Mon Jul 05 16:11:28 2021 UTC add support for hidden lines; push-button now toggle pre blocks commit - 5b0108187c5b7b5466f2e8b5c7172e7b9aa3e44d commit + 963c680c7051d662f760a610687bb45acdbb632e blob - f771635b4b7f4874bd933a22b8def62f6558801c blob + ba855645329bd01fe12bd6e919fb067429cabd90 --- ChangeLog +++ ChangeLog @@ -1,3 +1,7 @@ +2021-07-05 Omar Polo + + * cmd.c (cmd_push_button): push-button: toggle prefermatted blocks if invoked with the point on the header + 2021-06-26 Omar Polo * cmd.c (cmd_inc_fill_column): add inc-fill-column and dec-fill-column blob - 1394ab8c02d1eb924df52d129cbdd44d20a854bc blob + 62a6b39eb871aaab770af1a265fc98c10f68512b --- cmd.c +++ cmd.c @@ -29,19 +29,24 @@ forward_line(struct buffer *buffer, int n) if (buffer->current_line == NULL) return 0; + vl = buffer->current_line; did = 0; while (n != 0) { if (n > 0) { - vl = TAILQ_NEXT(buffer->current_line, vlines); + vl = TAILQ_NEXT(vl, vlines); if (vl == NULL) return did; + if (vl->parent->flags & L_HIDDEN) + continue; buffer->current_line = vl; n--; } else { - vl = TAILQ_PREV(buffer->current_line, vhead, vlines); + vl = TAILQ_PREV(vl, vhead, vlines); if (vl == NULL) return did; + if (vl->parent->flags & L_HIDDEN) + continue; if (buffer->current_line == buffer->top_line) buffer->top_line = vl; buffer->current_line = vl; @@ -190,12 +195,24 @@ void cmd_push_button(struct buffer *buffer) { struct vline *vl; + struct line *l; vl = buffer->current_line; - if (vl->parent->type != LINE_LINK) - return; - - load_url_in_tab(current_tab(), vl->parent->alt); + switch (vl->parent->type) { + case LINE_LINK: + load_url_in_tab(current_tab(), vl->parent->alt); + break; + case LINE_PRE_START: + l = TAILQ_NEXT(vl->parent, lines); + for (; l != NULL; l = TAILQ_NEXT(l, lines)) { + if (l->type == LINE_PRE_END) + break; + l->flags ^= L_HIDDEN; + } + break; + default: + break; + } } void blob - d0aa00a41fe1b7d1c3f698c0aa612c1497938598 blob + a0dbf4f90b84429cbab4831b9dcc486a410fdcaa --- telescope.h +++ telescope.h @@ -122,6 +122,12 @@ enum line_type { LINE_PRE_CONTENT, LINE_PRE_END, }; + +/* for lines: mark as hidden */ +#define L_HIDDEN 1 + +/* for vlines: mark as continuation */ +#define L_CONTINUATION 2 struct line { enum line_type type; blob - 06a3922d220a391b8a27c9aae0e6dc6d3c015505 blob + ccedaa8e62420b77214b4475aff8f6ef22da0464 --- ui.c +++ ui.c @@ -809,6 +809,9 @@ again: l = 0; onscreen = 0; for (vl = buffer->top_line; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) { + if (vl->parent->flags & L_HIDDEN) + continue; + wmove(win, l, 0); print_vline(x_offset, width, win, vl); @@ -827,6 +830,8 @@ again: for (; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) { if (vl == buffer->current_line) break; + if (vl->parent->flags & L_HIDDEN) + continue; buffer->line_off++; buffer->top_line = TAILQ_NEXT(buffer->top_line, vlines); } blob - 74bf37b2eb0117d7607d19ce9df11484d5537817 blob + 491455e3491608b7d1d462e7d1e2c099df0944e7 --- wrap.c +++ wrap.c @@ -131,7 +131,7 @@ wrap_text(struct buffer *buffer, const char *prfx, str : utf8_next_cp((char*)lastsep); if (!push_line(buffer, l, start, end - start, flags)) return 0; - flags = 1; + flags = L_CONTINUATION; start = end; cur = prfxwidth + utf8_swidth_between(start, lastchar); } else if (strchr(separators, *line) != NULL) {