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

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