commit - 1666374cfe63987ed24167a032d2d99a05da317b
commit + f350bc73eb44b726d2cfdfe499c168fb83c91bc4
blob - 99b46defa92628536ea7bd98665fe2b7cbd877e0
blob + 06b75e8bd05fd57d642da37367663c2817bf4c2e
--- cmd.c
+++ cmd.c
message("Wrap preformatted blocks");
ui_schedule_redraw();
+}
+
+void
+cmd_toggle_styling(struct buffer *buffer)
+{
+ dont_apply_styling = !dont_apply_styling;
+
+ config_apply_style();
+
+ /* Force a reload here, rather than calling ui_schedule_redraw() so
+ * that any lines which are set as L_HIDDEN are redrawn appropriately.
+ */
+ load_url_in_tab(current_tab, hist_cur(current_tab->hist), NULL,
+ LU_MODE_NOHIST);
}
void
blob - d87f17e9ab329739684235c9be32f2c8f12db25b
blob + bb81e7198c325db75faf09ebfbca2e3a5f86d316
--- cmd.h
+++ cmd.h
CMD(cmd_toggle_downloads, "Toggle the downloads side window.");
CMD(cmd_toggle_help, "Toggle side window with help.");
CMD(cmd_toggle_pre_wrap, "Toggle the wrapping of preformatted blocks.");
+CMD(cmd_toggle_styling, "Toggle the page styling.");
CMD(cmd_unload_certificate, "Forget the certificate on this page.");
CMD(cmd_up, "Go up one level.");
CMD(cmd_use_certificate, "Use a certificate for the current page.");
blob - d7cdaf8f9c6194b852216e440cdf6d93d99d7fcc
blob + a38bc8415b1dc64af1c6a14e701604bae142a54e
--- defaults.c
+++ defaults.c
int autosave = 20;
int dont_wrap_pre = 0;
+int dont_apply_styling = 0;
int emojify_link = 1;
int enable_colors = 1;
int fill_column = 120;
[LINE_PRE_START] = { "─── ", " " },
[LINE_PRE_CONTENT] = { "", "" },
[LINE_PRE_END] = { "─── ", "" },
+
+ [LINE_PATCH] = {"", ""},
+ [LINE_PATCH_HDR] = {"", ""},
+ [LINE_PATCH_HUNK_HDR] = {"", ""},
+ [LINE_PATCH_ADD] = {"", ""},
+ [LINE_PATCH_DEL] = {"", ""},
+
+ [LINE_COMPL] = {"", ""},
+ [LINE_COMPL_CURRENT] = {"", ""},
+
+ [LINE_HELP] = {"", ""},
+
+ [LINE_DOWNLOAD] = {" Fetching ", " "},
+ [LINE_DOWNLOAD_DONE] = {" Done ", " "},
+ [LINE_DOWNLOAD_INFO] = {" ", " "},
+
+ [LINE_FRINGE] = {"~", ""},
+};
+
+struct lineprefix raw_prefixes[] = {
+ [LINE_TEXT] = { "", "" },
+ [LINE_LINK] = { "=> ", "" },
+ [LINE_TITLE_1] = { "# ", "" },
+ [LINE_TITLE_2] = { "## ", "" },
+ [LINE_TITLE_3] = { "### ", "" },
+ [LINE_ITEM] = { "* ", "" },
+ [LINE_QUOTE] = { "> ", "" },
+ [LINE_PRE_START] = { "``` ", "" },
+ [LINE_PRE_CONTENT] = { "", "" },
+ [LINE_PRE_END] = { "``` ", "" },
[LINE_PATCH] = {"", ""},
[LINE_PATCH_HDR] = {"", ""},
{
size_t i, colors, len;
struct line_face *f;
+ int old_ec = enable_colors;
colors = COLORS;
+ if (dont_apply_styling)
+ enable_colors = 0;
+
len = sizeof(line_faces)/sizeof(line_faces[0]);
for (i = 0; i < len; ++i) {
f = &line_faces[i];
f->trail = COLOR_PAIR(f->trail_pair) | f->trail_attr;
}
+ /* body */
+ tl_init_pair(colors, PBODY, body_face.fg, body_face.bg);
+ body_face.body = COLOR_PAIR(PBODY);
+
+ /* Restore color setting here -- it's only potentially disabled for
+ * the body.
+ */
+ enable_colors = old_ec;
+
/* tab line */
tl_init_pair(colors, PTL_BG, tab_face.bg_fg, tab_face.bg_bg);
tab_face.background = COLOR_PAIR(PTL_BG) | tab_face.bg_attr;
tl_init_pair(colors, PTL_CURR, tab_face.c_fg, tab_face.c_bg);
tab_face.current = COLOR_PAIR(PTL_CURR) | tab_face.c_attr;
- /* body */
- tl_init_pair(colors, PBODY, body_face.fg, body_face.bg);
- body_face.body = COLOR_PAIR(PBODY);
-
tl_init_pair(colors, PBLEFT, body_face.lfg, body_face.lbg);
body_face.left = COLOR_PAIR(PBLEFT);
blob - 4b9955c4393483c90c51626f32ed09eb2d1a34ad
blob + b860d8acb7d1d179cdbbb5ca9afaee909897795b
--- defaults.h
+++ defaults.h
extern int autosave;
extern int dont_wrap_pre;
+extern int dont_apply_styling;
extern int emojify_link;
extern int enable_colors;
extern int fill_column;
const char *prfx1;
const char *prfx2;
};
+
+extern struct lineprefix raw_prefixes[];
extern struct lineprefix line_prefixes[];
struct line_face {
blob - 8166566d9575d140ce1a8e2279a105a10b57d0dd
blob + b0d9ca3a298cb4d901692cd4e411de3f15072874
--- parser_gemtext.c
+++ parser_gemtext.c
break;
}
+ if (dont_apply_styling)
+ l->flags &= ~L_HIDDEN;
+
TAILQ_INSERT_TAIL(&p->head, l, lines);
return 1;
blob - 0ab6bdcd5603e3fd5e515711da30ba7edfbac905
blob + 1ce4ef4cf05b1bf82365486a0498dde7fe74240d
--- telescope.1
+++ telescope.1
interactive command.
.It Ic toggle-pre-wrap
Toggle the wrapping of preformatted blocks.
+.It Ic toggle-styling
+Toggle the styling of the page.
+This remains in effect until toggled again.
.It Ic up
Go up one level in the path hierarchy.
.It Ic write-buffer
blob - d7c77490d1fef81b810f1a8aec2d0729c548baf8
blob + 48370bf48558b0666a827c6e7a7a0fda37ce158e
--- ui.c
+++ ui.c
restore_curs_x(struct buffer *buffer)
{
struct vline *vl;
+ struct lineprefix *lp = line_prefixes;
const char *prfx, *text;
+
+ if (dont_apply_styling)
+ lp = raw_prefixes;
vl = buffer->current_line;
if (vl == NULL || vl->len == 0)
buffer->curs_x += utf8_swidth_between(vl->parent->line,
vl->parent->data);
else {
- prfx = line_prefixes[vl->parent->type].prfx1;
+ prfx = lp[vl->parent->type].prfx1;
buffer->curs_x += utf8_swidth(prfx);
}
}
line_prefix_and_text(struct vline *vl, char *buf, size_t len,
const char **prfx_ret, const char **text_ret, int *text_len)
{
+ struct lineprefix *lp = line_prefixes;
int type, cont;
size_t i, width;
char *space, *t;
+
+ if (dont_apply_styling)
+ lp = raw_prefixes;
if (vl->len == 0) {
*text_ret = "";
cont = vl->flags & L_CONTINUATION;
type = vl->parent->type;
if (!cont)
- *prfx_ret = line_prefixes[type].prfx1;
+ *prfx_ret = lp[type].prfx1;
else
- *prfx_ret = line_prefixes[type].prfx2;
+ *prfx_ret = lp[type].prfx2;
space = vl->parent->data;
*text_ret = vl->parent->line + vl->from;