Update of /cvsroot/tmux/tmux
In directory vz-cvs-2.sog:/tmp/cvs-serv20353

Modified Files:
        input.c options-table.c screen.c server-client.c tmux.1 tmux.h 
        tty-term.c tty.c 
Log Message:
Sync OpenBSD patchset 915:

Support xterm(1) cursor colour change sequences through terminfo(5) Cc
(set) and Cr (reset) extensions. Originally by Sean Estabrooks, tweaked
by me and Ailin Nemui.


Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- server-client.c     18 May 2011 20:31:32 -0000      1.61
+++ server-client.c     22 May 2011 16:25:02 -0000      1.62
@@ -520,7 +520,7 @@
                mode &= ~MODE_MOUSE_UTF8;
 
        /* Set the terminal mode and reset attributes. */
-       tty_update_mode(&c->tty, mode);
+       tty_update_mode(&c->tty, mode, s);
        tty_reset(&c->tty);
 }
 

Index: tty-term.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tty-term.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- tty-term.c  22 May 2011 16:23:07 -0000      1.49
+++ tty-term.c  22 May 2011 16:25:02 -0000      1.50
@@ -41,10 +41,12 @@
        { TTYC_BEL, TTYCODE_STRING, "bel" },
        { TTYC_BLINK, TTYCODE_STRING, "blink" },
        { TTYC_BOLD, TTYCODE_STRING, "bold" },
+       { TTYC_CC, TTYCODE_STRING, "Cc" },
        { TTYC_CIVIS, TTYCODE_STRING, "civis" },
        { TTYC_CLEAR, TTYCODE_STRING, "clear" },
        { TTYC_CNORM, TTYCODE_STRING, "cnorm" },
        { TTYC_COLORS, TTYCODE_NUMBER, "colors" },
+       { TTYC_CR, TTYCODE_STRING, "Cr" },
        { TTYC_CSR, TTYCODE_STRING, "csr" },
        { TTYC_CUB, TTYCODE_STRING, "cub" },
        { TTYC_CUB1, TTYCODE_STRING, "cub1" },
@@ -499,6 +501,12 @@
 }
 
 const char *
+tty_term_ptr1(struct tty_term *term, enum tty_code_code code, const void *a)
+{
+       return (tparm((char *) tty_term_string(term, code), a));
+}
+
+const char *
 tty_term_ptr2(struct tty_term *term, enum tty_code_code code, const void *a, 
const void *b)
 {
        return (tparm((char *) tty_term_string(term, code), a, b, 0, 0, 0, 0, 
0, 0, 0));

Index: tty.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tty.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- tty.c       22 May 2011 16:23:07 -0000      1.210
+++ tty.c       22 May 2011 16:25:02 -0000      1.211
@@ -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

Index: input.c
===================================================================
RCS file: /cvsroot/tmux/tmux/input.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- input.c     19 Mar 2011 23:30:37 -0000      1.117
+++ input.c     22 May 2011 16:25:02 -0000      1.118
@@ -1445,17 +1445,39 @@
 void
 input_exit_osc(struct input_ctx *ictx)
 {
-       if (ictx->flags & INPUT_DISCARD)
-               return;
-       log_debug("%s: \"%s\"", __func__, ictx->input_buf);
+       u_char *p = ictx->input_buf;
+       int     option;
 
-       if (ictx->input_len < 2 || ictx->input_buf[1] != ';')
+       if (ictx->flags & INPUT_DISCARD)
                return;
-       if (ictx->input_buf[0] != '0' && ictx->input_buf[0] != '2')
+       if (ictx->input_len < 1 || *p < '0' || *p > '9')
                return;
 
-       screen_set_title(ictx->ctx.s, ictx->input_buf + 2);
-       server_status_window(ictx->wp->window);
+       log_debug("%s: \"%s\"", __func__, p);
+
+       option = 0;
+       while (*p >= '0' && *p <= '9')
+               option = option * 10 + *p++ - '0';
+       if (*p == ';')
+               p++;
+
+       switch (option) {
+       case 0:
+       case 2:
+               screen_set_title(ictx->ctx.s, p);
+               server_status_window(ictx->wp->window);
+               break;
+       case 12:
+               screen_set_cursor_colour(ictx->ctx.s, p);
+               break;
+       case 112:
+               if (*p == '\0') /* No arguments allowed. */
+                       screen_set_cursor_colour(ictx->ctx.s, "");
+               break;
+       default:
+               log_debug("%s: unknown '%u'", __func__, option);
+               break;
+       }
 }
 
 /* APC string started. */

Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.314
retrieving revision 1.315
diff -u -d -r1.314 -r1.315
--- tmux.1      22 May 2011 16:23:07 -0000      1.314
+++ tmux.1      22 May 2011 16:25:02 -0000      1.315
@@ -14,7 +14,7 @@
 .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: May 18 2011 $
+.Dd $Mdocdate: May 20 2011 $
 .Dt TMUX 1
 .Os
 .Sh NAME
@@ -2836,6 +2836,15 @@
 option above and the
 .Xr xterm 1
 man page.
+.It Em Cc, Cr
+The first takes one string argument and is used to set the cursor colour;
+the second takes no arguments and restores the default cursor colour.
+If they present, a sequence such as this may be used to change the
+cursor colour from inside
+.Nm :
+.Bd -literal -offset indent
+$ printf '\e033]12;red\e033\e\e'
+.Ed
 .El
 .Sh FILES
 .Bl -tag -width "/etc/tmux.confXXX" -compact

Index: options-table.c
===================================================================
RCS file: /cvsroot/tmux/tmux/options-table.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- options-table.c     22 May 2011 16:23:07 -0000      1.10
+++ options-table.c     22 May 2011 16:25:02 -0000      1.11
@@ -365,13 +365,14 @@
        { .name = "terminal-overrides",
          .type = OPTIONS_TABLE_STRING,
          .default_str = "*88col*:colors=88,*256col*:colors=256"
-                        ",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
+                        ",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
+                        ":Cc=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
        },
 
        { .name = "update-environment",
          .type = OPTIONS_TABLE_STRING,
          .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
-                           "SSH_CONNECTION WINDOWID XAUTHORITY"
+                        "SSH_CONNECTION WINDOWID XAUTHORITY"
 
        },
 

Index: screen.c
===================================================================
RCS file: /cvsroot/tmux/tmux/screen.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- screen.c    5 May 2011 10:10:57 -0000       1.104
+++ screen.c    22 May 2011 16:25:02 -0000      1.105
@@ -41,6 +41,7 @@
        else
                s->title = xstrdup("");
 
+       s->ccolour = xstrdup("");
        s->tabs = NULL;
 
        screen_reinit(s);
@@ -72,6 +73,7 @@
        if (s->tabs != NULL)
                xfree(s->tabs);
        xfree(s->title);
+       xfree(s->ccolour);
        grid_destroy(s->grid);
 }
 
@@ -90,6 +92,14 @@
                bit_set(s->tabs, i);
 }
 
+/* Set screen cursor colour. */
+void
+screen_set_cursor_colour(struct screen *s, const char *colour_string)
+{
+       xfree(s->ccolour);
+       s->ccolour = xstrdup(colour_string);
+}
+
 /* Set screen title. */
 void
 screen_set_title(struct screen *s, const char *title)

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.625
retrieving revision 1.626
diff -u -d -r1.625 -r1.626
--- tmux.h      22 May 2011 16:23:07 -0000      1.625
+++ tmux.h      22 May 2011 16:25:02 -0000      1.626
@@ -179,10 +179,12 @@
        TTYC_BEL,       /* bell, bl */
        TTYC_BLINK,     /* enter_blink_mode, mb */
        TTYC_BOLD,      /* enter_bold_mode, md */
+       TTYC_CC,        /* set colour cursor, Cc */
        TTYC_CIVIS,     /* cursor_invisible, vi */
        TTYC_CLEAR,     /* clear_screen, cl */
        TTYC_CNORM,     /* cursor_normal, ve */
        TTYC_COLORS,    /* max_colors, Co */
+       TTYC_CR,        /* restore cursor colour, Cr */
        TTYC_CSR,       /* change_scroll_region, cs */
        TTYC_CUB,       /* parm_left_cursor, LE */
        TTYC_CUB1,      /* cursor_left, le */
@@ -710,6 +712,8 @@
        u_int            cx;            /* cursor x */
        u_int            cy;            /* cursor y */
 
+       char            *ccolour;       /* cursor colour string */
+
        u_int            rupper;        /* scroll region top */
        u_int            rlower;        /* scroll region bottom */
 
@@ -1006,6 +1010,7 @@
 
        u_int            cx;
        u_int            cy;
+       char            *ccolour;
 
        int              mode;
 
@@ -1410,6 +1415,7 @@
 void   tty_putcode(struct tty *, enum tty_code_code);
 void   tty_putcode1(struct tty *, enum tty_code_code, int);
 void   tty_putcode2(struct tty *, enum tty_code_code, int, int);
+void   tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
 void   tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const 
void *);
 void   tty_puts(struct tty *, const char *);
 void   tty_putc(struct tty *, u_char);
@@ -1419,7 +1425,8 @@
 void   tty_start_tty(struct tty *);
 void   tty_stop_tty(struct tty *);
 void   tty_set_title(struct tty *, const char *);
-void   tty_update_mode(struct tty *, int);
+void   tty_update_mode(struct tty *, int, struct screen *);
+void   tty_force_cursor_colour(struct tty *, const char *);
 void   tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
 int    tty_open(struct tty *, const char *, char **);
 void   tty_close(struct tty *);
@@ -1455,6 +1462,8 @@
 const char     *tty_term_string1(struct tty_term *, enum tty_code_code, int);
 const char     *tty_term_string2(
                     struct tty_term *, enum tty_code_code, int, int);
+const char     *tty_term_ptr1(
+                    struct tty_term *, enum tty_code_code, const void *);
 const char     *tty_term_ptr2(
                     struct tty_term *, enum tty_code_code, const void *, const 
void *);
 int             tty_term_number(struct tty_term *, enum tty_code_code);
@@ -1837,6 +1846,7 @@
 void    screen_reinit(struct screen *);
 void    screen_free(struct screen *);
 void    screen_reset_tabs(struct screen *);
+void    screen_set_cursor_colour(struct screen *, const char *);
 void    screen_set_title(struct screen *, const char *);
 void    screen_resize(struct screen *, u_int, u_int);
 void    screen_set_selection(struct screen *,


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to