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

1.1     ! nicm        1: /* $OpenBSD$ */
        !             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:
        !            21: #include "tmux.h"
        !            22:
        !            23: void   tty_vwrite_cmd(struct window_pane *, enum tty_cmd, va_list);
        !            24:
        !            25: void
        !            26: tty_write_cmd(struct window_pane *wp, enum tty_cmd cmd, ...)
        !            27: {
        !            28:        va_list ap;
        !            29:
        !            30:        va_start(ap, cmd);
        !            31:        tty_vwrite_cmd(wp, cmd, ap);
        !            32:        va_end(ap);
        !            33: }
        !            34:
        !            35: void
        !            36: tty_vwrite_cmd(struct window_pane *wp, enum tty_cmd cmd, va_list ap)
        !            37: {
        !            38:        struct client   *c;
        !            39:        va_list          aq;
        !            40:        u_int            i;
        !            41:
        !            42:        if (wp == NULL)
        !            43:                return;
        !            44:
        !            45:        if (wp->window->flags & WINDOW_REDRAW || wp->flags & PANE_REDRAW)
        !            46:                return;
        !            47:        if (wp->window->flags & WINDOW_HIDDEN || wp->flags & PANE_HIDDEN)
        !            48:                return;
        !            49:
        !            50:        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
        !            51:                c = ARRAY_ITEM(&clients, i);
        !            52:                if (c == NULL || c->session == NULL)
        !            53:                        continue;
        !            54:                if (c->flags & CLIENT_SUSPENDED)
        !            55:                        continue;
        !            56:
        !            57:                if (c->session->curw->window == wp->window) {
        !            58:                        tty_update_mode(&c->tty, c->tty.mode & ~MODE_CURSOR);
        !            59:
        !            60:                        va_copy(aq, ap);
        !            61:                        tty_vwrite(&c->tty, wp, cmd, aq);
        !            62:                        va_end(aq);
        !            63:                }
        !            64:        }
        !            65: }
        !            66:
        !            67: void
        !            68: tty_write_mode(struct window_pane *wp, int mode)
        !            69: {
        !            70:        struct client   *c;
        !            71:        u_int            i;
        !            72:
        !            73:        if (wp == NULL)
        !            74:                return;
        !            75:
        !            76:        if (wp->window->flags & WINDOW_REDRAW || wp->flags & PANE_REDRAW)
        !            77:                return;
        !            78:        if (wp->window->flags & WINDOW_HIDDEN || wp->flags & PANE_HIDDEN)
        !            79:                return;
        !            80:
        !            81:        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
        !            82:                c = ARRAY_ITEM(&clients, i);
        !            83:                if (c == NULL || c->session == NULL)
        !            84:                        continue;
        !            85:                if (c->flags & CLIENT_SUSPENDED)
        !            86:                        continue;
        !            87:
        !            88:                tty_update_mode(&c->tty, mode);
        !            89:        }
        !            90: }
        !            91: