/* $Id: tmux.h,v 1.184 2008-09-08 22:03:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef TMUX_H
#define TMUX_H
#define PROTOCOL_VERSION -1
/* Shut up gcc warnings about empty if bodies. */
#define RB_AUGMENT(x) do {} while (0)
#include <sys/param.h>
#include <sys/time.h>
#ifndef NO_QUEUE_H
#include <sys/queue.h>
#else
#include "compat/queue.h"
#endif
#ifndef NO_TREE_H
#include <sys/tree.h>
#else
#include "compat/tree.h"
#endif
#ifndef BROKEN_POLL
#include <poll.h>
#else
#undef HAVE_POLL
#include "compat/bsd-poll.h"
#endif
#include <ncurses.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <term.h>
#include "array.h"
extern const char *__progname;
#ifndef INFTIM
#define INFTIM -1
#endif
#ifndef WAIT_ANY
#define WAIT_ANY -1
#endif
#ifndef SUN_LEN
#define SUN_LEN(sun) (sizeof (sun)->sun_path)
#endif
#ifndef __dead
#define __dead __attribute__ ((__noreturn__))
#endif
#ifndef __packed
#define __packed __attribute__ ((__packed__))
#endif
#ifndef timercmp
#define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
#endif
#ifndef timeradd
#define timeradd(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
if ((vvp)->tv_usec >= 1000000) { \
(vvp)->tv_sec++; \
(vvp)->tv_usec -= 1000000; \
} \
} while (0)
#endif
#ifndef TTY_NAME_MAX
#define TTY_NAME_MAX 32
#endif
#ifdef NO_PATHS_H
#define _PATH_BSHELL "/bin/sh"
#define _PATH_TMP "/tmp/"
#define _PATH_DEVNULL "/dev/null"
#endif
/* Default configuration file. */
#define DEFAULT_CFG ".tmux.conf"
/* Fatal errors. */
#define fatal(msg) log_fatal("%s: %s", __func__, msg);
#define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
/* Definition to shut gcc up about unused arguments. */
#define unused __attribute__ ((unused))
/* Attribute to make gcc check printf-like arguments. */
#define printflike1 __attribute__ ((format (printf, 1, 2)))
#define printflike2 __attribute__ ((format (printf, 2, 3)))
#define printflike3 __attribute__ ((format (printf, 3, 4)))
#define printflike4 __attribute__ ((format (printf, 4, 5)))
/* Buffer macros. */
#define BUFFER_USED(b) ((b)->size)
#define BUFFER_FREE(b) ((b)->space - (b)->off - (b)->size)
#define BUFFER_IN(b) ((b)->base + (b)->off + (b)->size)
#define BUFFER_OUT(b) ((b)->base + (b)->off)
/* Buffer structure. */
struct buffer {
u_char *base; /* buffer start */
size_t space; /* total size of buffer */
size_t size; /* size of data in buffer */
size_t off; /* offset of data in buffer */
};
/* Bell option values. */
#define BELL_NONE 0
#define BELL_ANY 1
#define BELL_CURRENT 2
/* Key codes. ncurses defines KEY_*. Grrr. */
#define KEYC_NONE 0x0ffff
#define KEYC_OFFSET 0x10000
#define KEYC_ESCAPE 0x20000
#define KEYC_ADDESCAPE(k) ((k) | KEYC_ESCAPE)
#define KEYC_REMOVEESCAPE(k) ((k) & ~KEYC_ESCAPE)
#define KEYC_ISESCAPE(k) ((k) != KEYC_NONE && ((k) & KEYC_ESCAPE))
/* #define KEYC_A1 (KEYC_OFFSET + 0x1) */
/* #define KEYC_A3 (KEYC_OFFSET + 0x2) */
/* #define KEYC_B2 (KEYC_OFFSET + 0x3) */
/* #define KEYC_BACKSPACE (KEYC_OFFSET + 0x4) */
#define KEYC_BEG (KEYC_OFFSET + 0x5)
#define KEYC_BTAB (KEYC_OFFSET + 0x6)
/* #define KEYC_C1 (KEYC_OFFSET + 0x7) */
/* #define KEYC_C3 (KEYC_OFFSET + 0x8) */
#define KEYC_CANCEL (KEYC_OFFSET + 0x9)
#define KEYC_CATAB (KEYC_OFFSET + 0xa)
#define KEYC_CLEAR (KEYC_OFFSET + 0xb)
#define KEYC_CLOSE (KEYC_OFFSET + 0xc)
#define KEYC_COMMAND (KEYC_OFFSET + 0xd)
#define KEYC_COPY (KEYC_OFFSET + 0xe)
#define KEYC_CREATE (KEYC_OFFSET + 0xf)
#define KEYC_CTAB (KEYC_OFFSET + 0x10)
#define KEYC_DC (KEYC_OFFSET + 0x11)
#define KEYC_DL (KEYC_OFFSET + 0x12)
#define KEYC_DOWN (KEYC_OFFSET + 0x13)
#define KEYC_EIC (KEYC_OFFSET +