[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.6

1.6     ! nicm        1: /* $OpenBSD: tty-write.c,v 1.5 2009/07/22 16:45:31 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
1.6     ! nicm       26: tty_write0(struct window_pane *wp, tty_cmd_func *cmdfn)
1.5       nicm       27: {
                     28:        struct tty_ctx  ctx;
                     29:
                     30:        memset(&ctx, 0, sizeof ctx);
                     31:        ctx.wp = wp;
1.6     ! nicm       32:        tty_write(cmdfn, &ctx);
1.5       nicm       33: }
                     34:
                     35: void
1.6     ! nicm       36: tty_writenum(struct window_pane *wp, tty_cmd_func *cmdfn, u_int num)
1.5       nicm       37: {
                     38:        struct tty_ctx  ctx;
                     39:
                     40:        memset(&ctx, 0, sizeof ctx);
                     41:        ctx.wp = wp;
                     42:        ctx.num = num;
1.6     ! nicm       43:        tty_write(cmdfn, &ctx);
1.5       nicm       44: }
1.1       nicm       45:
                     46: void
1.6     ! nicm       47: tty_writeptr(struct window_pane *wp, tty_cmd_func *cmdfn, 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;
1.6     ! nicm       54:        tty_write(cmdfn, &ctx);
1.1       nicm       55: }
                     56:
                     57: void
1.6     ! nicm       58: tty_write(tty_cmd_func *cmdfn, 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) {
1.6     ! nicm       80:                        if (c->tty.flags & TTY_FREEZE || c->tty.term == NULL)
        !            81:                                continue;
1.1       nicm       82:                        tty_update_mode(&c->tty, c->tty.mode & ~MODE_CURSOR);
1.6     ! nicm       83:                        cmdfn(&c->tty, ctx);
1.1       nicm       84:                }
                     85:        }
                     86: }