File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / tmux / tmux.h
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Wed Jun 14 12:22:44 2017 UTC (7 years ago) by misho
CVS tags: MAIN, HEAD
Initial revision

    1: /* $OpenBSD$ */
    2: 
    3: /*
    4:  * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
    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: #ifndef TMUX_H
   20: #define TMUX_H
   21: 
   22: #define PROTOCOL_VERSION 8
   23: 
   24: #include <sys/time.h>
   25: #include <sys/uio.h>
   26: 
   27: #include <event.h>
   28: #include <limits.h>
   29: #include <stdarg.h>
   30: #include <stdio.h>
   31: #include <termios.h>
   32: #include <wchar.h>
   33: 
   34: #ifdef HAVE_UTEMPTER
   35: #include <utempter.h>
   36: #endif
   37: 
   38: #include "compat.h"
   39: #include "xmalloc.h"
   40: 
   41: extern char   **environ;
   42: 
   43: struct args;
   44: struct client;
   45: struct cmdq_item;
   46: struct cmdq_list;
   47: struct environ;
   48: struct input_ctx;
   49: struct mode_key_cmdstr;
   50: struct mouse_event;
   51: struct options;
   52: struct options_entry;
   53: struct session;
   54: struct tmuxpeer;
   55: struct tmuxproc;
   56: 
   57: /* Default global configuration file. */
   58: #ifndef TMUX_CONF
   59: #define TMUX_CONF "/etc/tmux.conf"
   60: #endif
   61: 
   62: /*
   63:  * Minimum layout cell size, NOT including separator line. The scroll region
   64:  * cannot be one line in height so this must be at least two.
   65:  */
   66: #define PANE_MINIMUM 2
   67: 
   68: /* Automatic name refresh interval, in microseconds. Must be < 1 second. */
   69: #define NAME_INTERVAL 500000
   70: 
   71: /* Maximum size of data to hold from a pane. */
   72: #define READ_SIZE 4096
   73: 
   74: /* Attribute to make GCC check printf-like arguments. */
   75: #define printflike(a, b) __attribute__ ((format (printf, a, b)))
   76: 
   77: /* Number of items in array. */
   78: #ifndef nitems
   79: #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
   80: #endif
   81: 
   82: /* Bell option values. */
   83: #define BELL_NONE 0
   84: #define BELL_ANY 1
   85: #define BELL_CURRENT 2
   86: #define BELL_OTHER 3
   87: 
   88: /* Special key codes. */
   89: #define KEYC_NONE 0xffff00000000ULL
   90: #define KEYC_UNKNOWN 0xfffe00000000ULL
   91: #define KEYC_BASE 0x000010000000ULL
   92: 
   93: /* Key modifier bits. */
   94: #define KEYC_ESCAPE 0x200000000000ULL
   95: #define KEYC_CTRL   0x400000000000ULL
   96: #define KEYC_SHIFT  0x800000000000ULL
   97: 
   98: /* Mask to obtain key w/o modifiers. */
   99: #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT)
  100: #define KEYC_MASK_KEY (~KEYC_MASK_MOD)
  101: 
  102: /* Is this a mouse key? */
  103: #define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE &&	\
  104:     ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
  105: 
  106: /* Multiple click timeout. */
  107: #define KEYC_CLICK_TIMEOUT 300
  108: 
  109: /* Mouse key codes. */
  110: #define KEYC_MOUSE_KEY(name)				\
  111: 	KEYC_ ## name ## _PANE,				\
  112: 	KEYC_ ## name ## _STATUS,			\
  113: 	KEYC_ ## name ## _BORDER
  114: #define KEYC_MOUSE_STRING(name, s)			\
  115: 	{ #s "Pane", KEYC_ ## name ## _PANE },		\
  116: 	{ #s "Status", KEYC_ ## name ## _STATUS },	\
  117: 	{ #s "Border", KEYC_ ## name ## _BORDER }
  118: 
  119: /*
  120:  * A single key. This can be ASCII or Unicode or one of the keys starting at
  121:  * KEYC_BASE.
  122:  */
  123: typedef unsigned long long key_code;
  124: 
  125: /* Special key codes. */
  126: enum {
  127: 	/* Focus events. */
  128: 	KEYC_FOCUS_IN = KEYC_BASE,
  129: 	KEYC_FOCUS_OUT,
  130: 
  131: 	/* Mouse keys. */
  132: 	KEYC_MOUSE, /* unclassified mouse event */
  133: 	KEYC_DRAGGING, /* dragging in progress */
  134: 	KEYC_MOUSE_KEY(MOUSEMOVE),
  135: 	KEYC_MOUSE_KEY(MOUSEDOWN1),
  136: 	KEYC_MOUSE_KEY(MOUSEDOWN2),
  137: 	KEYC_MOUSE_KEY(MOUSEDOWN3),
  138: 	KEYC_MOUSE_KEY(MOUSEUP1),
  139: 	KEYC_MOUSE_KEY(MOUSEUP2),
  140: 	KEYC_MOUSE_KEY(MOUSEUP3),
  141: 	KEYC_MOUSE_KEY(MOUSEDRAG1),
  142: 	KEYC_MOUSE_KEY(MOUSEDRAG2),
  143: 	KEYC_MOUSE_KEY(MOUSEDRAG3),
  144: 	KEYC_MOUSE_KEY(MOUSEDRAGEND1),
  145: 	KEYC_MOUSE_KEY(MOUSEDRAGEND2),
  146: 	KEYC_MOUSE_KEY(MOUSEDRAGEND3),
  147: 	KEYC_MOUSE_KEY(WHEELUP),
  148: 	KEYC_MOUSE_KEY(WHEELDOWN),
  149: 	KEYC_MOUSE_KEY(DOUBLECLICK1),
  150: 	KEYC_MOUSE_KEY(DOUBLECLICK2),
  151: 	KEYC_MOUSE_KEY(DOUBLECLICK3),
  152: 	KEYC_MOUSE_KEY(TRIPLECLICK1),
  153: 	KEYC_MOUSE_KEY(TRIPLECLICK2),
  154: 	KEYC_MOUSE_KEY(TRIPLECLICK3),
  155: 
  156: 	/* Backspace key. */
  157: 	KEYC_BSPACE,
  158: 
  159: 	/* Function keys. */
  160: 	KEYC_F1,
  161: 	KEYC_F2,
  162: 	KEYC_F3,
  163: 	KEYC_F4,
  164: 	KEYC_F5,
  165: 	KEYC_F6,
  166: 	KEYC_F7,
  167: 	KEYC_F8,
  168: 	KEYC_F9,
  169: 	KEYC_F10,
  170: 	KEYC_F11,
  171: 	KEYC_F12,
  172: 	KEYC_IC,
  173: 	KEYC_DC,
  174: 	KEYC_HOME,
  175: 	KEYC_END,
  176: 	KEYC_NPAGE,
  177: 	KEYC_PPAGE,
  178: 	KEYC_BTAB,
  179: 
  180: 	/* Arrow keys. */
  181: 	KEYC_UP,
  182: 	KEYC_DOWN,
  183: 	KEYC_LEFT,
  184: 	KEYC_RIGHT,
  185: 
  186: 	/* Numeric keypad. */
  187: 	KEYC_KP_SLASH,
  188: 	KEYC_KP_STAR,
  189: 	KEYC_KP_MINUS,
  190: 	KEYC_KP_SEVEN,
  191: 	KEYC_KP_EIGHT,
  192: 	KEYC_KP_NINE,
  193: 	KEYC_KP_PLUS,
  194: 	KEYC_KP_FOUR,
  195: 	KEYC_KP_FIVE,
  196: 	KEYC_KP_SIX,
  197: 	KEYC_KP_ONE,
  198: 	KEYC_KP_TWO,
  199: 	KEYC_KP_THREE,
  200: 	KEYC_KP_ENTER,
  201: 	KEYC_KP_ZERO,
  202: 	KEYC_KP_PERIOD,
  203: };
  204: 
  205: /* Termcap codes. */
  206: enum tty_code_code {
  207: 	TTYC_AX = 0,
  208: 	TTYC_ACSC,	/* acs_chars, ac */
  209: 	TTYC_BCE,	/* back_color_erase, ut */
  210: 	TTYC_BEL,	/* bell, bl */
  211: 	TTYC_BLINK,	/* enter_blink_mode, mb */
  212: 	TTYC_BOLD,	/* enter_bold_mode, md */
  213: 	TTYC_CIVIS,	/* cursor_invisible, vi */
  214: 	TTYC_CLEAR,	/* clear_screen, cl */
  215: 	TTYC_CNORM,	/* cursor_normal, ve */
  216: 	TTYC_COLORS,	/* max_colors, Co */
  217: 	TTYC_CR,	/* restore cursor colour, Cr */
  218: 	TTYC_CS,	/* set cursor colour, Cs */
  219: 	TTYC_CSR,	/* change_scroll_region, cs */
  220: 	TTYC_CUB,	/* parm_left_cursor, LE */
  221: 	TTYC_CUB1,	/* cursor_left, le */
  222: 	TTYC_CUD,	/* parm_down_cursor, DO */
  223: 	TTYC_CUD1,	/* cursor_down, do */
  224: 	TTYC_CUF,	/* parm_right_cursor, RI */
  225: 	TTYC_CUF1,	/* cursor_right, nd */
  226: 	TTYC_CUP,	/* cursor_address, cm */
  227: 	TTYC_CUU,	/* parm_up_cursor, UP */
  228: 	TTYC_CUU1,	/* cursor_up, up */
  229: 	TTYC_CVVIS,	/* cursor_visible, vs */
  230: 	TTYC_DCH,	/* parm_dch, DC */
  231: 	TTYC_DCH1,	/* delete_character, dc */
  232: 	TTYC_DIM,	/* enter_dim_mode, mh */
  233: 	TTYC_DL,	/* parm_delete_line, DL */
  234: 	TTYC_DL1,	/* delete_line, dl */
  235: 	TTYC_E3,
  236: 	TTYC_ECH,	/* erase_chars, ec */
  237: 	TTYC_ED,	/* clr_eos, cd */
  238: 	TTYC_EL,	/* clr_eol, ce */
  239: 	TTYC_EL1,	/* clr_bol, cb */
  240: 	TTYC_ENACS,	/* ena_acs, eA */
  241: 	TTYC_FSL,	/* from_status_line, fsl */
  242: 	TTYC_HOME,	/* cursor_home, ho */
  243: 	TTYC_HPA,	/* column_address, ch */
  244: 	TTYC_ICH,	/* parm_ich, IC */
  245: 	TTYC_ICH1,	/* insert_character, ic */
  246: 	TTYC_IL,	/* parm_insert_line, IL */
  247: 	TTYC_IL1,	/* insert_line, il */
  248: 	TTYC_INDN,      /* parm_index, indn */
  249: 	TTYC_INVIS,	/* enter_secure_mode, mk */
  250: 	TTYC_KCBT,	/* key_btab, kB */
  251: 	TTYC_KCUB1,	/* key_left, kl */
  252: 	TTYC_KCUD1,	/* key_down, kd */
  253: 	TTYC_KCUF1,	/* key_right, kr */
  254: 	TTYC_KCUU1,	/* key_up, ku */
  255: 	TTYC_KDC2,
  256: 	TTYC_KDC3,
  257: 	TTYC_KDC4,
  258: 	TTYC_KDC5,
  259: 	TTYC_KDC6,
  260: 	TTYC_KDC7,
  261: 	TTYC_KDCH1,	/* key_dc, kD */
  262: 	TTYC_KDN2,
  263: 	TTYC_KDN3,
  264: 	TTYC_KDN4,
  265: 	TTYC_KDN5,
  266: 	TTYC_KDN6,
  267: 	TTYC_KDN7,
  268: 	TTYC_KEND,	/* key_end, ke */
  269: 	TTYC_KEND2,
  270: 	TTYC_KEND3,
  271: 	TTYC_KEND4,
  272: 	TTYC_KEND5,
  273: 	TTYC_KEND6,
  274: 	TTYC_KEND7,
  275: 	TTYC_KF1,
  276: 	TTYC_KF10,
  277: 	TTYC_KF11,
  278: 	TTYC_KF12,
  279: 	TTYC_KF13,
  280: 	TTYC_KF14,
  281: 	TTYC_KF15,
  282: 	TTYC_KF16,
  283: 	TTYC_KF17,
  284: 	TTYC_KF18,
  285: 	TTYC_KF19,
  286: 	TTYC_KF2,
  287: 	TTYC_KF20,
  288: 	TTYC_KF21,
  289: 	TTYC_KF22,
  290: 	TTYC_KF23,
  291: 	TTYC_KF24,
  292: 	TTYC_KF25,
  293: 	TTYC_KF26,
  294: 	TTYC_KF27,
  295: 	TTYC_KF28,
  296: 	TTYC_KF29,
  297: 	TTYC_KF3,
  298: 	TTYC_KF30,
  299: 	TTYC_KF31,
  300: 	TTYC_KF32,
  301: 	TTYC_KF33,
  302: 	TTYC_KF34,
  303: 	TTYC_KF35,
  304: 	TTYC_KF36,
  305: 	TTYC_KF37,
  306: 	TTYC_KF38,
  307: 	TTYC_KF39,
  308: 	TTYC_KF4,
  309: 	TTYC_KF40,
  310: 	TTYC_KF41,
  311: 	TTYC_KF42,
  312: 	TTYC_KF43,
  313: 	TTYC_KF44,
  314: 	TTYC_KF45,
  315: 	TTYC_KF46,
  316: 	TTYC_KF47,
  317: 	TTYC_KF48,
  318: 	TTYC_KF49,
  319: 	TTYC_KF5,
  320: 	TTYC_KF50,
  321: 	TTYC_KF51,
  322: 	TTYC_KF52,
  323: 	TTYC_KF53,
  324: 	TTYC_KF54,
  325: 	TTYC_KF55,
  326: 	TTYC_KF56,
  327: 	TTYC_KF57,
  328: 	TTYC_KF58,
  329: 	TTYC_KF59,
  330: 	TTYC_KF6,
  331: 	TTYC_KF60,
  332: 	TTYC_KF61,
  333: 	TTYC_KF62,
  334: 	TTYC_KF63,
  335: 	TTYC_KF7,
  336: 	TTYC_KF8,
  337: 	TTYC_KF9,
  338: 	TTYC_KHOM2,
  339: 	TTYC_KHOM3,
  340: 	TTYC_KHOM4,
  341: 	TTYC_KHOM5,
  342: 	TTYC_KHOM6,
  343: 	TTYC_KHOM7,
  344: 	TTYC_KHOME,	/* key_home, kh */
  345: 	TTYC_KIC2,
  346: 	TTYC_KIC3,
  347: 	TTYC_KIC4,
  348: 	TTYC_KIC5,
  349: 	TTYC_KIC6,
  350: 	TTYC_KIC7,
  351: 	TTYC_KICH1,	/* key_ic, kI */
  352: 	TTYC_KLFT2,
  353: 	TTYC_KLFT3,
  354: 	TTYC_KLFT4,
  355: 	TTYC_KLFT5,
  356: 	TTYC_KLFT6,
  357: 	TTYC_KLFT7,
  358: 	TTYC_KMOUS,	/* key_mouse, Km */
  359: 	TTYC_KNP,	/* key_npage, kN */
  360: 	TTYC_KNXT2,
  361: 	TTYC_KNXT3,
  362: 	TTYC_KNXT4,
  363: 	TTYC_KNXT5,
  364: 	TTYC_KNXT6,
  365: 	TTYC_KNXT7,
  366: 	TTYC_KPP,	/* key_ppage, kP */
  367: 	TTYC_KPRV2,
  368: 	TTYC_KPRV3,
  369: 	TTYC_KPRV4,
  370: 	TTYC_KPRV5,
  371: 	TTYC_KPRV6,
  372: 	TTYC_KPRV7,
  373: 	TTYC_KRIT2,
  374: 	TTYC_KRIT3,
  375: 	TTYC_KRIT4,
  376: 	TTYC_KRIT5,
  377: 	TTYC_KRIT6,
  378: 	TTYC_KRIT7,
  379: 	TTYC_KUP2,
  380: 	TTYC_KUP3,
  381: 	TTYC_KUP4,
  382: 	TTYC_KUP5,
  383: 	TTYC_KUP6,
  384: 	TTYC_KUP7,
  385: 	TTYC_MS,	/* modify xterm(1) selection */
  386: 	TTYC_OP,	/* orig_pair, op */
  387: 	TTYC_REV,	/* enter_reverse_mode, mr */
  388: 	TTYC_RI,	/* scroll_reverse, sr */
  389: 	TTYC_RMACS,	/* exit_alt_charset_mode */
  390: 	TTYC_RMCUP,	/* exit_ca_mode, te */
  391: 	TTYC_RMKX,	/* keypad_local, ke */
  392: 	TTYC_SE,	/* reset cursor style, Se */
  393: 	TTYC_SETAB,	/* set_a_background, AB */
  394: 	TTYC_SETAF,	/* set_a_foreground, AF */
  395: 	TTYC_SGR0,	/* exit_attribute_mode, me */
  396: 	TTYC_SITM,	/* enter_italics_mode, it */
  397: 	TTYC_SMACS,	/* enter_alt_charset_mode, as */
  398: 	TTYC_SMCUP,	/* enter_ca_mode, ti */
  399: 	TTYC_SMKX,	/* keypad_xmit, ks */
  400: 	TTYC_SMSO,	/* enter_standout_mode, so */
  401: 	TTYC_SMUL,	/* enter_underline_mode, us */
  402: 	TTYC_SMXX,
  403: 	TTYC_SS,	/* set cursor style, Ss */
  404: 	TTYC_TC,	/* 24-bit "true" colour, Tc */
  405: 	TTYC_TSL,	/* to_status_line, tsl */
  406: 	TTYC_VPA,	/* row_address, cv */
  407: 	TTYC_XENL,	/* eat_newline_glitch, xn */
  408: 	TTYC_XT,	/* xterm(1)-compatible title, XT */
  409: };
  410: 
  411: /* Message codes. */
  412: enum msgtype {
  413: 	MSG_VERSION = 12,
  414: 
  415: 	MSG_IDENTIFY_FLAGS = 100,
  416: 	MSG_IDENTIFY_TERM,
  417: 	MSG_IDENTIFY_TTYNAME,
  418: 	MSG_IDENTIFY_OLDCWD, /* unused */
  419: 	MSG_IDENTIFY_STDIN,
  420: 	MSG_IDENTIFY_ENVIRON,
  421: 	MSG_IDENTIFY_DONE,
  422: 	MSG_IDENTIFY_CLIENTPID,
  423: 	MSG_IDENTIFY_CWD,
  424: 
  425: 	MSG_COMMAND = 200,
  426: 	MSG_DETACH,
  427: 	MSG_DETACHKILL,
  428: 	MSG_EXIT,
  429: 	MSG_EXITED,
  430: 	MSG_EXITING,
  431: 	MSG_LOCK,
  432: 	MSG_READY,
  433: 	MSG_RESIZE,
  434: 	MSG_SHELL,
  435: 	MSG_SHUTDOWN,
  436: 	MSG_STDERR,
  437: 	MSG_STDIN,
  438: 	MSG_STDOUT,
  439: 	MSG_SUSPEND,
  440: 	MSG_UNLOCK,
  441: 	MSG_WAKEUP,
  442: 	MSG_EXEC,
  443: };
  444: 
  445: /*
  446:  * Message data.
  447:  *
  448:  * Don't forget to bump PROTOCOL_VERSION if any of these change!
  449:  */
  450: struct msg_command_data {
  451: 	int	argc;
  452: }; /* followed by packed argv */
  453: 
  454: struct msg_stdin_data {
  455: 	ssize_t	size;
  456: 	char	data[BUFSIZ];
  457: };
  458: 
  459: struct msg_stdout_data {
  460: 	ssize_t	size;
  461: 	char	data[BUFSIZ];
  462: };
  463: 
  464: struct msg_stderr_data {
  465: 	ssize_t	size;
  466: 	char	data[BUFSIZ];
  467: };
  468: 
  469: /* Mode keys. */
  470: #define MODEKEY_EMACS 0
  471: #define MODEKEY_VI 1
  472: 
  473: /* Modes. */
  474: #define MODE_CURSOR 0x1
  475: #define MODE_INSERT 0x2
  476: #define MODE_KCURSOR 0x4
  477: #define MODE_KKEYPAD 0x8	/* set = application, clear = number */
  478: #define MODE_WRAP 0x10		/* whether lines wrap */
  479: #define MODE_MOUSE_STANDARD 0x20
  480: #define MODE_MOUSE_BUTTON 0x40
  481: #define MODE_BLINKING 0x80
  482: #define MODE_MOUSE_UTF8 0x100
  483: #define MODE_MOUSE_SGR 0x200
  484: #define MODE_BRACKETPASTE 0x400
  485: #define MODE_FOCUSON 0x800
  486: #define MODE_MOUSE_ALL 0x1000
  487: 
  488: #define ALL_MODES 0xffffff
  489: #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
  490: 
  491: /*
  492:  * A single UTF-8 character. UTF8_SIZE must be big enough to hold at least one
  493:  * combining character as well.
  494: */
  495: #define UTF8_SIZE 9
  496: struct utf8_data {
  497: 	u_char	data[UTF8_SIZE];
  498: 
  499: 	u_char	have;
  500: 	u_char	size;
  501: 
  502: 	u_char	width;	/* 0xff if invalid */
  503: } __packed;
  504: enum utf8_state {
  505: 	UTF8_MORE,
  506: 	UTF8_DONE,
  507: 	UTF8_ERROR
  508: };
  509: 
  510: /* Colour flags. */
  511: #define COLOUR_FLAG_256 0x01000000
  512: #define COLOUR_FLAG_RGB 0x02000000
  513: 
  514: /* Grid attributes. Anything above 0xff is stored in an extended cell. */
  515: #define GRID_ATTR_BRIGHT 0x1
  516: #define GRID_ATTR_DIM 0x2
  517: #define GRID_ATTR_UNDERSCORE 0x4
  518: #define GRID_ATTR_BLINK 0x8
  519: #define GRID_ATTR_REVERSE 0x10
  520: #define GRID_ATTR_HIDDEN 0x20
  521: #define GRID_ATTR_ITALICS 0x40
  522: #define GRID_ATTR_CHARSET 0x80	/* alternative character set */
  523: #define GRID_ATTR_STRIKETHROUGH 0x100
  524: 
  525: /* Grid flags. */
  526: #define GRID_FLAG_FG256 0x1
  527: #define GRID_FLAG_BG256 0x2
  528: #define GRID_FLAG_PADDING 0x4
  529: #define GRID_FLAG_EXTENDED 0x8
  530: #define GRID_FLAG_SELECTED 0x10
  531: #define GRID_FLAG_NOPALETTE 0x20
  532: 
  533: /* Grid line flags. */
  534: #define GRID_LINE_WRAPPED 0x1
  535: #define GRID_LINE_EXTENDED 0x2
  536: 
  537: /* Grid cell data. */
  538: struct grid_cell {
  539: 	u_char			flags;
  540: 	u_short			attr;
  541: 	int			fg;
  542: 	int			bg;
  543: 	struct utf8_data	data;
  544: };
  545: struct grid_cell_entry {
  546: 	u_char			flags;
  547: 	union {
  548: 		u_int		offset;
  549: 		struct {
  550: 			u_char	attr;
  551: 			u_char	fg;
  552: 			u_char	bg;
  553: 			u_char	data;
  554: 		} data;
  555: 	};
  556: } __packed;
  557: 
  558: /* Grid line. */
  559: struct grid_line {
  560: 	u_int			 cellused;
  561: 	u_int			 cellsize;
  562: 	struct grid_cell_entry	*celldata;
  563: 
  564: 	u_int			 extdsize;
  565: 	struct grid_cell	*extddata;
  566: 
  567: 	int			 flags;
  568: } __packed;
  569: 
  570: /* Entire grid of cells. */
  571: struct grid {
  572: 	int			 flags;
  573: #define GRID_HISTORY 0x1 /* scroll lines into history */
  574: 
  575: 	u_int			 sx;
  576: 	u_int			 sy;
  577: 
  578: 	u_int			 hscrolled;
  579: 	u_int			 hsize;
  580: 	u_int			 hlimit;
  581: 
  582: 	struct grid_line	*linedata;
  583: };
  584: 
  585: /* Hook data structures. */
  586: struct hook {
  587: 	const char	*name;
  588: 
  589: 	struct cmd_list	*cmdlist;
  590: 
  591: 	RB_ENTRY(hook)	 entry;
  592: };
  593: 
  594: /* Scheduled job. */
  595: struct job {
  596: 	enum {
  597: 		JOB_RUNNING,
  598: 		JOB_DEAD,
  599: 		JOB_CLOSED
  600: 	} state;
  601: 
  602: 	char		*cmd;
  603: 	pid_t		 pid;
  604: 	int		 status;
  605: 
  606: 	int		 fd;
  607: 	struct bufferevent *event;
  608: 
  609: 	void		(*callbackfn)(struct job *);
  610: 	void		(*freefn)(void *);
  611: 	void		*data;
  612: 
  613: 	LIST_ENTRY(job)	 lentry;
  614: };
  615: LIST_HEAD(joblist, job);
  616: 
  617: /* Screen selection. */
  618: struct screen_sel {
  619: 	int		 flag;
  620: 	int		 hidden;
  621: 
  622: 	int		 rectflag;
  623: 	enum {
  624: 		LINE_SEL_NONE,
  625: 		LINE_SEL_LEFT_RIGHT,
  626: 		LINE_SEL_RIGHT_LEFT,
  627: 	} lineflag;
  628: 
  629: 	int		 modekeys;
  630: 
  631: 	u_int		 sx;
  632: 	u_int		 sy;
  633: 
  634: 	u_int		 ex;
  635: 	u_int		 ey;
  636: 
  637: 	struct grid_cell cell;
  638: };
  639: 
  640: /* Virtual screen. */
  641: struct screen {
  642: 	char			*title;
  643: 
  644: 	struct grid		*grid;		/* grid data */
  645: 
  646: 	u_int			 cx;		/* cursor x */
  647: 	u_int			 cy;		/* cursor y */
  648: 
  649: 	u_int			 cstyle;	/* cursor style */
  650: 	char			*ccolour;	/* cursor colour string */
  651: 
  652: 	u_int			 rupper;	/* scroll region top */
  653: 	u_int			 rlower;	/* scroll region bottom */
  654: 
  655: 	int			 mode;
  656: 
  657: 	bitstr_t		*tabs;
  658: 
  659: 	struct screen_sel	 sel;
  660: };
  661: 
  662: /* Screen write context. */
  663: struct screen_write_collect_item;
  664: struct screen_write_collect_line;
  665: struct screen_write_ctx {
  666: 	struct window_pane	*wp;
  667: 	struct screen		*s;
  668: 
  669: 	struct screen_write_collect_item *item;
  670: 	struct screen_write_collect_line *list;
  671: 	u_int			 scrolled;
  672: 
  673: 	u_int			 cells;
  674: 	u_int			 written;
  675: 	u_int			 skipped;
  676: };
  677: 
  678: /* Screen size. */
  679: #define screen_size_x(s) ((s)->grid->sx)
  680: #define screen_size_y(s) ((s)->grid->sy)
  681: #define screen_hsize(s) ((s)->grid->hsize)
  682: #define screen_hlimit(s) ((s)->grid->hlimit)
  683: 
  684: /*
  685:  * Window mode. Windows can be in several modes and this is used to call the
  686:  * right function to handle input and output.
  687:  */
  688: struct window_mode {
  689: 	struct screen *(*init)(struct window_pane *);
  690: 	void	(*free)(struct window_pane *);
  691: 	void	(*resize)(struct window_pane *, u_int, u_int);
  692: 	void	(*key)(struct window_pane *, struct client *, struct session *,
  693: 		    key_code, struct mouse_event *);
  694: 
  695: 	const char *(*key_table)(struct window_pane *);
  696: 	void	(*command)(struct window_pane *, struct client *,
  697: 		    struct session *, struct args *, struct mouse_event *);
  698: };
  699: #define WINDOW_MODE_TIMEOUT 180
  700: 
  701: /* Structures for choose mode. */
  702: struct window_choose_data {
  703: 	struct client		*start_client;
  704: 	struct session		*start_session;
  705: 
  706: 	u_int			 idx;
  707: 	int			 type;
  708: #define TREE_OTHER 0x0
  709: #define TREE_WINDOW 0x1
  710: #define TREE_SESSION 0x2
  711: 
  712: 	struct session		*tree_session; /* session of items in tree */
  713: 
  714: 	struct winlink		*wl;
  715: 	int			 pane_id;
  716: 
  717: 	char			*ft_template;
  718: 	struct format_tree	*ft;
  719: 
  720: 	char			*command;
  721: };
  722: 
  723: /* Child window structure. */
  724: struct window_pane {
  725: 	u_int		 id;
  726: 	u_int		 active_point;
  727: 
  728: 	struct window	*window;
  729: 
  730: 	struct layout_cell *layout_cell;
  731: 	struct layout_cell *saved_layout_cell;
  732: 
  733: 	u_int		 sx;
  734: 	u_int		 sy;
  735: 
  736: 	u_int		 xoff;
  737: 	u_int		 yoff;
  738: 
  739: 	int		 flags;
  740: #define PANE_REDRAW 0x1
  741: #define PANE_DROP 0x2
  742: #define PANE_FOCUSED 0x4
  743: #define PANE_RESIZE 0x8
  744: #define PANE_FOCUSPUSH 0x10
  745: #define PANE_INPUTOFF 0x20
  746: #define PANE_CHANGED 0x40
  747: 
  748: 	int		 argc;
  749: 	char	       **argv;
  750: 	char		*shell;
  751: 	const char	*cwd;
  752: 
  753: 	pid_t		 pid;
  754: 	char		 tty[TTY_NAME_MAX];
  755: 	int		 status;
  756: 
  757: 	int		 fd;
  758: 	struct bufferevent *event;
  759: 
  760: 	struct event	 resize_timer;
  761: 
  762: 	struct input_ctx *ictx;
  763: 
  764: 	struct grid_cell colgc;
  765: 
  766: 	int		*palette;
  767: 
  768: 	int		 pipe_fd;
  769: 	struct bufferevent *pipe_event;
  770: 	size_t		 pipe_off;
  771: 
  772: 	struct screen	*screen;
  773: 	struct screen	 base;
  774: 
  775: 	struct screen	 status_screen;
  776: 	size_t		 status_size;
  777: 
  778: 	/* Saved in alternative screen mode. */
  779: 	u_int		 saved_cx;
  780: 	u_int		 saved_cy;
  781: 	struct grid	*saved_grid;
  782: 	struct grid_cell saved_cell;
  783: 
  784: 	const struct window_mode *mode;
  785: 	void		*modedata;
  786: 	struct event	 modetimer;
  787: 	time_t		 modelast;
  788: 	u_int		 modeprefix;
  789: 
  790: 	TAILQ_ENTRY(window_pane) entry;
  791: 	RB_ENTRY(window_pane) tree_entry;
  792: };
  793: TAILQ_HEAD(window_panes, window_pane);
  794: RB_HEAD(window_pane_tree, window_pane);
  795: 
  796: /* Window structure. */
  797: struct window {
  798: 	u_int		 id;
  799: 
  800: 	char		*name;
  801: 	struct event	 name_event;
  802: 	struct timeval	 name_time;
  803: 
  804: 	struct event	 alerts_timer;
  805: 
  806: 	struct timeval	 activity_time;
  807: 
  808: 	struct window_pane *active;
  809: 	struct window_pane *last;
  810: 	struct window_panes panes;
  811: 
  812: 	int		 lastlayout;
  813: 	struct layout_cell *layout_root;
  814: 	struct layout_cell *saved_layout_root;
  815: 	char		*old_layout;
  816: 
  817: 	u_int		 sx;
  818: 	u_int		 sy;
  819: 
  820: 	int		 flags;
  821: #define WINDOW_BELL 0x1
  822: #define WINDOW_ACTIVITY 0x2
  823: /* 0x4 unused */
  824: #define WINDOW_SILENCE 0x8
  825: #define WINDOW_ZOOMED 0x1000
  826: #define WINDOW_FORCEWIDTH 0x2000
  827: #define WINDOW_FORCEHEIGHT 0x4000
  828: #define WINDOW_STYLECHANGED 0x8000
  829: #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
  830: 
  831: 	int		 alerts_queued;
  832: 	TAILQ_ENTRY(window) alerts_entry;
  833: 
  834: 	struct options	*options;
  835: 
  836: 	struct grid_cell style;
  837: 	struct grid_cell active_style;
  838: 
  839: 	u_int		 references;
  840: 	TAILQ_HEAD(, winlink) winlinks;
  841: 
  842: 	RB_ENTRY(window) entry;
  843: };
  844: RB_HEAD(windows, window);
  845: 
  846: /* Entry on local window list. */
  847: struct winlink {
  848: 	int		 idx;
  849: 	struct session	*session;
  850: 	struct window	*window;
  851: 
  852: 	size_t		 status_width;
  853: 	struct grid_cell status_cell;
  854: 	char		*status_text;
  855: 
  856: 	int		 flags;
  857: #define WINLINK_BELL 0x1
  858: #define WINLINK_ACTIVITY 0x2
  859: #define WINLINK_SILENCE 0x4
  860: #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
  861: 
  862: 	RB_ENTRY(winlink) entry;
  863: 	TAILQ_ENTRY(winlink) wentry;
  864: 	TAILQ_ENTRY(winlink) sentry;
  865: };
  866: RB_HEAD(winlinks, winlink);
  867: TAILQ_HEAD(winlink_stack, winlink);
  868: 
  869: /* Layout direction. */
  870: enum layout_type {
  871: 	LAYOUT_LEFTRIGHT,
  872: 	LAYOUT_TOPBOTTOM,
  873: 	LAYOUT_WINDOWPANE
  874: };
  875: 
  876: /* Layout cells queue. */
  877: TAILQ_HEAD(layout_cells, layout_cell);
  878: 
  879: /* Layout cell. */
  880: struct layout_cell {
  881: 	enum layout_type type;
  882: 
  883: 	struct layout_cell *parent;
  884: 
  885: 	u_int		 sx;
  886: 	u_int		 sy;
  887: 
  888: 	u_int		 xoff;
  889: 	u_int		 yoff;
  890: 
  891: 	struct window_pane *wp;
  892: 	struct layout_cells cells;
  893: 
  894: 	TAILQ_ENTRY(layout_cell) entry;
  895: };
  896: 
  897: /* Environment variable. */
  898: struct environ_entry {
  899: 	char		*name;
  900: 	char		*value;
  901: 
  902: 	RB_ENTRY(environ_entry) entry;
  903: };
  904: 
  905: /* Client session. */
  906: struct session_group {
  907: 	const char		*name;
  908: 	TAILQ_HEAD(, session)	 sessions;
  909: 
  910: 	RB_ENTRY(session_group)	 entry;
  911: };
  912: RB_HEAD(session_groups, session_group);
  913: 
  914: struct session {
  915: 	u_int		 id;
  916: 
  917: 	char		*name;
  918: 	const char	*cwd;
  919: 
  920: 	struct timeval	 creation_time;
  921: 	struct timeval	 last_attached_time;
  922: 	struct timeval	 activity_time;
  923: 	struct timeval	 last_activity_time;
  924: 
  925: 	struct event	 lock_timer;
  926: 
  927: 	u_int		 sx;
  928: 	u_int		 sy;
  929: 
  930: 	struct winlink	*curw;
  931: 	struct winlink_stack lastw;
  932: 	struct winlinks	 windows;
  933: 
  934: 	int		 statusat;
  935: 
  936: 	struct hooks	*hooks;
  937: 	struct options	*options;
  938: 
  939: #define SESSION_UNATTACHED 0x1	/* not attached to any clients */
  940: #define SESSION_PASTING 0x2
  941: #define SESSION_ALERTED 0x4
  942: 	int		 flags;
  943: 
  944: 	u_int		 attached;
  945: 
  946: 	struct termios	*tio;
  947: 
  948: 	struct environ	*environ;
  949: 
  950: 	int		 references;
  951: 
  952: 	TAILQ_ENTRY(session) gentry;
  953: 	RB_ENTRY(session)    entry;
  954: };
  955: RB_HEAD(sessions, session);
  956: 
  957: /* Mouse button masks. */
  958: #define MOUSE_MASK_BUTTONS 3
  959: #define MOUSE_MASK_SHIFT 4
  960: #define MOUSE_MASK_META 8
  961: #define MOUSE_MASK_CTRL 16
  962: #define MOUSE_MASK_DRAG 32
  963: #define MOUSE_MASK_WHEEL 64
  964: 
  965: /* Mouse wheel states. */
  966: #define MOUSE_WHEEL_UP 0
  967: #define MOUSE_WHEEL_DOWN 64
  968: 
  969: /* Mouse helpers. */
  970: #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
  971: #define MOUSE_WHEEL(b) ((b) & MOUSE_MASK_WHEEL)
  972: #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
  973: #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
  974: 
  975: /* Mouse input. */
  976: struct mouse_event {
  977: 	int		valid;
  978: 
  979: 	key_code	key;
  980: 	int		statusat;
  981: 
  982: 	u_int		x;
  983: 	u_int		y;
  984: 	u_int		b;
  985: 
  986: 	u_int		lx;
  987: 	u_int		ly;
  988: 	u_int		lb;
  989: 
  990: 	int		s;
  991: 	int		w;
  992: 	int		wp;
  993: 
  994: 	u_int		sgr_type;
  995: 	u_int		sgr_b;
  996: };
  997: 
  998: /* TTY information. */
  999: struct tty_key {
 1000: 	char		 ch;
 1001: 	key_code	 key;
 1002: 
 1003: 	struct tty_key	*left;
 1004: 	struct tty_key	*right;
 1005: 
 1006: 	struct tty_key	*next;
 1007: };
 1008: 
 1009: struct tty_code;
 1010: struct tty_term {
 1011: 	char		*name;
 1012: 	u_int		 references;
 1013: 
 1014: 	char		 acs[UCHAR_MAX + 1][2];
 1015: 
 1016: 	struct tty_code	*codes;
 1017: 
 1018: #define TERM_256COLOURS 0x1
 1019: #define TERM_EARLYWRAP 0x2
 1020: 	int		 flags;
 1021: 
 1022: 	LIST_ENTRY(tty_term) entry;
 1023: };
 1024: LIST_HEAD(tty_terms, tty_term);
 1025: 
 1026: struct tty {
 1027: 	struct client	*client;
 1028: 
 1029: 	u_int		 sx;
 1030: 	u_int		 sy;
 1031: 
 1032: 	u_int		 cx;
 1033: 	u_int		 cy;
 1034: 	u_int		 cstyle;
 1035: 	char		*ccolour;
 1036: 
 1037: 	int		 mode;
 1038: 
 1039: 	u_int		 rlower;
 1040: 	u_int		 rupper;
 1041: 
 1042: 	u_int		 rleft;
 1043: 	u_int		 rright;
 1044: 
 1045: 	int		 fd;
 1046: 	struct event	 event_in;
 1047: 	struct evbuffer	*in;
 1048: 	struct event	 event_out;
 1049: 	struct evbuffer	*out;
 1050: 	size_t		 written;
 1051: 
 1052: 	struct termios	 tio;
 1053: 
 1054: 	struct grid_cell cell;
 1055: 
 1056: 	int		 last_wp;
 1057: 	struct grid_cell last_cell;
 1058: 
 1059: #define TTY_NOCURSOR 0x1
 1060: #define TTY_FREEZE 0x2
 1061: #define TTY_TIMER 0x4
 1062: #define TTY_UTF8 0x8
 1063: #define TTY_STARTED 0x10
 1064: #define TTY_OPENED 0x20
 1065: #define TTY_FOCUS 0x40
 1066: 	int		 flags;
 1067: 
 1068: 	struct tty_term	*term;
 1069: 	char		*term_name;
 1070: 	int		 term_flags;
 1071: 	enum {
 1072: 		TTY_VT100,
 1073: 		TTY_VT101,
 1074: 		TTY_VT102,
 1075: 		TTY_VT220,
 1076: 		TTY_VT320,
 1077: 		TTY_VT420,
 1078: 		TTY_UNKNOWN
 1079: 	} term_type;
 1080: 
 1081: 	struct mouse_event mouse;
 1082: 	int		 mouse_drag_flag;
 1083: 	void		(*mouse_drag_update)(struct client *,
 1084: 			    struct mouse_event *);
 1085: 	void		(*mouse_drag_release)(struct client *,
 1086: 			    struct mouse_event *);
 1087: 
 1088: 	struct event	 key_timer;
 1089: 	struct tty_key	*key_tree;
 1090: };
 1091: #define TTY_TYPES \
 1092: 	{ "VT100", "VT101", "VT102", "VT220", "VT320", "VT420", "UNKNOWN" }
 1093: 
 1094: /* TTY command context. */
 1095: struct tty_ctx {
 1096: 	struct window_pane	*wp;
 1097: 
 1098: 	const struct grid_cell	*cell;
 1099: 
 1100: 	u_int		 num;
 1101: 	void		*ptr;
 1102: 
 1103: 	/*
 1104: 	 * Cursor and region position before the screen was updated - this is
 1105: 	 * where the command should be applied; the values in the screen have
 1106: 	 * already been updated.
 1107: 	 */
 1108: 	u_int		 ocx;
 1109: 	u_int		 ocy;
 1110: 
 1111: 	u_int		 orupper;
 1112: 	u_int		 orlower;
 1113: 
 1114: 	u_int		 xoff;
 1115: 	u_int		 yoff;
 1116: 
 1117: 	/* The background colour used for clearing (erasing). */
 1118: 	u_int		 bg;
 1119: };
 1120: 
 1121: /* Saved message entry. */
 1122: struct message_entry {
 1123: 	char	*msg;
 1124: 	u_int	 msg_num;
 1125: 	time_t	 msg_time;
 1126: 	TAILQ_ENTRY(message_entry) entry;
 1127: };
 1128: 
 1129: /* Parsed arguments structures. */
 1130: struct args_entry;
 1131: RB_HEAD(args_tree, args_entry);
 1132: struct args {
 1133: 	struct args_tree	  tree;
 1134: 	int			  argc;
 1135: 	char			**argv;
 1136: };
 1137: 
 1138: /* Command find structures. */
 1139: enum cmd_find_type {
 1140: 	CMD_FIND_PANE,
 1141: 	CMD_FIND_WINDOW,
 1142: 	CMD_FIND_SESSION,
 1143: };
 1144: struct cmd_find_state {
 1145: 	struct cmdq_item	*item;
 1146: 	int			 flags;
 1147: 	struct cmd_find_state	*current;
 1148: 
 1149: 	struct session		*s;
 1150: 	struct winlink		*wl;
 1151: 	struct window		*w;
 1152: 	struct window_pane	*wp;
 1153: 	int			 idx;
 1154: };
 1155: 
 1156: /* Command find flags. */
 1157: #define CMD_FIND_PREFER_UNATTACHED 0x1
 1158: #define CMD_FIND_QUIET 0x2
 1159: #define CMD_FIND_WINDOW_INDEX 0x4
 1160: #define CMD_FIND_DEFAULT_MARKED 0x8
 1161: #define CMD_FIND_EXACT_SESSION 0x10
 1162: #define CMD_FIND_EXACT_WINDOW 0x20
 1163: 
 1164: /* Context for command being executed. */
 1165: struct cmd_state {
 1166: 	struct client		*c;
 1167: 	struct cmd_find_state	 tflag;
 1168: 	struct cmd_find_state	 sflag;
 1169: };
 1170: 
 1171: /* Command and list of commands. */
 1172: struct cmd {
 1173: 	const struct cmd_entry	*entry;
 1174: 	struct args		*args;
 1175: 
 1176: 	char			*file;
 1177: 	u_int			 line;
 1178: 
 1179: #define CMD_CONTROL 0x1
 1180: 	int			 flags;
 1181: 
 1182: 	TAILQ_ENTRY(cmd)	 qentry;
 1183: };
 1184: 
 1185: struct cmd_list {
 1186: 	int			 references;
 1187: 	TAILQ_HEAD(, cmd)	 list;
 1188: };
 1189: 
 1190: /* Command return values. */
 1191: enum cmd_retval {
 1192: 	CMD_RETURN_ERROR = -1,
 1193: 	CMD_RETURN_NORMAL = 0,
 1194: 	CMD_RETURN_WAIT,
 1195: 	CMD_RETURN_STOP
 1196: };
 1197: 
 1198: /* Command queue item type. */
 1199: enum cmdq_type {
 1200: 	CMDQ_COMMAND,
 1201: 	CMDQ_CALLBACK,
 1202: };
 1203: 
 1204: /* Command queue item. */
 1205: typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
 1206: struct cmdq_item {
 1207: 	const char		*name;
 1208: 	struct cmdq_list	*queue;
 1209: 	struct cmdq_item	*next;
 1210: 
 1211: 	struct client		*client;
 1212: 
 1213: 	enum cmdq_type		 type;
 1214: 	u_int			 group;
 1215: 
 1216: 	u_int			 number;
 1217: 	time_t			 time;
 1218: 
 1219: 	struct format_tree	*formats;
 1220: 
 1221: 	int			 flags;
 1222: #define CMDQ_FIRED 0x1
 1223: #define CMDQ_WAITING 0x2
 1224: #define CMDQ_NOHOOKS 0x4
 1225: 
 1226: 	struct cmd_list		*cmdlist;
 1227: 	struct cmd		*cmd;
 1228: 	int			 repeat;
 1229: 
 1230: 	cmdq_cb			 cb;
 1231: 	void			*data;
 1232: 
 1233: 	struct cmd_find_state	 current;
 1234: 	struct cmd_state	 state;
 1235: 
 1236: 	struct mouse_event	 mouse;
 1237: 
 1238: 	TAILQ_ENTRY(cmdq_item)	 entry;
 1239: };
 1240: TAILQ_HEAD(cmdq_list, cmdq_item);
 1241: 
 1242: /* Command -c, -t or -s flags. */
 1243: enum cmd_entry_flag {
 1244: 	CMD_NONE,
 1245: 
 1246: 	CMD_CLIENT,
 1247: 	CMD_CLIENT_CANFAIL,
 1248: 
 1249: 	CMD_SESSION,
 1250: 	CMD_SESSION_CANFAIL,
 1251: 	CMD_SESSION_PREFERUNATTACHED,
 1252: 	CMD_SESSION_WITHPANE, /* implies PREFERUNATTACHED */
 1253: 
 1254: 	CMD_WINDOW,
 1255: 	CMD_WINDOW_CANFAIL,
 1256: 	CMD_WINDOW_MARKED,
 1257: 	CMD_WINDOW_INDEX,
 1258: 
 1259: 	CMD_PANE,
 1260: 	CMD_PANE_CANFAIL,
 1261: 	CMD_PANE_MARKED,
 1262: 
 1263: 	CMD_MOVEW_R,
 1264: };
 1265: 
 1266: /* Command definition. */
 1267: struct cmd_entry {
 1268: 	const char		*name;
 1269: 	const char		*alias;
 1270: 
 1271: 	struct {
 1272: 		const char	*template;
 1273: 		int		 lower;
 1274: 		int		 upper;
 1275: 	} args;
 1276: 	const char		*usage;
 1277: 
 1278: 	enum cmd_entry_flag	 tflag;
 1279: 	enum cmd_entry_flag	 sflag;
 1280: 	enum cmd_entry_flag	 cflag;
 1281: 
 1282: #define CMD_STARTSERVER 0x1
 1283: #define CMD_READONLY 0x2
 1284: #define CMD_AFTERHOOK 0x4
 1285: 	int		 flags;
 1286: 
 1287: 	enum cmd_retval		 (*exec)(struct cmd *, struct cmdq_item *);
 1288: };
 1289: 
 1290: /* Client connection. */
 1291: struct client {
 1292: 	const char	*name;
 1293: 	struct tmuxpeer	*peer;
 1294: 	struct cmdq_list queue;
 1295: 
 1296: 	pid_t		 pid;
 1297: 	int		 fd;
 1298: 	struct event	 event;
 1299: 	int		 retval;
 1300: 
 1301: 	struct timeval	 creation_time;
 1302: 	struct timeval	 activity_time;
 1303: 
 1304: 	struct environ	*environ;
 1305: 
 1306: 	char		*title;
 1307: 	const char	*cwd;
 1308: 
 1309: 	char		*term;
 1310: 	char		*ttyname;
 1311: 	struct tty	 tty;
 1312: 
 1313: 	void		(*stdin_callback)(struct client *, int, void *);
 1314: 	void		*stdin_callback_data;
 1315: 	struct evbuffer	*stdin_data;
 1316: 	int		 stdin_closed;
 1317: 	struct evbuffer	*stdout_data;
 1318: 	struct evbuffer	*stderr_data;
 1319: 
 1320: 	struct event	 repeat_timer;
 1321: 
 1322: 	struct event	 click_timer;
 1323: 	u_int		 click_button;
 1324: 
 1325: 	struct event	 status_timer;
 1326: 	struct screen	 status;
 1327: 
 1328: #define CLIENT_TERMINAL 0x1
 1329: #define CLIENT_LOGIN 0x2
 1330: #define CLIENT_EXIT 0x4
 1331: #define CLIENT_REDRAW 0x8
 1332: #define CLIENT_STATUS 0x10
 1333: #define CLIENT_REPEAT 0x20
 1334: #define CLIENT_SUSPENDED 0x40
 1335: #define CLIENT_ATTACHED 0x80
 1336: #define CLIENT_IDENTIFY 0x100
 1337: #define CLIENT_DEAD 0x200
 1338: #define CLIENT_BORDERS 0x400
 1339: #define CLIENT_READONLY 0x800
 1340: /* 0x1000 unused */
 1341: #define CLIENT_CONTROL 0x2000
 1342: #define CLIENT_CONTROLCONTROL 0x4000
 1343: #define CLIENT_FOCUSED 0x8000
 1344: #define CLIENT_UTF8 0x10000
 1345: #define CLIENT_256COLOURS 0x20000
 1346: #define CLIENT_IDENTIFIED 0x40000
 1347: #define CLIENT_STATUSFORCE 0x80000
 1348: #define CLIENT_DOUBLECLICK 0x100000
 1349: #define CLIENT_TRIPLECLICK 0x200000
 1350: 	int		 flags;
 1351: 	struct key_table *keytable;
 1352: 
 1353: 	struct event	 identify_timer;
 1354: 	void		(*identify_callback)(struct client *, struct window_pane *);
 1355: 	void		*identify_callback_data;
 1356: 
 1357: 	char		*message_string;
 1358: 	struct event	 message_timer;
 1359: 	u_int		 message_next;
 1360: 	TAILQ_HEAD(, message_entry) message_log;
 1361: 
 1362: 	char		*prompt_string;
 1363: 	struct utf8_data *prompt_buffer;
 1364: 	size_t		 prompt_index;
 1365: 	int		 (*prompt_callbackfn)(void *, const char *, int);
 1366: 	void		 (*prompt_freefn)(void *);
 1367: 	void		*prompt_data;
 1368: 	u_int		 prompt_hindex;
 1369: 	enum { PROMPT_ENTRY, PROMPT_COMMAND } prompt_mode;
 1370: 
 1371: #define PROMPT_SINGLE 0x1
 1372: #define PROMPT_NUMERIC 0x2
 1373: #define PROMPT_INCREMENTAL 0x4
 1374: 	int		 prompt_flags;
 1375: 
 1376: 	struct session	*session;
 1377: 	struct session	*last_session;
 1378: 
 1379: 	int		 wlmouse;
 1380: 
 1381: 	int		 references;
 1382: 
 1383: 	TAILQ_ENTRY(client) entry;
 1384: };
 1385: TAILQ_HEAD(clients, client);
 1386: 
 1387: /* Key binding and key table. */
 1388: struct key_binding {
 1389: 	key_code		 key;
 1390: 	struct cmd_list		*cmdlist;
 1391: 	int			 can_repeat;
 1392: 
 1393: 	RB_ENTRY(key_binding)	 entry;
 1394: };
 1395: RB_HEAD(key_bindings, key_binding);
 1396: 
 1397: struct key_table {
 1398: 	const char		 *name;
 1399: 	struct key_bindings	 key_bindings;
 1400: 
 1401: 	u_int			 references;
 1402: 
 1403: 	RB_ENTRY(key_table)	 entry;
 1404: };
 1405: RB_HEAD(key_tables, key_table);
 1406: 
 1407: /* Option table entries. */
 1408: enum options_table_type {
 1409: 	OPTIONS_TABLE_STRING,
 1410: 	OPTIONS_TABLE_NUMBER,
 1411: 	OPTIONS_TABLE_KEY,
 1412: 	OPTIONS_TABLE_COLOUR,
 1413: 	OPTIONS_TABLE_ATTRIBUTES,
 1414: 	OPTIONS_TABLE_FLAG,
 1415: 	OPTIONS_TABLE_CHOICE,
 1416: 	OPTIONS_TABLE_STYLE,
 1417: 	OPTIONS_TABLE_ARRAY,
 1418: };
 1419: enum options_table_scope {
 1420: 	OPTIONS_TABLE_NONE,
 1421: 	OPTIONS_TABLE_SERVER,
 1422: 	OPTIONS_TABLE_SESSION,
 1423: 	OPTIONS_TABLE_WINDOW,
 1424: };
 1425: 
 1426: struct options_table_entry {
 1427: 	const char		 *name;
 1428: 	enum options_table_type	  type;
 1429: 	enum options_table_scope  scope;
 1430: 
 1431: 	u_int			  minimum;
 1432: 	u_int			  maximum;
 1433: 	const char		**choices;
 1434: 
 1435: 	const char		 *default_str;
 1436: 	long long		  default_num;
 1437: 
 1438: 	const char		 *separator;
 1439: 	const char		 *style;
 1440: };
 1441: 
 1442: /* Common command usages. */
 1443: #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
 1444: #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
 1445: #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
 1446: #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
 1447: #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
 1448: #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
 1449: #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
 1450: #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
 1451: #define CMD_BUFFER_USAGE "[-b buffer-name]"
 1452: 
 1453: /* tmux.c */
 1454: extern struct hooks	*global_hooks;
 1455: extern struct options	*global_options;
 1456: extern struct options	*global_s_options;
 1457: extern struct options	*global_w_options;
 1458: extern struct environ	*global_environ;
 1459: extern struct timeval	 start_time;
 1460: extern const char	*socket_path;
 1461: extern int		 ptm_fd;
 1462: int		 areshell(const char *);
 1463: void		 setblocking(int, int);
 1464: const char	*find_home(void);
 1465: 
 1466: /* proc.c */
 1467: struct imsg;
 1468: int	proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t);
 1469: int	proc_send_s(struct tmuxpeer *, enum msgtype, const char *);
 1470: struct tmuxproc *proc_start(const char *, struct event_base *, int,
 1471: 	    void (*)(int));
 1472: void	proc_loop(struct tmuxproc *, int (*)(void));
 1473: void	proc_exit(struct tmuxproc *);
 1474: struct tmuxpeer *proc_add_peer(struct tmuxproc *, int,
 1475: 	    void (*)(struct imsg *, void *), void *);
 1476: void	proc_remove_peer(struct tmuxpeer *);
 1477: void	proc_kill_peer(struct tmuxpeer *);
 1478: 
 1479: /* cfg.c */
 1480: extern int cfg_finished;
 1481: extern struct client *cfg_client;
 1482: void	start_cfg(void);
 1483: int	load_cfg(const char *, struct client *, struct cmdq_item *, int);
 1484: void	set_cfg_file(const char *);
 1485: void printflike(1, 2) cfg_add_cause(const char *, ...);
 1486: void	cfg_print_causes(struct cmdq_item *);
 1487: void	cfg_show_causes(struct session *);
 1488: 
 1489: /* paste.c */
 1490: struct paste_buffer;
 1491: const char	*paste_buffer_name(struct paste_buffer *);
 1492: u_int		 paste_buffer_order(struct paste_buffer *);
 1493: time_t		 paste_buffer_created(struct paste_buffer *);
 1494: const char	*paste_buffer_data(struct paste_buffer *, size_t *);
 1495: struct paste_buffer *paste_walk(struct paste_buffer *);
 1496: struct paste_buffer *paste_get_top(const char **);
 1497: struct paste_buffer *paste_get_name(const char *);
 1498: void		 paste_free(struct paste_buffer *);
 1499: void		 paste_add(char *, size_t);
 1500: int		 paste_rename(const char *, const char *, char **);
 1501: int		 paste_set(char *, size_t, const char *, char **);
 1502: char		*paste_make_sample(struct paste_buffer *);
 1503: 
 1504: /* format.c */
 1505: #define FORMAT_STATUS 0x1
 1506: #define FORMAT_FORCE 0x2
 1507: #define FORMAT_NOJOBS 0x4
 1508: #define FORMAT_NONE 0
 1509: #define FORMAT_PANE 0x80000000U
 1510: #define FORMAT_WINDOW 0x40000000U
 1511: struct format_tree;
 1512: struct format_tree *format_create(struct cmdq_item *, int, int);
 1513: void		 format_free(struct format_tree *);
 1514: void printflike(3, 4) format_add(struct format_tree *, const char *,
 1515: 		     const char *, ...);
 1516: char		*format_expand_time(struct format_tree *, const char *, time_t);
 1517: char		*format_expand(struct format_tree *, const char *);
 1518: char		*format_single(struct cmdq_item *, const char *,
 1519: 		     struct client *, struct session *, struct winlink *,
 1520: 		     struct window_pane *);
 1521: void		 format_defaults(struct format_tree *, struct client *,
 1522: 		     struct session *, struct winlink *, struct window_pane *);
 1523: void		 format_defaults_window(struct format_tree *, struct window *);
 1524: void		 format_defaults_pane(struct format_tree *,
 1525: 		     struct window_pane *);
 1526: void		 format_defaults_paste_buffer(struct format_tree *,
 1527: 		     struct paste_buffer *);
 1528: 
 1529: /* hooks.c */
 1530: struct hook;
 1531: struct hooks	*hooks_get(struct session *);
 1532: struct hooks	*hooks_create(struct hooks *);
 1533: void		 hooks_free(struct hooks *);
 1534: struct hook	*hooks_first(struct hooks *);
 1535: struct hook	*hooks_next(struct hook *);
 1536: void		 hooks_add(struct hooks *, const char *, struct cmd_list *);
 1537: void		 hooks_copy(struct hooks *, struct hooks *);
 1538: void		 hooks_remove(struct hooks *, const char *);
 1539: struct hook	*hooks_find(struct hooks *, const char *);
 1540: void printflike(4, 5) hooks_run(struct hooks *, struct client *,
 1541: 		    struct cmd_find_state *, const char *, ...);
 1542: void printflike(4, 5) hooks_insert(struct hooks *, struct cmdq_item *,
 1543: 		    struct cmd_find_state *, const char *, ...);
 1544: 
 1545: /* notify.c */
 1546: void	notify_input(struct window_pane *, struct evbuffer *);
 1547: void	notify_client(const char *, struct client *);
 1548: void	notify_session(const char *, struct session *);
 1549: void	notify_winlink(const char *, struct session *, struct winlink *);
 1550: void	notify_session_window(const char *, struct session *, struct window *);
 1551: void	notify_window(const char *, struct window *);
 1552: void	notify_pane(const char *, struct window_pane *);
 1553: 
 1554: /* options.c */
 1555: struct options	*options_create(struct options *);
 1556: void		 options_free(struct options *);
 1557: struct options_entry *options_first(struct options *);
 1558: struct options_entry *options_next(struct options_entry *);
 1559: struct options_entry *options_empty(struct options *,
 1560: 		     const struct options_table_entry *);
 1561: struct options_entry *options_default(struct options *,
 1562: 		     const struct options_table_entry *);
 1563: const char	*options_name(struct options_entry *);
 1564: const struct options_table_entry *options_table_entry(struct options_entry *);
 1565: struct options_entry *options_get_only(struct options *, const char *);
 1566: struct options_entry *options_get(struct options *, const char *);
 1567: void		 options_remove(struct options_entry *);
 1568: void		 options_array_clear(struct options_entry *);
 1569: const char	*options_array_get(struct options_entry *, u_int);
 1570: int		 options_array_set(struct options_entry *, u_int, const char *,
 1571: 		     int);
 1572: int		 options_array_size(struct options_entry *, u_int *);
 1573: void		 options_array_assign(struct options_entry *, const char *);
 1574: int		 options_isstring(struct options_entry *);
 1575: const char	*options_tostring(struct options_entry *, int, int);
 1576: char		*options_parse(const char *, int *);
 1577: struct options_entry *options_parse_get(struct options *, const char *, int *,
 1578: 		     int);
 1579: char		*options_match(const char *, int *, int *);
 1580: struct options_entry *options_match_get(struct options *, const char *, int *,
 1581: 		     int, int *);
 1582: const char	*options_get_string(struct options *, const char *);
 1583: long long	 options_get_number(struct options *, const char *);
 1584: const struct grid_cell *options_get_style(struct options *, const char *);
 1585: struct options_entry * printflike(4, 5) options_set_string(struct options *,
 1586: 		     const char *, int, const char *, ...);
 1587: struct options_entry *options_set_number(struct options *, const char *,
 1588: 		     long long);
 1589: struct options_entry *options_set_style(struct options *, const char *, int,
 1590: 		     const char *);
 1591: enum options_table_scope options_scope_from_flags(struct args *, int,
 1592: 		     struct cmd_find_state *, struct options **, char **);
 1593: void		 options_style_update_new(struct options *,
 1594: 		     struct options_entry *);
 1595: void		 options_style_update_old(struct options *,
 1596: 		     struct options_entry *);
 1597: 
 1598: /* options-table.c */
 1599: extern const struct options_table_entry options_table[];
 1600: 
 1601: /* job.c */
 1602: extern struct joblist all_jobs;
 1603: struct job *job_run(const char *, struct session *, const char *,
 1604: 	    void (*)(struct job *), void (*)(void *), void *);
 1605: void	job_free(struct job *);
 1606: void	job_died(struct job *, int);
 1607: 
 1608: /* environ.c */
 1609: struct environ *environ_create(void);
 1610: void	environ_free(struct environ *);
 1611: struct environ_entry *environ_first(struct environ *);
 1612: struct environ_entry *environ_next(struct environ_entry *);
 1613: void	environ_copy(struct environ *, struct environ *);
 1614: struct environ_entry *environ_find(struct environ *, const char *);
 1615: void printflike(3, 4) environ_set(struct environ *, const char *, const char *,
 1616: 	    ...);
 1617: void	environ_clear(struct environ *, const char *);
 1618: void	environ_put(struct environ *, const char *);
 1619: void	environ_unset(struct environ *, const char *);
 1620: void	environ_update(struct options *, struct environ *, struct environ *);
 1621: void	environ_push(struct environ *);
 1622: void	environ_log(struct environ *, const char *);
 1623: struct environ *environ_for_session(struct session *);
 1624: 
 1625: /* tty.c */
 1626: void	tty_create_log(void);
 1627: void	tty_raw(struct tty *, const char *);
 1628: void	tty_attributes(struct tty *, const struct grid_cell *,
 1629: 	    const struct window_pane *);
 1630: void	tty_reset(struct tty *);
 1631: void	tty_region_off(struct tty *);
 1632: void	tty_margin_off(struct tty *);
 1633: void	tty_cursor(struct tty *, u_int, u_int);
 1634: void	tty_putcode(struct tty *, enum tty_code_code);
 1635: void	tty_putcode1(struct tty *, enum tty_code_code, int);
 1636: void	tty_putcode2(struct tty *, enum tty_code_code, int, int);
 1637: void	tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
 1638: void	tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *,
 1639: 	    const void *);
 1640: void	tty_puts(struct tty *, const char *);
 1641: void	tty_putc(struct tty *, u_char);
 1642: void	tty_putn(struct tty *, const void *, size_t, u_int);
 1643: int	tty_init(struct tty *, struct client *, int, char *);
 1644: int	tty_resize(struct tty *);
 1645: int	tty_set_size(struct tty *, u_int, u_int);
 1646: void	tty_start_tty(struct tty *);
 1647: void	tty_stop_tty(struct tty *);
 1648: void	tty_set_title(struct tty *, const char *);
 1649: void	tty_update_mode(struct tty *, int, struct screen *);
 1650: void	tty_draw_pane(struct tty *, const struct window_pane *, u_int, u_int,
 1651: 	    u_int);
 1652: void	tty_draw_line(struct tty *, const struct window_pane *, struct screen *,
 1653: 	    u_int, u_int, u_int);
 1654: int	tty_open(struct tty *, char **);
 1655: void	tty_close(struct tty *);
 1656: void	tty_free(struct tty *);
 1657: void	tty_set_type(struct tty *, int);
 1658: void	tty_write(void (*)(struct tty *, const struct tty_ctx *),
 1659: 	    struct tty_ctx *);
 1660: void	tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
 1661: void	tty_cmd_cell(struct tty *, const struct tty_ctx *);
 1662: void	tty_cmd_cells(struct tty *, const struct tty_ctx *);
 1663: void	tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
 1664: void	tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
 1665: void	tty_cmd_clearline(struct tty *, const struct tty_ctx *);
 1666: void	tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
 1667: void	tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
 1668: void	tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
 1669: void	tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
 1670: void	tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *);
 1671: void	tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
 1672: void	tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *);
 1673: void	tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
 1674: void	tty_cmd_insertline(struct tty *, const struct tty_ctx *);
 1675: void	tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
 1676: void	tty_cmd_scrollup(struct tty *, const struct tty_ctx *);
 1677: void	tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
 1678: void	tty_cmd_setselection(struct tty *, const struct tty_ctx *);
 1679: void	tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
 1680: 
 1681: /* tty-term.c */
 1682: extern struct tty_terms tty_terms;
 1683: u_int		 tty_term_ncodes(void);
 1684: struct tty_term *tty_term_find(char *, int, char **);
 1685: void		 tty_term_free(struct tty_term *);
 1686: int		 tty_term_has(struct tty_term *, enum tty_code_code);
 1687: const char	*tty_term_string(struct tty_term *, enum tty_code_code);
 1688: const char	*tty_term_string1(struct tty_term *, enum tty_code_code, int);
 1689: const char	*tty_term_string2(struct tty_term *, enum tty_code_code, int,
 1690: 		     int);
 1691: const char	*tty_term_ptr1(struct tty_term *, enum tty_code_code,
 1692: 		     const void *);
 1693: const char	*tty_term_ptr2(struct tty_term *, enum tty_code_code,
 1694: 		     const void *, const void *);
 1695: int		 tty_term_number(struct tty_term *, enum tty_code_code);
 1696: int		 tty_term_flag(struct tty_term *, enum tty_code_code);
 1697: const char	*tty_term_describe(struct tty_term *, enum tty_code_code);
 1698: 
 1699: /* tty-acs.c */
 1700: const char	*tty_acs_get(struct tty *, u_char);
 1701: 
 1702: /* tty-keys.c */
 1703: void		tty_keys_build(struct tty *);
 1704: void		tty_keys_free(struct tty *);
 1705: key_code	tty_keys_next(struct tty *);
 1706: 
 1707: /* arguments.c */
 1708: struct args	*args_parse(const char *, int, char **);
 1709: void		 args_free(struct args *);
 1710: char		*args_print(struct args *);
 1711: int		 args_has(struct args *, u_char);
 1712: const char	*args_get(struct args *, u_char);
 1713: long long	 args_strtonum(struct args *, u_char, long long, long long,
 1714: 		     char **);
 1715: 
 1716: /* cmd-find.c */
 1717: int		 cmd_find_current(struct cmd_find_state *, struct cmdq_item *,
 1718: 		     int);
 1719: int		 cmd_find_target(struct cmd_find_state *,
 1720: 		     struct cmd_find_state *, struct cmdq_item *, const char *,
 1721: 		     enum cmd_find_type, int);
 1722: struct client	*cmd_find_client(struct cmdq_item *, const char *, int);
 1723: void		 cmd_find_clear_state(struct cmd_find_state *,
 1724: 		     struct cmdq_item *, int);
 1725: int		 cmd_find_empty_state(struct cmd_find_state *);
 1726: int		 cmd_find_valid_state(struct cmd_find_state *);
 1727: void		 cmd_find_copy_state(struct cmd_find_state *,
 1728: 		     struct cmd_find_state *);
 1729: void		 cmd_find_log_state(const char *, struct cmd_find_state *);
 1730: int		 cmd_find_from_session(struct cmd_find_state *,
 1731: 		     struct session *);
 1732: int		 cmd_find_from_winlink(struct cmd_find_state *,
 1733: 		     struct session *, struct winlink *);
 1734: int		 cmd_find_from_session_window(struct cmd_find_state *,
 1735: 		     struct session *, struct window *);
 1736: int		 cmd_find_from_window(struct cmd_find_state *, struct window *);
 1737: int		 cmd_find_from_pane(struct cmd_find_state *,
 1738: 		     struct window_pane *);
 1739: 
 1740: /* cmd.c */
 1741: int		 cmd_pack_argv(int, char **, char *, size_t);
 1742: int		 cmd_unpack_argv(char *, size_t, int, char ***);
 1743: char	       **cmd_copy_argv(int, char **);
 1744: void		 cmd_free_argv(int, char **);
 1745: char		*cmd_stringify_argv(int, char **);
 1746: struct cmd	*cmd_parse(int, char **, const char *, u_int, char **);
 1747: int		 cmd_prepare_state(struct cmd *, struct cmdq_item *);
 1748: char		*cmd_print(struct cmd *);
 1749: int		 cmd_mouse_at(struct window_pane *, struct mouse_event *,
 1750: 		     u_int *, u_int *, int);
 1751: struct winlink	*cmd_mouse_window(struct mouse_event *, struct session **);
 1752: struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **,
 1753: 		     struct winlink **);
 1754: char		*cmd_template_replace(const char *, const char *, int);
 1755: extern const struct cmd_entry *cmd_table[];
 1756: 
 1757: /* cmd-attach-session.c */
 1758: enum cmd_retval	 cmd_attach_session(struct cmdq_item *, int, int, const char *,
 1759: 		     int);
 1760: 
 1761: /* cmd-list.c */
 1762: struct cmd_list	*cmd_list_parse(int, char **, const char *, u_int, char **);
 1763: void		 cmd_list_free(struct cmd_list *);
 1764: char		*cmd_list_print(struct cmd_list *);
 1765: 
 1766: /* cmd-queue.c */
 1767: struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *,
 1768: 		     struct mouse_event *, int);
 1769: #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
 1770: struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *);
 1771: void		 cmdq_insert_after(struct cmdq_item *, struct cmdq_item *);
 1772: void		 cmdq_append(struct client *, struct cmdq_item *);
 1773: void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *,
 1774: 		     const char *, ...);
 1775: u_int		 cmdq_next(struct client *);
 1776: void		 cmdq_guard(struct cmdq_item *, const char *, int);
 1777: void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
 1778: void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
 1779: 
 1780: /* cmd-string.c */
 1781: int		 cmd_string_split(const char *, int *, char ***);
 1782: struct cmd_list	*cmd_string_parse(const char *, const char *, u_int, char **);
 1783: 
 1784: /* cmd-wait-for.c */
 1785: void	cmd_wait_for_flush(void);
 1786: 
 1787: /* client.c */
 1788: int	client_main(struct event_base *, int, char **, int, const char *);
 1789: 
 1790: /* key-bindings.c */
 1791: RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
 1792: RB_PROTOTYPE(key_tables, key_table, entry, key_table_cmp);
 1793: extern struct key_tables key_tables;
 1794: int	 key_table_cmp(struct key_table *, struct key_table *);
 1795: int	 key_bindings_cmp(struct key_binding *, struct key_binding *);
 1796: struct key_table *key_bindings_get_table(const char *, int);
 1797: void	 key_bindings_unref_table(struct key_table *);
 1798: void	 key_bindings_add(const char *, key_code, int, struct cmd_list *);
 1799: void	 key_bindings_remove(const char *, key_code);
 1800: void	 key_bindings_remove_table(const char *);
 1801: void	 key_bindings_init(void);
 1802: void	 key_bindings_dispatch(struct key_binding *, struct client *,
 1803: 	     struct mouse_event *, struct cmd_find_state *);
 1804: 
 1805: /* key-string.c */
 1806: key_code	 key_string_lookup_string(const char *);
 1807: const char	*key_string_lookup_key(key_code);
 1808: 
 1809: /* alerts.c */
 1810: void	alerts_reset_all(void);
 1811: void	alerts_queue(struct window *, int);
 1812: void	alerts_check_session(struct session *);
 1813: 
 1814: /* server.c */
 1815: extern struct tmuxproc *server_proc;
 1816: extern struct clients clients;
 1817: extern struct cmd_find_state marked_pane;
 1818: void	 server_set_marked(struct session *, struct winlink *,
 1819: 	     struct window_pane *);
 1820: void	 server_clear_marked(void);
 1821: int	 server_is_marked(struct session *, struct winlink *,
 1822: 	     struct window_pane *);
 1823: int	 server_check_marked(void);
 1824: int	 server_start(struct event_base *, int, char *);
 1825: void	 server_update_socket(void);
 1826: void	 server_add_accept(int);
 1827: 
 1828: /* server-client.c */
 1829: void	 server_client_set_identify(struct client *);
 1830: void	 server_client_clear_identify(struct client *, struct window_pane *);
 1831: void	 server_client_set_key_table(struct client *, const char *);
 1832: const char *server_client_get_key_table(struct client *);
 1833: int	 server_client_is_default_key_table(struct client *);
 1834: int	 server_client_check_nested(struct client *);
 1835: void	 server_client_handle_key(struct client *, key_code);
 1836: void	 server_client_create(int);
 1837: int	 server_client_open(struct client *, char **);
 1838: void	 server_client_unref(struct client *);
 1839: void	 server_client_lost(struct client *);
 1840: void	 server_client_detach(struct client *, enum msgtype);
 1841: void	 server_client_exec(struct client *, const char *);
 1842: void	 server_client_loop(void);
 1843: void	 server_client_push_stdout(struct client *);
 1844: void	 server_client_push_stderr(struct client *);
 1845: void printflike(2, 3) server_client_add_message(struct client *, const char *,
 1846: 	     ...);
 1847: char	*server_client_get_path(struct client *, const char *);
 1848: const char *server_client_get_cwd(struct client *);
 1849: 
 1850: /* server-fn.c */
 1851: void	 server_redraw_client(struct client *);
 1852: void	 server_status_client(struct client *);
 1853: void	 server_redraw_session(struct session *);
 1854: void	 server_redraw_session_group(struct session *);
 1855: void	 server_status_session(struct session *);
 1856: void	 server_status_session_group(struct session *);
 1857: void	 server_redraw_window(struct window *);
 1858: void	 server_redraw_window_borders(struct window *);
 1859: void	 server_status_window(struct window *);
 1860: void	 server_lock(void);
 1861: void	 server_lock_session(struct session *);
 1862: void	 server_lock_client(struct client *);
 1863: void	 server_kill_window(struct window *);
 1864: int	 server_link_window(struct session *,
 1865: 	     struct winlink *, struct session *, int, int, int, char **);
 1866: void	 server_unlink_window(struct session *, struct winlink *);
 1867: void	 server_destroy_pane(struct window_pane *, int);
 1868: void	 server_destroy_session(struct session *);
 1869: void	 server_check_unattached(void);
 1870: int	 server_set_stdin_callback(struct client *, void (*)(struct client *,
 1871: 	     int, void *), void *, char **);
 1872: void	 server_unzoom_window(struct window *);
 1873: 
 1874: /* status.c */
 1875: void	 status_timer_start(struct client *);
 1876: void	 status_timer_start_all(void);
 1877: void	 status_update_saved(struct session *s);
 1878: int	 status_at_line(struct client *);
 1879: struct window *status_get_window_at(struct client *, u_int);
 1880: int	 status_redraw(struct client *);
 1881: void printflike(2, 3) status_message_set(struct client *, const char *, ...);
 1882: void	 status_message_clear(struct client *);
 1883: int	 status_message_redraw(struct client *);
 1884: void	 status_prompt_set(struct client *, const char *, const char *,
 1885: 	     int (*)(void *, const char *, int), void (*)(void *), void *, int);
 1886: void	 status_prompt_clear(struct client *);
 1887: int	 status_prompt_redraw(struct client *);
 1888: int	 status_prompt_key(struct client *, key_code);
 1889: void	 status_prompt_update(struct client *, const char *, const char *);
 1890: void	 status_prompt_load_history(void);
 1891: void	 status_prompt_save_history(void);
 1892: 
 1893: /* resize.c */
 1894: void	 recalculate_sizes(void);
 1895: 
 1896: /* input.c */
 1897: void	 input_init(struct window_pane *);
 1898: void	 input_free(struct window_pane *);
 1899: void	 input_reset(struct window_pane *, int);
 1900: struct evbuffer *input_pending(struct window_pane *);
 1901: void	 input_parse(struct window_pane *);
 1902: 
 1903: /* input-key.c */
 1904: void	 input_key(struct window_pane *, key_code, struct mouse_event *);
 1905: 
 1906: /* xterm-keys.c */
 1907: char	*xterm_keys_lookup(key_code);
 1908: int	 xterm_keys_find(const char *, size_t, size_t *, key_code *);
 1909: 
 1910: /* colour.c */
 1911: int	 colour_find_rgb(u_char, u_char, u_char);
 1912: int	 colour_join_rgb(u_char, u_char, u_char);
 1913: void	 colour_split_rgb(int, u_char *, u_char *, u_char *);
 1914: const char *colour_tostring(int);
 1915: int	 colour_fromstring(const char *s);
 1916: u_char	 colour_256to16(u_char);
 1917: 
 1918: /* attributes.c */
 1919: const char *attributes_tostring(int);
 1920: int	 attributes_fromstring(const char *);
 1921: 
 1922: /* grid.c */
 1923: extern const struct grid_cell grid_default_cell;
 1924: int	 grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
 1925: struct grid *grid_create(u_int, u_int, u_int);
 1926: void	 grid_destroy(struct grid *);
 1927: int	 grid_compare(struct grid *, struct grid *);
 1928: void	 grid_collect_history(struct grid *, u_int);
 1929: void	 grid_scroll_history(struct grid *, u_int);
 1930: void	 grid_scroll_history_region(struct grid *, u_int, u_int);
 1931: void	 grid_clear_history(struct grid *);
 1932: const struct grid_line *grid_peek_line(struct grid *, u_int);
 1933: void	 grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
 1934: void	 grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
 1935: void	 grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *,
 1936: 	     const char *, size_t);
 1937: void	 grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
 1938: void	 grid_clear_lines(struct grid *, u_int, u_int, u_int);
 1939: void	 grid_move_lines(struct grid *, u_int, u_int, u_int, u_int);
 1940: void	 grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int);
 1941: char	*grid_string_cells(struct grid *, u_int, u_int, u_int,
 1942: 	     struct grid_cell **, int, int, int);
 1943: void	 grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
 1944: 	     u_int);
 1945: u_int	 grid_reflow(struct grid *, struct grid *, u_int);
 1946: 
 1947: /* grid-view.c */
 1948: void	 grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
 1949: void	 grid_view_set_cell(struct grid *, u_int, u_int,
 1950: 	     const struct grid_cell *);
 1951: void	 grid_view_set_cells(struct grid *, u_int, u_int,
 1952: 	     const struct grid_cell *, const char *, size_t);
 1953: void	 grid_view_clear_history(struct grid *, u_int);
 1954: void	 grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
 1955: void	 grid_view_scroll_region_up(struct grid *, u_int, u_int);
 1956: void	 grid_view_scroll_region_down(struct grid *, u_int, u_int);
 1957: void	 grid_view_insert_lines(struct grid *, u_int, u_int, u_int);
 1958: void	 grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int,
 1959: 	u_int);
 1960: void	 grid_view_delete_lines(struct grid *, u_int, u_int, u_int);
 1961: void	 grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int,
 1962: 	u_int);
 1963: void	 grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int);
 1964: void	 grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int);
 1965: char	*grid_view_string_cells(struct grid *, u_int, u_int, u_int);
 1966: 
 1967: /* screen-write.c */
 1968: void	 screen_write_start(struct screen_write_ctx *, struct window_pane *,
 1969: 	     struct screen *);
 1970: void	 screen_write_stop(struct screen_write_ctx *);
 1971: void	 screen_write_reset(struct screen_write_ctx *);
 1972: size_t printflike(1, 2) screen_write_cstrlen(const char *, ...);
 1973: void printflike(4, 5) screen_write_cnputs(struct screen_write_ctx *,
 1974: 	     ssize_t, const struct grid_cell *, const char *, ...);
 1975: size_t printflike(1, 2) screen_write_strlen(const char *, ...);
 1976: void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
 1977: 	     const struct grid_cell *, const char *, ...);
 1978: void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *,
 1979: 	     ssize_t, const struct grid_cell *, const char *, ...);
 1980: void	 screen_write_vnputs(struct screen_write_ctx *, ssize_t,
 1981: 	     const struct grid_cell *, const char *, va_list);
 1982: void	 screen_write_putc(struct screen_write_ctx *, const struct grid_cell *,
 1983: 	     u_char);
 1984: void	 screen_write_copy(struct screen_write_ctx *, struct screen *, u_int,
 1985: 	     u_int, u_int, u_int, bitstr_t *, const struct grid_cell *);
 1986: void	 screen_write_backspace(struct screen_write_ctx *);
 1987: void	 screen_write_mode_set(struct screen_write_ctx *, int);
 1988: void	 screen_write_mode_clear(struct screen_write_ctx *, int);
 1989: void	 screen_write_cursorup(struct screen_write_ctx *, u_int);
 1990: void	 screen_write_cursordown(struct screen_write_ctx *, u_int);
 1991: void	 screen_write_cursorright(struct screen_write_ctx *, u_int);
 1992: void	 screen_write_cursorleft(struct screen_write_ctx *, u_int);
 1993: void	 screen_write_alignmenttest(struct screen_write_ctx *);
 1994: void	 screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int);
 1995: void	 screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int);
 1996: void	 screen_write_clearcharacter(struct screen_write_ctx *, u_int);
 1997: void	 screen_write_insertline(struct screen_write_ctx *, u_int, u_int);
 1998: void	 screen_write_deleteline(struct screen_write_ctx *, u_int, u_int);
 1999: void	 screen_write_clearline(struct screen_write_ctx *, u_int);
 2000: void	 screen_write_clearendofline(struct screen_write_ctx *, u_int);
 2001: void	 screen_write_clearstartofline(struct screen_write_ctx *, u_int);
 2002: void	 screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
 2003: void	 screen_write_reverseindex(struct screen_write_ctx *);
 2004: void	 screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
 2005: void	 screen_write_linefeed(struct screen_write_ctx *, int);
 2006: void	 screen_write_scrollup(struct screen_write_ctx *, u_int);
 2007: void	 screen_write_carriagereturn(struct screen_write_ctx *);
 2008: void	 screen_write_clearendofscreen(struct screen_write_ctx *, u_int);
 2009: void	 screen_write_clearstartofscreen(struct screen_write_ctx *, u_int);
 2010: void	 screen_write_clearscreen(struct screen_write_ctx *, u_int);
 2011: void	 screen_write_clearhistory(struct screen_write_ctx *);
 2012: void	 screen_write_collect_end(struct screen_write_ctx *);
 2013: void	 screen_write_collect_add(struct screen_write_ctx *,
 2014: 	     const struct grid_cell *);
 2015: void	 screen_write_cell(struct screen_write_ctx *, const struct grid_cell *);
 2016: void	 screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
 2017: void	 screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
 2018: 
 2019: /* screen-redraw.c */
 2020: void	 screen_redraw_update(struct client *);
 2021: void	 screen_redraw_screen(struct client *, int, int, int);
 2022: void	 screen_redraw_pane(struct client *, struct window_pane *);
 2023: 
 2024: /* screen.c */
 2025: void	 screen_init(struct screen *, u_int, u_int, u_int);
 2026: void	 screen_reinit(struct screen *);
 2027: void	 screen_free(struct screen *);
 2028: void	 screen_reset_tabs(struct screen *);
 2029: void	 screen_set_cursor_style(struct screen *, u_int);
 2030: void	 screen_set_cursor_colour(struct screen *, const char *);
 2031: void	 screen_set_title(struct screen *, const char *);
 2032: void	 screen_resize(struct screen *, u_int, u_int, int);
 2033: void	 screen_set_selection(struct screen *,
 2034: 	     u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
 2035: void	 screen_clear_selection(struct screen *);
 2036: void	 screen_hide_selection(struct screen *);
 2037: int	 screen_check_selection(struct screen *, u_int, u_int);
 2038: void	 screen_select_cell(struct screen *, struct grid_cell *,
 2039: 	     const struct grid_cell *);
 2040: 
 2041: /* window.c */
 2042: extern struct windows windows;
 2043: extern struct window_pane_tree all_window_panes;
 2044: int		 window_cmp(struct window *, struct window *);
 2045: RB_PROTOTYPE(windows, window, entry, window_cmp);
 2046: int		 winlink_cmp(struct winlink *, struct winlink *);
 2047: RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
 2048: int		 window_pane_cmp(struct window_pane *, struct window_pane *);
 2049: RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
 2050: struct winlink	*winlink_find_by_index(struct winlinks *, int);
 2051: struct winlink	*winlink_find_by_window(struct winlinks *, struct window *);
 2052: struct winlink	*winlink_find_by_window_id(struct winlinks *, u_int);
 2053: u_int		 winlink_count(struct winlinks *);
 2054: struct winlink	*winlink_add(struct winlinks *, int);
 2055: void		 winlink_set_window(struct winlink *, struct window *);
 2056: void		 winlink_remove(struct winlinks *, struct winlink *);
 2057: struct winlink	*winlink_next(struct winlink *);
 2058: struct winlink	*winlink_previous(struct winlink *);
 2059: struct winlink	*winlink_next_by_number(struct winlink *, struct session *,
 2060: 		     int);
 2061: struct winlink	*winlink_previous_by_number(struct winlink *, struct session *,
 2062: 		     int);
 2063: void		 winlink_stack_push(struct winlink_stack *, struct winlink *);
 2064: void		 winlink_stack_remove(struct winlink_stack *, struct winlink *);
 2065: struct window	*window_find_by_id_str(const char *);
 2066: struct window	*window_find_by_id(u_int);
 2067: void		 window_update_activity(struct window *);
 2068: struct window	*window_create(u_int, u_int);
 2069: struct window	*window_create_spawn(const char *, int, char **, const char *,
 2070: 		     const char *, const char *, struct environ *,
 2071: 		     struct termios *, u_int, u_int, u_int, char **);
 2072: struct window_pane *window_get_active_at(struct window *, u_int, u_int);
 2073: struct window_pane *window_find_string(struct window *, const char *);
 2074: int		 window_has_pane(struct window *, struct window_pane *);
 2075: int		 window_set_active_pane(struct window *, struct window_pane *);
 2076: void		 window_redraw_active_switch(struct window *,
 2077: 		     struct window_pane *);
 2078: struct window_pane *window_add_pane(struct window *, struct window_pane *,
 2079: 		     int, u_int);
 2080: void		 window_resize(struct window *, u_int, u_int);
 2081: int		 window_zoom(struct window_pane *);
 2082: int		 window_unzoom(struct window *);
 2083: void		 window_lost_pane(struct window *, struct window_pane *);
 2084: void		 window_remove_pane(struct window *, struct window_pane *);
 2085: struct window_pane *window_pane_at_index(struct window *, u_int);
 2086: struct window_pane *window_pane_next_by_number(struct window *,
 2087: 			struct window_pane *, u_int);
 2088: struct window_pane *window_pane_previous_by_number(struct window *,
 2089: 			struct window_pane *, u_int);
 2090: int		 window_pane_index(struct window_pane *, u_int *);
 2091: u_int		 window_count_panes(struct window *);
 2092: void		 window_destroy_panes(struct window *);
 2093: struct window_pane *window_pane_find_by_id_str(const char *);
 2094: struct window_pane *window_pane_find_by_id(u_int);
 2095: int		 window_pane_spawn(struct window_pane *, int, char **,
 2096: 		     const char *, const char *, const char *, struct environ *,
 2097: 		     struct termios *, char **);
 2098: void		 window_pane_resize(struct window_pane *, u_int, u_int);
 2099: void		 window_pane_alternate_on(struct window_pane *,
 2100: 		     struct grid_cell *, int);
 2101: void		 window_pane_alternate_off(struct window_pane *,
 2102: 		     struct grid_cell *, int);
 2103: void		 window_pane_set_palette(struct window_pane *, u_int, int);
 2104: void		 window_pane_unset_palette(struct window_pane *, u_int);
 2105: void		 window_pane_reset_palette(struct window_pane *);
 2106: int		 window_pane_get_palette(const struct window_pane *, int);
 2107: int		 window_pane_set_mode(struct window_pane *,
 2108: 		     const struct window_mode *);
 2109: void		 window_pane_reset_mode(struct window_pane *);
 2110: void		 window_pane_key(struct window_pane *, struct client *,
 2111: 		     struct session *, key_code, struct mouse_event *);
 2112: int		 window_pane_outside(struct window_pane *);
 2113: int		 window_pane_visible(struct window_pane *);
 2114: char		*window_pane_search(struct window_pane *, const char *,
 2115: 		     u_int *);
 2116: char		*window_printable_flags(struct session *, struct winlink *);
 2117: struct window_pane *window_pane_find_up(struct window_pane *);
 2118: struct window_pane *window_pane_find_down(struct window_pane *);
 2119: struct window_pane *window_pane_find_left(struct window_pane *);
 2120: struct window_pane *window_pane_find_right(struct window_pane *);
 2121: void		 window_set_name(struct window *, const char *);
 2122: void		 window_remove_ref(struct window *);
 2123: void		 winlink_clear_flags(struct winlink *);
 2124: int		 winlink_shuffle_up(struct session *, struct winlink *);
 2125: 
 2126: /* layout.c */
 2127: u_int		 layout_count_cells(struct layout_cell *);
 2128: struct layout_cell *layout_create_cell(struct layout_cell *);
 2129: void		 layout_free_cell(struct layout_cell *);
 2130: void		 layout_print_cell(struct layout_cell *, const char *, u_int);
 2131: void		 layout_destroy_cell(struct window *, struct layout_cell *,
 2132: 		     struct layout_cell **);
 2133: void		 layout_set_size(struct layout_cell *, u_int, u_int, u_int,
 2134: 		     u_int);
 2135: void		 layout_make_leaf(struct layout_cell *, struct window_pane *);
 2136: void		 layout_make_node(struct layout_cell *, enum layout_type);
 2137: void		 layout_fix_offsets(struct layout_cell *);
 2138: void		 layout_fix_panes(struct window *, u_int, u_int);
 2139: void		 layout_resize_adjust(struct window *, struct layout_cell *,
 2140: 		     enum layout_type, int);
 2141: void		 layout_init(struct window *, struct window_pane *);
 2142: void		 layout_free(struct window *);
 2143: void		 layout_resize(struct window *, u_int, u_int);
 2144: void		 layout_resize_pane(struct window_pane *, enum layout_type,
 2145: 		     int, int);
 2146: void		 layout_resize_pane_to(struct window_pane *, enum layout_type,
 2147: 		     u_int);
 2148: void		 layout_assign_pane(struct layout_cell *, struct window_pane *);
 2149: struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type,
 2150: 		     int, int, int);
 2151: void		 layout_close_pane(struct window_pane *);
 2152: 
 2153: /* layout-custom.c */
 2154: char		*layout_dump(struct layout_cell *);
 2155: int		 layout_parse(struct window *, const char *);
 2156: 
 2157: /* layout-set.c */
 2158: int		 layout_set_lookup(const char *);
 2159: u_int		 layout_set_select(struct window *, u_int);
 2160: u_int		 layout_set_next(struct window *);
 2161: u_int		 layout_set_previous(struct window *);
 2162: 
 2163: /* window-clock.c */
 2164: extern const struct window_mode window_clock_mode;
 2165: extern const char window_clock_table[14][5][5];
 2166: 
 2167: /* window-copy.c */
 2168: extern const struct window_mode window_copy_mode;
 2169: void		 window_copy_init_from_pane(struct window_pane *, int);
 2170: void		 window_copy_init_for_output(struct window_pane *);
 2171: void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
 2172: void		 window_copy_vadd(struct window_pane *, const char *, va_list);
 2173: void		 window_copy_pageup(struct window_pane *, int);
 2174: void		 window_copy_start_drag(struct client *, struct mouse_event *);
 2175: int		 window_copy_scroll_position(struct window_pane *);
 2176: 
 2177: /* window-choose.c */
 2178: extern const struct window_mode window_choose_mode;
 2179: void		 window_choose_add(struct window_pane *,
 2180: 			 struct window_choose_data *);
 2181: void		 window_choose_ready(struct window_pane *,
 2182: 		     u_int, void (*)(struct window_choose_data *));
 2183: struct window_choose_data	*window_choose_data_create (int,
 2184: 		     struct client *, struct session *);
 2185: void	window_choose_data_run(struct window_choose_data *);
 2186: struct window_choose_data	*window_choose_add_window(struct window_pane *,
 2187: 			struct client *, struct session *, struct winlink *,
 2188: 			const char *, const char *, u_int);
 2189: struct window_choose_data	*window_choose_add_session(struct window_pane *,
 2190: 			struct client *, struct session *, const char *,
 2191: 			const char *, u_int);
 2192: void	window_choose_expand_all(struct window_pane *);
 2193: void	window_choose_set_current(struct window_pane *, u_int);
 2194: 
 2195: /* names.c */
 2196: void	 check_window_name(struct window *);
 2197: char	*default_window_name(struct window *);
 2198: char	*parse_window_name(const char *);
 2199: 
 2200: /* signal.c */
 2201: void	set_signals(void(*)(int, short, void *), void *);
 2202: void	clear_signals(int);
 2203: 
 2204: /* control.c */
 2205: void	control_callback(struct client *, int, void *);
 2206: void printflike(2, 3) control_write(struct client *, const char *, ...);
 2207: void	control_write_buffer(struct client *, struct evbuffer *);
 2208: 
 2209: /* control-notify.c */
 2210: void	control_notify_input(struct client *, struct window_pane *,
 2211: 	    struct evbuffer *);
 2212: void	control_notify_window_layout_changed(struct window *);
 2213: void	control_notify_window_unlinked(struct session *, struct window *);
 2214: void	control_notify_window_linked(struct session *, struct window *);
 2215: void	control_notify_window_renamed(struct window *);
 2216: void	control_notify_client_session_changed(struct client *);
 2217: void	control_notify_session_renamed(struct session *);
 2218: void	control_notify_session_created(struct session *);
 2219: void	control_notify_session_closed(struct session *);
 2220: 
 2221: /* session.c */
 2222: extern struct sessions sessions;
 2223: extern struct session_groups session_groups;
 2224: int	session_cmp(struct session *, struct session *);
 2225: RB_PROTOTYPE(sessions, session, entry, session_cmp);
 2226: int	session_group_cmp(struct session_group *, struct session_group *);
 2227: RB_PROTOTYPE(session_groups, session_group, entry, session_group_cmp);
 2228: int		 session_alive(struct session *);
 2229: struct session	*session_find(const char *);
 2230: struct session	*session_find_by_id_str(const char *);
 2231: struct session	*session_find_by_id(u_int);
 2232: struct session	*session_create(const char *, const char *, int, char **,
 2233: 		     const char *, const char *, struct environ *,
 2234: 		     struct termios *, int, u_int, u_int, char **);
 2235: void		 session_destroy(struct session *);
 2236: void		 session_unref(struct session *);
 2237: int		 session_check_name(const char *);
 2238: void		 session_update_activity(struct session *, struct timeval *);
 2239: struct session	*session_next_session(struct session *);
 2240: struct session	*session_previous_session(struct session *);
 2241: struct winlink	*session_new(struct session *, const char *, int, char **,
 2242: 		     const char *, const char *, int, char **);
 2243: struct winlink	*session_attach(struct session *, struct window *, int,
 2244: 		     char **);
 2245: int		 session_detach(struct session *, struct winlink *);
 2246: int		 session_has(struct session *, struct window *);
 2247: int		 session_is_linked(struct session *, struct window *);
 2248: int		 session_next(struct session *, int);
 2249: int		 session_previous(struct session *, int);
 2250: int		 session_select(struct session *, int);
 2251: int		 session_last(struct session *);
 2252: int		 session_set_current(struct session *, struct winlink *);
 2253: struct session_group *session_group_contains(struct session *);
 2254: struct session_group *session_group_find(const char *);
 2255: struct session_group *session_group_new(const char *);
 2256: void		 session_group_add(struct session_group *, struct session *);
 2257: void		 session_group_synchronize_to(struct session *);
 2258: void		 session_group_synchronize_from(struct session *);
 2259: void		 session_renumber_windows(struct session *);
 2260: 
 2261: /* utf8.c */
 2262: void		 utf8_set(struct utf8_data *, u_char);
 2263: void		 utf8_copy(struct utf8_data *, const struct utf8_data *);
 2264: enum utf8_state	 utf8_open(struct utf8_data *, u_char);
 2265: enum utf8_state	 utf8_append(struct utf8_data *, u_char);
 2266: enum utf8_state	 utf8_combine(const struct utf8_data *, wchar_t *);
 2267: enum utf8_state	 utf8_split(wchar_t, struct utf8_data *);
 2268: int		 utf8_strvis(char *, const char *, size_t, int);
 2269: int		 utf8_stravis(char **, const char *, int);
 2270: char		*utf8_sanitize(const char *);
 2271: size_t		 utf8_strlen(const struct utf8_data *);
 2272: u_int		 utf8_strwidth(const struct utf8_data *, ssize_t);
 2273: struct utf8_data *utf8_fromcstr(const char *);
 2274: char		*utf8_tocstr(struct utf8_data *);
 2275: u_int		 utf8_cstrwidth(const char *);
 2276: char		*utf8_rtrimcstr(const char *, u_int);
 2277: char		*utf8_trimcstr(const char *, u_int);
 2278: char		*utf8_padcstr(const char *, u_int);
 2279: 
 2280: /* osdep-*.c */
 2281: char		*osdep_get_name(int, char *);
 2282: char		*osdep_get_cwd(int);
 2283: struct event_base *osdep_event_init(void);
 2284: 
 2285: /* log.c */
 2286: void	log_add_level(void);
 2287: int	log_get_level(void);
 2288: void	log_open(const char *);
 2289: void	log_close(void);
 2290: void printflike(1, 2) log_debug(const char *, ...);
 2291: __dead void printflike(1, 2) fatal(const char *, ...);
 2292: __dead void printflike(1, 2) fatalx(const char *, ...);
 2293: 
 2294: /* style.c */
 2295: int		 style_parse(const struct grid_cell *,
 2296: 		     struct grid_cell *, const char *);
 2297: const char	*style_tostring(struct grid_cell *);
 2298: void		 style_apply(struct grid_cell *, struct options *,
 2299: 		     const char *);
 2300: void		 style_apply_update(struct grid_cell *, struct options *,
 2301: 		     const char *);
 2302: int		 style_equal(const struct grid_cell *,
 2303: 		     const struct grid_cell *);
 2304: 
 2305: /* pty.c */
 2306: int		 pty_open(int *);
 2307: pid_t		 pty_fork(int, int *, char *, size_t, struct winsize *);
 2308: 
 2309: #endif /* TMUX_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>