From: Sadrul Habib Chowdhury Date: Sun, 8 Feb 2009 00:44:54 +0000 (-0500) Subject: Allow highlighting bell/monitor windows in caption X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/76edff82efbe2f9c228e33b728d2e5f363c8509c Allow highlighting bell/monitor windows in caption The command is 'rendition'. Details in man-page. The defaults are currently set in a way to make sure that the new settings are noticeable. This changeset is preferred over either of the patches in savannah #18382, because it allows specifying the renditions for both bell and monitor windows, and is flexible enough that new renditions can be added if desired. --- diff --git a/src/ansi.c b/src/ansi.c index 2ac0f60..a38bd12 100644 --- a/src/ansi.c +++ b/src/ansi.c @@ -78,6 +78,8 @@ struct mchar mchar_null; struct mchar mchar_blank = {' ' /* , 0, 0, ... */}; struct mchar mchar_so = {' ', A_SO /* , 0, 0, ... */}; +int renditions[NUM_RENDS] = {6750175 /* =B dd */, 6750205 /* =u dd */}; + /* keep string_t and string_t_string in sync! */ static char *string_t_string[] = { diff --git a/src/comm.c b/src/comm.c index ff218a0..b9b7a24 100644 --- a/src/comm.c +++ b/src/comm.c @@ -277,6 +277,7 @@ struct comm comms[RC_LAST + 1] = #ifdef COPY_PASTE { "removebuf", ARGS_0 }, #endif + { "rendition", ARGS_23 }, { "reset", NEED_FORE|ARGS_0 }, { "resize", NEED_DISPLAY|ARGS_0|ARGS_ORMORE }, { "screen", ARGS_0|ARGS_ORMORE }, diff --git a/src/doc/screen.1 b/src/doc/screen.1 index 879dc83..53af799 100644 --- a/src/doc/screen.1 +++ b/src/doc/screen.1 @@ -2518,6 +2518,15 @@ Unlinks the screen-exchange file used by the commands \*Qwritebuf\*U and \*Qreadbuf\*U. .sp .ne 3 +.B "rendition bell" | monitor | so +.RB "\fIattr\fR " [ \fIcolor ] +.PP +Change the way +.I screen +renders the titles of windows that have monitor or bell flags set in caption or hardstatus or windowlist. See the \*QSTRING ESCAPES\*U chapter for the syntax of the modifiers. +The default for monitor is currently \*Q=u dd\*U (underline, default colors) and for bell \*Q=B dd\*U (blink, default colors). +.sp +.ne 3 .B "reset" .PP Reset the virtual terminal to its \*Qpower-on\*U values. Useful when strange diff --git a/src/extern.h b/src/extern.h index 6ca155b..e803d36 100644 --- a/src/extern.h +++ b/src/extern.h @@ -50,6 +50,7 @@ extern void Finit __P((int)); extern void MakeNewEnv __P((void)); extern char *MakeWinMsg __P((char *, struct win *, int)); extern char *MakeWinMsgEv __P((char *, struct win *, int, int, struct event *, int)); +extern int AddWinMsgRend __P((const char *, int)); extern void PutWinMsg __P((char *, int, int)); #ifdef BSDWAIT extern void WindowDied __P((struct win *, union wait, int)); diff --git a/src/help.c b/src/help.c index b0d0db0..106af6a 100644 --- a/src/help.c +++ b/src/help.c @@ -40,6 +40,7 @@ extern struct display *display, *displays; extern struct win *windows; extern char *noargs[]; extern struct mchar mchar_blank, mchar_so; +extern int renditions[]; extern unsigned char *blank; extern struct win *wtab[]; #ifdef MAPKEYS @@ -1079,6 +1080,8 @@ int isblank; int yoff, xoff = 0; struct wlistdata *wlistdata; struct win *group; + struct mchar mchar_rend = mchar_blank; + struct mchar *mchar = (struct mchar *)0; if (i == MAXWIN) return; @@ -1094,9 +1097,23 @@ int isblank; if (i != pos && isblank) while (n && str[n - 1] == ' ') n--; - LPutWinMsg(flayer, str, (i == pos || !isblank) ? flayer->l_width : n, i == pos ? &mchar_so : &mchar_blank, xoff, y + yoff); + if (i == pos) + mchar = &mchar_so; + else if (wtab[i]->w_monitor == MON_DONE && renditions[REND_MONITOR] != -1) + { + mchar = &mchar_rend; + ApplyAttrColor(renditions[REND_MONITOR], mchar); + } + else if ((wtab[i]->w_bell == BELL_DONE || wtab[i]->w_bell == BELL_FOUND) && renditions[REND_BELL] != -1) + { + mchar = &mchar_rend; + ApplyAttrColor(renditions[REND_BELL], mchar); + } + else + mchar = &mchar_blank; + LPutWinMsg(flayer, str, (i == pos || !isblank) ? flayer->l_width : n, mchar, xoff, y + yoff); if (xoff) - LPutWinMsg(flayer, "", xoff, i == pos ? &mchar_so : &mchar_blank, 0, y + yoff); + LPutWinMsg(flayer, "", xoff, mchar, 0, y + yoff); #if 0 LPutStr(flayer, str, n, i == pos ? &mchar_so : &mchar_blank, 0, y + yoff); if (i == pos || !isblank) diff --git a/src/image.h b/src/image.h index 67d0aec..5a65ebf 100644 --- a/src/image.h +++ b/src/image.h @@ -166,3 +166,11 @@ IFDWCHAR((mc)->mbcs = 0; ) \ # define cole2i(c) ((c) ^ 9) # endif #endif + +enum +{ + REND_BELL = 0, + REND_MONITOR, + NUM_RENDS +}; + diff --git a/src/process.c b/src/process.c index 929afba..690b677 100644 --- a/src/process.c +++ b/src/process.c @@ -106,6 +106,7 @@ extern char *kmapadef[]; extern char *kmapmdef[]; #endif extern struct mchar mchar_so, mchar_null; +extern int renditions[]; extern int VerboseCreate; #ifdef UTF8 extern char *screenencodings; @@ -3746,6 +3747,36 @@ int key; nattr2color = n; break; #endif + case RC_RENDITION: + i = -1; + if (strcmp(args[0], "bell") == 0) + { + i = REND_BELL; + } + else if (strcmp(args[0], "monitor") == 0) + { + i = REND_MONITOR; + } + else if (strcmp(args[0], "so") != 0) + { + Msg(0, "Invalid option '%s' for rendition", args[0]); + break; + } + + ++args; + ++argl; + + if (i != -1) + { + renditions[i] = ParseAttrColor(args[0], args[1], 1); + WindowChanged((struct win *)0, 'w'); + WindowChanged((struct win *)0, 'W'); + WindowChanged((struct win *)0, 0); + break; + } + + /* We are here, means we want to set the sorendition. */ + /* FALLTHROUGH*/ case RC_SORENDITION: i = 0; if (*args) @@ -3754,6 +3785,7 @@ int key; if (i == -1) break; ApplyAttrColor(i, &mchar_so); + WindowChanged((struct win *)0, 0); debug2("--> %x %x\n", mchar_so.attr, mchar_so.color); } if (msgok) @@ -5238,6 +5270,7 @@ int where; s = ss = buf; for (pp = ((flags & 4) && where >= 0) ? wtab + where + 1: wtab; pp < wtab + MAXWIN; pp++) { + int rend = -1; if (pp - wtab == where && ss == buf) ss = s; if ((p = *pp) == 0) @@ -5258,6 +5291,16 @@ int where; *s++ = ' '; *s++ = ' '; } + if (((flags & 4) && where >= 0 && where < p->w_number) || + (!(flags & 4) && where >= 0 && where > p->w_number)) + { + if (p->w_monitor == MON_DONE && renditions[REND_MONITOR] != -1) + rend = renditions[REND_MONITOR]; + else if ((p->w_bell == BELL_DONE || p->w_bell == BELL_FOUND) && renditions[REND_BELL] != -1) + rend = renditions[REND_BELL]; + } + if (rend != -1) + AddWinMsgRend(s, rend); sprintf(s, "%d", p->w_number); if (p->w_number == where) ss = s; @@ -5273,6 +5316,8 @@ int where; *s++ = ' '; strncpy(s, cmd, l); s += l; + if (rend != -1) + AddWinMsgRend(s, -1); } *s = 0; return ss; diff --git a/src/screen.c b/src/screen.c index 7239560..512e9f6 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2417,6 +2417,22 @@ time_t now; return bt->result; } +int +AddWinMsgRend(str, r) +const char *str; +int r; +{ + if (winmsg_numrend >= MAX_WINMSG_REND || str < winmsg_buf || + str >= winmsg_buf + MAXSTR) + return -1; + + winmsg_rend[winmsg_numrend] = r; + winmsg_rendpos[winmsg_numrend] = str - winmsg_buf; + winmsg_numrend++; + + return 0; +} + char * MakeWinMsgEv(str, win, esc, padlen, ev, rec) char *str;