Add M-s to (temporarily) reveal spoiler text

weechat-hashes
June McEnroe 2022-02-03 22:10:54 -05:00
parent ceee69f905
commit 8dec54801c
2 changed files with 14 additions and 0 deletions

View File

@ -699,6 +699,8 @@ Insert a blank line in the window.
Scroll to next highlight. Scroll to next highlight.
.It Ic M-p .It Ic M-p
Scroll to previous highlight. Scroll to previous highlight.
.It Ic M-s
Reveal spoiler text.
.It Ic M-t .It Ic M-t
Toggle timestamps. Toggle timestamps.
.It Ic M-u .It Ic M-u

12
ui.c
View File

@ -210,6 +210,7 @@ static short colorPair(short fg, short bg) {
X(KeyMetaN, "\33n", NULL) \ X(KeyMetaN, "\33n", NULL) \
X(KeyMetaP, "\33p", NULL) \ X(KeyMetaP, "\33p", NULL) \
X(KeyMetaQ, "\33q", NULL) \ X(KeyMetaQ, "\33q", NULL) \
X(KeyMetaS, "\33s", NULL) \
X(KeyMetaT, "\33t", NULL) \ X(KeyMetaT, "\33t", NULL) \
X(KeyMetaU, "\33u", NULL) \ X(KeyMetaU, "\33u", NULL) \
X(KeyMetaV, "\33v", NULL) \ X(KeyMetaV, "\33v", NULL) \
@ -384,7 +385,12 @@ static attr_t styleAttr(struct Style style) {
return attr | colorAttr(Colors[style.fg]); return attr | colorAttr(Colors[style.fg]);
} }
static bool spoilerReveal;
static short stylePair(struct Style style) { static short stylePair(struct Style style) {
if (spoilerReveal && style.fg == style.bg) {
return colorPair(Colors[Default], Colors[style.bg]);
}
return colorPair(Colors[style.fg], Colors[style.bg]); return colorPair(Colors[style.fg], Colors[style.bg]);
} }
@ -986,6 +992,7 @@ static void keyCode(int code) {
break; case KeyMetaN: scrollHot(window, +1); break; case KeyMetaN: scrollHot(window, +1);
break; case KeyMetaP: scrollHot(window, -1); break; case KeyMetaP: scrollHot(window, -1);
break; case KeyMetaQ: edit(id, EditCollapse, 0); break; case KeyMetaQ: edit(id, EditCollapse, 0);
break; case KeyMetaS: spoilerReveal ^= true; mainUpdate();
break; case KeyMetaT: toggleTime(window); break; case KeyMetaT: toggleTime(window);
break; case KeyMetaU: scrollTo(window, window->unreadHard); break; case KeyMetaU: scrollTo(window, window->unreadHard);
break; case KeyMetaV: scrollPage(window, +1); break; case KeyMetaV: scrollPage(window, +1);
@ -1088,6 +1095,7 @@ void uiRead(void) {
wint_t ch; wint_t ch;
static bool paste, style, literal; static bool paste, style, literal;
for (int ret; ERR != (ret = wget_wch(input, &ch));) { for (int ret; ERR != (ret = wget_wch(input, &ch));) {
bool spr = spoilerReveal;
if (ret == KEY_CODE_YES && ch == KeyPasteOn) { if (ret == KEY_CODE_YES && ch == KeyPasteOn) {
paste = true; paste = true;
} else if (ret == KEY_CODE_YES && ch == KeyPasteOff) { } else if (ret == KEY_CODE_YES && ch == KeyPasteOff) {
@ -1113,6 +1121,10 @@ void uiRead(void) {
} }
style = false; style = false;
literal = false; literal = false;
if (spr) {
spoilerReveal = false;
mainUpdate();
}
} }
inputUpdate(); inputUpdate();
} }