Add C-z s to set spoiler text

master
June McEnroe 2022-02-03 21:50:31 -05:00
parent 605f889ab5
commit ceee69f905
2 changed files with 16 additions and 11 deletions

View File

@ -1,4 +1,4 @@
.Dd July 20, 2021 .Dd February 3, 2022
.Dt CATGIRL 1 .Dt CATGIRL 1
.Os .Os
. .
@ -723,6 +723,8 @@ Reset formatting.
Manually toggle paste mode. Manually toggle paste mode.
.It Ic C-z r .It Ic C-z r
Toggle reverse color. Toggle reverse color.
.It Ic C-z s
Set spoiler text (black on black).
.It Ic C-z u .It Ic C-z u
Toggle underline. Toggle underline.
.El .El

23
ui.c
View File

@ -1041,6 +1041,7 @@ static void keyCtrl(wchar_t ch) {
static void keyStyle(wchar_t ch) { static void keyStyle(wchar_t ch) {
uint id = windows.ptrs[windows.show]->id; uint id = windows.ptrs[windows.show]->id;
if (iswcntrl(ch)) ch = towlower(ch ^ L'@'); if (iswcntrl(ch)) ch = towlower(ch ^ L'@');
char buf[8] = {0};
enum Color color = Default; enum Color color = Default;
switch (ch) { switch (ch) {
break; case L'A': color = Gray; break; case L'A': color = Gray;
@ -1055,19 +1056,21 @@ static void keyStyle(wchar_t ch) {
break; case L'R': color = Red; break; case L'R': color = Red;
break; case L'W': color = White; break; case L'W': color = White;
break; case L'Y': color = Yellow; break; case L'Y': color = Yellow;
break; case L'b': edit(id, EditInsert, B); break; case L'b': buf[0] = B;
break; case L'c': edit(id, EditInsert, C); break; case L'c': buf[0] = C;
break; case L'i': edit(id, EditInsert, I); break; case L'i': buf[0] = I;
break; case L'o': edit(id, EditInsert, O); break; case L'o': buf[0] = O;
break; case L'r': edit(id, EditInsert, R); break; case L'r': buf[0] = R;
break; case L'u': edit(id, EditInsert, U); break; case L's': {
snprintf(buf, sizeof(buf), "%c%02d,%02d", C, Black, Black);
}
break; case L'u': buf[0] = U;
} }
if (color != Default) { if (color != Default) {
char buf[4];
snprintf(buf, sizeof(buf), "%c%02d", C, color); 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);
} }
} }