=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty-term.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/tmux/tty-term.c 2009/08/02 20:47:35 1.4 --- src/usr.bin/tmux/tty-term.c 2009/08/03 14:10:54 1.5 *************** *** 1,4 **** ! /* $OpenBSD: tty-term.c,v 1.4 2009/08/02 20:47:35 matthieu Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty-term.c,v 1.5 2009/08/03 14:10:54 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott *************** *** 19,30 **** #include #include #include #include #include "tmux.h" ! void tty_term_quirks(struct tty_term *); char *tty_term_strip(const char *); struct tty_terms tty_terms = SLIST_HEAD_INITIALIZER(tty_terms); --- 19,33 ---- #include #include + #include + #include #include #include + #include #include "tmux.h" ! void tty_term_override(struct tty_term *, const char *); char *tty_term_strip(const char *); struct tty_terms tty_terms = SLIST_HEAD_INITIALIZER(tty_terms); *************** *** 140,166 **** } void ! tty_term_quirks(struct tty_term *term) { ! if (strncmp(term->name, "rxvt", 4) == 0) { ! /* rxvt supports dch1 but some termcap files do not have it. */ ! if (!tty_term_has(term, TTYC_DCH1)) { ! term->codes[TTYC_DCH1].type = TTYCODE_STRING; ! term->codes[TTYC_DCH1].value.string = xstrdup("\033[P"); ! } ! } ! if (strncmp(term->name, "xterm", 5) == 0) { ! /* xterm supports ich1 but some termcaps omit it. */ ! if (!tty_term_has(term, TTYC_ICH1)) { ! term->codes[TTYC_ICH1].type = TTYCODE_STRING; ! term->codes[TTYC_ICH1].value.string = xstrdup("\033[@"); } } } struct tty_term * ! tty_term_find(char *name, int fd, char **cause) { struct tty_term *term; struct tty_term_code_entry *ent; --- 143,229 ---- } void ! tty_term_override(struct tty_term *term, const char *overrides) { ! struct tty_term_code_entry *ent; ! struct tty_code *code; ! char *termnext, *termstr, *entnext, *entstr; ! char *s, *ptr, *val; ! const char *errstr; ! u_int i; ! int n, removeflag; ! s = xstrdup(overrides); ! ! termnext = s; ! while ((termstr = strsep(&termnext, ",")) != NULL) { ! entnext = termstr; ! ! entstr = strsep(&entnext, ":"); ! if (entstr == NULL || entnext == NULL) ! continue; ! if (fnmatch(entstr, term->name, 0) != 0) ! continue; ! while ((entstr = strsep(&entnext, ":")) != NULL) { ! if (*entstr == '\0') ! continue; ! ! val = NULL; ! removeflag = 0; ! if ((ptr = strchr(entstr, '=')) != NULL) { ! *ptr++ = '\0'; ! val = xstrdup(ptr); ! if (strunvis(val, ptr) == NULL) { ! xfree(val); ! val = xstrdup(ptr); ! } ! } else if (entstr[strlen(entstr) - 1] == '@') { ! entstr[strlen(entstr) - 1] = '\0'; ! removeflag = 1; ! } ! ! for (i = 0; i < NTTYCODE; i++) { ! ent = &tty_term_codes[i]; ! if (strcmp(entstr, ent->name) != 0) ! continue; ! code = &term->codes[ent->code]; ! ! if (removeflag) { ! code->type = TTYCODE_NONE; ! continue; ! } ! switch (ent->type) { ! case TTYCODE_NONE: ! break; ! case TTYCODE_STRING: ! xfree(code->value.string); ! code->value.string = xstrdup(val); ! code->type = ent->type; ! break; ! case TTYCODE_NUMBER: ! n = strtonum(val, 0, INT_MAX, &errstr); ! if (errstr != NULL) ! break; ! code->value.number = n; ! code->type = ent->type; ! break; ! case TTYCODE_FLAG: ! code->value.flag = 1; ! code->type = ent->type; ! break; ! } ! } ! ! if (val != NULL) ! xfree(val); } } + + xfree(s); } struct tty_term * ! tty_term_find(char *name, int fd, const char *overrides, char **cause) { struct tty_term *term; struct tty_term_code_entry *ent; *************** *** 235,241 **** break; } } ! tty_term_quirks(term); /* Delete curses data. */ del_curterm(cur_term); --- 298,304 ---- break; } } ! tty_term_override(term, overrides); /* Delete curses data. */ del_curterm(cur_term); *************** *** 297,307 **** */ if (tty_term_number(term, TTYC_COLORS) == 256) term->flags |= TERM_256COLOURS; - if (strstr(name, "256col") != NULL) /* XXX HACK */ - term->flags |= TERM_256COLOURS; if (tty_term_number(term, TTYC_COLORS) == 88) - term->flags |= TERM_88COLOURS; - if (strstr(name, "88col") != NULL) /* XXX HACK */ term->flags |= TERM_88COLOURS; /* --- 360,366 ----