MCPcopy Index your code
hub / github.com/NetHack/NetHack / analyze_seq

Function analyze_seq

win/tty/termcap.c:1098–1150  ·  view source on GitHub ↗

find the foreground and background colors set by nh_HI or nh_HE */

Source from the content-addressed store, hash-verified

1096#ifndef TOS
1097/* find the foreground and background colors set by nh_HI or nh_HE */
1098static void
1099analyze_seq(char *str, int *fg, int *bg)
1100{
1101 int c, code;
1102 int len;
1103
1104#ifdef MICRO
1105 *fg = CLR_GRAY;
1106 *bg = CLR_BLACK;
1107#else
1108 *fg = *bg = NO_COLOR;
1109#endif
1110
1111 c = (str[0] == '\233') ? 1 : 2; /* index of char beyond esc prefix */
1112 len = strlen(str) - 1; /* length excluding attrib suffix */
1113 if ((c != 1 && (str[0] != '\033' || str[1] != '[')) || (len - c) < 1
1114 || str[len] != 'm')
1115 return;
1116
1117 while (c < len) {
1118 if ((code = atoi(&str[c])) == 0) { /* reset */
1119 /* this also catches errors */
1120#ifdef MICRO
1121 *fg = CLR_GRAY;
1122 *bg = CLR_BLACK;
1123#else
1124 *fg = *bg = NO_COLOR;
1125#endif
1126 } else if (code == 1) { /* bold */
1127 *fg |= BRIGHT;
1128#if 0
1129 /* I doubt we'll ever resort to using blinking characters,
1130 unless we want a pulsing glow for something. But, in case
1131 we do... -3. */
1132 } else if (code == 5) { /* blinking */
1133 *fg |= BLINK;
1134 } else if (code == 25) { /* stop blinking */
1135 *fg &= ~BLINK;
1136#endif
1137 } else if (code == 7 || code == 27) { /* reverse */
1138 code = *fg & ~BRIGHT;
1139 *fg = *bg | (*fg & BRIGHT);
1140 *bg = code;
1141 } else if (code >= 30 && code <= 37) { /* hi_foreground RGB */
1142 *fg = code - 30;
1143 } else if (code >= 40 && code <= 47) { /* hi_background RGB */
1144 *bg = code - 40;
1145 }
1146 while (digit(str[++c]))
1147 ;
1148 c++;
1149 }
1150}
1151#endif
1152
1153/*

Callers 1

init_hiliteFunction · 0.85

Calls 1

digitFunction · 0.85

Tested by

no test coverage detected