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

Function init_hilite

win/tty/termcap.c:937–1035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

935static char nilstring[] = "";
936
937static void
938init_hilite(void)
939{
940 int c, colors;
941 char *setf, *scratch;
942
943 colors = tgetnum(nhStr("Co"));
944 iflags.colorcount = colors;
945 int md_len = 0;
946
947 if (colors < 8 || !MD || !*MD
948 || ((setf = tgetstr(nhStr("AF"), (char **) 0)) == (char *) 0
949 && (setf = tgetstr(nhStr("Sf"), (char **) 0)) == (char *) 0)) {
950 /* Fallback when colors not available
951 * It's arbitrary to collapse all colors except gray
952 * together, but that's what the previous code did.
953 */
954 hilites[CLR_BLACK] = nh_HI;
955 hilites[CLR_RED] = nh_HI;
956 hilites[CLR_GREEN] = nh_HI;
957 hilites[CLR_BROWN] = nh_HI;
958 hilites[CLR_BLUE] = nh_HI;
959 hilites[CLR_MAGENTA] = nh_HI;
960 hilites[CLR_CYAN] = nh_HI;
961 hilites[CLR_GRAY] = nilstring;
962 hilites[NO_COLOR] = nilstring;
963 hilites[CLR_ORANGE] = nh_HI;
964 hilites[CLR_BRIGHT_GREEN] = nh_HI;
965 hilites[CLR_YELLOW] = nh_HI;
966 hilites[CLR_BRIGHT_BLUE] = nh_HI;
967 hilites[CLR_BRIGHT_MAGENTA] = nh_HI;
968 hilites[CLR_BRIGHT_CYAN] = nh_HI;
969 hilites[CLR_WHITE] = nh_HI;
970 return;
971 }
972
973 if (colors >= 16) {
974 for (c = 0; c < SIZE(ti_map); c++) {
975 /* system colors */
976 scratch = tparm(setf, ti_map[c].nh_color);
977 hilites[ti_map[c].nh_color] = dupstr(scratch);
978 /* bright colors */
979 scratch = tparm(setf, ti_map[c].nh_bright_color);
980 hilites[ti_map[c].nh_bright_color] = dupstr(scratch);
981 }
982 } else {
983 /* 8 system colors */
984 md_len = (int) strlen(MD);
985
986 c = 6;
987 while (c--) {
988 char *work;
989
990 scratch = tparm(setf, ti_map[c].ti_color);
991 work = (char *) alloc(strlen(scratch) + md_len + 1);
992 Strcpy(work, MD);
993 hilites[ti_map[c].nh_bright_color] = work;
994 work += md_len;

Callers 3

term_startupFunction · 0.85
term_start_screenFunction · 0.85

Calls 6

tgetnumFunction · 0.85
tgetstrFunction · 0.85
dupstrFunction · 0.85
analyze_seqFunction · 0.85
eosFunction · 0.85
allocFunction · 0.50

Tested by

no test coverage detected