diff options
Diffstat (limited to '')
-rw-r--r-- | ui.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/ui.c b/ui.c index 5282407..61c0b0a 100644 --- a/ui.c +++ b/ui.c @@ -210,6 +210,7 @@ static short colorPair(short fg, short bg) { X(KeyMetaN, "\33n", NULL) \ X(KeyMetaP, "\33p", NULL) \ X(KeyMetaQ, "\33q", NULL) \ + X(KeyMetaS, "\33s", NULL) \ X(KeyMetaT, "\33t", NULL) \ X(KeyMetaU, "\33u", NULL) \ X(KeyMetaV, "\33v", NULL) \ @@ -384,7 +385,12 @@ static attr_t styleAttr(struct Style style) { return attr | colorAttr(Colors[style.fg]); } +static bool spoilerReveal; + 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]); } @@ -986,6 +992,7 @@ static void keyCode(int code) { break; case KeyMetaN: scrollHot(window, +1); break; case KeyMetaP: scrollHot(window, -1); break; case KeyMetaQ: edit(id, EditCollapse, 0); + break; case KeyMetaS: spoilerReveal ^= true; mainUpdate(); break; case KeyMetaT: toggleTime(window); break; case KeyMetaU: scrollTo(window, window->unreadHard); break; case KeyMetaV: scrollPage(window, +1); @@ -1041,6 +1048,7 @@ static void keyCtrl(wchar_t ch) { static void keyStyle(wchar_t ch) { uint id = windows.ptrs[windows.show]->id; if (iswcntrl(ch)) ch = towlower(ch ^ L'@'); + char buf[8] = {0}; enum Color color = Default; switch (ch) { break; case L'A': color = Gray; @@ -1055,19 +1063,21 @@ static void keyStyle(wchar_t ch) { break; case L'R': color = Red; break; case L'W': color = White; break; case L'Y': color = Yellow; - break; case L'b': edit(id, EditInsert, B); - break; case L'c': edit(id, EditInsert, C); - break; case L'i': edit(id, EditInsert, I); - break; case L'o': edit(id, EditInsert, O); - break; case L'r': edit(id, EditInsert, R); - break; case L'u': edit(id, EditInsert, U); + break; case L'b': buf[0] = B; + break; case L'c': buf[0] = C; + break; case L'i': buf[0] = I; + break; case L'o': buf[0] = O; + break; case L'r': buf[0] = R; + break; case L's': { + snprintf(buf, sizeof(buf), "%c%02d,%02d", C, Black, Black); + } + break; case L'u': buf[0] = U; } if (color != Default) { - char buf[4]; snprintf(buf, sizeof(buf), "%c%02d", C, color); - for (char *ch = buf; *ch; ++ch) { - edit(id, EditInsert, *ch); - } + } + for (char *ch = buf; *ch; ++ch) { + edit(id, EditInsert, *ch); } } @@ -1085,6 +1095,7 @@ void uiRead(void) { wint_t ch; static bool paste, style, literal; for (int ret; ERR != (ret = wget_wch(input, &ch));) { + bool spr = spoilerReveal; if (ret == KEY_CODE_YES && ch == KeyPasteOn) { paste = true; } else if (ret == KEY_CODE_YES && ch == KeyPasteOff) { @@ -1110,6 +1121,10 @@ void uiRead(void) { } style = false; literal = false; + if (spr) { + spoilerReveal = false; + mainUpdate(); + } } inputUpdate(); } |