From ceee69f905ef59de46da692e4db7b4cd28c95929 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 3 Feb 2022 21:50:31 -0500 Subject: Add C-z s to set spoiler text --- catgirl.1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'catgirl.1') diff --git a/catgirl.1 b/catgirl.1 index 89e982e..7b9af11 100644 --- a/catgirl.1 +++ b/catgirl.1 @@ -1,4 +1,4 @@ -.Dd July 20, 2021 +.Dd February 3, 2022 .Dt CATGIRL 1 .Os . @@ -723,6 +723,8 @@ Reset formatting. Manually toggle paste mode. .It Ic C-z r Toggle reverse color. +.It Ic C-z s +Set spoiler text (black on black). .It Ic C-z u Toggle underline. .El -- cgit 1.4.1 From 8dec54801c210ecbd833e517fb7b1cbeabc3cf1f Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 3 Feb 2022 22:10:54 -0500 Subject: Add M-s to (temporarily) reveal spoiler text --- catgirl.1 | 2 ++ ui.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'catgirl.1') diff --git a/catgirl.1 b/catgirl.1 index 7b9af11..34b9718 100644 --- a/catgirl.1 +++ b/catgirl.1 @@ -699,6 +699,8 @@ Insert a blank line in the window. Scroll to next highlight. .It Ic M-p Scroll to previous highlight. +.It Ic M-s +Reveal spoiler text. .It Ic M-t Toggle timestamps. .It Ic M-u diff --git a/ui.c b/ui.c index 32aaf2b..369ed75 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); @@ -1088,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) { @@ -1113,6 +1121,10 @@ void uiRead(void) { } style = false; literal = false; + if (spr) { + spoilerReveal = false; + mainUpdate(); + } } inputUpdate(); } -- cgit 1.4.1