[BACK]Return to tmux.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Annotation of src/usr.bin/tmux/tmux.h, Revision 1.72

1.72    ! nicm        1: /* $OpenBSD: tmux.h,v 1.71 2009/08/08 13:29:27 nicm Exp $ */
1.1       nicm        2:
                      3: /*
                      4:  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
                      5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
                      9:  *
                     10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
                     15:  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                     16:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17:  */
                     18:
                     19: #ifndef TMUX_H
                     20: #define TMUX_H
                     21:
1.55      nicm       22: #define PROTOCOL_VERSION -15
1.1       nicm       23:
                     24: #include <sys/param.h>
                     25: #include <sys/time.h>
                     26: #include <sys/queue.h>
                     27: #include <sys/tree.h>
                     28:
1.6       nicm       29: #include <bitstring.h>
1.1       nicm       30: #include <getopt.h>
                     31: #include <limits.h>
                     32: #include <poll.h>
                     33: #include <signal.h>
                     34: #include <stdarg.h>
                     35: #include <stdint.h>
                     36: #include <stdio.h>
                     37: #include <termios.h>
                     38:
                     39: #include "array.h"
                     40:
1.42      nicm       41: extern char    *__progname;
1.1       nicm       42:
1.22      nicm       43: /* Default configuration files. */
1.1       nicm       44: #define DEFAULT_CFG ".tmux.conf"
1.22      nicm       45: #define SYSTEM_CFG "/etc/tmux.conf"
1.1       nicm       46:
                     47: /* Default prompt history length. */
                     48: #define PROMPT_HISTORY 100
                     49:
1.39      nicm       50: /*
                     51:  * Minimum layout cell size, NOT including separator line. The scroll region
                     52:  * cannot be one line in height so this must be at least two.
                     53:  */
                     54: #define PANE_MINIMUM 2
1.1       nicm       55:
                     56: /* Automatic name refresh interval, in milliseconds. */
                     57: #define NAME_INTERVAL 500
                     58:
                     59: /* Escape timer period, in milliseconds. */
                     60: #define ESCAPE_PERIOD 250
                     61:
                     62: /* Maximum poll timeout (when attached). */
                     63: #define POLL_TIMEOUT 50
                     64:
1.55      nicm       65: /*
                     66:  * Maximum sizes of strings in message data. Don't forget to bump
                     67:  * PROTOCOL_VERSION if any of these change!
                     68:  */
                     69: #define COMMAND_LENGTH 2048    /* packed argv size */
                     70: #define TERMINAL_LENGTH 128    /* length of TERM environment variable */
                     71: #define PRINT_LENGTH 512       /* printed error/message size */
                     72:
1.1       nicm       73: /* Fatal errors. */
                     74: #define fatal(msg) log_fatal("%s: %s", __func__, msg);
                     75: #define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
                     76:
                     77: /* Definition to shut gcc up about unused arguments. */
                     78: #define unused __attribute__ ((unused))
                     79:
                     80: /* Attribute to make gcc check printf-like arguments. */
                     81: #define printflike1 __attribute__ ((format (printf, 1, 2)))
                     82: #define printflike2 __attribute__ ((format (printf, 2, 3)))
                     83: #define printflike3 __attribute__ ((format (printf, 3, 4)))
                     84: #define printflike4 __attribute__ ((format (printf, 4, 5)))
1.4       nicm       85: #define printflike5 __attribute__ ((format (printf, 5, 6)))
1.1       nicm       86:
                     87: /* Number of items in array. */
1.14      nicm       88: #ifndef nitems
1.1       nicm       89: #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
1.14      nicm       90: #endif
1.1       nicm       91:
                     92: /* Buffer macros. */
                     93: #define BUFFER_USED(b) ((b)->size)
                     94: #define BUFFER_FREE(b) ((b)->space - (b)->off - (b)->size)
                     95: #define BUFFER_IN(b) ((b)->base + (b)->off + (b)->size)
                     96: #define BUFFER_OUT(b) ((b)->base + (b)->off)
                     97:
                     98: /* Buffer structure. */
                     99: struct buffer {
                    100:        u_char  *base;          /* buffer start */
                    101:        size_t   space;         /* total size of buffer */
                    102:
                    103:        size_t   size;          /* size of data in buffer */
                    104:        size_t   off;           /* offset of data in buffer */
                    105: };
                    106:
                    107: /* Bell option values. */
                    108: #define BELL_NONE 0
                    109: #define BELL_ANY 1
                    110: #define BELL_CURRENT 2
                    111:
                    112: /* Key codes. ncurses defines KEY_*. Grrr. */
1.54      nicm      113: #define KEYC_NONE 0xfff
                    114: /* 0x1000 is base for special keys */
                    115: #define KEYC_ESCAPE 0x2000
                    116: #define KEYC_CTRL 0x4000
                    117: #define KEYC_SHIFT 0x8000
                    118: #define KEYC_PREFIX 0x10000
1.41      nicm      119:
                    120: enum key_code {
                    121:        /* Mouse key. */
                    122:        KEYC_MOUSE = 0x1000,
1.56      nicm      123:
                    124:        /* Backspace key. */
                    125:        KEYC_BSPACE,
1.41      nicm      126:
                    127:        /* Function keys. */
                    128:        KEYC_F1,
                    129:        KEYC_F2,
                    130:        KEYC_F3,
                    131:        KEYC_F4,
                    132:        KEYC_F5,
                    133:        KEYC_F6,
                    134:        KEYC_F7,
                    135:        KEYC_F8,
                    136:        KEYC_F9,
                    137:        KEYC_F10,
                    138:        KEYC_F11,
                    139:        KEYC_F12,
                    140:        KEYC_F13,
                    141:        KEYC_F14,
                    142:        KEYC_F15,
                    143:        KEYC_F16,
                    144:        KEYC_F17,
                    145:        KEYC_F18,
                    146:        KEYC_F19,
                    147:        KEYC_F20,
                    148:        KEYC_IC,
                    149:        KEYC_DC,
                    150:        KEYC_HOME,
                    151:        KEYC_END,
                    152:        KEYC_NPAGE,
                    153:        KEYC_PPAGE,
                    154:        KEYC_BTAB,
                    155:
                    156:        /* Arrow keys. */
                    157:        KEYC_UP,
                    158:        KEYC_DOWN,
                    159:        KEYC_LEFT,
                    160:        KEYC_RIGHT,
                    161:
                    162:        /* Numeric keypad. Numbered from top-left, KPY_X. */
                    163:        KEYC_KP0_1,
                    164:        KEYC_KP0_2,
                    165:        KEYC_KP0_3,
                    166:        KEYC_KP1_0,
                    167:        KEYC_KP1_1,
                    168:        KEYC_KP1_2,
                    169:        KEYC_KP1_3,
                    170:        KEYC_KP2_0,
                    171:        KEYC_KP2_1,
                    172:        KEYC_KP2_2,
                    173:        KEYC_KP3_0,
                    174:        KEYC_KP3_1,
                    175:        KEYC_KP3_2,
                    176:        KEYC_KP3_3,
                    177:        KEYC_KP4_0,
                    178:        KEYC_KP4_2,
                    179: };
1.1       nicm      180:
                    181: /* Termcap codes. */
                    182: enum tty_code_code {
                    183:        TTYC_AX = 0,
                    184:        TTYC_ACSC,      /* acs_chars, ac */
                    185:        TTYC_BEL,       /* bell, bl */
                    186:        TTYC_BLINK,     /* enter_blink_mode, mb */
                    187:        TTYC_BOLD,      /* enter_bold_mode, md */
                    188:        TTYC_CIVIS,     /* cursor_invisible, vi */
                    189:        TTYC_CLEAR,     /* clear_screen, cl */
                    190:        TTYC_CNORM,     /* cursor_normal, ve */
                    191:        TTYC_COLORS,    /* max_colors, Co */
                    192:        TTYC_CSR,       /* change_scroll_region, cs */
                    193:        TTYC_CUD,       /* parm_down_cursor, DO */
                    194:        TTYC_CUD1,      /* cursor_down, do */
                    195:        TTYC_CUP,       /* cursor_address, cm */
                    196:        TTYC_DCH,       /* parm_dch, DC */
                    197:        TTYC_DCH1,      /* delete_character, dc */
                    198:        TTYC_DIM,       /* enter_dim_mode, mh */
                    199:        TTYC_DL,        /* parm_delete_line, DL */
                    200:        TTYC_DL1,       /* delete_line, dl */
                    201:        TTYC_EL,        /* clr_eol, ce */
                    202:        TTYC_EL1,       /* clr_bol, cb */
                    203:        TTYC_ENACS,     /* ena_acs, eA */
                    204:        TTYC_ICH,       /* parm_ich, IC */
                    205:        TTYC_ICH1,      /* insert_character, ic */
                    206:        TTYC_IL,        /* parm_insert_line, IL */
                    207:        TTYC_IL1,       /* insert_line, il */
                    208:        TTYC_INVIS,     /* enter_secure_mode, mk */
                    209:        TTYC_IS1,       /* init_1string, i1 */
                    210:        TTYC_IS2,       /* init_2string, i2 */
                    211:        TTYC_IS3,       /* init_3string, i3 */
                    212:        TTYC_KCBT,      /* key_btab, kB */
                    213:        TTYC_KCUB1,     /* key_left, kl */
                    214:        TTYC_KCUD1,     /* key_down, kd */
                    215:        TTYC_KCUF1,     /* key_right, kr */
                    216:        TTYC_KCUU1,     /* key_up, ku */
                    217:        TTYC_KDCH1,     /* key_dc, kD */
                    218:        TTYC_KEND,      /* key_end, ke */
                    219:        TTYC_KF1,       /* key_f1, k1 */
                    220:        TTYC_KF10,      /* key_f10, k; */
                    221:        TTYC_KF11,      /* key_f11, F1 */
                    222:        TTYC_KF12,      /* key_f12, F2 */
                    223:        TTYC_KF13,      /* key_f13, F3 */
                    224:        TTYC_KF14,      /* key_f14, F4 */
                    225:        TTYC_KF15,      /* key_f15, F5 */
                    226:        TTYC_KF16,      /* key_f16, F6 */
                    227:        TTYC_KF17,      /* key_f17, F7 */
                    228:        TTYC_KF18,      /* key_f18, F8 */
                    229:        TTYC_KF19,      /* key_f19, F9 */
                    230:        TTYC_KF20,      /* key_f20, F10 */
                    231:        TTYC_KF2,       /* key_f2, k2 */
                    232:        TTYC_KF3,       /* key_f3, k3 */
                    233:        TTYC_KF4,       /* key_f4, k4 */
                    234:        TTYC_KF5,       /* key_f5, k5 */
                    235:        TTYC_KF6,       /* key_f6, k6 */
                    236:        TTYC_KF7,       /* key_f7, k7 */
                    237:        TTYC_KF8,       /* key_f8, k8 */
                    238:        TTYC_KF9,       /* key_f9, k9 */
                    239:        TTYC_KHOME,     /* key_home, kh */
                    240:        TTYC_KICH1,     /* key_ic, kI */
                    241:        TTYC_KMOUS,     /* key_mouse, Km */
                    242:        TTYC_KNP,       /* key_npage, kN */
                    243:        TTYC_KPP,       /* key_ppage, kP */
                    244:        TTYC_OP,        /* orig_pair, op */
                    245:        TTYC_REV,       /* enter_reverse_mode, mr */
                    246:        TTYC_RI,        /* scroll_reverse, sr */
                    247:        TTYC_RMACS,     /* exit_alt_charset_mode */
                    248:        TTYC_RMCUP,     /* exit_ca_mode, te */
                    249:        TTYC_RMIR,      /* exit_insert_mode, ei */
                    250:        TTYC_RMKX,      /* keypad_local, ke */
                    251:        TTYC_SETAB,     /* set_a_background, AB */
                    252:        TTYC_SETAF,     /* set_a_foreground, AF */
                    253:        TTYC_SGR0,      /* exit_attribute_mode, me */
                    254:        TTYC_SMACS,     /* enter_alt_charset_mode, as */
                    255:        TTYC_SMCUP,     /* enter_ca_mode, ti */
                    256:        TTYC_SMIR,      /* enter_insert_mode, im */
                    257:        TTYC_SMKX,      /* keypad_xmit, ks */
                    258:        TTYC_SMSO,      /* enter_standout_mode, so */
                    259:        TTYC_SMUL,      /* enter_underline_mode, us */
                    260:        TTYC_XENL,      /* eat_newline_glitch, xn */
                    261: };
                    262: #define NTTYCODE (TTYC_XENL + 1)
                    263:
                    264: /* Termcap types. */
                    265: enum tty_code_type {
                    266:        TTYCODE_NONE = 0,
                    267:        TTYCODE_STRING,
                    268:        TTYCODE_NUMBER,
                    269:        TTYCODE_FLAG,
                    270: };
                    271:
                    272: /* Termcap code. */
                    273: struct tty_code {
                    274:        enum tty_code_type      type;
                    275:        union {
                    276:                char           *string;
                    277:                int             number;
                    278:                int             flag;
                    279:        } value;
                    280: };
                    281:
                    282: /* Entry in terminal code table. */
                    283: struct tty_term_code_entry {
                    284:        enum tty_code_code      code;
                    285:        enum tty_code_type      type;
                    286:        const char             *name;
                    287: };
                    288:
                    289: /* Message codes. */
1.64      nicm      290: enum msgtype {
1.1       nicm      291:        MSG_COMMAND,
                    292:        MSG_DETACH,
                    293:        MSG_ERROR,
                    294:        MSG_EXIT,
                    295:        MSG_EXITED,
                    296:        MSG_EXITING,
                    297:        MSG_IDENTIFY,
                    298:        MSG_PRINT,
                    299:        MSG_READY,
                    300:        MSG_RESIZE,
                    301:        MSG_SHUTDOWN,
                    302:        MSG_SUSPEND,
                    303:        MSG_UNLOCK,
                    304:        MSG_WAKEUP,
                    305: };
                    306:
1.55      nicm      307: /*
                    308:  * Message header and data.
                    309:  *
                    310:  * Don't forget to bump PROTOCOL_VERSION if any of these change!
                    311:  *
                    312:  * Changing sizeof (struct hdr) or sizeof (struct msg_identify_data) will make
                    313:  * the tmux client hang even if the protocol version is bumped.
                    314:  */
1.1       nicm      315: struct hdr {
1.64      nicm      316:        enum msgtype    type;
1.1       nicm      317:        size_t          size;
                    318: };
                    319:
1.55      nicm      320: struct msg_print_data {
                    321:        char            msg[PRINT_LENGTH];
                    322: };
                    323:
1.1       nicm      324: struct msg_command_data {
                    325:        pid_t           pid;                    /* pid from $TMUX or -1 */
                    326:        u_int           idx;                    /* index from $TMUX */
                    327:
1.55      nicm      328:        int             argc;
                    329:        char            argv[COMMAND_LENGTH];
1.1       nicm      330: };
                    331:
                    332: struct msg_identify_data {
                    333:        char            tty[TTY_NAME_MAX];
                    334:        int             version;
                    335:
                    336:        char            cwd[MAXPATHLEN];
                    337:
1.55      nicm      338:        char            term[TERMINAL_LENGTH];
                    339:
1.1       nicm      340: #define IDENTIFY_UTF8 0x1
                    341: #define IDENTIFY_256COLOURS 0x2
                    342: #define IDENTIFY_88COLOURS 0x4
                    343: #define IDENTIFY_HASDEFAULTS 0x8
                    344:        int             flags;
                    345:
                    346:        u_int           sx;
                    347:        u_int           sy;
                    348: };
                    349:
                    350: struct msg_resize_data {
                    351:        u_int           sx;
                    352:        u_int           sy;
                    353: };
                    354:
1.55      nicm      355: struct msg_unlock_data {
                    356:        char            pass[PASS_MAX];
                    357: };
                    358:
1.62      nicm      359: /* Mode key commands. */
1.1       nicm      360: enum mode_key_cmd {
1.59      nicm      361:        MODEKEY_NONE,
                    362:        MODEKEY_OTHER,
                    363:
                    364:        /* Editing keys. */
                    365:        MODEKEYEDIT_BACKSPACE,
                    366:        MODEKEYEDIT_CANCEL,
                    367:        MODEKEYEDIT_COMPLETE,
                    368:        MODEKEYEDIT_CURSORLEFT,
                    369:        MODEKEYEDIT_CURSORRIGHT,
                    370:        MODEKEYEDIT_DELETE,
                    371:        MODEKEYEDIT_DELETETOENDOFLINE,
                    372:        MODEKEYEDIT_ENDOFLINE,
                    373:        MODEKEYEDIT_ENTER,
                    374:        MODEKEYEDIT_HISTORYDOWN,
                    375:        MODEKEYEDIT_HISTORYUP,
                    376:        MODEKEYEDIT_PASTE,
                    377:        MODEKEYEDIT_STARTOFLINE,
                    378:        MODEKEYEDIT_SWITCHMODE,
                    379:        MODEKEYEDIT_SWITCHMODEAPPEND,
                    380:
                    381:        /* Menu (choice) keys. */
                    382:        MODEKEYCHOICE_CANCEL,
                    383:        MODEKEYCHOICE_CHOOSE,
                    384:        MODEKEYCHOICE_DOWN,
                    385:        MODEKEYCHOICE_PAGEDOWN,
                    386:        MODEKEYCHOICE_PAGEUP,
                    387:        MODEKEYCHOICE_UP,
                    388:
                    389:        /* Copy keys. */
                    390:        MODEKEYCOPY_CANCEL,
                    391:        MODEKEYCOPY_BACKTOINDENTATION,
                    392:        MODEKEYCOPY_CLEARSELECTION,
                    393:        MODEKEYCOPY_COPYSELECTION,
                    394:        MODEKEYCOPY_DOWN,
                    395:        MODEKEYCOPY_ENDOFLINE,
                    396:        MODEKEYCOPY_LEFT,
                    397:        MODEKEYCOPY_NEXTPAGE,
                    398:        MODEKEYCOPY_NEXTWORD,
                    399:        MODEKEYCOPY_PREVIOUSPAGE,
                    400:        MODEKEYCOPY_PREVIOUSWORD,
                    401:        MODEKEYCOPY_RIGHT,
                    402:        MODEKEYCOPY_STARTOFLINE,
                    403:        MODEKEYCOPY_STARTSELECTION,
                    404:        MODEKEYCOPY_UP,
1.1       nicm      405: };
                    406:
1.62      nicm      407: /* Entry in the default mode key tables. */
1.59      nicm      408: struct mode_key_entry {
                    409:        int                     key;
                    410:
                    411:        /*
                    412:         * Editing mode for vi: 0 is edit mode, keys not in the table are
                    413:         * returned as MODEKEY_OTHER; 1 is command mode, keys not in the table
                    414:         * are returned as MODEKEY_NONE. This is also matched on, allowing some
                    415:         * keys to be bound in edit mode.
                    416:         */
                    417:        int                     mode;
                    418:        enum mode_key_cmd       cmd;
                    419: };
1.62      nicm      420:
                    421: /* Data required while mode keys are in use. */
1.1       nicm      422: struct mode_key_data {
1.62      nicm      423:        struct mode_key_tree   *tree;
                    424:        int                     mode;
1.1       nicm      425: };
                    426: #define MODEKEY_EMACS 0
                    427: #define MODEKEY_VI 1
                    428:
1.62      nicm      429: /* Binding between a key and a command. */
                    430: struct mode_key_binding {
                    431:        int                     key;
                    432:
                    433:        int                     mode;
                    434:        enum mode_key_cmd       cmd;
                    435:
                    436:        SPLAY_ENTRY(mode_key_binding) entry;
                    437: };
                    438: SPLAY_HEAD(mode_key_tree, mode_key_binding);
                    439:
                    440: /* Command to string mapping. */
                    441: struct mode_key_cmdstr {
                    442:        enum mode_key_cmd        cmd;
                    443:        const char              *name;
                    444: };
                    445:
                    446: /* Named mode key table description. */
                    447: struct mode_key_table {
                    448:        const char              *name;
                    449:        struct mode_key_cmdstr  *cmdstr;
                    450:        struct mode_key_tree    *tree;
                    451:        const struct mode_key_entry *table;     /* default entries */
                    452: };
                    453:
1.1       nicm      454: /* Modes. */
                    455: #define MODE_CURSOR 0x1
                    456: #define MODE_INSERT 0x2
                    457: #define MODE_KCURSOR 0x4
                    458: #define MODE_KKEYPAD 0x8
                    459: #define MODE_MOUSE 0x10
                    460:
                    461: /* Grid output. */
                    462: #if defined(DEBUG) && \
                    463:     ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
                    464:      (defined(__GNUC__) && __GNUC__ >= 3))
1.48      nicm      465: #define GRID_DEBUG(gd, fmt, ...) log_debug2("%s: (sx=%u, sy=%u, hsize=%u) " \
1.1       nicm      466:     fmt, __func__, (gd)->sx, (gd)->sy, (gd)->hsize, ## __VA_ARGS__)
                    467: #else
                    468: #define GRID_DEBUG(...)
                    469: #endif
                    470:
                    471: /* Grid attributes. */
                    472: #define GRID_ATTR_BRIGHT 0x1
                    473: #define GRID_ATTR_DIM 0x2
                    474: #define GRID_ATTR_UNDERSCORE 0x4
                    475: #define GRID_ATTR_BLINK 0x8
                    476: #define GRID_ATTR_REVERSE 0x10
                    477: #define GRID_ATTR_HIDDEN 0x20
                    478: #define GRID_ATTR_ITALICS 0x40
                    479: #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
                    480:
                    481: /* Grid flags. */
                    482: #define GRID_FLAG_FG256 0x1
                    483: #define GRID_FLAG_BG256 0x2
                    484: #define GRID_FLAG_PADDING 0x4
                    485: #define GRID_FLAG_UTF8 0x8
                    486:
1.72    ! nicm      487: /* Grid line flags. */
        !           488: #define GRID_LINE_WRAPPED 0x1
        !           489:
1.1       nicm      490: /* Grid cell data. */
                    491: struct grid_cell {
                    492:        u_char  attr;
                    493:        u_char  flags;
                    494:        u_char  fg;
                    495:        u_char  bg;
                    496:        u_char  data;
                    497: } __packed;
                    498:
                    499: /* Grid cell UTF-8 data. Used instead of data in grid_cell for UTF-8 cells. */
                    500: #define UTF8_SIZE 8
                    501: struct grid_utf8 {
                    502:        u_char  width;
                    503:        u_char  data[UTF8_SIZE];
                    504: } __packed;
                    505:
1.71      nicm      506: /* Grid line. */
                    507: struct grid_line {
                    508:        u_int   cellsize;
                    509:        struct grid_cell *celldata;
                    510:
                    511:        u_int   utf8size;
                    512:        struct grid_utf8 *utf8data;
1.72    ! nicm      513:
        !           514:        int     flags;
1.71      nicm      515: } __packed;
                    516:
1.1       nicm      517: /* Entire grid of cells. */
                    518: struct grid {
1.25      nicm      519:        int     flags;
                    520: #define GRID_HISTORY 0x1       /* scroll lines into history */
                    521:
1.1       nicm      522:        u_int   sx;
                    523:        u_int   sy;
                    524:
                    525:        u_int   hsize;
                    526:        u_int   hlimit;
                    527:
1.71      nicm      528:        struct grid_line *linedata;
1.1       nicm      529: };
                    530:
                    531: /* Option data structures. */
                    532: struct options_entry {
                    533:        char            *name;
                    534:
                    535:        enum {
                    536:                OPTIONS_STRING,
                    537:                OPTIONS_NUMBER,
                    538:                OPTIONS_KEY,
                    539:        } type;
                    540:        union {
                    541:                char    *string;
                    542:                long long number;
                    543:                int      key;
                    544:        } value;
                    545:
                    546:        SPLAY_ENTRY(options_entry) entry;
                    547: };
                    548:
                    549: struct options {
                    550:        SPLAY_HEAD(options_tree, options_entry) tree;
                    551:        struct options  *parent;
                    552: };
                    553:
                    554: /* Screen selection. */
                    555: struct screen_sel {
                    556:        int              flag;
                    557:
                    558:        u_int            sx;
                    559:        u_int            sy;
                    560:
                    561:        u_int            ex;
                    562:        u_int            ey;
                    563:
                    564:        struct grid_cell cell;
                    565: };
                    566:
                    567: /* Virtual screen. */
                    568: struct screen {
                    569:        char            *title;
                    570:
                    571:        struct grid     *grid;          /* grid data */
                    572:
                    573:        u_int            cx;            /* cursor x */
                    574:        u_int            cy;            /* cursor y */
                    575:
                    576:        u_int            rupper;        /* scroll region top */
                    577:        u_int            rlower;        /* scroll region bottom */
                    578:
                    579:        int              mode;
                    580:
1.6       nicm      581:        bitstr_t        *tabs;
                    582:
1.1       nicm      583:        struct screen_sel sel;
                    584: };
                    585:
                    586: /* Screen write context. */
                    587: struct screen_write_ctx {
                    588:        struct window_pane *wp;
                    589:        struct screen   *s;
                    590: };
                    591:
                    592: /* Screen size. */
                    593: #define screen_size_x(s) ((s)->grid->sx)
                    594: #define screen_size_y(s) ((s)->grid->sy)
                    595: #define screen_hsize(s) ((s)->grid->hsize)
                    596: #define screen_hlimit(s) ((s)->grid->hlimit)
                    597:
                    598: /* Input parser sequence argument. */
                    599: struct input_arg {
                    600:        u_char           data[64];
                    601:        size_t           used;
                    602: };
                    603:
                    604: /* Input parser context. */
                    605: struct input_ctx {
                    606:        struct window_pane *wp;
                    607:        struct screen_write_ctx ctx;
                    608:
                    609:        u_char          *buf;
                    610:        size_t           len;
                    611:        size_t           off;
                    612:
                    613:        struct grid_cell cell;
                    614:
                    615:        struct grid_cell saved_cell;
                    616:        u_int            saved_cx;
                    617:        u_int            saved_cy;
                    618:
                    619: #define MAXSTRINGLEN   1024
                    620:        u_char          *string_buf;
                    621:        size_t           string_len;
                    622:        int              string_type;
                    623: #define STRING_SYSTEM 0
                    624: #define STRING_APPLICATION 1
                    625: #define STRING_NAME 2
                    626:
                    627:        u_char           utf8_buf[4];
                    628:        u_int            utf8_len;
                    629:        u_int            utf8_off;
                    630:
                    631:        u_char           intermediate;
                    632:        void            *(*state)(u_char, struct input_ctx *);
                    633:
                    634:        u_char           private;
                    635:        ARRAY_DECL(, struct input_arg) args;
                    636: };
                    637:
                    638: /*
                    639:  * Window mode. Windows can be in several modes and this is used to call the
                    640:  * right function to handle input and output.
                    641:  */
                    642: struct client;
                    643: struct window;
                    644: struct window_mode {
                    645:        struct screen *(*init)(struct window_pane *);
                    646:        void    (*free)(struct window_pane *);
                    647:        void    (*resize)(struct window_pane *, u_int, u_int);
                    648:        void    (*key)(struct window_pane *, struct client *, int);
                    649:        void    (*mouse)(struct window_pane *,
                    650:                    struct client *, u_char, u_char, u_char);
                    651:        void    (*timer)(struct window_pane *);
                    652: };
                    653:
                    654: /* Child window structure. */
                    655: struct window_pane {
                    656:        struct window   *window;
1.39      nicm      657:        struct layout_cell *layout_cell;
1.1       nicm      658:
                    659:        u_int            sx;
                    660:        u_int            sy;
                    661:
                    662:        u_int            xoff;
                    663:        u_int            yoff;
                    664:
                    665:        int              flags;
1.28      nicm      666: #define PANE_REDRAW 0x1
1.1       nicm      667:
                    668:        char            *cmd;
                    669:        char            *cwd;
                    670:
                    671:        pid_t            pid;
                    672:        int              fd;
                    673:        char             tty[TTY_NAME_MAX];
                    674:        struct buffer   *in;
                    675:        struct buffer   *out;
                    676:
                    677:        struct input_ctx ictx;
                    678:
                    679:        struct screen   *screen;
                    680:        struct screen    base;
                    681:
1.25      nicm      682:        /* Saved in alternative screen mode. */
                    683:        u_int            saved_cx;
                    684:        u_int            saved_cy;
                    685:        struct grid     *saved_grid;
1.69      nicm      686:        struct grid_cell saved_cell;
1.25      nicm      687:
1.1       nicm      688:        const struct window_mode *mode;
                    689:        void            *modedata;
                    690:
                    691:        TAILQ_ENTRY(window_pane) entry;
                    692: };
                    693: TAILQ_HEAD(window_panes, window_pane);
                    694:
                    695: /* Window structure. */
                    696: struct window {
                    697:        char            *name;
                    698:        struct timeval   name_timer;
                    699:
                    700:        struct window_pane *active;
                    701:        struct window_panes panes;
1.39      nicm      702:
1.61      nicm      703:        int              lastlayout;
1.39      nicm      704:        struct layout_cell *layout_root;
1.1       nicm      705:
                    706:        u_int            sx;
                    707:        u_int            sy;
                    708:
                    709:        int              flags;
                    710: #define WINDOW_BELL 0x1
                    711: #define WINDOW_HIDDEN 0x2
                    712: #define WINDOW_ACTIVITY 0x4
1.38      nicm      713: #define WINDOW_CONTENT 0x8
                    714: #define WINDOW_REDRAW 0x10
1.1       nicm      715:
                    716:        struct options   options;
                    717:
                    718:        u_int            references;
                    719: };
                    720: ARRAY_DECL(windows, struct window *);
                    721:
                    722: /* Entry on local window list. */
                    723: struct winlink {
                    724:        int              idx;
                    725:        struct window   *window;
                    726:
                    727:        RB_ENTRY(winlink) entry;
                    728:        SLIST_ENTRY(winlink) sentry;
                    729: };
                    730: RB_HEAD(winlinks, winlink);
                    731: SLIST_HEAD(winlink_stack, winlink);
                    732:
1.39      nicm      733: /* Layout direction. */
                    734: enum layout_type {
                    735:        LAYOUT_LEFTRIGHT,
                    736:        LAYOUT_TOPBOTTOM,
                    737:        LAYOUT_WINDOWPANE
                    738: };
                    739:
                    740: /* Layout cells queue. */
                    741: TAILQ_HEAD(layout_cells, layout_cell);
                    742:
                    743: /* Layout cell. */
                    744: struct layout_cell {
                    745:        enum layout_type type;
                    746:
                    747:        struct layout_cell *parent;
                    748:
                    749:        u_int            sx;
                    750:        u_int            sy;
                    751:
                    752:        u_int            xoff;
                    753:        u_int            yoff;
                    754:
                    755:        struct window_pane *wp;
                    756:        struct layout_cells cells;
                    757:
                    758:        TAILQ_ENTRY(layout_cell) entry;
                    759: };
                    760:
1.1       nicm      761: /* Paste buffer. */
                    762: struct paste_buffer {
                    763:        char            *data;
                    764:        struct timeval   tv;
                    765: };
                    766: ARRAY_DECL(paste_stack, struct paste_buffer *);
                    767:
                    768: /* Client session. */
                    769: struct session_alert {
                    770:        struct winlink  *wl;
                    771:        int              type;
                    772:
                    773:        SLIST_ENTRY(session_alert) entry;
                    774: };
                    775:
                    776: struct session {
                    777:        char            *name;
                    778:        struct timeval   tv;
                    779:
                    780:        u_int            sx;
                    781:        u_int            sy;
                    782:
                    783:        struct winlink  *curw;
                    784:        struct winlink_stack lastw;
                    785:        struct winlinks  windows;
                    786:
                    787:        struct options   options;
                    788:
                    789:        struct paste_stack buffers;
                    790:
                    791:        SLIST_HEAD(, session_alert) alerts;
                    792:
                    793: #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
                    794:        int              flags;
                    795: };
                    796: ARRAY_DECL(sessions, struct session *);
                    797:
                    798: /* TTY information. */
                    799: struct tty_key {
                    800:        int              key;
                    801:        char            *string;
                    802:
                    803:        int              flags;
                    804: #define TTYKEY_CTRL 0x1
                    805: #define TTYKEY_RAW 0x2
                    806:
                    807:        RB_ENTRY(tty_key) entry;
                    808: };
                    809:
                    810: struct tty_term {
                    811:        char            *name;
                    812:        u_int            references;
                    813:
                    814:        struct tty_code  codes[NTTYCODE];
                    815:
                    816: #define TERM_HASDEFAULTS 0x1
                    817: #define TERM_256COLOURS 0x2
                    818: #define TERM_88COLOURS 0x4
                    819: #define TERM_EARLYWRAP 0x8
                    820:        int              flags;
                    821:
                    822:        SLIST_ENTRY(tty_term) entry;
                    823: };
                    824: SLIST_HEAD(tty_terms, tty_term);
                    825:
                    826: struct tty {
                    827:        char            *path;
                    828:
                    829:         u_int            sx;
                    830:         u_int            sy;
                    831:
                    832:        u_int            cx;
                    833:        u_int            cy;
                    834:
                    835:        int              mode;
                    836:
                    837:        u_int            rlower;
                    838:        u_int            rupper;
                    839:
                    840:        char            *termname;
                    841:        struct tty_term *term;
                    842:
                    843:        int              fd;
                    844:        struct buffer   *in;
                    845:        struct buffer   *out;
                    846:
                    847:        int              log_fd;
                    848:
                    849:        struct termios   tio;
                    850:
                    851:        struct grid_cell cell;
                    852:
                    853:        u_char           acs[UCHAR_MAX + 1];
                    854:
                    855: #define TTY_NOCURSOR 0x1
                    856: #define TTY_FREEZE 0x2
                    857: #define TTY_ESCAPE 0x4
                    858: #define TTY_UTF8 0x8
                    859:        int              flags;
                    860:
                    861:        int              term_flags;
                    862:
                    863:        struct timeval   key_timer;
                    864:
                    865:        size_t           ksize; /* maximum key size */
                    866:        RB_HEAD(tty_keys, tty_key) ktree;
                    867: };
                    868:
1.47      nicm      869: /* TTY command context and function pointer. */
                    870: struct tty_ctx {
                    871:        struct window_pane *wp;
                    872:
                    873:        const struct grid_cell *cell;
                    874:        const struct grid_utf8 *utf8;
                    875:
1.49      nicm      876:        u_int            num;
                    877:        void            *ptr;
                    878:
                    879:        /*
                    880:         * Cursor and region position before the screen was updated - this is
                    881:         * where the command should be applied; the values in the screen have
                    882:         * already been updated.
                    883:         */
                    884:        u_int            ocx;
                    885:        u_int            ocy;
                    886:
                    887:        u_int            orupper;
                    888:        u_int            orlower;
1.47      nicm      889: };
                    890:
1.1       nicm      891: /* Client connection. */
                    892: struct client {
                    893:        int              fd;
                    894:        struct buffer   *in;
                    895:        struct buffer   *out;
                    896:
                    897:        char            *title;
                    898:        char            *cwd;
                    899:
                    900:        struct tty       tty;
                    901:        struct timeval   status_timer;
                    902:        struct timeval   repeat_timer;
                    903:
                    904:        struct screen    status;
                    905:
                    906: #define CLIENT_TERMINAL 0x1
                    907: #define CLIENT_PREFIX 0x2
                    908: #define CLIENT_MOUSE 0x4
                    909: #define CLIENT_REDRAW 0x8
                    910: #define CLIENT_STATUS 0x10
                    911: #define CLIENT_REPEAT 0x20     /* allow command to repeat within repeat time */
                    912: #define CLIENT_SUSPENDED 0x40
1.70      nicm      913: #define CLIENT_BAD 0x80
1.1       nicm      914:        int              flags;
                    915:
                    916:        char            *message_string;
                    917:        struct timeval   message_timer;
                    918:
                    919:        char            *prompt_string;
                    920:        char            *prompt_buffer;
                    921:        size_t           prompt_index;
1.33      nicm      922:        int              (*prompt_callbackfn)(void *, const char *);
                    923:        void             (*prompt_freefn)(void *);
1.1       nicm      924:        void            *prompt_data;
                    925:
                    926: #define PROMPT_HIDDEN 0x1
                    927: #define PROMPT_SINGLE 0x2
                    928:        int              prompt_flags;
                    929:
                    930:        u_int            prompt_hindex;
                    931:        ARRAY_DECL(, char *) prompt_hdata;
                    932:
                    933:        struct mode_key_data prompt_mdata;
                    934:
                    935:        struct session  *session;
                    936: };
                    937: ARRAY_DECL(clients, struct client *);
                    938:
                    939: /* Client context. */
                    940: struct client_ctx {
                    941:        int              srv_fd;
                    942:        struct buffer   *srv_in;
                    943:        struct buffer   *srv_out;
                    944:
1.53      nicm      945:        enum {
                    946:                CCTX_DETACH,
                    947:                CCTX_EXIT,
                    948:                CCTX_DIED,
                    949:                CCTX_SHUTDOWN,
                    950:        } exittype;
                    951:        const char      *errstr;
1.1       nicm      952: };
                    953:
                    954: /* Key/command line command. */
                    955: struct cmd_ctx {
1.35      nicm      956:        /*
                    957:         * curclient is the client where this command was executed if inside
                    958:         * tmux. This is NULL if the command came from the command-line.
                    959:         *
                    960:         * cmdclient is the client which sent the MSG_COMMAND to the server, if
                    961:         * any. This is NULL unless the command came from the command-line.
                    962:         *
1.52      nicm      963:         * cmdclient and curclient may both be NULL if the command is in the
                    964:         * configuration file.
1.35      nicm      965:         */
1.1       nicm      966:        struct client  *curclient;
1.54      nicm      967:        struct client  *cmdclient;
                    968:
1.1       nicm      969:        struct session *cursession;
1.35      nicm      970:
1.1       nicm      971:        struct msg_command_data *msgdata;
                    972:
                    973:        void            (*print)(struct cmd_ctx *, const char *, ...);
                    974:        void            (*info)(struct cmd_ctx *, const char *, ...);
                    975:        void            (*error)(struct cmd_ctx *, const char *, ...);
                    976: };
                    977:
                    978: struct cmd {
                    979:        const struct cmd_entry *entry;
                    980:        void            *data;
                    981:
                    982:        TAILQ_ENTRY(cmd) qentry;
                    983: };
                    984: TAILQ_HEAD(cmd_list, cmd);
                    985:
                    986: struct cmd_entry {
                    987:        const char      *name;
                    988:        const char      *alias;
                    989:        const char      *usage;
                    990:
                    991: #define CMD_STARTSERVER 0x1
                    992: #define CMD_CANTNEST 0x2
                    993: #define CMD_ARG1 0x4
                    994: #define CMD_ARG01 0x8
1.27      nicm      995:        int              flags;
1.1       nicm      996:
1.27      nicm      997: #define CMD_CHFLAG(flag) \
                    998:        ((flag) >= 'a' && (flag) <= 'z' ? 1ULL << ((flag) - 'a') :      \
                    999:        (flag) >= 'A' && (flag) <= 'Z' ? 1ULL << (26 + (flag) - 'A') : 0)
                   1000:        uint64_t         chflags;
1.1       nicm     1001:
                   1002:        void             (*init)(struct cmd *, int);
                   1003:        int              (*parse)(struct cmd *, int, char **, char **);
                   1004:        int              (*exec)(struct cmd *, struct cmd_ctx *);
                   1005:        void             (*free)(struct cmd *);
                   1006:        size_t           (*print)(struct cmd *, char *, size_t);
                   1007: };
                   1008:
                   1009: /* Generic command data. */
                   1010: struct cmd_target_data {
1.27      nicm     1011:        uint64_t chflags;
1.1       nicm     1012:        char    *target;
                   1013:        char    *arg;
                   1014: };
                   1015:
                   1016: struct cmd_srcdst_data {
1.27      nicm     1017:        uint64_t chflags;
1.1       nicm     1018:        char    *src;
                   1019:        char    *dst;
                   1020:        char    *arg;
                   1021: };
                   1022:
                   1023: struct cmd_buffer_data {
1.27      nicm     1024:        uint64_t chflags;
1.1       nicm     1025:        char    *target;
                   1026:        int      buffer;
                   1027:        char    *arg;
                   1028: };
                   1029:
                   1030: struct cmd_option_data {
1.27      nicm     1031:        uint64_t chflags;
1.1       nicm     1032:        char    *target;
                   1033:        char    *option;
                   1034:        char    *value;
                   1035: };
                   1036:
                   1037: /* Key binding. */
                   1038: struct key_binding {
                   1039:        int              key;
                   1040:        struct cmd_list *cmdlist;
                   1041:        int              can_repeat;
                   1042:
                   1043:        SPLAY_ENTRY(key_binding) entry;
                   1044: };
                   1045: SPLAY_HEAD(key_bindings, key_binding);
                   1046:
                   1047: /* Set/display option data. */
                   1048: struct set_option_entry {
                   1049:        const char      *name;
                   1050:        enum {
                   1051:                SET_OPTION_STRING,
                   1052:                SET_OPTION_NUMBER,
                   1053:                SET_OPTION_KEY,
                   1054:                SET_OPTION_COLOUR,
                   1055:                SET_OPTION_ATTRIBUTES,
                   1056:                SET_OPTION_FLAG,
                   1057:                SET_OPTION_CHOICE
                   1058:        } type;
                   1059:
                   1060:        u_int            minimum;
                   1061:        u_int            maximum;
                   1062:
                   1063:        const char     **choices;
                   1064: };
                   1065: extern const struct set_option_entry set_option_table[];
                   1066: extern const struct set_option_entry set_window_option_table[];
                   1067:
                   1068: /* tmux.c */
                   1069: extern volatile sig_atomic_t sigwinch;
                   1070: extern volatile sig_atomic_t sigterm;
                   1071: extern volatile sig_atomic_t sigcont;
                   1072: extern volatile sig_atomic_t sigchld;
                   1073: extern volatile sig_atomic_t sigusr1;
                   1074: extern volatile sig_atomic_t sigusr2;
1.16      nicm     1075: extern struct options global_s_options;
                   1076: extern struct options global_w_options;
1.1       nicm     1077: extern char    *cfg_file;
                   1078: extern int      server_locked;
1.40      nicm     1079: extern u_int    password_failures;
1.1       nicm     1080: extern char    *server_password;
                   1081: extern time_t   server_activity;
                   1082: extern int      debug_level;
                   1083: extern int      be_quiet;
                   1084: extern time_t   start_time;
                   1085: extern char    *socket_path;
                   1086: void            logfile(const char *);
                   1087: void            siginit(void);
                   1088: void            sigreset(void);
                   1089: void            sighandler(int);
                   1090:
                   1091: /* cfg.c */
                   1092: int             load_cfg(const char *, char **x);
                   1093:
                   1094: /* mode-key.c */
1.62      nicm     1095: extern const struct mode_key_table mode_key_tables[];
                   1096: extern struct mode_key_tree mode_key_tree_vi_edit;
                   1097: extern struct mode_key_tree mode_key_tree_vi_choice;
                   1098: extern struct mode_key_tree mode_key_tree_vi_copy;
                   1099: extern struct mode_key_tree mode_key_tree_emacs_edit;
                   1100: extern struct mode_key_tree mode_key_tree_emacs_choice;
                   1101: extern struct mode_key_tree mode_key_tree_emacs_copy;
                   1102: int    mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
                   1103: SPLAY_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
                   1104: const char *mode_key_tostring(struct mode_key_cmdstr *r, enum mode_key_cmd);
1.63      nicm     1105: enum mode_key_cmd mode_key_fromstring(struct mode_key_cmdstr *, const char *);
                   1106: const struct mode_key_table *mode_key_findtable(const char *);
1.62      nicm     1107: void   mode_key_init_trees(void);
                   1108: void   mode_key_free_trees(void);
                   1109: void   mode_key_init(struct mode_key_data *, struct mode_key_tree *);
1.1       nicm     1110: enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
                   1111:
                   1112: /* options.c */
                   1113: int    options_cmp(struct options_entry *, struct options_entry *);
                   1114: SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
                   1115: void   options_init(struct options *, struct options *);
                   1116: void   options_free(struct options *);
                   1117: struct options_entry *options_find1(struct options *, const char *);
                   1118: struct options_entry *options_find(struct options *, const char *);
1.44      nicm     1119: void   options_remove(struct options *, const char *);
1.1       nicm     1120: void printflike3 options_set_string(
                   1121:            struct options *, const char *, const char *, ...);
                   1122: char   *options_get_string(struct options *, const char *);
                   1123: void   options_set_number(struct options *, const char *, long long);
                   1124: long long options_get_number(struct options *, const char *);
                   1125:
                   1126: /* tty.c */
1.47      nicm     1127: u_char tty_get_acs(struct tty *, u_char);
                   1128: void   tty_reset(struct tty *);
                   1129: void   tty_region(struct tty *, u_int, u_int, u_int);
                   1130: void   tty_cursor(struct tty *, u_int, u_int, u_int, u_int);
                   1131: void   tty_putcode(struct tty *, enum tty_code_code);
                   1132: void   tty_putcode1(struct tty *, enum tty_code_code, int);
                   1133: void   tty_putcode2(struct tty *, enum tty_code_code, int, int);
                   1134: void   tty_puts(struct tty *, const char *);
                   1135: void   tty_putc(struct tty *, u_char);
                   1136: void   tty_pututf8(struct tty *, const struct grid_utf8 *);
                   1137: void   tty_init(struct tty *, char *, char *);
                   1138: void   tty_start_tty(struct tty *);
                   1139: void   tty_stop_tty(struct tty *);
                   1140: void   tty_detect_utf8(struct tty *);
                   1141: void   tty_set_title(struct tty *, const char *);
                   1142: void   tty_update_mode(struct tty *, int);
                   1143: void   tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
1.67      nicm     1144: int    tty_open(struct tty *, const char *, char **);
1.47      nicm     1145: void   tty_close(struct tty *, int);
                   1146: void   tty_free(struct tty *, int);
1.49      nicm     1147: void   tty_write(void (*)(struct tty *, struct tty_ctx *), struct tty_ctx *);
1.47      nicm     1148: void   tty_cmd_alignmenttest(struct tty *, struct tty_ctx *);
                   1149: void   tty_cmd_cell(struct tty *, struct tty_ctx *);
                   1150: void   tty_cmd_clearendofline(struct tty *, struct tty_ctx *);
                   1151: void   tty_cmd_clearendofscreen(struct tty *, struct tty_ctx *);
                   1152: void   tty_cmd_clearline(struct tty *, struct tty_ctx *);
                   1153: void   tty_cmd_clearscreen(struct tty *, struct tty_ctx *);
                   1154: void   tty_cmd_clearstartofline(struct tty *, struct tty_ctx *);
                   1155: void   tty_cmd_clearstartofscreen(struct tty *, struct tty_ctx *);
                   1156: void   tty_cmd_deletecharacter(struct tty *, struct tty_ctx *);
                   1157: void   tty_cmd_deleteline(struct tty *, struct tty_ctx *);
                   1158: void   tty_cmd_insertcharacter(struct tty *, struct tty_ctx *);
                   1159: void   tty_cmd_insertline(struct tty *, struct tty_ctx *);
                   1160: void   tty_cmd_linefeed(struct tty *, struct tty_ctx *);
                   1161: void   tty_cmd_utf8character(struct tty *, struct tty_ctx *);
                   1162: void   tty_cmd_reverseindex(struct tty *, struct tty_ctx *);
1.1       nicm     1163:
                   1164: /* tty-term.c */
                   1165: extern struct tty_terms tty_terms;
                   1166: extern struct tty_term_code_entry tty_term_codes[NTTYCODE];
1.67      nicm     1167: struct tty_term *tty_term_find(char *, int, const char *, char **);
1.1       nicm     1168: void            tty_term_free(struct tty_term *);
                   1169: int             tty_term_has(struct tty_term *, enum tty_code_code);
                   1170: const char     *tty_term_string(struct tty_term *, enum tty_code_code);
                   1171: const char     *tty_term_string1(struct tty_term *, enum tty_code_code, int);
                   1172: const char     *tty_term_string2(
                   1173:                     struct tty_term *, enum tty_code_code, int, int);
                   1174: int             tty_term_number(struct tty_term *, enum tty_code_code);
                   1175: int             tty_term_flag(struct tty_term *, enum tty_code_code);
                   1176:
                   1177: /* tty-keys.c */
1.47      nicm     1178: int    tty_keys_cmp(struct tty_key *, struct tty_key *);
1.1       nicm     1179: RB_PROTOTYPE(tty_keys, tty_key, entry, tty_keys_cmp);
1.47      nicm     1180: void   tty_keys_init(struct tty *);
                   1181: void   tty_keys_free(struct tty *);
                   1182: int    tty_keys_next(struct tty *, int *, u_char *);
1.1       nicm     1183:
                   1184: /* options-cmd.c */
                   1185: void   set_option_string(struct cmd_ctx *,
1.68      nicm     1186:            struct options *, const struct set_option_entry *, char *, int);
1.1       nicm     1187: void   set_option_number(struct cmd_ctx *,
                   1188:            struct options *, const struct set_option_entry *, char *);
                   1189: void   set_option_key(struct cmd_ctx *,
                   1190:            struct options *, const struct set_option_entry *, char *);
                   1191: void   set_option_colour(struct cmd_ctx *,
                   1192:            struct options *, const struct set_option_entry *, char *);
                   1193: void   set_option_attributes(struct cmd_ctx *,
                   1194:            struct options *, const struct set_option_entry *, char *);
                   1195: void   set_option_flag(struct cmd_ctx *,
                   1196:            struct options *, const struct set_option_entry *, char *);
                   1197: void   set_option_choice(struct cmd_ctx *,
                   1198:            struct options *, const struct set_option_entry *, char *);
                   1199:
                   1200: /* paste.c */
                   1201: void            paste_init_stack(struct paste_stack *);
                   1202: void            paste_free_stack(struct paste_stack *);
                   1203: struct paste_buffer *paste_walk_stack(struct paste_stack *, uint *);
                   1204: struct paste_buffer *paste_get_top(struct paste_stack *);
                   1205: struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
                   1206: int             paste_free_top(struct paste_stack *);
                   1207: int             paste_free_index(struct paste_stack *, u_int);
                   1208: void            paste_add(struct paste_stack *, char *, u_int);
                   1209: int             paste_replace(struct paste_stack *, u_int, char *);
                   1210:
                   1211: /* clock.c */
                   1212: void            clock_draw(struct screen_write_ctx *, u_int, int);
                   1213:
                   1214: /* cmd.c */
1.55      nicm     1215: int             cmd_pack_argv(int, char **, char *, size_t);
                   1216: int             cmd_unpack_argv(char *, size_t, int, char ***);
                   1217: void            cmd_free_argv(int, char **);
1.1       nicm     1218: struct cmd     *cmd_parse(int, char **, char **);
                   1219: int             cmd_exec(struct cmd *, struct cmd_ctx *);
                   1220: void            cmd_free(struct cmd *);
                   1221: size_t          cmd_print(struct cmd *, char *, size_t);
                   1222: struct session *cmd_current_session(struct cmd_ctx *);
                   1223: struct client  *cmd_find_client(struct cmd_ctx *, const char *);
                   1224: struct session *cmd_find_session(struct cmd_ctx *, const char *);
                   1225: struct winlink *cmd_find_window(
1.26      nicm     1226:                     struct cmd_ctx *, const char *, struct session **);
                   1227: int             cmd_find_index(
                   1228:                     struct cmd_ctx *, const char *, struct session **);
1.65      nicm     1229: struct winlink *cmd_find_pane(struct cmd_ctx *,
                   1230:                     const char *, struct session **, struct window_pane **);
1.1       nicm     1231: extern const struct cmd_entry *cmd_table[];
                   1232: extern const struct cmd_entry cmd_attach_session_entry;
                   1233: extern const struct cmd_entry cmd_bind_key_entry;
                   1234: extern const struct cmd_entry cmd_break_pane_entry;
                   1235: extern const struct cmd_entry cmd_choose_session_entry;
                   1236: extern const struct cmd_entry cmd_choose_window_entry;
                   1237: extern const struct cmd_entry cmd_clear_history_entry;
                   1238: extern const struct cmd_entry cmd_clock_mode_entry;
                   1239: extern const struct cmd_entry cmd_command_prompt_entry;
                   1240: extern const struct cmd_entry cmd_confirm_before_entry;
                   1241: extern const struct cmd_entry cmd_copy_buffer_entry;
                   1242: extern const struct cmd_entry cmd_copy_mode_entry;
                   1243: extern const struct cmd_entry cmd_delete_buffer_entry;
                   1244: extern const struct cmd_entry cmd_detach_client_entry;
1.36      nicm     1245: extern const struct cmd_entry cmd_display_message_entry;
1.1       nicm     1246: extern const struct cmd_entry cmd_down_pane_entry;
                   1247: extern const struct cmd_entry cmd_find_window_entry;
                   1248: extern const struct cmd_entry cmd_has_session_entry;
1.19      nicm     1249: extern const struct cmd_entry cmd_if_shell_entry;
1.1       nicm     1250: extern const struct cmd_entry cmd_kill_pane_entry;
                   1251: extern const struct cmd_entry cmd_kill_server_entry;
                   1252: extern const struct cmd_entry cmd_kill_session_entry;
                   1253: extern const struct cmd_entry cmd_kill_window_entry;
                   1254: extern const struct cmd_entry cmd_last_window_entry;
                   1255: extern const struct cmd_entry cmd_link_window_entry;
                   1256: extern const struct cmd_entry cmd_list_buffers_entry;
                   1257: extern const struct cmd_entry cmd_list_clients_entry;
                   1258: extern const struct cmd_entry cmd_list_commands_entry;
                   1259: extern const struct cmd_entry cmd_list_keys_entry;
                   1260: extern const struct cmd_entry cmd_list_sessions_entry;
                   1261: extern const struct cmd_entry cmd_list_windows_entry;
                   1262: extern const struct cmd_entry cmd_load_buffer_entry;
                   1263: extern const struct cmd_entry cmd_lock_server_entry;
                   1264: extern const struct cmd_entry cmd_move_window_entry;
                   1265: extern const struct cmd_entry cmd_new_session_entry;
                   1266: extern const struct cmd_entry cmd_new_window_entry;
                   1267: extern const struct cmd_entry cmd_next_layout_entry;
                   1268: extern const struct cmd_entry cmd_next_window_entry;
                   1269: extern const struct cmd_entry cmd_paste_buffer_entry;
                   1270: extern const struct cmd_entry cmd_previous_layout_entry;
                   1271: extern const struct cmd_entry cmd_previous_window_entry;
                   1272: extern const struct cmd_entry cmd_refresh_client_entry;
                   1273: extern const struct cmd_entry cmd_rename_session_entry;
                   1274: extern const struct cmd_entry cmd_rename_window_entry;
                   1275: extern const struct cmd_entry cmd_resize_pane_entry;
                   1276: extern const struct cmd_entry cmd_respawn_window_entry;
                   1277: extern const struct cmd_entry cmd_rotate_window_entry;
                   1278: extern const struct cmd_entry cmd_save_buffer_entry;
                   1279: extern const struct cmd_entry cmd_scroll_mode_entry;
                   1280: extern const struct cmd_entry cmd_select_layout_entry;
                   1281: extern const struct cmd_entry cmd_select_pane_entry;
                   1282: extern const struct cmd_entry cmd_select_prompt_entry;
                   1283: extern const struct cmd_entry cmd_select_window_entry;
                   1284: extern const struct cmd_entry cmd_send_keys_entry;
                   1285: extern const struct cmd_entry cmd_send_prefix_entry;
                   1286: extern const struct cmd_entry cmd_server_info_entry;
                   1287: extern const struct cmd_entry cmd_set_buffer_entry;
                   1288: extern const struct cmd_entry cmd_set_option_entry;
                   1289: extern const struct cmd_entry cmd_set_password_entry;
                   1290: extern const struct cmd_entry cmd_set_window_option_entry;
                   1291: extern const struct cmd_entry cmd_show_buffer_entry;
                   1292: extern const struct cmd_entry cmd_show_options_entry;
                   1293: extern const struct cmd_entry cmd_show_window_options_entry;
                   1294: extern const struct cmd_entry cmd_source_file_entry;
                   1295: extern const struct cmd_entry cmd_split_window_entry;
                   1296: extern const struct cmd_entry cmd_start_server_entry;
                   1297: extern const struct cmd_entry cmd_suspend_client_entry;
                   1298: extern const struct cmd_entry cmd_swap_pane_entry;
                   1299: extern const struct cmd_entry cmd_swap_window_entry;
                   1300: extern const struct cmd_entry cmd_switch_client_entry;
                   1301: extern const struct cmd_entry cmd_unbind_key_entry;
                   1302: extern const struct cmd_entry cmd_unlink_window_entry;
                   1303: extern const struct cmd_entry cmd_up_pane_entry;
                   1304:
                   1305: /* cmd-list.c */
                   1306: struct cmd_list        *cmd_list_parse(int, char **, char **);
                   1307: int             cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
                   1308: void            cmd_list_free(struct cmd_list *);
                   1309: size_t          cmd_list_print(struct cmd_list *, char *, size_t);
                   1310:
                   1311: /* cmd-string.c */
                   1312: int    cmd_string_parse(const char *, struct cmd_list **, char **);
                   1313:
                   1314: /* cmd-generic.c */
                   1315: size_t  cmd_prarg(char *, size_t, const char *, char *);
1.65      nicm     1316: #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1.1       nicm     1317: #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
                   1318: #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
                   1319: #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
                   1320: void   cmd_target_init(struct cmd *, int);
                   1321: int    cmd_target_parse(struct cmd *, int, char **, char **);
                   1322: void   cmd_target_free(struct cmd *);
                   1323: size_t cmd_target_print(struct cmd *, char *, size_t);
1.65      nicm     1324: #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1.1       nicm     1325: #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
                   1326: #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
                   1327: #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
                   1328: void   cmd_srcdst_init(struct cmd *, int);
                   1329: int    cmd_srcdst_parse(struct cmd *, int, char **, char **);
                   1330: void   cmd_srcdst_free(struct cmd *);
                   1331: size_t cmd_srcdst_print(struct cmd *, char *, size_t);
1.65      nicm     1332: #define CMD_BUFFER_PANE_USAGE "[-b buffer-index] [-t target-pane]"
1.1       nicm     1333: #define CMD_BUFFER_WINDOW_USAGE "[-b buffer-index] [-t target-window]"
                   1334: #define CMD_BUFFER_SESSION_USAGE "[-b buffer-index] [-t target-session]"
                   1335: #define CMD_BUFFER_CLIENT_USAGE "[-b buffer-index] [-t target-client]"
                   1336: void   cmd_buffer_init(struct cmd *, int);
                   1337: int    cmd_buffer_parse(struct cmd *, int, char **, char **);
                   1338: void   cmd_buffer_free(struct cmd *);
                   1339: size_t cmd_buffer_print(struct cmd *, char *, size_t);
1.68      nicm     1340: #define CMD_OPTION_PANE_USAGE "[-t target-pane] option [value]"
                   1341: #define CMD_OPTION_WINDOW_USAGE "[-t target-window] option [value]"
                   1342: #define CMD_OPTION_SESSION_USAGE "[-t target-session] option [value]"
                   1343: #define CMD_OPTION_CLIENT_USAGE "[-t target-client] option [value]"
1.1       nicm     1344: void   cmd_option_init(struct cmd *, int);
                   1345: int    cmd_option_parse(struct cmd *, int, char **, char **);
                   1346: void   cmd_option_free(struct cmd *);
                   1347: size_t cmd_option_print(struct cmd *, char *, size_t);
                   1348:
                   1349: /* client.c */
                   1350: int     client_init(char *, struct client_ctx *, int, int);
                   1351: int     client_main(struct client_ctx *);
1.53      nicm     1352: int     client_msg_dispatch(struct client_ctx *);
1.1       nicm     1353:
                   1354: /* client-fn.c */
1.64      nicm     1355: void    client_write_server(struct client_ctx *, enum msgtype, void *, size_t);
1.1       nicm     1356: void    client_fill_session(struct msg_command_data *);
1.66      nicm     1357: void    client_suspend(void);
1.1       nicm     1358:
                   1359: /* key-bindings.c */
                   1360: extern struct key_bindings key_bindings;
                   1361: int     key_bindings_cmp(struct key_binding *, struct key_binding *);
                   1362: SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
                   1363: struct key_binding *key_bindings_lookup(int);
                   1364: void    key_bindings_add(int, int, struct cmd_list *);
                   1365: void    key_bindings_remove(int);
1.24      nicm     1366: void    key_bindings_clean(void);
1.1       nicm     1367: void    key_bindings_init(void);
                   1368: void    key_bindings_free(void);
                   1369: void    key_bindings_dispatch(struct key_binding *, struct client *);
                   1370: void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
                   1371: void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
                   1372: void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
                   1373:
                   1374: /* key-string.c */
                   1375: int     key_string_lookup_string(const char *);
                   1376: const char *key_string_lookup_key(int);
                   1377:
                   1378: /* server.c */
                   1379: extern struct clients clients;
                   1380: int     server_client_index(struct client *);
                   1381: int     server_start(char *);
                   1382:
                   1383: /* server-msg.c */
                   1384: int     server_msg_dispatch(struct client *);
                   1385:
                   1386: /* server-fn.c */
                   1387: const char **server_fill_environ(struct session *);
1.55      nicm     1388: void    server_write_error(struct client *, const char *);
1.1       nicm     1389: void    server_write_client(
1.64      nicm     1390:              struct client *, enum msgtype, const void *, size_t);
1.1       nicm     1391: void    server_write_session(
1.64      nicm     1392:              struct session *, enum msgtype, const void *, size_t);
1.1       nicm     1393: void    server_redraw_client(struct client *);
                   1394: void    server_status_client(struct client *);
                   1395: void    server_redraw_session(struct session *);
                   1396: void    server_status_session(struct session *);
                   1397: void    server_redraw_window(struct window *);
                   1398: void    server_status_window(struct window *);
                   1399: void    server_lock(void);
                   1400: int     server_unlock(const char *);
1.37      nicm     1401: void    server_kill_window(struct window *);
1.1       nicm     1402:
                   1403: /* status.c */
                   1404: int     status_redraw(struct client *);
1.36      nicm     1405: char   *status_replace(struct session *, const char *, time_t);
1.32      nicm     1406: void printflike2 status_message_set(struct client *, const char *, ...);
1.1       nicm     1407: void    status_message_clear(struct client *);
                   1408: int     status_message_redraw(struct client *);
1.33      nicm     1409: void    status_prompt_set(struct client *, const char *,
                   1410:             int (*)(void *, const char *), void (*)(void *), void *, int);
1.1       nicm     1411: void    status_prompt_clear(struct client *);
                   1412: int     status_prompt_redraw(struct client *);
                   1413: void    status_prompt_key(struct client *, int);
                   1414:
                   1415: /* resize.c */
                   1416: void    recalculate_sizes(void);
                   1417:
                   1418: /* input.c */
                   1419: void    input_init(struct window_pane *);
                   1420: void    input_free(struct window_pane *);
                   1421: void    input_parse(struct window_pane *);
                   1422:
                   1423: /* input-key.c */
                   1424: void    input_key(struct window_pane *, int);
                   1425: void    input_mouse(struct window_pane *, u_char, u_char, u_char);
                   1426:
                   1427: /* colour.c */
                   1428: const char *colour_tostring(u_char);
                   1429: int     colour_fromstring(const char *);
                   1430: u_char  colour_256to16(u_char);
                   1431: u_char  colour_256to88(u_char);
                   1432:
                   1433: /* attributes.c */
                   1434: const char *attributes_tostring(u_char);
                   1435: int     attributes_fromstring(const char *);
                   1436:
                   1437: /* grid.c */
                   1438: extern const struct grid_cell grid_default_cell;
                   1439: struct grid *grid_create(u_int, u_int, u_int);
                   1440: void    grid_destroy(struct grid *);
                   1441: int     grid_compare(struct grid *, struct grid *);
                   1442: void    grid_expand_line(struct grid *, u_int, u_int);
                   1443: void    grid_expand_line_utf8(struct grid *, u_int, u_int);
                   1444: void    grid_scroll_line(struct grid *);
                   1445: const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
                   1446: struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
                   1447: void    grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
                   1448: const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
                   1449: struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
                   1450: void    grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
                   1451: void    grid_clear(struct grid *, u_int, u_int, u_int, u_int);
                   1452: void    grid_clear_lines(struct grid *, u_int, u_int);
                   1453: void    grid_move_lines(struct grid *, u_int, u_int, u_int);
                   1454: void    grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1.9       nicm     1455: char   *grid_string_cells(struct grid *, u_int, u_int, u_int);
1.25      nicm     1456: void    grid_duplicate_lines(
                   1457:             struct grid *, u_int, struct grid *, u_int, u_int);
1.1       nicm     1458:
                   1459: /* grid-view.c */
                   1460: const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
                   1461: struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
                   1462: void    grid_view_set_cell(
                   1463:             struct grid *, u_int, u_int, const struct grid_cell *);
                   1464: const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
                   1465: struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
                   1466: void    grid_view_set_utf8(
                   1467:             struct grid *, u_int, u_int, const struct grid_utf8 *);
                   1468: void    grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
                   1469: void    grid_view_scroll_region_up(struct grid *, u_int, u_int);
                   1470: void    grid_view_scroll_region_down(struct grid *, u_int, u_int);
                   1471: void    grid_view_insert_lines(struct grid *, u_int, u_int);
1.18      nicm     1472: void    grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1.1       nicm     1473: void    grid_view_delete_lines(struct grid *, u_int, u_int);
1.18      nicm     1474: void    grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1.1       nicm     1475: void    grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
                   1476: void    grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1.9       nicm     1477: char   *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1.1       nicm     1478:
                   1479: /* screen-write.c */
                   1480: void    screen_write_start(
                   1481:             struct screen_write_ctx *, struct window_pane *, struct screen *);
                   1482: void    screen_write_stop(struct screen_write_ctx *);
1.4       nicm     1483: size_t printflike2 screen_write_strlen(int, const char *, ...);
1.3       nicm     1484: void printflike3 screen_write_puts(struct screen_write_ctx *,
                   1485:             struct grid_cell *, const char *, ...);
1.4       nicm     1486: void printflike5 screen_write_nputs(struct screen_write_ctx *,
                   1487:     ssize_t, struct grid_cell *, int, const char *, ...);
1.3       nicm     1488: void    screen_write_vnputs(struct screen_write_ctx *,
1.4       nicm     1489:             ssize_t, struct grid_cell *, int, const char *, va_list);
1.1       nicm     1490: void    screen_write_putc(
                   1491:             struct screen_write_ctx *, struct grid_cell *, u_char);
                   1492: void    screen_write_copy(struct screen_write_ctx *,
                   1493:             struct screen *, u_int, u_int, u_int, u_int);
                   1494: void    screen_write_cursorup(struct screen_write_ctx *, u_int);
                   1495: void    screen_write_cursordown(struct screen_write_ctx *, u_int);
                   1496: void    screen_write_cursorright(struct screen_write_ctx *, u_int);
                   1497: void    screen_write_cursorleft(struct screen_write_ctx *, u_int);
1.5       nicm     1498: void    screen_write_alignmenttest(struct screen_write_ctx *);
1.1       nicm     1499: void    screen_write_insertcharacter(struct screen_write_ctx *, u_int);
                   1500: void    screen_write_deletecharacter(struct screen_write_ctx *, u_int);
                   1501: void    screen_write_insertline(struct screen_write_ctx *, u_int);
                   1502: void    screen_write_deleteline(struct screen_write_ctx *, u_int);
                   1503: void    screen_write_clearline(struct screen_write_ctx *);
                   1504: void    screen_write_clearendofline(struct screen_write_ctx *);
                   1505: void    screen_write_clearstartofline(struct screen_write_ctx *);
                   1506: void    screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
                   1507: void    screen_write_cursormode(struct screen_write_ctx *, int);
                   1508: void    screen_write_reverseindex(struct screen_write_ctx *);
                   1509: void    screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
                   1510: void    screen_write_insertmode(struct screen_write_ctx *, int);
                   1511: void    screen_write_mousemode(struct screen_write_ctx *, int);
1.72    ! nicm     1512: void    screen_write_linefeed(struct screen_write_ctx *, int);
1.1       nicm     1513: void    screen_write_carriagereturn(struct screen_write_ctx *);
                   1514: void    screen_write_kcursormode(struct screen_write_ctx *, int);
                   1515: void    screen_write_kkeypadmode(struct screen_write_ctx *, int);
                   1516: void    screen_write_clearendofscreen(struct screen_write_ctx *);
                   1517: void    screen_write_clearstartofscreen(struct screen_write_ctx *);
                   1518: void    screen_write_clearscreen(struct screen_write_ctx *);
                   1519: void    screen_write_cell(
                   1520:             struct screen_write_ctx *, const struct grid_cell *, u_char *);
                   1521:
                   1522: /* screen-redraw.c */
1.29      nicm     1523: void    screen_redraw_screen(struct client *, int);
1.1       nicm     1524: void    screen_redraw_pane(struct client *, struct window_pane *);
                   1525:
                   1526: /* screen.c */
                   1527: void    screen_init(struct screen *, u_int, u_int, u_int);
                   1528: void    screen_reinit(struct screen *);
                   1529: void    screen_free(struct screen *);
1.6       nicm     1530: void    screen_reset_tabs(struct screen *);
1.1       nicm     1531: void    screen_set_title(struct screen *, const char *);
                   1532: void    screen_resize(struct screen *, u_int, u_int);
                   1533: void    screen_set_selection(
                   1534:             struct screen *, u_int, u_int, u_int, u_int, struct grid_cell *);
                   1535: void    screen_clear_selection(struct screen *);
                   1536: int     screen_check_selection(struct screen *, u_int, u_int);
                   1537:
                   1538: /* window.c */
                   1539: extern struct windows windows;
1.17      nicm     1540: const char     *window_default_command(void);
1.1       nicm     1541: int             window_cmp(struct window *, struct window *);
                   1542: int             winlink_cmp(struct winlink *, struct winlink *);
                   1543: RB_PROTOTYPE(windows, window, entry, window_cmp);
                   1544: RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
                   1545: struct winlink *winlink_find_by_index(struct winlinks *, int);
                   1546: struct winlink         *winlink_find_by_window(struct winlinks *, struct window *);
                   1547: int             winlink_next_index(struct winlinks *);
                   1548: u_int           winlink_count(struct winlinks *);
                   1549: struct winlink *winlink_add(struct winlinks *, struct window *, int);
                   1550: void            winlink_remove(struct winlinks *, struct winlink *);
                   1551: struct winlink *winlink_next(struct winlinks *, struct winlink *);
                   1552: struct winlink *winlink_previous(struct winlinks *, struct winlink *);
                   1553: void            winlink_stack_push(struct winlink_stack *, struct winlink *);
                   1554: void            winlink_stack_remove(struct winlink_stack *, struct winlink *);
                   1555: int             window_index(struct window *, u_int *);
                   1556: struct window  *window_create1(u_int, u_int);
                   1557: struct window  *window_create(const char *, const char *,
                   1558:                     const char *, const char **, u_int, u_int, u_int, char **);
                   1559: void            window_destroy(struct window *);
                   1560: void            window_set_active_pane(struct window *, struct window_pane *);
1.51      nicm     1561: struct window_pane *window_add_pane(struct window *, u_int);
1.44      nicm     1562: void            window_resize(struct window *, u_int, u_int);
1.1       nicm     1563: void            window_remove_pane(struct window *, struct window_pane *);
                   1564: struct window_pane *window_pane_at_index(struct window *, u_int);
1.36      nicm     1565: u_int           window_pane_index(struct window *, struct window_pane *);
1.1       nicm     1566: u_int           window_count_panes(struct window *);
                   1567: void            window_destroy_panes(struct window *);
                   1568: struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
                   1569: void            window_pane_destroy(struct window_pane *);
                   1570: int             window_pane_spawn(struct window_pane *,
                   1571:                     const char *, const char *, const char **, char **);
1.44      nicm     1572: void            window_pane_resize(struct window_pane *, u_int, u_int);
1.1       nicm     1573: int             window_pane_set_mode(
                   1574:                     struct window_pane *, const struct window_mode *);
                   1575: void            window_pane_reset_mode(struct window_pane *);
                   1576: void            window_pane_parse(struct window_pane *);
                   1577: void            window_pane_key(struct window_pane *, struct client *, int);
                   1578: void            window_pane_mouse(struct window_pane *,
                   1579:                     struct client *, u_char, u_char, u_char);
1.28      nicm     1580: int             window_pane_visible(struct window_pane *);
1.10      nicm     1581: char           *window_pane_search(
1.39      nicm     1582:                     struct window_pane *, const char *, u_int *);
1.1       nicm     1583:
                   1584: /* layout.c */
1.39      nicm     1585: struct layout_cell *layout_create_cell(struct layout_cell *);
                   1586: void            layout_free_cell(struct layout_cell *);
                   1587: void            layout_print_cell(struct layout_cell *, const char *, u_int);
                   1588: void            layout_set_size(
                   1589:                     struct layout_cell *, u_int, u_int, u_int, u_int);
                   1590: void            layout_make_leaf(
                   1591:                     struct layout_cell *, struct window_pane *);
                   1592: void            layout_make_node(struct layout_cell *, enum layout_type);
                   1593: void            layout_fix_offsets(struct layout_cell *);
                   1594: void            layout_fix_panes(struct window *, u_int, u_int);
                   1595: u_int           layout_resize_check(struct layout_cell *, enum layout_type);
                   1596: void            layout_resize_adjust(
                   1597:                     struct layout_cell *, enum layout_type, int);
                   1598: void            layout_init(struct window *);
                   1599: void            layout_free(struct window *);
                   1600: void            layout_resize(struct window *, u_int, u_int);
                   1601: void            layout_resize_pane(
                   1602:                     struct window_pane *, enum layout_type, int);
                   1603: int             layout_split_pane(struct window_pane *,
                   1604:                     enum layout_type, int, struct window_pane *);
                   1605: void            layout_close_pane(struct window_pane *);
                   1606:
                   1607: /* layout-set.c */
                   1608: const char     *layout_set_name(u_int);
                   1609: int             layout_set_lookup(const char *);
                   1610: u_int           layout_set_select(struct window *, u_int);
                   1611: u_int           layout_set_next(struct window *);
                   1612: u_int           layout_set_previous(struct window *);
                   1613: void            layout_set_active_changed(struct window *);
1.1       nicm     1614:
                   1615: /* window-clock.c */
                   1616: extern const struct window_mode window_clock_mode;
                   1617:
                   1618: /* window-copy.c */
                   1619: extern const struct window_mode window_copy_mode;
                   1620: void            window_copy_pageup(struct window_pane *);
                   1621:
                   1622: /* window-scroll.c */
                   1623: extern const struct window_mode window_scroll_mode;
                   1624: void            window_scroll_pageup(struct window_pane *);
                   1625:
                   1626: /* window-more.c */
                   1627: extern const struct window_mode window_more_mode;
                   1628: void            window_more_vadd(struct window_pane *, const char *, va_list);
                   1629:
                   1630: /* window-choose.c */
                   1631: extern const struct window_mode window_choose_mode;
                   1632: void            window_choose_vadd(
                   1633:                     struct window_pane *, int, const char *, va_list);
                   1634: void printflike3 window_choose_add(
                   1635:                     struct window_pane *, int, const char *, ...);
                   1636: void            window_choose_ready(struct window_pane *,
1.34      nicm     1637:                     u_int, void (*)(void *, int), void (*)(void *), void *);
1.1       nicm     1638:
                   1639: /* names.c */
                   1640: void            set_window_names(void);
                   1641: char           *default_window_name(struct window *);
                   1642:
                   1643: /* session.c */
                   1644: extern struct sessions sessions;
                   1645: void    session_alert_add(struct session *, struct window *, int);
                   1646: void    session_alert_cancel(struct session *, struct winlink *);
                   1647: int     session_alert_has(struct session *, struct winlink *, int);
                   1648: int     session_alert_has_window(struct session *, struct window *, int);
                   1649: struct session *session_find(const char *);
                   1650: struct session *session_create(const char *, const char *,
                   1651:                     const char *, u_int, u_int, char **);
                   1652: void            session_destroy(struct session *);
                   1653: int             session_index(struct session *, u_int *);
                   1654: struct winlink *session_new(struct session *,
                   1655:                     const char *, const char *, const char *, int, char **);
                   1656: struct winlink *session_attach(
                   1657:                     struct session *, struct window *, int, char **);
                   1658: int             session_detach(struct session *, struct winlink *);
                   1659: int             session_has(struct session *, struct window *);
                   1660: int             session_next(struct session *, int);
                   1661: int             session_previous(struct session *, int);
                   1662: int             session_select(struct session *, int);
                   1663: int             session_last(struct session *);
                   1664:
                   1665: /* utf8.c */
                   1666: void   utf8_build(void);
1.7       nicm     1667: int    utf8_width(const u_char *);
1.1       nicm     1668:
                   1669: /* procname.c */
                   1670: char   *get_proc_name(int, char *);
                   1671:
                   1672: /* buffer.c */
                   1673: struct buffer  *buffer_create(size_t);
                   1674: void            buffer_destroy(struct buffer *);
                   1675: void            buffer_ensure(struct buffer *, size_t);
                   1676: void            buffer_add(struct buffer *, size_t);
                   1677: void            buffer_remove(struct buffer *, size_t);
                   1678: void            buffer_write(struct buffer *, const void *, size_t);
                   1679: void            buffer_read(struct buffer *, void *, size_t);
                   1680: void            buffer_write8(struct buffer *, uint8_t);
                   1681: uint8_t                 buffer_read8(struct buffer *);
                   1682:
                   1683: /* buffer-poll.c */
                   1684: int             buffer_poll(struct pollfd *, struct buffer *, struct buffer *);
                   1685:
                   1686: /* log.c */
                   1687: void            log_open_tty(int);
                   1688: void            log_open_file(int, const char *);
                   1689: void            log_close(void);
                   1690: void printflike1 log_warn(const char *, ...);
                   1691: void printflike1 log_warnx(const char *, ...);
                   1692: void printflike1 log_info(const char *, ...);
                   1693: void printflike1 log_debug(const char *, ...);
                   1694: void printflike1 log_debug2(const char *, ...);
                   1695: __dead void     log_fatal(const char *, ...);
                   1696: __dead void     log_fatalx(const char *, ...);
                   1697:
                   1698: /* xmalloc.c */
                   1699: char           *xstrdup(const char *);
                   1700: void           *xcalloc(size_t, size_t);
                   1701: void           *xmalloc(size_t);
                   1702: void           *xrealloc(void *, size_t, size_t);
                   1703: void            xfree(void *);
                   1704: int printflike2         xasprintf(char **, const char *, ...);
                   1705: int             xvasprintf(char **, const char *, va_list);
                   1706: int printflike3         xsnprintf(char *, size_t, const char *, ...);
                   1707: int             xvsnprintf(char *, size_t, const char *, va_list);
                   1708:
                   1709: #endif /* TMUX_H */