=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- src/usr.bin/tmux/tty.c 2011/05/18 20:24:29 1.106 +++ src/usr.bin/tmux/tty.c 2011/05/20 19:03:58 1.107 @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.106 2011/05/18 20:24:29 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.107 2011/05/20 19:03:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -69,6 +69,7 @@ if ((path = ttyname(fd)) == NULL) fatalx("ttyname failed"); tty->path = xstrdup(path); + tty->ccolour = xstrdup(""); tty->flags = 0; tty->term_flags = 0; @@ -210,6 +211,8 @@ tty->mode = MODE_CURSOR; tty->flags |= TTY_STARTED; + + tty_force_cursor_colour(tty, ""); } void @@ -241,6 +244,7 @@ tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0)); tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX)); tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR)); + tty_raw(tty, tty_term_string(tty->term, TTYC_CR)); tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM)); if (tty_term_has(tty->term, TTYC_KMOUS)) @@ -280,6 +284,7 @@ { tty_close(tty); + xfree(tty->ccolour); if (tty->path != NULL) xfree(tty->path); if (tty->termname != NULL) @@ -315,6 +320,13 @@ } void +tty_putcode_ptr1(struct tty *tty, enum tty_code_code code, const void *a) +{ + if (a != NULL) + tty_puts(tty, tty_term_ptr1(tty->term, code, a)); +} + +void tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a, const void *b) { if (a != NULL && b != NULL) @@ -389,10 +401,24 @@ } void -tty_update_mode(struct tty *tty, int mode) +tty_force_cursor_colour(struct tty *tty, const char *ccolour) { + if (*ccolour == '\0') + tty_putcode(tty, TTYC_CR); + else + tty_putcode_ptr1(tty, TTYC_CC, ccolour); + xfree(tty->ccolour); + tty->ccolour = xstrdup(ccolour); +} + +void +tty_update_mode(struct tty *tty, int mode, struct screen *s) +{ int changed; + if (strcmp(s->ccolour, tty->ccolour)) + tty_force_cursor_colour(tty, s->ccolour); + if (tty->flags & TTY_NOCURSOR) mode &= ~MODE_CURSOR; @@ -486,7 +512,7 @@ const struct grid_utf8 *gu; u_int i, sx; - tty_update_mode(tty, tty->mode & ~MODE_CURSOR); + tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s); sx = screen_size_x(s); if (sx > s->grid->linedata[s->grid->hsize + py].cellsize) @@ -526,7 +552,7 @@ } if (sx >= tty->sx) { - tty_update_mode(tty, tty->mode); + tty_update_mode(tty, tty->mode, s); return; } tty_reset(tty); @@ -538,7 +564,7 @@ for (i = sx; i < screen_size_x(s); i++) tty_putc(tty, ' '); } - tty_update_mode(tty, tty->mode); + tty_update_mode(tty, tty->mode, s); } void