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

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