[BACK]Return to tty-write.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Annotation of src/usr.bin/tmux/tty-write.c, Revision 1.5

1.5     ! nicm        1: /* $OpenBSD: tty-write.c,v 1.4 2009/07/14 07:23:36 nicm Exp $ */
1.1       nicm        2:
                      3: /*
                      4:  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
                      5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
                      9:  *
                     10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
                     15:  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                     16:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17:  */
                     18:
                     19: #include <sys/types.h>
                     20:
1.5     ! nicm       21: #include <string.h>
        !            22:
1.1       nicm       23: #include "tmux.h"
                     24:
1.5     ! nicm       25: void
        !            26: tty_write0(struct window_pane *wp, enum tty_cmd cmd)
        !            27: {
        !            28:        struct tty_ctx  ctx;
        !            29:
        !            30:        memset(&ctx, 0, sizeof ctx);
        !            31:        ctx.wp = wp;
        !            32:        tty_write_cmd(cmd, &ctx);
        !            33: }
        !            34:
        !            35: void
        !            36: tty_writenum(struct window_pane *wp, enum tty_cmd cmd, u_int num)
        !            37: {
        !            38:        struct tty_ctx  ctx;
        !            39:
        !            40:        memset(&ctx, 0, sizeof ctx);
        !            41:        ctx.wp = wp;
        !            42:        ctx.num = num;
        !            43:        tty_write_cmd(cmd, &ctx);
        !            44: }
1.1       nicm       45:
                     46: void
1.5     ! nicm       47: tty_writeptr(struct window_pane *wp, enum tty_cmd cmd, void *ptr)
1.1       nicm       48: {
1.5     ! nicm       49:        struct tty_ctx  ctx;
1.1       nicm       50:
1.5     ! nicm       51:        memset(&ctx, 0, sizeof ctx);
        !            52:        ctx.wp = wp;
        !            53:        ctx.ptr = ptr;
        !            54:        tty_write_cmd(cmd, &ctx);
1.1       nicm       55: }
                     56:
                     57: void
1.5     ! nicm       58: tty_write_cmd(enum tty_cmd cmd, struct tty_ctx *ctx)
1.1       nicm       59: {
1.5     ! nicm       60:        struct window_pane      *wp = ctx->wp;
        !            61:        struct client           *c;
        !            62:        u_int                    i;
1.1       nicm       63:
                     64:        if (wp == NULL)
                     65:                return;
                     66:
                     67:        if (wp->window->flags & WINDOW_REDRAW || wp->flags & PANE_REDRAW)
                     68:                return;
1.4       nicm       69:        if (wp->window->flags & WINDOW_HIDDEN || !window_pane_visible(wp))
1.1       nicm       70:                return;
                     71:
                     72:        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
                     73:                c = ARRAY_ITEM(&clients, i);
                     74:                if (c == NULL || c->session == NULL)
                     75:                        continue;
                     76:                if (c->flags & CLIENT_SUSPENDED)
                     77:                        continue;
                     78:
                     79:                if (c->session->curw->window == wp->window) {
                     80:                        tty_update_mode(&c->tty, c->tty.mode & ~MODE_CURSOR);
                     81:
1.5     ! nicm       82:                        tty_write(&c->tty, cmd, ctx);
1.1       nicm       83:                }
                     84:        }
                     85: }