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

1.352   ! nicm        1: /* $OpenBSD: tmux.h,v 1.351 2012/08/14 08:51:53 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.332     nicm       22: #define PROTOCOL_VERSION 7
1.1       nicm       23:
                     24: #include <sys/param.h>
                     25: #include <sys/time.h>
                     26: #include <sys/queue.h>
                     27: #include <sys/tree.h>
1.75      nicm       28: #include <sys/uio.h>
1.1       nicm       29:
1.6       nicm       30: #include <bitstring.h>
1.159     nicm       31: #include <event.h>
1.1       nicm       32: #include <getopt.h>
1.222     nicm       33: #include <imsg.h>
1.1       nicm       34: #include <limits.h>
                     35: #include <signal.h>
                     36: #include <stdarg.h>
                     37: #include <stdint.h>
                     38: #include <stdio.h>
                     39: #include <termios.h>
                     40:
                     41: #include "array.h"
                     42:
1.42      nicm       43: extern char    *__progname;
1.73      nicm       44: extern char   **environ;
1.1       nicm       45:
1.22      nicm       46: /* Default configuration files. */
1.1       nicm       47: #define DEFAULT_CFG ".tmux.conf"
1.22      nicm       48: #define SYSTEM_CFG "/etc/tmux.conf"
1.1       nicm       49:
                     50: /* Default prompt history length. */
                     51: #define PROMPT_HISTORY 100
                     52:
1.195     nicm       53: /*
1.39      nicm       54:  * Minimum layout cell size, NOT including separator line. The scroll region
                     55:  * cannot be one line in height so this must be at least two.
                     56:  */
                     57: #define PANE_MINIMUM 2
1.1       nicm       58:
                     59: /* Automatic name refresh interval, in milliseconds. */
                     60: #define NAME_INTERVAL 500
1.152     nicm       61:
1.55      nicm       62: /*
                     63:  * Maximum sizes of strings in message data. Don't forget to bump
                     64:  * PROTOCOL_VERSION if any of these change!
                     65:  */
                     66: #define COMMAND_LENGTH 2048    /* packed argv size */
                     67: #define TERMINAL_LENGTH 128    /* length of TERM environment variable */
1.73      nicm       68: #define ENVIRON_LENGTH 1024    /* environment variable length */
1.55      nicm       69:
1.181     nicm       70: /*
                     71:  * UTF-8 data size. This must be big enough to hold combined characters as well
                     72:  * as single.
                     73:  */
                     74: #define UTF8_SIZE 9
                     75:
1.1       nicm       76: /* Fatal errors. */
                     77: #define fatal(msg) log_fatal("%s: %s", __func__, msg);
                     78: #define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
                     79:
                     80: /* Definition to shut gcc up about unused arguments. */
                     81: #define unused __attribute__ ((unused))
                     82:
                     83: /* Attribute to make gcc check printf-like arguments. */
                     84: #define printflike1 __attribute__ ((format (printf, 1, 2)))
                     85: #define printflike2 __attribute__ ((format (printf, 2, 3)))
                     86: #define printflike3 __attribute__ ((format (printf, 3, 4)))
                     87: #define printflike4 __attribute__ ((format (printf, 4, 5)))
1.4       nicm       88: #define printflike5 __attribute__ ((format (printf, 5, 6)))
1.1       nicm       89:
                     90: /* Number of items in array. */
1.14      nicm       91: #ifndef nitems
1.1       nicm       92: #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
1.14      nicm       93: #endif
1.1       nicm       94:
1.351     nicm       95: /* Default template for choose-buffer. */
                     96: #define CHOOSE_BUFFER_TEMPLATE                                 \
1.335     nicm       97:        "#{line}: #{buffer_size} bytes: \"#{buffer_sample}\""
1.351     nicm       98:
                     99: /* Default template for choose-client. */
                    100: #define CHOOSE_CLIENT_TEMPLATE                                 \
1.335     nicm      101:        "#{client_tty}: #{session_name} "                       \
1.340     nicm      102:        "[#{client_width}x#{client_height} #{client_termname}]" \
                    103:        "#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
1.351     nicm      104:
                    105: /* Default templates for choose-tree. */
                    106: #define CHOOSE_TREE_SESSION_TEMPLATE                           \
                    107:        "#{session_name}: #{session_windows} windows "          \
                    108:        "#{?session_grouped, (group ,}"                         \
                    109:        "#{session_group}#{?session_grouped,),}"                \
                    110:        "#{?session_attached, (attached),}"
                    111: #define CHOOSE_TREE_WINDOW_TEMPLATE                            \
                    112:        "#{window_index}: #{window_name}#{window_flags} "       \
                    113:        "\"#{pane_title}\""
                    114:
                    115: /* Default template for display-message. */
                    116: #define DISPLAY_MESSAGE_TEMPLATE                               \
1.335     nicm      117:        "[#{session_name}] #{window_index}:"                    \
                    118:        "#{window_name}, current pane #{pane_index} "           \
                    119:        "- (%H:%M %d-%b-%y)"
1.351     nicm      120:
                    121: /* Default template for find-window. */
                    122: #define FIND_WINDOW_TEMPLATE                                   \
1.335     nicm      123:        "#{window_index}: #{window_name} "                      \
                    124:        "[#{window_width}x#{window_height}] "                   \
                    125:        "(#{window_panes} panes) #{window_find_matches}"
1.351     nicm      126:
                    127: /* Default template for list-buffers. */
                    128: #define LIST_BUFFERS_TEMPLATE                                  \
                    129:        "#{line}: #{buffer_size} bytes: \"#{buffer_sample}\""
                    130:
                    131: /* Default template for list-clients. */
                    132: #define LIST_CLIENTS_TEMPLATE                                  \
                    133:        "#{client_tty}: #{session_name} "                       \
                    134:        "[#{client_width}x#{client_height} #{client_termname}]" \
                    135:        "#{?client_utf8, (utf8),} #{?client_readonly, (ro),}"
                    136:
                    137: /* Default template for list-sessions. */
                    138: #define LIST_SESSIONS_TEMPLATE                                 \
1.335     nicm      139:        "#{session_name}: #{session_windows} windows "          \
                    140:        "(created #{session_created_string}) "                  \
                    141:        "[#{session_width}x#{session_height}]"                  \
                    142:        "#{?session_grouped, (group ,}"                         \
                    143:        "#{session_group}#{?session_grouped,),}"                \
                    144:        "#{?session_attached, (attached),}"
1.351     nicm      145:
                    146: /* Default templates for list-windows. */
                    147: #define LIST_WINDOWS_TEMPLATE                                  \
1.335     nicm      148:        "#{window_index}: #{window_name}#{window_flags} "       \
                    149:        "(#{window_panes} panes) "                              \
1.351     nicm      150:        "[#{window_width}x#{window_height}] "                   \
                    151:        "[layout #{window_layout}] #{window_id}"                \
                    152:        "#{?window_active, (active),}";
                    153: #define LIST_WINDOWS_WITH_SESSION_TEMPLATE                     \
                    154:        "#{session_name}: "                                     \
                    155:        "#{window_index}: #{window_name}#{window_flags} "       \
                    156:        "(#{window_panes} panes) "                              \
                    157:        "[#{window_width}x#{window_height}] "
                    158:
                    159: /* Default templates for break-pane, new-window and split-window. */
                    160: #define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"
                    161: #define NEW_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
                    162: #define SPLIT_WINDOW_TEMPLATE BREAK_PANE_TEMPLATE
1.335     nicm      163:
1.1       nicm      164: /* Bell option values. */
                    165: #define BELL_NONE 0
                    166: #define BELL_ANY 1
                    167: #define BELL_CURRENT 2
                    168:
1.174     nicm      169: /* Special key codes. */
1.54      nicm      170: #define KEYC_NONE 0xfff
1.174     nicm      171: #define KEYC_BASE 0x1000
                    172:
                    173: /* Key modifier bits. */
1.54      nicm      174: #define KEYC_ESCAPE 0x2000
                    175: #define KEYC_CTRL 0x4000
                    176: #define KEYC_SHIFT 0x8000
                    177: #define KEYC_PREFIX 0x10000
1.225     nicm      178:
1.275     nicm      179: /* Mask to obtain key w/o modifiers. */
1.225     nicm      180: #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_PREFIX)
                    181: #define KEYC_MASK_KEY (~KEYC_MASK_MOD)
1.41      nicm      182:
1.174     nicm      183: /* Other key codes. */
1.41      nicm      184: enum key_code {
                    185:        /* Mouse key. */
1.174     nicm      186:        KEYC_MOUSE = KEYC_BASE,
1.56      nicm      187:
                    188:        /* Backspace key. */
                    189:        KEYC_BSPACE,
1.41      nicm      190:
                    191:        /* Function keys. */
                    192:        KEYC_F1,
                    193:        KEYC_F2,
                    194:        KEYC_F3,
                    195:        KEYC_F4,
                    196:        KEYC_F5,
                    197:        KEYC_F6,
                    198:        KEYC_F7,
                    199:        KEYC_F8,
                    200:        KEYC_F9,
                    201:        KEYC_F10,
                    202:        KEYC_F11,
                    203:        KEYC_F12,
                    204:        KEYC_F13,
                    205:        KEYC_F14,
                    206:        KEYC_F15,
                    207:        KEYC_F16,
                    208:        KEYC_F17,
                    209:        KEYC_F18,
                    210:        KEYC_F19,
                    211:        KEYC_F20,
                    212:        KEYC_IC,
                    213:        KEYC_DC,
                    214:        KEYC_HOME,
                    215:        KEYC_END,
                    216:        KEYC_NPAGE,
                    217:        KEYC_PPAGE,
                    218:        KEYC_BTAB,
                    219:
                    220:        /* Arrow keys. */
                    221:        KEYC_UP,
                    222:        KEYC_DOWN,
                    223:        KEYC_LEFT,
                    224:        KEYC_RIGHT,
                    225:
1.148     nicm      226:        /* Numeric keypad. */
                    227:        KEYC_KP_SLASH,
                    228:        KEYC_KP_STAR,
                    229:        KEYC_KP_MINUS,
                    230:        KEYC_KP_SEVEN,
                    231:        KEYC_KP_EIGHT,
                    232:        KEYC_KP_NINE,
                    233:        KEYC_KP_PLUS,
                    234:        KEYC_KP_FOUR,
                    235:        KEYC_KP_FIVE,
                    236:        KEYC_KP_SIX,
                    237:        KEYC_KP_ONE,
                    238:        KEYC_KP_TWO,
                    239:        KEYC_KP_THREE,
                    240:        KEYC_KP_ENTER,
                    241:        KEYC_KP_ZERO,
                    242:        KEYC_KP_PERIOD,
1.41      nicm      243: };
1.1       nicm      244:
                    245: /* Termcap codes. */
                    246: enum tty_code_code {
                    247:        TTYC_AX = 0,
                    248:        TTYC_ACSC,      /* acs_chars, ac */
                    249:        TTYC_BEL,       /* bell, bl */
                    250:        TTYC_BLINK,     /* enter_blink_mode, mb */
                    251:        TTYC_BOLD,      /* enter_bold_mode, md */
1.287     nicm      252:        TTYC_CC,        /* set colour cursor, Cc */
1.1       nicm      253:        TTYC_CIVIS,     /* cursor_invisible, vi */
                    254:        TTYC_CLEAR,     /* clear_screen, cl */
                    255:        TTYC_CNORM,     /* cursor_normal, ve */
                    256:        TTYC_COLORS,    /* max_colors, Co */
1.287     nicm      257:        TTYC_CR,        /* restore cursor colour, Cr */
1.288     nicm      258:        TTYC_CS1,       /* set cursor style, Cs */
1.1       nicm      259:        TTYC_CSR,       /* change_scroll_region, cs */
1.288     nicm      260:        TTYC_CSR1,      /* reset cursor style, Csr */
1.135     nicm      261:        TTYC_CUB,       /* parm_left_cursor, LE */
                    262:        TTYC_CUB1,      /* cursor_left, le */
1.1       nicm      263:        TTYC_CUD,       /* parm_down_cursor, DO */
                    264:        TTYC_CUD1,      /* cursor_down, do */
1.135     nicm      265:        TTYC_CUF,       /* parm_right_cursor, RI */
                    266:        TTYC_CUF1,      /* cursor_right, nd */
1.1       nicm      267:        TTYC_CUP,       /* cursor_address, cm */
1.135     nicm      268:        TTYC_CUU,       /* parm_up_cursor, UP */
                    269:        TTYC_CUU1,      /* cursor_up, up */
1.1       nicm      270:        TTYC_DCH,       /* parm_dch, DC */
                    271:        TTYC_DCH1,      /* delete_character, dc */
                    272:        TTYC_DIM,       /* enter_dim_mode, mh */
                    273:        TTYC_DL,        /* parm_delete_line, DL */
                    274:        TTYC_DL1,       /* delete_line, dl */
1.297     nicm      275:        TTYC_E3,
1.1       nicm      276:        TTYC_EL,        /* clr_eol, ce */
                    277:        TTYC_EL1,       /* clr_bol, cb */
                    278:        TTYC_ENACS,     /* ena_acs, eA */
1.283     nicm      279:        TTYC_FSL,       /* from_status_line, fsl */
1.135     nicm      280:        TTYC_HOME,      /* cursor_home, ho */
                    281:        TTYC_HPA,       /* column_address, ch */
1.1       nicm      282:        TTYC_ICH,       /* parm_ich, IC */
                    283:        TTYC_ICH1,      /* insert_character, ic */
                    284:        TTYC_IL,        /* parm_insert_line, IL */
                    285:        TTYC_IL1,       /* insert_line, il */
                    286:        TTYC_INVIS,     /* enter_secure_mode, mk */
                    287:        TTYC_IS1,       /* init_1string, i1 */
                    288:        TTYC_IS2,       /* init_2string, i2 */
                    289:        TTYC_IS3,       /* init_3string, i3 */
                    290:        TTYC_KCBT,      /* key_btab, kB */
                    291:        TTYC_KCUB1,     /* key_left, kl */
                    292:        TTYC_KCUD1,     /* key_down, kd */
                    293:        TTYC_KCUF1,     /* key_right, kr */
                    294:        TTYC_KCUU1,     /* key_up, ku */
1.149     nicm      295:        TTYC_KDC2,
                    296:        TTYC_KDC3,
                    297:        TTYC_KDC4,
                    298:        TTYC_KDC5,
                    299:        TTYC_KDC6,
                    300:        TTYC_KDC7,
1.1       nicm      301:        TTYC_KDCH1,     /* key_dc, kD */
1.149     nicm      302:        TTYC_KDN2,
                    303:        TTYC_KDN3,
                    304:        TTYC_KDN4,
                    305:        TTYC_KDN5,
                    306:        TTYC_KDN6,
                    307:        TTYC_KDN7,
1.1       nicm      308:        TTYC_KEND,      /* key_end, ke */
1.149     nicm      309:        TTYC_KEND2,
                    310:        TTYC_KEND3,
                    311:        TTYC_KEND4,
                    312:        TTYC_KEND5,
                    313:        TTYC_KEND6,
                    314:        TTYC_KEND7,
1.1       nicm      315:        TTYC_KF1,       /* key_f1, k1 */
                    316:        TTYC_KF10,      /* key_f10, k; */
                    317:        TTYC_KF11,      /* key_f11, F1 */
                    318:        TTYC_KF12,      /* key_f12, F2 */
                    319:        TTYC_KF13,      /* key_f13, F3 */
                    320:        TTYC_KF14,      /* key_f14, F4 */
                    321:        TTYC_KF15,      /* key_f15, F5 */
                    322:        TTYC_KF16,      /* key_f16, F6 */
                    323:        TTYC_KF17,      /* key_f17, F7 */
                    324:        TTYC_KF18,      /* key_f18, F8 */
                    325:        TTYC_KF19,      /* key_f19, F9 */
1.135     nicm      326:        TTYC_KF2,       /* key_f2, k2 */
1.1       nicm      327:        TTYC_KF20,      /* key_f20, F10 */
                    328:        TTYC_KF3,       /* key_f3, k3 */
                    329:        TTYC_KF4,       /* key_f4, k4 */
                    330:        TTYC_KF5,       /* key_f5, k5 */
                    331:        TTYC_KF6,       /* key_f6, k6 */
                    332:        TTYC_KF7,       /* key_f7, k7 */
                    333:        TTYC_KF8,       /* key_f8, k8 */
                    334:        TTYC_KF9,       /* key_f9, k9 */
1.149     nicm      335:        TTYC_KHOM2,
                    336:        TTYC_KHOM3,
                    337:        TTYC_KHOM4,
                    338:        TTYC_KHOM5,
                    339:        TTYC_KHOM6,
                    340:        TTYC_KHOM7,
1.1       nicm      341:        TTYC_KHOME,     /* key_home, kh */
1.149     nicm      342:        TTYC_KIC2,
                    343:        TTYC_KIC3,
                    344:        TTYC_KIC4,
                    345:        TTYC_KIC5,
                    346:        TTYC_KIC6,
                    347:        TTYC_KIC7,
1.1       nicm      348:        TTYC_KICH1,     /* key_ic, kI */
1.149     nicm      349:        TTYC_KLFT2,
                    350:        TTYC_KLFT3,
                    351:        TTYC_KLFT4,
                    352:        TTYC_KLFT5,
                    353:        TTYC_KLFT6,
                    354:        TTYC_KLFT7,
1.1       nicm      355:        TTYC_KMOUS,     /* key_mouse, Km */
                    356:        TTYC_KNP,       /* key_npage, kN */
1.149     nicm      357:        TTYC_KNXT2,
                    358:        TTYC_KNXT3,
                    359:        TTYC_KNXT4,
                    360:        TTYC_KNXT5,
                    361:        TTYC_KNXT6,
                    362:        TTYC_KNXT7,
1.1       nicm      363:        TTYC_KPP,       /* key_ppage, kP */
1.149     nicm      364:        TTYC_KPRV2,
                    365:        TTYC_KPRV3,
                    366:        TTYC_KPRV4,
                    367:        TTYC_KPRV5,
                    368:        TTYC_KPRV6,
                    369:        TTYC_KPRV7,
                    370:        TTYC_KRIT2,
                    371:        TTYC_KRIT3,
                    372:        TTYC_KRIT4,
                    373:        TTYC_KRIT5,
                    374:        TTYC_KRIT6,
                    375:        TTYC_KRIT7,
                    376:        TTYC_KUP2,
                    377:        TTYC_KUP3,
                    378:        TTYC_KUP4,
                    379:        TTYC_KUP5,
                    380:        TTYC_KUP6,
                    381:        TTYC_KUP7,
1.286     nicm      382:        TTYC_MS,        /* modify xterm(1) selection */
1.1       nicm      383:        TTYC_OP,        /* orig_pair, op */
                    384:        TTYC_REV,       /* enter_reverse_mode, mr */
                    385:        TTYC_RI,        /* scroll_reverse, sr */
                    386:        TTYC_RMACS,     /* exit_alt_charset_mode */
                    387:        TTYC_RMCUP,     /* exit_ca_mode, te */
                    388:        TTYC_RMKX,      /* keypad_local, ke */
                    389:        TTYC_SETAB,     /* set_a_background, AB */
                    390:        TTYC_SETAF,     /* set_a_foreground, AF */
                    391:        TTYC_SGR0,      /* exit_attribute_mode, me */
1.283     nicm      392:        TTYC_SITM,      /* enter_italics_mode, it */
1.1       nicm      393:        TTYC_SMACS,     /* enter_alt_charset_mode, as */
                    394:        TTYC_SMCUP,     /* enter_ca_mode, ti */
                    395:        TTYC_SMKX,      /* keypad_xmit, ks */
                    396:        TTYC_SMSO,      /* enter_standout_mode, so */
                    397:        TTYC_SMUL,      /* enter_underline_mode, us */
1.283     nicm      398:        TTYC_TSL,       /* to_status_line, tsl */
1.135     nicm      399:        TTYC_VPA,       /* row_address, cv */
1.1       nicm      400:        TTYC_XENL,      /* eat_newline_glitch, xn */
1.283     nicm      401:        TTYC_XT,        /* xterm(1)-compatible title, XT */
1.1       nicm      402: };
1.283     nicm      403: #define NTTYCODE (TTYC_XT + 1)
1.1       nicm      404:
                    405: /* Termcap types. */
                    406: enum tty_code_type {
                    407:        TTYCODE_NONE = 0,
                    408:        TTYCODE_STRING,
                    409:        TTYCODE_NUMBER,
                    410:        TTYCODE_FLAG,
                    411: };
                    412:
                    413: /* Termcap code. */
                    414: struct tty_code {
                    415:        enum tty_code_type      type;
                    416:        union {
1.192     nicm      417:                char           *string;
                    418:                int             number;
                    419:                int             flag;
1.1       nicm      420:        } value;
                    421: };
                    422:
                    423: /* Entry in terminal code table. */
                    424: struct tty_term_code_entry {
                    425:        enum tty_code_code      code;
                    426:        enum tty_code_type      type;
                    427:        const char             *name;
                    428: };
                    429:
                    430: /* Message codes. */
1.64      nicm      431: enum msgtype {
1.1       nicm      432:        MSG_COMMAND,
                    433:        MSG_DETACH,
                    434:        MSG_ERROR,
                    435:        MSG_EXIT,
                    436:        MSG_EXITED,
                    437:        MSG_EXITING,
                    438:        MSG_IDENTIFY,
1.332     nicm      439:        MSG_STDIN,
1.1       nicm      440:        MSG_READY,
                    441:        MSG_RESIZE,
                    442:        MSG_SHUTDOWN,
                    443:        MSG_SUSPEND,
1.75      nicm      444:        MSG_VERSION,
1.1       nicm      445:        MSG_WAKEUP,
1.115     nicm      446:        MSG_ENVIRON,
                    447:        MSG_UNLOCK,
1.116     nicm      448:        MSG_LOCK,
1.231     nicm      449:        MSG_SHELL,
                    450:        MSG_STDERR,
                    451:        MSG_STDOUT,
1.272     nicm      452:        MSG_DETACHKILL
1.1       nicm      453: };
                    454:
1.55      nicm      455: /*
1.75      nicm      456:  * Message data.
1.55      nicm      457:  *
                    458:  * Don't forget to bump PROTOCOL_VERSION if any of these change!
                    459:  */
1.1       nicm      460: struct msg_command_data {
1.267     nicm      461:        pid_t           pid;    /* PID from $TMUX or -1 */
                    462:        int             idx;    /* index from $TMUX or -1 */
1.1       nicm      463:
1.55      nicm      464:        int             argc;
                    465:        char            argv[COMMAND_LENGTH];
1.1       nicm      466: };
                    467:
                    468: struct msg_identify_data {
                    469:        char            cwd[MAXPATHLEN];
                    470:
1.55      nicm      471:        char            term[TERMINAL_LENGTH];
                    472:
1.1       nicm      473: #define IDENTIFY_UTF8 0x1
                    474: #define IDENTIFY_256COLOURS 0x2
                    475: #define IDENTIFY_88COLOURS 0x4
1.342     nicm      476: #define IDENTIFY_CONTROL 0x8
                    477: #define IDENTIFY_TERMIOS 0x10
1.1       nicm      478:        int             flags;
                    479: };
                    480:
1.115     nicm      481: struct msg_lock_data {
1.192     nicm      482:        char            cmd[COMMAND_LENGTH];
1.55      nicm      483: };
                    484:
1.73      nicm      485: struct msg_environ_data {
1.192     nicm      486:        char            var[ENVIRON_LENGTH];
1.116     nicm      487: };
                    488:
                    489: struct msg_shell_data {
1.192     nicm      490:        char            shell[MAXPATHLEN];
1.73      nicm      491: };
                    492:
1.234     nicm      493: struct msg_exit_data {
                    494:        int             retcode;
                    495: };
                    496:
1.332     nicm      497: struct msg_stdin_data {
                    498:        ssize_t size;
                    499:        char    data[BUFSIZ];
                    500: };
                    501:
                    502: struct msg_stdout_data {
                    503:        ssize_t size;
                    504:        char    data[BUFSIZ];
                    505: };
                    506:
                    507: struct msg_stderr_data {
                    508:        ssize_t size;
                    509:        char    data[BUFSIZ];
                    510: };
                    511:
1.62      nicm      512: /* Mode key commands. */
1.1       nicm      513: enum mode_key_cmd {
1.59      nicm      514:        MODEKEY_NONE,
                    515:        MODEKEY_OTHER,
                    516:
                    517:        /* Editing keys. */
                    518:        MODEKEYEDIT_BACKSPACE,
                    519:        MODEKEYEDIT_CANCEL,
                    520:        MODEKEYEDIT_COMPLETE,
                    521:        MODEKEYEDIT_CURSORLEFT,
                    522:        MODEKEYEDIT_CURSORRIGHT,
                    523:        MODEKEYEDIT_DELETE,
1.84      nicm      524:        MODEKEYEDIT_DELETELINE,
1.59      nicm      525:        MODEKEYEDIT_DELETETOENDOFLINE,
1.299     nicm      526:        MODEKEYEDIT_DELETEWORD,
1.59      nicm      527:        MODEKEYEDIT_ENDOFLINE,
                    528:        MODEKEYEDIT_ENTER,
                    529:        MODEKEYEDIT_HISTORYDOWN,
                    530:        MODEKEYEDIT_HISTORYUP,
1.302     nicm      531:        MODEKEYEDIT_NEXTSPACE,
                    532:        MODEKEYEDIT_NEXTSPACEEND,
1.299     nicm      533:        MODEKEYEDIT_NEXTWORD,
                    534:        MODEKEYEDIT_NEXTWORDEND,
1.59      nicm      535:        MODEKEYEDIT_PASTE,
1.302     nicm      536:        MODEKEYEDIT_PREVIOUSSPACE,
1.299     nicm      537:        MODEKEYEDIT_PREVIOUSWORD,
1.59      nicm      538:        MODEKEYEDIT_STARTOFLINE,
                    539:        MODEKEYEDIT_SWITCHMODE,
                    540:        MODEKEYEDIT_SWITCHMODEAPPEND,
1.318     nicm      541:        MODEKEYEDIT_SWITCHMODEAPPENDLINE,
                    542:        MODEKEYEDIT_SWITCHMODEBEGINLINE,
1.94      nicm      543:        MODEKEYEDIT_TRANSPOSECHARS,
1.192     nicm      544:
1.59      nicm      545:        /* Menu (choice) keys. */
1.350     nicm      546:        MODEKEYCHOICE_BACKSPACE,
1.59      nicm      547:        MODEKEYCHOICE_CANCEL,
                    548:        MODEKEYCHOICE_CHOOSE,
                    549:        MODEKEYCHOICE_DOWN,
                    550:        MODEKEYCHOICE_PAGEDOWN,
                    551:        MODEKEYCHOICE_PAGEUP,
1.201     nicm      552:        MODEKEYCHOICE_SCROLLDOWN,
                    553:        MODEKEYCHOICE_SCROLLUP,
1.350     nicm      554:        MODEKEYCHOICE_STARTNUMBERPREFIX,
1.59      nicm      555:        MODEKEYCHOICE_UP,
                    556:
                    557:        /* Copy keys. */
1.82      nicm      558:        MODEKEYCOPY_BACKTOINDENTATION,
1.138     nicm      559:        MODEKEYCOPY_BOTTOMLINE,
1.59      nicm      560:        MODEKEYCOPY_CANCEL,
                    561:        MODEKEYCOPY_CLEARSELECTION,
1.285     nicm      562:        MODEKEYCOPY_COPYLINE,
                    563:        MODEKEYCOPY_COPYENDOFLINE,
1.59      nicm      564:        MODEKEYCOPY_COPYSELECTION,
                    565:        MODEKEYCOPY_DOWN,
                    566:        MODEKEYCOPY_ENDOFLINE,
1.83      nicm      567:        MODEKEYCOPY_GOTOLINE,
1.82      nicm      568:        MODEKEYCOPY_HALFPAGEDOWN,
                    569:        MODEKEYCOPY_HALFPAGEUP,
1.199     nicm      570:        MODEKEYCOPY_HISTORYBOTTOM,
                    571:        MODEKEYCOPY_HISTORYTOP,
1.212     nicm      572:        MODEKEYCOPY_JUMP,
                    573:        MODEKEYCOPY_JUMPAGAIN,
                    574:        MODEKEYCOPY_JUMPREVERSE,
                    575:        MODEKEYCOPY_JUMPBACK,
1.300     nicm      576:        MODEKEYCOPY_JUMPTO,
                    577:        MODEKEYCOPY_JUMPTOBACK,
1.59      nicm      578:        MODEKEYCOPY_LEFT,
1.138     nicm      579:        MODEKEYCOPY_MIDDLELINE,
1.59      nicm      580:        MODEKEYCOPY_NEXTPAGE,
1.202     nicm      581:        MODEKEYCOPY_NEXTSPACE,
                    582:        MODEKEYCOPY_NEXTSPACEEND,
1.59      nicm      583:        MODEKEYCOPY_NEXTWORD,
1.200     nicm      584:        MODEKEYCOPY_NEXTWORDEND,
1.59      nicm      585:        MODEKEYCOPY_PREVIOUSPAGE,
1.202     nicm      586:        MODEKEYCOPY_PREVIOUSSPACE,
1.59      nicm      587:        MODEKEYCOPY_PREVIOUSWORD,
1.204     nicm      588:        MODEKEYCOPY_RECTANGLETOGGLE,
1.59      nicm      589:        MODEKEYCOPY_RIGHT,
1.120     nicm      590:        MODEKEYCOPY_SCROLLDOWN,
                    591:        MODEKEYCOPY_SCROLLUP,
1.83      nicm      592:        MODEKEYCOPY_SEARCHAGAIN,
                    593:        MODEKEYCOPY_SEARCHDOWN,
1.207     nicm      594:        MODEKEYCOPY_SEARCHREVERSE,
1.83      nicm      595:        MODEKEYCOPY_SEARCHUP,
1.285     nicm      596:        MODEKEYCOPY_SELECTLINE,
1.209     nicm      597:        MODEKEYCOPY_STARTNUMBERPREFIX,
1.59      nicm      598:        MODEKEYCOPY_STARTOFLINE,
                    599:        MODEKEYCOPY_STARTSELECTION,
1.138     nicm      600:        MODEKEYCOPY_TOPLINE,
1.59      nicm      601:        MODEKEYCOPY_UP,
1.1       nicm      602: };
                    603:
1.62      nicm      604: /* Entry in the default mode key tables. */
1.59      nicm      605: struct mode_key_entry {
                    606:        int                     key;
                    607:
                    608:        /*
                    609:         * Editing mode for vi: 0 is edit mode, keys not in the table are
                    610:         * returned as MODEKEY_OTHER; 1 is command mode, keys not in the table
                    611:         * are returned as MODEKEY_NONE. This is also matched on, allowing some
                    612:         * keys to be bound in edit mode.
                    613:         */
                    614:        int                     mode;
                    615:        enum mode_key_cmd       cmd;
                    616: };
1.62      nicm      617:
                    618: /* Data required while mode keys are in use. */
1.1       nicm      619: struct mode_key_data {
1.62      nicm      620:        struct mode_key_tree   *tree;
                    621:        int                     mode;
1.1       nicm      622: };
                    623: #define MODEKEY_EMACS 0
                    624: #define MODEKEY_VI 1
                    625:
1.62      nicm      626: /* Binding between a key and a command. */
                    627: struct mode_key_binding {
                    628:        int                     key;
                    629:
                    630:        int                     mode;
                    631:        enum mode_key_cmd       cmd;
                    632:
1.306     nicm      633:        RB_ENTRY(mode_key_binding) entry;
1.62      nicm      634: };
1.306     nicm      635: RB_HEAD(mode_key_tree, mode_key_binding);
1.62      nicm      636:
                    637: /* Command to string mapping. */
                    638: struct mode_key_cmdstr {
1.192     nicm      639:        enum mode_key_cmd        cmd;
1.62      nicm      640:        const char              *name;
                    641: };
                    642:
                    643: /* Named mode key table description. */
                    644: struct mode_key_table {
1.261     nicm      645:        const char                      *name;
                    646:        const struct mode_key_cmdstr    *cmdstr;
                    647:        struct mode_key_tree            *tree;
                    648:        const struct mode_key_entry     *table; /* default entries */
1.62      nicm      649: };
                    650:
1.1       nicm      651: /* Modes. */
                    652: #define MODE_CURSOR 0x1
                    653: #define MODE_INSERT 0x2
                    654: #define MODE_KCURSOR 0x4
1.185     nicm      655: #define MODE_KKEYPAD 0x8       /* set = application, clear = number */
1.255     nicm      656: #define MODE_WRAP 0x10         /* whether lines wrap */
                    657: #define MODE_MOUSE_STANDARD 0x20
1.266     nicm      658: #define MODE_MOUSE_BUTTON 0x40
                    659: #define MODE_MOUSE_ANY 0x80
                    660: #define MODE_MOUSE_UTF8 0x100
1.317     nicm      661: #define MODE_BRACKETPASTE 0x200
1.255     nicm      662:
1.266     nicm      663: #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY)
1.1       nicm      664:
1.143     nicm      665: /*
1.181     nicm      666:  * A single UTF-8 character.
1.143     nicm      667:  *
                    668:  * The data member in this must be UTF8_SIZE to allow screen_write_copy to
                    669:  * reinject stored UTF-8 data back into screen_write_cell after combining (ugh
                    670:  * XXX XXX).
                    671:  */
                    672: struct utf8_data {
                    673:        u_char  data[UTF8_SIZE];
                    674:
                    675:        size_t  have;
                    676:        size_t  size;
                    677:
                    678:        u_int   width;
                    679: };
                    680:
1.1       nicm      681: /* Grid output. */
                    682: #if defined(DEBUG) && \
                    683:     ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
                    684:      (defined(__GNUC__) && __GNUC__ >= 3))
1.48      nicm      685: #define GRID_DEBUG(gd, fmt, ...) log_debug2("%s: (sx=%u, sy=%u, hsize=%u) " \
1.1       nicm      686:     fmt, __func__, (gd)->sx, (gd)->sy, (gd)->hsize, ## __VA_ARGS__)
                    687: #else
                    688: #define GRID_DEBUG(...)
                    689: #endif
                    690:
                    691: /* Grid attributes. */
                    692: #define GRID_ATTR_BRIGHT 0x1
                    693: #define GRID_ATTR_DIM 0x2
                    694: #define GRID_ATTR_UNDERSCORE 0x4
                    695: #define GRID_ATTR_BLINK 0x8
                    696: #define GRID_ATTR_REVERSE 0x10
                    697: #define GRID_ATTR_HIDDEN 0x20
                    698: #define GRID_ATTR_ITALICS 0x40
                    699: #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
                    700:
                    701: /* Grid flags. */
                    702: #define GRID_FLAG_FG256 0x1
                    703: #define GRID_FLAG_BG256 0x2
                    704: #define GRID_FLAG_PADDING 0x4
                    705: #define GRID_FLAG_UTF8 0x8
                    706:
1.72      nicm      707: /* Grid line flags. */
                    708: #define GRID_LINE_WRAPPED 0x1
                    709:
1.1       nicm      710: /* Grid cell data. */
                    711: struct grid_cell {
                    712:        u_char  attr;
                    713:        u_char  flags;
                    714:        u_char  fg;
                    715:        u_char  bg;
                    716:        u_char  data;
                    717: } __packed;
                    718:
                    719: /* Grid cell UTF-8 data. Used instead of data in grid_cell for UTF-8 cells. */
                    720: struct grid_utf8 {
                    721:        u_char  width;
                    722:        u_char  data[UTF8_SIZE];
                    723: } __packed;
                    724:
1.71      nicm      725: /* Grid line. */
                    726: struct grid_line {
                    727:        u_int   cellsize;
                    728:        struct grid_cell *celldata;
                    729:
                    730:        u_int   utf8size;
                    731:        struct grid_utf8 *utf8data;
1.72      nicm      732:
                    733:        int     flags;
1.71      nicm      734: } __packed;
                    735:
1.1       nicm      736: /* Entire grid of cells. */
                    737: struct grid {
1.25      nicm      738:        int     flags;
                    739: #define GRID_HISTORY 0x1       /* scroll lines into history */
                    740:
1.1       nicm      741:        u_int   sx;
                    742:        u_int   sy;
                    743:
                    744:        u_int   hsize;
                    745:        u_int   hlimit;
                    746:
1.71      nicm      747:        struct grid_line *linedata;
1.1       nicm      748: };
                    749:
                    750: /* Option data structures. */
                    751: struct options_entry {
                    752:        char            *name;
                    753:
                    754:        enum {
                    755:                OPTIONS_STRING,
                    756:                OPTIONS_NUMBER,
1.112     nicm      757:                OPTIONS_DATA,
1.1       nicm      758:        } type;
1.109     nicm      759:
                    760:        char            *str;
                    761:        long long        num;
1.1       nicm      762:
1.306     nicm      763:        RB_ENTRY(options_entry) entry;
1.1       nicm      764: };
                    765:
                    766: struct options {
1.306     nicm      767:        RB_HEAD(options_tree, options_entry) tree;
1.1       nicm      768:        struct options  *parent;
                    769: };
                    770:
1.126     nicm      771: /* Scheduled job. */
                    772: struct job {
                    773:        char            *cmd;
                    774:        pid_t            pid;
1.130     nicm      775:        int              status;
1.126     nicm      776:
                    777:        int              fd;
1.160     nicm      778:        struct bufferevent *event;
1.126     nicm      779:
                    780:        void            (*callbackfn)(struct job *);
                    781:        void            (*freefn)(void *);
                    782:        void            *data;
1.130     nicm      783:
1.270     nicm      784:        LIST_ENTRY(job)  lentry;
1.126     nicm      785: };
1.270     nicm      786: LIST_HEAD(joblist, job);
1.126     nicm      787:
1.1       nicm      788: /* Screen selection. */
                    789: struct screen_sel {
                    790:        int              flag;
1.204     nicm      791:        int              rectflag;
1.1       nicm      792:
                    793:        u_int            sx;
                    794:        u_int            sy;
                    795:
                    796:        u_int            ex;
                    797:        u_int            ey;
                    798:
                    799:        struct grid_cell cell;
                    800: };
                    801:
                    802: /* Virtual screen. */
                    803: struct screen {
                    804:        char            *title;
                    805:
1.192     nicm      806:        struct grid     *grid;          /* grid data */
1.1       nicm      807:
                    808:        u_int            cx;            /* cursor x */
                    809:        u_int            cy;            /* cursor y */
                    810:
1.288     nicm      811:        u_int            cstyle;        /* cursor style */
1.287     nicm      812:        char            *ccolour;       /* cursor colour string */
                    813:
1.1       nicm      814:        u_int            rupper;        /* scroll region top */
                    815:        u_int            rlower;        /* scroll region bottom */
                    816:
                    817:        int              mode;
                    818:
1.192     nicm      819:        bitstr_t        *tabs;
1.6       nicm      820:
1.1       nicm      821:        struct screen_sel sel;
                    822: };
                    823:
                    824: /* Screen write context. */
                    825: struct screen_write_ctx {
                    826:        struct window_pane *wp;
                    827:        struct screen   *s;
                    828: };
                    829:
                    830: /* Screen size. */
                    831: #define screen_size_x(s) ((s)->grid->sx)
                    832: #define screen_size_y(s) ((s)->grid->sy)
                    833: #define screen_hsize(s) ((s)->grid->hsize)
                    834: #define screen_hlimit(s) ((s)->grid->hlimit)
                    835:
                    836: /* Input parser context. */
                    837: struct input_ctx {
1.210     nicm      838:        struct window_pane     *wp;
1.1       nicm      839:        struct screen_write_ctx ctx;
                    840:
1.210     nicm      841:        struct grid_cell        cell;
                    842:
                    843:        struct grid_cell        old_cell;
                    844:        u_int                   old_cx;
                    845:        u_int                   old_cy;
                    846:
                    847:        u_char                  interm_buf[4];
                    848:        size_t                  interm_len;
1.1       nicm      849:
1.210     nicm      850:        u_char                  param_buf[64];
                    851:        size_t                  param_len;
1.1       nicm      852:
1.210     nicm      853:        u_char                  input_buf[256];
                    854:        size_t                  input_len;
1.1       nicm      855:
1.210     nicm      856:        int                     param_list[24]; /* -1 not present */
                    857:        u_int                   param_list_len;
1.1       nicm      858:
1.210     nicm      859:        struct utf8_data        utf8data;
1.1       nicm      860:
1.210     nicm      861:        int                     ch;
                    862:        int                     flags;
                    863: #define INPUT_DISCARD 0x1
1.1       nicm      864:
1.210     nicm      865:        const struct input_state *state;
1.329     nicm      866:
                    867:        /*
                    868:         * All input received since we were last in the ground state. Sent to
                    869:         * control clients on connection.
                    870:         */
                    871:        struct evbuffer         *since_ground;
1.1       nicm      872: };
                    873:
                    874: /*
                    875:  * Window mode. Windows can be in several modes and this is used to call the
                    876:  * right function to handle input and output.
                    877:  */
1.221     nicm      878: struct session;
1.1       nicm      879: struct window;
1.129     nicm      880: struct mouse_event;
1.1       nicm      881: struct window_mode {
                    882:        struct screen *(*init)(struct window_pane *);
                    883:        void    (*free)(struct window_pane *);
                    884:        void    (*resize)(struct window_pane *, u_int, u_int);
1.221     nicm      885:        void    (*key)(struct window_pane *, struct session *, int);
1.1       nicm      886:        void    (*mouse)(struct window_pane *,
1.221     nicm      887:                    struct session *, struct mouse_event *);
1.1       nicm      888:        void    (*timer)(struct window_pane *);
                    889: };
                    890:
1.343     nicm      891: /* Structures for choose mode. */
                    892: struct window_choose_data {
                    893:        struct client           *client;
                    894:        struct session          *session;
                    895:        struct format_tree      *ft;
1.350     nicm      896:        struct winlink          *wl;
1.343     nicm      897:        char                    *ft_template;
1.344     nicm      898:        char                    *command;
1.343     nicm      899:        u_int                    idx;
                    900: };
                    901:
                    902: struct window_choose_mode_item {
1.350     nicm      903:        struct window_choose_data       *wcd;
                    904:        char                            *name;
                    905:        int                              pos;
1.343     nicm      906: };
                    907:
1.1       nicm      908: /* Child window structure. */
                    909: struct window_pane {
1.274     nicm      910:        u_int            id;
                    911:
1.1       nicm      912:        struct window   *window;
1.39      nicm      913:        struct layout_cell *layout_cell;
1.1       nicm      914:
                    915:        u_int            sx;
                    916:        u_int            sy;
                    917:
                    918:        u_int            xoff;
                    919:        u_int            yoff;
                    920:
                    921:        int              flags;
1.28      nicm      922: #define PANE_REDRAW 0x1
1.325     nicm      923: #define PANE_DROP 0x2
1.1       nicm      924:
                    925:        char            *cmd;
1.93      nicm      926:        char            *shell;
1.1       nicm      927:        char            *cwd;
                    928:
                    929:        pid_t            pid;
1.159     nicm      930:        char             tty[TTY_NAME_MAX];
                    931:
1.325     nicm      932:        u_int            changes;
                    933:        struct event     changes_timer;
                    934:        u_int            changes_redraw;
                    935:
1.1       nicm      936:        int              fd;
1.163     nicm      937:        struct bufferevent *event;
1.1       nicm      938:
                    939:        struct input_ctx ictx;
                    940:
1.131     nicm      941:        int              pipe_fd;
1.162     nicm      942:        struct bufferevent *pipe_event;
1.131     nicm      943:        size_t           pipe_off;
                    944:
1.1       nicm      945:        struct screen   *screen;
                    946:        struct screen    base;
                    947:
1.25      nicm      948:        /* Saved in alternative screen mode. */
1.192     nicm      949:        u_int            saved_cx;
                    950:        u_int            saved_cy;
1.25      nicm      951:        struct grid     *saved_grid;
1.69      nicm      952:        struct grid_cell saved_cell;
1.25      nicm      953:
1.1       nicm      954:        const struct window_mode *mode;
                    955:        void            *modedata;
                    956:
                    957:        TAILQ_ENTRY(window_pane) entry;
1.274     nicm      958:        RB_ENTRY(window_pane) tree_entry;
1.1       nicm      959: };
                    960: TAILQ_HEAD(window_panes, window_pane);
1.274     nicm      961: RB_HEAD(window_pane_tree, window_pane);
1.1       nicm      962:
1.326     nicm      963: /* Window last layout. */
                    964: struct last_layout {
                    965:        char    *layout;
                    966:
                    967:        TAILQ_ENTRY(last_layout) entry;
                    968: };
                    969:
1.1       nicm      970: /* Window structure. */
                    971: struct window {
1.309     nicm      972:        u_int            id;
1.1       nicm      973:        char            *name;
1.168     nicm      974:        struct event     name_timer;
1.248     nicm      975:        struct timeval   silence_timer;
1.1       nicm      976:
                    977:        struct window_pane *active;
1.244     nicm      978:        struct window_pane *last;
1.1       nicm      979:        struct window_panes panes;
1.39      nicm      980:
1.61      nicm      981:        int              lastlayout;
1.39      nicm      982:        struct layout_cell *layout_root;
1.326     nicm      983:        TAILQ_HEAD(last_layouts, last_layout) layout_list;
                    984:        u_int            layout_list_size;
                    985:        struct last_layout *layout_list_last;
1.1       nicm      986:
                    987:        u_int            sx;
                    988:        u_int            sy;
                    989:
                    990:        int              flags;
                    991: #define WINDOW_BELL 0x1
1.247     nicm      992: #define WINDOW_ACTIVITY 0x2
                    993: #define WINDOW_REDRAW 0x4
1.248     nicm      994: #define WINDOW_SILENCE 0x8
1.1       nicm      995:
                    996:        struct options   options;
                    997:
                    998:        u_int            references;
                    999: };
                   1000: ARRAY_DECL(windows, struct window *);
                   1001:
                   1002: /* Entry on local window list. */
                   1003: struct winlink {
                   1004:        int              idx;
                   1005:        struct window   *window;
1.184     nicm     1006:
                   1007:        size_t           status_width;
                   1008:        struct grid_cell status_cell;
                   1009:        char            *status_text;
1.1       nicm     1010:
1.226     nicm     1011:        int              flags;
                   1012: #define WINLINK_BELL 0x1
                   1013: #define WINLINK_ACTIVITY 0x2
                   1014: #define WINLINK_CONTENT 0x4
1.248     nicm     1015: #define WINLINK_SILENCE 0x8
                   1016: #define WINLINK_ALERTFLAGS \
                   1017:     (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
1.226     nicm     1018:
1.1       nicm     1019:        RB_ENTRY(winlink) entry;
1.124     nicm     1020:        TAILQ_ENTRY(winlink) sentry;
1.1       nicm     1021: };
                   1022: RB_HEAD(winlinks, winlink);
1.124     nicm     1023: TAILQ_HEAD(winlink_stack, winlink);
1.1       nicm     1024:
1.39      nicm     1025: /* Layout direction. */
                   1026: enum layout_type {
                   1027:        LAYOUT_LEFTRIGHT,
                   1028:        LAYOUT_TOPBOTTOM,
                   1029:        LAYOUT_WINDOWPANE
                   1030: };
                   1031:
                   1032: /* Layout cells queue. */
                   1033: TAILQ_HEAD(layout_cells, layout_cell);
                   1034:
                   1035: /* Layout cell. */
                   1036: struct layout_cell {
                   1037:        enum layout_type type;
                   1038:
                   1039:        struct layout_cell *parent;
                   1040:
                   1041:        u_int            sx;
                   1042:        u_int            sy;
                   1043:
                   1044:        u_int            xoff;
                   1045:        u_int            yoff;
                   1046:
                   1047:        struct window_pane *wp;
                   1048:        struct layout_cells cells;
                   1049:
                   1050:        TAILQ_ENTRY(layout_cell) entry;
                   1051: };
                   1052:
1.1       nicm     1053: /* Paste buffer. */
                   1054: struct paste_buffer {
1.187     nicm     1055:        char            *data;
1.100     nicm     1056:        size_t           size;
1.1       nicm     1057: };
                   1058: ARRAY_DECL(paste_stack, struct paste_buffer *);
                   1059:
1.73      nicm     1060: /* Environment variable. */
                   1061: struct environ_entry {
                   1062:        char            *name;
                   1063:        char            *value;
                   1064:
                   1065:        RB_ENTRY(environ_entry) entry;
                   1066: };
                   1067: RB_HEAD(environ, environ_entry);
                   1068:
1.1       nicm     1069: /* Client session. */
1.124     nicm     1070: struct session_group {
                   1071:        TAILQ_HEAD(, session) sessions;
                   1072:
                   1073:        TAILQ_ENTRY(session_group) entry;
                   1074: };
                   1075: TAILQ_HEAD(session_groups, session_group);
                   1076:
1.1       nicm     1077: struct session {
1.254     nicm     1078:        u_int            idx;
                   1079:
1.1       nicm     1080:        char            *name;
1.230     nicm     1081:        char            *cwd;
1.156     nicm     1082:
                   1083:        struct timeval   creation_time;
                   1084:        struct timeval   activity_time;
1.1       nicm     1085:
                   1086:        u_int            sx;
                   1087:        u_int            sy;
                   1088:
                   1089:        struct winlink  *curw;
                   1090:        struct winlink_stack lastw;
                   1091:        struct winlinks  windows;
                   1092:
                   1093:        struct options   options;
                   1094:
                   1095: #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
                   1096:        int              flags;
1.73      nicm     1097:
1.105     nicm     1098:        struct termios  *tio;
1.80      nicm     1099:
1.73      nicm     1100:        struct environ   environ;
1.101     nicm     1101:
                   1102:        int              references;
1.124     nicm     1103:
                   1104:        TAILQ_ENTRY(session) gentry;
1.254     nicm     1105:        RB_ENTRY(session)    entry;
1.1       nicm     1106: };
1.254     nicm     1107: RB_HEAD(sessions, session);
                   1108: ARRAY_DECL(sessionslist, struct session *);
1.1       nicm     1109:
1.336     nicm     1110: /*
                   1111:  * Mouse input. xterm mouse mode is fairly silly. Buttons are in the bottom two
                   1112:  * bits: 0 = button 1; 1 = button 2; 2 = button 3; 3 = buttons released. Bits
                   1113:  * 3, 4 and 5 are for keys. Bit 6 is set for dragging and 7 for mouse buttons 4
                   1114:  * and 5.
                   1115:  */
                   1116: struct mouse_event {
                   1117:        u_int   b;
                   1118: #define MOUSE_1 0
                   1119: #define MOUSE_2 1
                   1120: #define MOUSE_3 2
                   1121: #define MOUSE_UP 3
                   1122: #define MOUSE_BUTTON 3
                   1123: #define MOUSE_SHIFT 4
                   1124: #define MOUSE_ESCAPE 8
                   1125: #define MOUSE_CTRL 16
                   1126: #define MOUSE_DRAG 32
                   1127: #define MOUSE_45 64
                   1128: #define MOUSE_RESIZE_PANE 128 /* marker for resizing */
                   1129:        u_int   x;
                   1130:        u_int   y;
                   1131: };
                   1132:
1.1       nicm     1133: /* TTY information. */
                   1134: struct tty_key {
1.173     nicm     1135:        char             ch;
1.192     nicm     1136:        int              key;
1.1       nicm     1137:
1.173     nicm     1138:        struct tty_key  *left;
                   1139:        struct tty_key  *right;
                   1140:
                   1141:        struct tty_key  *next;
1.1       nicm     1142: };
                   1143:
                   1144: struct tty_term {
                   1145:        char            *name;
                   1146:        u_int            references;
                   1147:
1.240     nicm     1148:        char             acs[UCHAR_MAX + 1][2];
                   1149:
1.1       nicm     1150:        struct tty_code  codes[NTTYCODE];
                   1151:
1.147     nicm     1152: #define TERM_256COLOURS 0x1
                   1153: #define TERM_88COLOURS 0x2
                   1154: #define TERM_EARLYWRAP 0x4
1.1       nicm     1155:        int              flags;
                   1156:
1.270     nicm     1157:        LIST_ENTRY(tty_term) entry;
1.1       nicm     1158: };
1.270     nicm     1159: LIST_HEAD(tty_terms, tty_term);
1.1       nicm     1160:
                   1161: struct tty {
1.337     nicm     1162:        struct client   *client;
                   1163:
1.1       nicm     1164:        char            *path;
1.321     nicm     1165:        u_int            xterm_version;
1.1       nicm     1166:
1.192     nicm     1167:        u_int            sx;
                   1168:        u_int            sy;
1.1       nicm     1169:
                   1170:        u_int            cx;
                   1171:        u_int            cy;
1.288     nicm     1172:        u_int            cstyle;
1.287     nicm     1173:        char            *ccolour;
1.1       nicm     1174:
                   1175:        int              mode;
                   1176:
                   1177:        u_int            rlower;
                   1178:        u_int            rupper;
                   1179:
                   1180:        char            *termname;
                   1181:        struct tty_term *term;
                   1182:
                   1183:        int              fd;
1.161     nicm     1184:        struct bufferevent *event;
1.1       nicm     1185:
                   1186:        int              log_fd;
                   1187:
1.192     nicm     1188:        struct termios   tio;
1.1       nicm     1189:
                   1190:        struct grid_cell cell;
                   1191:
                   1192: #define TTY_NOCURSOR 0x1
                   1193: #define TTY_FREEZE 0x2
                   1194: #define TTY_ESCAPE 0x4
                   1195: #define TTY_UTF8 0x8
1.76      nicm     1196: #define TTY_STARTED 0x10
1.77      nicm     1197: #define TTY_OPENED 0x20
1.192     nicm     1198:        int              flags;
1.1       nicm     1199:
                   1200:        int              term_flags;
                   1201:
1.337     nicm     1202:        struct mouse_event mouse;
                   1203:
1.170     nicm     1204:        struct event     key_timer;
1.173     nicm     1205:        struct tty_key  *key_tree;
1.1       nicm     1206: };
                   1207:
1.47      nicm     1208: /* TTY command context and function pointer. */
                   1209: struct tty_ctx {
                   1210:        struct window_pane *wp;
                   1211:
                   1212:        const struct grid_cell *cell;
                   1213:        const struct grid_utf8 *utf8;
                   1214:
1.49      nicm     1215:        u_int            num;
1.196     nicm     1216:        void            *ptr;
1.49      nicm     1217:
1.196     nicm     1218:        /*
1.49      nicm     1219:         * Cursor and region position before the screen was updated - this is
                   1220:         * where the command should be applied; the values in the screen have
                   1221:         * already been updated.
                   1222:         */
                   1223:        u_int            ocx;
                   1224:        u_int            ocy;
                   1225:
                   1226:        u_int            orupper;
                   1227:        u_int            orlower;
1.140     nicm     1228:
1.308     nicm     1229:        u_int            xoff;
                   1230:        u_int            yoff;
                   1231:
1.140     nicm     1232:        /* Saved last cell on line. */
                   1233:        struct grid_cell last_cell;
                   1234:        struct grid_utf8 last_utf8;
                   1235:        u_int            last_width;
1.47      nicm     1236: };
                   1237:
1.180     nicm     1238: /* Saved message entry. */
                   1239: struct message_entry {
                   1240:        char   *msg;
                   1241:        time_t  msg_time;
                   1242: };
                   1243:
1.271     nicm     1244: /* Status output data from a job. */
                   1245: struct status_out {
                   1246:        char   *cmd;
                   1247:        char   *out;
                   1248:
                   1249:        RB_ENTRY(status_out) entry;
                   1250: };
                   1251: RB_HEAD(status_out_tree, status_out);
                   1252:
1.1       nicm     1253: /* Client connection. */
                   1254: struct client {
1.75      nicm     1255:        struct imsgbuf   ibuf;
1.159     nicm     1256:        struct event     event;
1.234     nicm     1257:        int              retcode;
1.156     nicm     1258:
                   1259:        struct timeval   creation_time;
1.158     nicm     1260:        struct timeval   activity_time;
1.1       nicm     1261:
1.73      nicm     1262:        struct environ   environ;
                   1263:
1.1       nicm     1264:        char            *title;
                   1265:        char            *cwd;
                   1266:
1.192     nicm     1267:        struct tty       tty;
1.236     nicm     1268:
1.332     nicm     1269:        void            (*stdin_callback)(struct client *, int, void *);
                   1270:        void            *stdin_callback_data;
                   1271:        struct evbuffer *stdin_data;
                   1272:        int              stdin_closed;
                   1273:        struct evbuffer *stdout_data;
                   1274:        struct evbuffer *stderr_data;
1.231     nicm     1275:
1.169     nicm     1276:        struct event     repeat_timer;
1.1       nicm     1277:
1.271     nicm     1278:        struct status_out_tree status_old;
                   1279:        struct status_out_tree status_new;
1.126     nicm     1280:        struct timeval   status_timer;
1.1       nicm     1281:        struct screen    status;
                   1282:
                   1283: #define CLIENT_TERMINAL 0x1
                   1284: #define CLIENT_PREFIX 0x2
1.236     nicm     1285: #define CLIENT_EXIT 0x4
1.1       nicm     1286: #define CLIENT_REDRAW 0x8
                   1287: #define CLIENT_STATUS 0x10
1.336     nicm     1288: #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
1.1       nicm     1289: #define CLIENT_SUSPENDED 0x40
1.70      nicm     1290: #define CLIENT_BAD 0x80
1.92      nicm     1291: #define CLIENT_IDENTIFY 0x100
1.101     nicm     1292: #define CLIENT_DEAD 0x200
1.197     nicm     1293: #define CLIENT_BORDERS 0x400
1.205     nicm     1294: #define CLIENT_READONLY 0x800
1.307     nicm     1295: #define CLIENT_REDRAWWINDOW 0x1000
1.342     nicm     1296: #define CLIENT_CONTROL 0x2000
1.1       nicm     1297:        int              flags;
                   1298:
1.166     nicm     1299:        struct event     identify_timer;
1.92      nicm     1300:
1.1       nicm     1301:        char            *message_string;
1.166     nicm     1302:        struct event     message_timer;
1.180     nicm     1303:        ARRAY_DECL(, struct message_entry) message_log;
1.1       nicm     1304:
                   1305:        char            *prompt_string;
                   1306:        char            *prompt_buffer;
                   1307:        size_t           prompt_index;
1.33      nicm     1308:        int              (*prompt_callbackfn)(void *, const char *);
                   1309:        void             (*prompt_freefn)(void *);
1.1       nicm     1310:        void            *prompt_data;
1.249     nicm     1311:        u_int            prompt_hindex;
1.1       nicm     1312:
1.117     nicm     1313: #define PROMPT_SINGLE 0x1
1.1       nicm     1314:        int              prompt_flags;
                   1315:
                   1316:        struct mode_key_data prompt_mdata;
                   1317:
                   1318:        struct session  *session;
1.252     nicm     1319:        struct session  *last_session;
1.101     nicm     1320:
1.284     nicm     1321:        struct mouse_event last_mouse;
1.316     nicm     1322:
                   1323:        int              wlmouse;
1.284     nicm     1324:
1.101     nicm     1325:        int              references;
1.1       nicm     1326: };
                   1327: ARRAY_DECL(clients, struct client *);
                   1328:
1.264     nicm     1329: /* Parsed arguments. */
                   1330: struct args {
                   1331:        bitstr_t        *flags;
                   1332:        char            *values[SCHAR_MAX]; /* XXX This is awfully big. */
                   1333:
                   1334:        int              argc;
                   1335:        char           **argv;
                   1336: };
                   1337:
1.1       nicm     1338: /* Key/command line command. */
                   1339: struct cmd_ctx {
1.35      nicm     1340:        /*
                   1341:         * curclient is the client where this command was executed if inside
                   1342:         * tmux. This is NULL if the command came from the command-line.
                   1343:         *
                   1344:         * cmdclient is the client which sent the MSG_COMMAND to the server, if
                   1345:         * any. This is NULL unless the command came from the command-line.
                   1346:         *
1.52      nicm     1347:         * cmdclient and curclient may both be NULL if the command is in the
                   1348:         * configuration file.
1.35      nicm     1349:         */
1.1       nicm     1350:        struct client  *curclient;
1.54      nicm     1351:        struct client  *cmdclient;
1.35      nicm     1352:
1.1       nicm     1353:        struct msg_command_data *msgdata;
                   1354:
1.90      nicm     1355:        /* gcc2 doesn't understand attributes on function pointers... */
                   1356: #if defined(__GNUC__) && __GNUC__ >= 3
1.85      nicm     1357:        void printflike2 (*print)(struct cmd_ctx *, const char *, ...);
                   1358:        void printflike2 (*info)(struct cmd_ctx *, const char *, ...);
                   1359:        void printflike2 (*error)(struct cmd_ctx *, const char *, ...);
1.90      nicm     1360: #else
                   1361:        void (*print)(struct cmd_ctx *, const char *, ...);
                   1362:        void (*info)(struct cmd_ctx *, const char *, ...);
                   1363:        void (*error)(struct cmd_ctx *, const char *, ...);
                   1364: #endif
1.1       nicm     1365: };
                   1366:
                   1367: struct cmd {
1.264     nicm     1368:        const struct cmd_entry  *entry;
                   1369:        struct args             *args;
1.1       nicm     1370:
1.264     nicm     1371:        TAILQ_ENTRY(cmd)         qentry;
1.1       nicm     1372: };
1.229     nicm     1373: struct cmd_list {
1.264     nicm     1374:        int                      references;
                   1375:        TAILQ_HEAD(, cmd)        list;
1.229     nicm     1376: };
1.1       nicm     1377:
1.348     nicm     1378: enum cmd_retval {
                   1379:        CMD_RETURN_ERROR = -1,
                   1380:        CMD_RETURN_NORMAL = 0,
                   1381:        CMD_RETURN_YIELD,
                   1382:        CMD_RETURN_ATTACH
                   1383: };
                   1384:
1.1       nicm     1385: struct cmd_entry {
                   1386:        const char      *name;
                   1387:        const char      *alias;
1.264     nicm     1388:
                   1389:        const char      *args_template;
                   1390:        int              args_lower;
                   1391:        int              args_upper;
                   1392:
1.1       nicm     1393:        const char      *usage;
                   1394:
                   1395: #define CMD_STARTSERVER 0x1
                   1396: #define CMD_CANTNEST 0x2
1.74      nicm     1397: #define CMD_SENDENVIRON 0x4
1.264     nicm     1398: #define CMD_READONLY 0x8
1.27      nicm     1399:        int              flags;
1.1       nicm     1400:
1.264     nicm     1401:        void             (*key_binding)(struct cmd *, int);
                   1402:        int              (*check)(struct args *);
1.348     nicm     1403:        enum cmd_retval  (*exec)(struct cmd *, struct cmd_ctx *);
1.1       nicm     1404: };
                   1405:
                   1406: /* Key binding. */
                   1407: struct key_binding {
                   1408:        int              key;
                   1409:        struct cmd_list *cmdlist;
                   1410:        int              can_repeat;
                   1411:
1.306     nicm     1412:        RB_ENTRY(key_binding) entry;
1.1       nicm     1413: };
1.306     nicm     1414: RB_HEAD(key_bindings, key_binding);
1.1       nicm     1415:
1.262     nicm     1416: /*
                   1417:  * Option table entries. The option table is the user-visible part of the
                   1418:  * option, as opposed to the internal options (struct option) which are just
                   1419:  * number or string.
                   1420:  */
                   1421: enum options_table_type {
                   1422:        OPTIONS_TABLE_STRING,
                   1423:        OPTIONS_TABLE_NUMBER,
1.305     nicm     1424:        OPTIONS_TABLE_KEY,
1.262     nicm     1425:        OPTIONS_TABLE_COLOUR,
                   1426:        OPTIONS_TABLE_ATTRIBUTES,
                   1427:        OPTIONS_TABLE_FLAG,
                   1428:        OPTIONS_TABLE_CHOICE
                   1429: };
                   1430:
                   1431: struct options_table_entry {
                   1432:        const char             *name;
                   1433:        enum options_table_type type;
1.1       nicm     1434:
1.262     nicm     1435:        u_int                   minimum;
                   1436:        u_int                   maximum;
                   1437:        const char            **choices;
1.1       nicm     1438:
1.262     nicm     1439:        const char             *default_str;
                   1440:        long long               default_num;
1.1       nicm     1441: };
                   1442:
1.294     nicm     1443: /* Tree of format entries. */
                   1444: struct format_entry {
                   1445:        char                   *key;
                   1446:        char                   *value;
                   1447:
                   1448:        RB_ENTRY(format_entry)  entry;
                   1449: };
                   1450: RB_HEAD(format_tree, format_entry);
                   1451:
1.206     nicm     1452: /* List of configuration causes. */
                   1453: ARRAY_DECL(causelist, char *);
                   1454:
1.264     nicm     1455: /* Common command usages. */
                   1456: #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
                   1457: #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
                   1458: #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
                   1459: #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
                   1460: #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
                   1461: #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
                   1462: #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
                   1463: #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
                   1464: #define CMD_BUFFER_USAGE "[-b buffer-index]"
                   1465:
1.1       nicm     1466: /* tmux.c */
1.194     nicm     1467: extern struct options global_options;
1.16      nicm     1468: extern struct options global_s_options;
                   1469: extern struct options global_w_options;
1.73      nicm     1470: extern struct environ global_environ;
1.219     nicm     1471: extern struct event_base *ev_base;
1.1       nicm     1472: extern char    *cfg_file;
1.243     nicm     1473: extern char    *shell_cmd;
1.1       nicm     1474: extern int      debug_level;
                   1475: extern time_t   start_time;
1.243     nicm     1476: extern char     socket_path[MAXPATHLEN];
1.96      nicm     1477: extern int      login_shell;
1.243     nicm     1478: extern char    *environ_path;
                   1479: extern pid_t    environ_pid;
1.267     nicm     1480: extern int      environ_idx;
1.1       nicm     1481: void            logfile(const char *);
1.93      nicm     1482: const char     *getshell(void);
                   1483: int             checkshell(const char *);
                   1484: int             areshell(const char *);
1.296     nicm     1485: const char*     get_full_path(const char *, const char *);
1.265     nicm     1486: void            setblocking(int, int);
1.243     nicm     1487: __dead void     shell_exec(const char *, const char *);
1.1       nicm     1488:
                   1489: /* cfg.c */
1.203     nicm     1490: extern int       cfg_finished;
1.246     nicm     1491: extern struct causelist cfg_causes;
1.206     nicm     1492: void printflike2 cfg_add_cause(struct causelist *, const char *, ...);
                   1493: int             load_cfg(const char *, struct cmd_ctx *, struct causelist *);
1.294     nicm     1494:
                   1495: /* format.c */
                   1496: int             format_cmp(struct format_entry *, struct format_entry *);
                   1497: RB_PROTOTYPE(format_tree, format_entry, entry, format_cmp);
                   1498: struct format_tree *format_create(void);
                   1499: void            format_free(struct format_tree *);
1.314     nicm     1500: void printflike3 format_add(
1.294     nicm     1501:                     struct format_tree *, const char *, const char *, ...);
                   1502: const char     *format_find(struct format_tree *, const char *);
                   1503: char           *format_expand(struct format_tree *, const char *);
                   1504: void            format_session(struct format_tree *, struct session *);
1.295     nicm     1505: void            format_client(struct format_tree *, struct client *);
1.294     nicm     1506: void            format_winlink(
                   1507:                     struct format_tree *, struct session *, struct winlink *);
                   1508: void            format_window_pane(struct format_tree *, struct window_pane *);
1.335     nicm     1509: void            format_paste_buffer(struct format_tree *, struct paste_buffer *);
1.1       nicm     1510:
                   1511: /* mode-key.c */
1.62      nicm     1512: extern const struct mode_key_table mode_key_tables[];
                   1513: extern struct mode_key_tree mode_key_tree_vi_edit;
                   1514: extern struct mode_key_tree mode_key_tree_vi_choice;
                   1515: extern struct mode_key_tree mode_key_tree_vi_copy;
                   1516: extern struct mode_key_tree mode_key_tree_emacs_edit;
                   1517: extern struct mode_key_tree mode_key_tree_emacs_choice;
                   1518: extern struct mode_key_tree mode_key_tree_emacs_copy;
                   1519: int    mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
1.306     nicm     1520: RB_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
1.261     nicm     1521: const char *mode_key_tostring(const struct mode_key_cmdstr *,
                   1522:            enum mode_key_cmd);
                   1523: enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
                   1524:            const char *);
1.63      nicm     1525: const struct mode_key_table *mode_key_findtable(const char *);
1.62      nicm     1526: void   mode_key_init_trees(void);
                   1527: void   mode_key_init(struct mode_key_data *, struct mode_key_tree *);
1.1       nicm     1528: enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
1.323     nicm     1529:
                   1530: /* notify.c */
1.349     nicm     1531: void   notify_enable(void);
                   1532: void   notify_disable(void);
1.323     nicm     1533: void   notify_window_layout_changed(struct window *);
                   1534: void   notify_window_unlinked(struct session *, struct window *);
                   1535: void   notify_window_linked(struct session *, struct window *);
                   1536: void   notify_window_renamed(struct window *);
                   1537: void   notify_attached_session_changed(struct client *);
                   1538: void   notify_session_renamed(struct session *);
                   1539: void   notify_session_created(struct session *);
                   1540: void   notify_session_closed(struct session *);
1.1       nicm     1541:
                   1542: /* options.c */
                   1543: int    options_cmp(struct options_entry *, struct options_entry *);
1.306     nicm     1544: RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
1.1       nicm     1545: void   options_init(struct options *, struct options *);
                   1546: void   options_free(struct options *);
                   1547: struct options_entry *options_find1(struct options *, const char *);
                   1548: struct options_entry *options_find(struct options *, const char *);
1.44      nicm     1549: void   options_remove(struct options *, const char *);
1.111     nicm     1550: struct options_entry *printflike3 options_set_string(
1.192     nicm     1551:            struct options *, const char *, const char *, ...);
1.1       nicm     1552: char   *options_get_string(struct options *, const char *);
1.111     nicm     1553: struct options_entry *options_set_number(
1.192     nicm     1554:            struct options *, const char *, long long);
1.1       nicm     1555: long long options_get_number(struct options *, const char *);
                   1556:
1.262     nicm     1557: /* options-table.c */
                   1558: extern const struct options_table_entry server_options_table[];
                   1559: extern const struct options_table_entry session_options_table[];
                   1560: extern const struct options_table_entry window_options_table[];
                   1561: void   options_table_populate_tree(
                   1562:            const struct options_table_entry *, struct options *);
                   1563: const char *options_table_print_entry(
                   1564:            const struct options_table_entry *, struct options_entry *);
1.313     nicm     1565: int    options_table_find(
                   1566:            const char *, const struct options_table_entry **,
                   1567:            const struct options_table_entry **);
1.262     nicm     1568:
1.126     nicm     1569: /* job.c */
1.128     nicm     1570: extern struct joblist all_jobs;
1.271     nicm     1571: struct job *job_run(
1.126     nicm     1572:            const char *, void (*)(struct job *), void (*)(void *), void *);
                   1573: void   job_free(struct job *);
1.160     nicm     1574: void   job_died(struct job *, int);
1.126     nicm     1575:
1.73      nicm     1576: /* environ.c */
                   1577: int    environ_cmp(struct environ_entry *, struct environ_entry *);
                   1578: RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp);
                   1579: void   environ_init(struct environ *);
                   1580: void   environ_free(struct environ *);
                   1581: void   environ_copy(struct environ *, struct environ *);
                   1582: struct environ_entry *environ_find(struct environ *, const char *);
                   1583: void   environ_set(struct environ *, const char *, const char *);
                   1584: void   environ_put(struct environ *, const char *);
                   1585: void   environ_unset(struct environ *, const char *);
1.192     nicm     1586: void   environ_update(const char *, struct environ *, struct environ *);
1.215     nicm     1587: void   environ_push(struct environ *);
1.73      nicm     1588:
1.1       nicm     1589: /* tty.c */
1.322     nicm     1590: void   tty_init_termios(int, struct termios *, struct bufferevent *);
1.115     nicm     1591: void   tty_raw(struct tty *, const char *);
1.92      nicm     1592: void   tty_attributes(struct tty *, const struct grid_cell *);
1.47      nicm     1593: void   tty_reset(struct tty *);
1.132     nicm     1594: void   tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1.133     nicm     1595: void   tty_region(struct tty *, u_int, u_int);
1.134     nicm     1596: void   tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
                   1597: void   tty_cursor(struct tty *, u_int, u_int);
1.47      nicm     1598: void   tty_putcode(struct tty *, enum tty_code_code);
                   1599: void   tty_putcode1(struct tty *, enum tty_code_code, int);
                   1600: void   tty_putcode2(struct tty *, enum tty_code_code, int, int);
1.287     nicm     1601: void   tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
1.286     nicm     1602: void   tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const void *);
1.47      nicm     1603: void   tty_puts(struct tty *, const char *);
                   1604: void   tty_putc(struct tty *, u_char);
                   1605: void   tty_pututf8(struct tty *, const struct grid_utf8 *);
1.337     nicm     1606: void   tty_init(struct tty *, struct client *, int, char *);
1.224     nicm     1607: int    tty_resize(struct tty *);
1.324     nicm     1608: int    tty_set_size(struct tty *, u_int, u_int);
1.47      nicm     1609: void   tty_start_tty(struct tty *);
1.324     nicm     1610: void   tty_set_version(struct tty *, u_int);
1.47      nicm     1611: void   tty_stop_tty(struct tty *);
                   1612: void   tty_set_title(struct tty *, const char *);
1.287     nicm     1613: void   tty_update_mode(struct tty *, int, struct screen *);
                   1614: void   tty_force_cursor_colour(struct tty *, const char *);
1.47      nicm     1615: void   tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
1.67      nicm     1616: int    tty_open(struct tty *, const char *, char **);
1.76      nicm     1617: void   tty_close(struct tty *);
                   1618: void   tty_free(struct tty *);
1.308     nicm     1619: void   tty_write(
                   1620:            void (*)(struct tty *, const struct tty_ctx *), struct tty_ctx *);
1.79      nicm     1621: void   tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
                   1622: void   tty_cmd_cell(struct tty *, const struct tty_ctx *);
                   1623: void   tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
                   1624: void   tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
                   1625: void   tty_cmd_clearline(struct tty *, const struct tty_ctx *);
                   1626: void   tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
                   1627: void   tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
                   1628: void   tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
                   1629: void   tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
                   1630: void   tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
1.282     nicm     1631: void   tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *);
1.79      nicm     1632: void   tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
                   1633: void   tty_cmd_insertline(struct tty *, const struct tty_ctx *);
                   1634: void   tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
                   1635: void   tty_cmd_utf8character(struct tty *, const struct tty_ctx *);
                   1636: void   tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
1.286     nicm     1637: void   tty_cmd_setselection(struct tty *, const struct tty_ctx *);
1.273     nicm     1638: void   tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
1.293     nicm     1639: void   tty_bell(struct tty *);
1.1       nicm     1640:
                   1641: /* tty-term.c */
                   1642: extern struct tty_terms tty_terms;
1.260     nicm     1643: extern const struct tty_term_code_entry tty_term_codes[NTTYCODE];
1.67      nicm     1644: struct tty_term *tty_term_find(char *, int, const char *, char **);
1.192     nicm     1645: void            tty_term_free(struct tty_term *);
1.1       nicm     1646: int             tty_term_has(struct tty_term *, enum tty_code_code);
                   1647: const char     *tty_term_string(struct tty_term *, enum tty_code_code);
                   1648: const char     *tty_term_string1(struct tty_term *, enum tty_code_code, int);
                   1649: const char     *tty_term_string2(
1.192     nicm     1650:                     struct tty_term *, enum tty_code_code, int, int);
1.287     nicm     1651: const char     *tty_term_ptr1(
                   1652:                     struct tty_term *, enum tty_code_code, const void *);
1.286     nicm     1653: const char     *tty_term_ptr2(
                   1654:                     struct tty_term *, enum tty_code_code, const void *, const void *);
1.1       nicm     1655: int             tty_term_number(struct tty_term *, enum tty_code_code);
                   1656: int             tty_term_flag(struct tty_term *, enum tty_code_code);
1.240     nicm     1657:
                   1658: /* tty-acs.c */
                   1659: const char     *tty_acs_get(struct tty *, u_char);
1.1       nicm     1660:
                   1661: /* tty-keys.c */
1.47      nicm     1662: void   tty_keys_init(struct tty *);
                   1663: void   tty_keys_free(struct tty *);
1.170     nicm     1664: int    tty_keys_next(struct tty *);
1.1       nicm     1665:
                   1666: /* paste.c */
1.276     nicm     1667: struct paste_buffer *paste_walk_stack(struct paste_stack *, u_int *);
1.1       nicm     1668: struct paste_buffer *paste_get_top(struct paste_stack *);
                   1669: struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
1.192     nicm     1670: int             paste_free_top(struct paste_stack *);
1.1       nicm     1671: int             paste_free_index(struct paste_stack *, u_int);
1.187     nicm     1672: void            paste_add(struct paste_stack *, char *, size_t, u_int);
                   1673: int             paste_replace(struct paste_stack *, u_int, char *, size_t);
1.228     nicm     1674: char           *paste_print(struct paste_buffer *, size_t);
1.1       nicm     1675:
                   1676: /* clock.c */
1.92      nicm     1677: extern const char clock_table[14][5][5];
1.188     nicm     1678: void            clock_draw(struct screen_write_ctx *, int, int);
1.1       nicm     1679:
1.264     nicm     1680: /* arguments.c */
                   1681: struct args    *args_create(int, ...);
                   1682: struct args    *args_parse(const char *, int, char **);
                   1683: void            args_free(struct args *);
                   1684: size_t          args_print(struct args *, char *, size_t);
                   1685: int             args_has(struct args *, u_char);
                   1686: void            args_set(struct args *, u_char, const char *);
                   1687: const char     *args_get(struct args *, u_char);
                   1688: long long       args_strtonum(
                   1689:                    struct args *, u_char, long long, long long, char **);
                   1690:
1.1       nicm     1691: /* cmd.c */
1.55      nicm     1692: int             cmd_pack_argv(int, char **, char *, size_t);
                   1693: int             cmd_unpack_argv(char *, size_t, int, char ***);
1.264     nicm     1694: char          **cmd_copy_argv(int, char *const *);
1.55      nicm     1695: void            cmd_free_argv(int, char **);
1.1       nicm     1696: struct cmd     *cmd_parse(int, char **, char **);
1.348     nicm     1697: enum cmd_retval         cmd_exec(struct cmd *, struct cmd_ctx *);
1.1       nicm     1698: void            cmd_free(struct cmd *);
                   1699: size_t          cmd_print(struct cmd *, char *, size_t);
1.278     nicm     1700: struct session *cmd_current_session(struct cmd_ctx *, int);
1.157     nicm     1701: struct client  *cmd_current_client(struct cmd_ctx *);
1.1       nicm     1702: struct client  *cmd_find_client(struct cmd_ctx *, const char *);
1.278     nicm     1703: struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
1.1       nicm     1704: struct winlink *cmd_find_window(
1.26      nicm     1705:                     struct cmd_ctx *, const char *, struct session **);
                   1706: int             cmd_find_index(
                   1707:                     struct cmd_ctx *, const char *, struct session **);
1.65      nicm     1708: struct winlink *cmd_find_pane(struct cmd_ctx *,
                   1709:                     const char *, struct session **, struct window_pane **);
1.91      nicm     1710: char           *cmd_template_replace(char *, const char *, int);
1.310     nicm     1711: const char             *cmd_get_default_path(struct cmd_ctx *, const char *);
1.1       nicm     1712: extern const struct cmd_entry *cmd_table[];
                   1713: extern const struct cmd_entry cmd_attach_session_entry;
                   1714: extern const struct cmd_entry cmd_bind_key_entry;
                   1715: extern const struct cmd_entry cmd_break_pane_entry;
1.190     nicm     1716: extern const struct cmd_entry cmd_capture_pane_entry;
1.228     nicm     1717: extern const struct cmd_entry cmd_choose_buffer_entry;
1.91      nicm     1718: extern const struct cmd_entry cmd_choose_client_entry;
1.1       nicm     1719: extern const struct cmd_entry cmd_choose_session_entry;
1.346     nicm     1720: extern const struct cmd_entry cmd_choose_tree_entry;
1.1       nicm     1721: extern const struct cmd_entry cmd_choose_window_entry;
                   1722: extern const struct cmd_entry cmd_clear_history_entry;
                   1723: extern const struct cmd_entry cmd_clock_mode_entry;
                   1724: extern const struct cmd_entry cmd_command_prompt_entry;
                   1725: extern const struct cmd_entry cmd_confirm_before_entry;
                   1726: extern const struct cmd_entry cmd_copy_mode_entry;
                   1727: extern const struct cmd_entry cmd_delete_buffer_entry;
                   1728: extern const struct cmd_entry cmd_detach_client_entry;
1.36      nicm     1729: extern const struct cmd_entry cmd_display_message_entry;
1.92      nicm     1730: extern const struct cmd_entry cmd_display_panes_entry;
1.1       nicm     1731: extern const struct cmd_entry cmd_down_pane_entry;
                   1732: extern const struct cmd_entry cmd_find_window_entry;
                   1733: extern const struct cmd_entry cmd_has_session_entry;
1.19      nicm     1734: extern const struct cmd_entry cmd_if_shell_entry;
1.198     nicm     1735: extern const struct cmd_entry cmd_join_pane_entry;
1.1       nicm     1736: extern const struct cmd_entry cmd_kill_pane_entry;
                   1737: extern const struct cmd_entry cmd_kill_server_entry;
                   1738: extern const struct cmd_entry cmd_kill_session_entry;
                   1739: extern const struct cmd_entry cmd_kill_window_entry;
1.244     nicm     1740: extern const struct cmd_entry cmd_last_pane_entry;
1.1       nicm     1741: extern const struct cmd_entry cmd_last_window_entry;
                   1742: extern const struct cmd_entry cmd_link_window_entry;
                   1743: extern const struct cmd_entry cmd_list_buffers_entry;
                   1744: extern const struct cmd_entry cmd_list_clients_entry;
                   1745: extern const struct cmd_entry cmd_list_commands_entry;
                   1746: extern const struct cmd_entry cmd_list_keys_entry;
1.127     nicm     1747: extern const struct cmd_entry cmd_list_panes_entry;
1.1       nicm     1748: extern const struct cmd_entry cmd_list_sessions_entry;
                   1749: extern const struct cmd_entry cmd_list_windows_entry;
                   1750: extern const struct cmd_entry cmd_load_buffer_entry;
1.118     nicm     1751: extern const struct cmd_entry cmd_lock_client_entry;
1.1       nicm     1752: extern const struct cmd_entry cmd_lock_server_entry;
1.118     nicm     1753: extern const struct cmd_entry cmd_lock_session_entry;
1.315     nicm     1754: extern const struct cmd_entry cmd_move_pane_entry;
1.1       nicm     1755: extern const struct cmd_entry cmd_move_window_entry;
                   1756: extern const struct cmd_entry cmd_new_session_entry;
                   1757: extern const struct cmd_entry cmd_new_window_entry;
                   1758: extern const struct cmd_entry cmd_next_layout_entry;
                   1759: extern const struct cmd_entry cmd_next_window_entry;
                   1760: extern const struct cmd_entry cmd_paste_buffer_entry;
1.131     nicm     1761: extern const struct cmd_entry cmd_pipe_pane_entry;
1.1       nicm     1762: extern const struct cmd_entry cmd_previous_layout_entry;
                   1763: extern const struct cmd_entry cmd_previous_window_entry;
                   1764: extern const struct cmd_entry cmd_refresh_client_entry;
                   1765: extern const struct cmd_entry cmd_rename_session_entry;
                   1766: extern const struct cmd_entry cmd_rename_window_entry;
                   1767: extern const struct cmd_entry cmd_resize_pane_entry;
1.290     nicm     1768: extern const struct cmd_entry cmd_respawn_pane_entry;
1.1       nicm     1769: extern const struct cmd_entry cmd_respawn_window_entry;
                   1770: extern const struct cmd_entry cmd_rotate_window_entry;
1.107     nicm     1771: extern const struct cmd_entry cmd_run_shell_entry;
1.1       nicm     1772: extern const struct cmd_entry cmd_save_buffer_entry;
                   1773: extern const struct cmd_entry cmd_select_layout_entry;
                   1774: extern const struct cmd_entry cmd_select_pane_entry;
                   1775: extern const struct cmd_entry cmd_select_window_entry;
                   1776: extern const struct cmd_entry cmd_send_keys_entry;
                   1777: extern const struct cmd_entry cmd_send_prefix_entry;
                   1778: extern const struct cmd_entry cmd_server_info_entry;
                   1779: extern const struct cmd_entry cmd_set_buffer_entry;
1.73      nicm     1780: extern const struct cmd_entry cmd_set_environment_entry;
1.1       nicm     1781: extern const struct cmd_entry cmd_set_option_entry;
                   1782: extern const struct cmd_entry cmd_set_window_option_entry;
                   1783: extern const struct cmd_entry cmd_show_buffer_entry;
1.73      nicm     1784: extern const struct cmd_entry cmd_show_environment_entry;
1.180     nicm     1785: extern const struct cmd_entry cmd_show_messages_entry;
1.1       nicm     1786: extern const struct cmd_entry cmd_show_options_entry;
                   1787: extern const struct cmd_entry cmd_show_window_options_entry;
                   1788: extern const struct cmd_entry cmd_source_file_entry;
                   1789: extern const struct cmd_entry cmd_split_window_entry;
                   1790: extern const struct cmd_entry cmd_start_server_entry;
                   1791: extern const struct cmd_entry cmd_suspend_client_entry;
                   1792: extern const struct cmd_entry cmd_swap_pane_entry;
                   1793: extern const struct cmd_entry cmd_swap_window_entry;
                   1794: extern const struct cmd_entry cmd_switch_client_entry;
                   1795: extern const struct cmd_entry cmd_unbind_key_entry;
                   1796: extern const struct cmd_entry cmd_unlink_window_entry;
                   1797: extern const struct cmd_entry cmd_up_pane_entry;
                   1798:
                   1799: /* cmd-list.c */
                   1800: struct cmd_list        *cmd_list_parse(int, char **, char **);
1.348     nicm     1801: enum cmd_retval         cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
1.1       nicm     1802: void            cmd_list_free(struct cmd_list *);
                   1803: size_t          cmd_list_print(struct cmd_list *, char *, size_t);
                   1804:
                   1805: /* cmd-string.c */
                   1806: int    cmd_string_parse(const char *, struct cmd_list **, char **);
                   1807:
                   1808: /* client.c */
1.243     nicm     1809: int    client_main(int, char **, int);
1.1       nicm     1810:
                   1811: /* key-bindings.c */
                   1812: extern struct key_bindings key_bindings;
                   1813: int     key_bindings_cmp(struct key_binding *, struct key_binding *);
1.306     nicm     1814: RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
1.1       nicm     1815: struct key_binding *key_bindings_lookup(int);
                   1816: void    key_bindings_add(int, int, struct cmd_list *);
                   1817: void    key_bindings_remove(int);
1.24      nicm     1818: void    key_bindings_clean(void);
1.1       nicm     1819: void    key_bindings_init(void);
                   1820: void    key_bindings_dispatch(struct key_binding *, struct client *);
                   1821: void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
                   1822: void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
                   1823: void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
                   1824:
                   1825: /* key-string.c */
                   1826: int     key_string_lookup_string(const char *);
                   1827: const char *key_string_lookup_key(int);
                   1828:
                   1829: /* server.c */
                   1830: extern struct clients clients;
1.101     nicm     1831: extern struct clients dead_clients;
1.257     nicm     1832: extern struct paste_stack global_buffers;
1.319     nicm     1833: int     server_start(int, char *);
1.175     nicm     1834: void    server_update_socket(void);
1.328     nicm     1835: void    server_add_accept(int);
1.1       nicm     1836:
1.146     nicm     1837: /* server-client.c */
1.337     nicm     1838: void    server_client_handle_key(struct client *, int);
1.146     nicm     1839: void    server_client_create(int);
1.331     nicm     1840: int      server_client_open(struct client *, struct session *, char **);
1.146     nicm     1841: void    server_client_lost(struct client *);
1.159     nicm     1842: void    server_client_callback(int, short, void *);
1.167     nicm     1843: void    server_client_status_timer(void);
1.146     nicm     1844: void    server_client_loop(void);
                   1845:
                   1846: /* server-window.c */
                   1847: void    server_window_loop(void);
1.1       nicm     1848:
                   1849: /* server-fn.c */
1.73      nicm     1850: void    server_fill_environ(struct session *, struct environ *);
1.334     nicm     1851: void    server_write_ready(struct client *);
1.332     nicm     1852: int     server_write_client(
1.192     nicm     1853:             struct client *, enum msgtype, const void *, size_t);
1.1       nicm     1854: void    server_write_session(
1.192     nicm     1855:             struct session *, enum msgtype, const void *, size_t);
1.1       nicm     1856: void    server_redraw_client(struct client *);
                   1857: void    server_status_client(struct client *);
                   1858: void    server_redraw_session(struct session *);
1.124     nicm     1859: void    server_redraw_session_group(struct session *);
1.1       nicm     1860: void    server_status_session(struct session *);
1.124     nicm     1861: void    server_status_session_group(struct session *);
1.1       nicm     1862: void    server_redraw_window(struct window *);
1.197     nicm     1863: void    server_redraw_window_borders(struct window *);
1.1       nicm     1864: void    server_status_window(struct window *);
                   1865: void    server_lock(void);
1.118     nicm     1866: void    server_lock_session(struct session *);
                   1867: void    server_lock_client(struct client *);
1.1       nicm     1868: int     server_unlock(const char *);
1.37      nicm     1869: void    server_kill_window(struct window *);
1.124     nicm     1870: int     server_link_window(struct session *,
1.106     nicm     1871:             struct winlink *, struct session *, int, int, int, char **);
                   1872: void    server_unlink_window(struct session *, struct winlink *);
1.177     nicm     1873: void    server_destroy_pane(struct window_pane *);
1.124     nicm     1874: void    server_destroy_session_group(struct session *);
1.103     nicm     1875: void    server_destroy_session(struct session *);
1.241     nicm     1876: void    server_check_unattached (void);
1.92      nicm     1877: void    server_set_identify(struct client *);
                   1878: void    server_clear_identify(struct client *);
1.165     nicm     1879: void    server_update_event(struct client *);
1.332     nicm     1880: void    server_push_stdout(struct client *);
                   1881: void    server_push_stderr(struct client *);
                   1882: int     server_set_stdin_callback(struct client *, void (*)(struct client *,
                   1883:             int, void *), void *, char **);
1.1       nicm     1884:
                   1885: /* status.c */
1.271     nicm     1886: int     status_out_cmp(struct status_out *, struct status_out *);
                   1887: RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
1.308     nicm     1888: int     status_at_line(struct client *);
1.271     nicm     1889: void    status_free_jobs(struct status_out_tree *);
                   1890: void    status_update_jobs(struct client *);
1.281     nicm     1891: void    status_set_window_at(struct client *, u_int);
1.1       nicm     1892: int     status_redraw(struct client *);
1.277     nicm     1893: char   *status_replace(struct client *, struct session *,
                   1894:             struct winlink *, struct window_pane *, const char *, time_t, int);
1.32      nicm     1895: void printflike2 status_message_set(struct client *, const char *, ...);
1.1       nicm     1896: void    status_message_clear(struct client *);
                   1897: int     status_message_redraw(struct client *);
1.292     nicm     1898: void    status_prompt_set(struct client *, const char *, const char *,
1.192     nicm     1899:             int (*)(void *, const char *), void (*)(void *), void *, int);
1.1       nicm     1900: void    status_prompt_clear(struct client *);
                   1901: int     status_prompt_redraw(struct client *);
                   1902: void    status_prompt_key(struct client *, int);
1.292     nicm     1903: void    status_prompt_update(struct client *, const char *, const char *);
1.1       nicm     1904:
                   1905: /* resize.c */
                   1906: void    recalculate_sizes(void);
                   1907:
                   1908: /* input.c */
                   1909: void    input_init(struct window_pane *);
                   1910: void    input_free(struct window_pane *);
                   1911: void    input_parse(struct window_pane *);
                   1912:
                   1913: /* input-key.c */
                   1914: void    input_key(struct window_pane *, int);
1.129     nicm     1915: void    input_mouse(struct window_pane *, struct mouse_event *);
1.150     nicm     1916:
                   1917: /* xterm-keys.c */
1.192     nicm     1918: char   *xterm_keys_lookup(int);
1.189     nicm     1919: int     xterm_keys_find(const char *, size_t, size_t *, int *);
1.1       nicm     1920:
                   1921: /* colour.c */
1.102     nicm     1922: void    colour_set_fg(struct grid_cell *, int);
                   1923: void    colour_set_bg(struct grid_cell *, int);
                   1924: const char *colour_tostring(int);
1.1       nicm     1925: int     colour_fromstring(const char *);
                   1926: u_char  colour_256to16(u_char);
                   1927: u_char  colour_256to88(u_char);
                   1928:
                   1929: /* attributes.c */
                   1930: const char *attributes_tostring(u_char);
                   1931: int     attributes_fromstring(const char *);
                   1932:
                   1933: /* grid.c */
                   1934: extern const struct grid_cell grid_default_cell;
1.338     nicm     1935: extern const struct grid_cell grid_marker_cell;
1.1       nicm     1936: struct grid *grid_create(u_int, u_int, u_int);
                   1937: void    grid_destroy(struct grid *);
                   1938: int     grid_compare(struct grid *, struct grid *);
1.139     nicm     1939: void    grid_collect_history(struct grid *);
                   1940: void    grid_scroll_history(struct grid *);
                   1941: void    grid_scroll_history_region(struct grid *, u_int, u_int);
1.1       nicm     1942: void    grid_expand_line(struct grid *, u_int, u_int);
                   1943: void    grid_expand_line_utf8(struct grid *, u_int, u_int);
                   1944: const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
                   1945: struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
                   1946: void    grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
                   1947: const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
                   1948: struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
                   1949: void    grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
                   1950: void    grid_clear(struct grid *, u_int, u_int, u_int, u_int);
                   1951: void    grid_clear_lines(struct grid *, u_int, u_int);
                   1952: void    grid_move_lines(struct grid *, u_int, u_int, u_int);
                   1953: void    grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1.9       nicm     1954: char   *grid_string_cells(struct grid *, u_int, u_int, u_int);
1.25      nicm     1955: void    grid_duplicate_lines(
1.192     nicm     1956:             struct grid *, u_int, struct grid *, u_int, u_int);
1.181     nicm     1957:
                   1958: /* grid-utf8.c */
                   1959: size_t  grid_utf8_size(const struct grid_utf8 *);
                   1960: size_t  grid_utf8_copy(const struct grid_utf8 *, char *, size_t);
                   1961: void    grid_utf8_set(struct grid_utf8 *, const struct utf8_data *);
                   1962: int     grid_utf8_append(struct grid_utf8 *, const struct utf8_data *);
                   1963: int     grid_utf8_compare(const struct grid_utf8 *, const struct grid_utf8 *);
1.1       nicm     1964:
                   1965: /* grid-view.c */
                   1966: const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
                   1967: struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
                   1968: void    grid_view_set_cell(
1.192     nicm     1969:             struct grid *, u_int, u_int, const struct grid_cell *);
1.1       nicm     1970: const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
                   1971: struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
                   1972: void    grid_view_set_utf8(
1.192     nicm     1973:             struct grid *, u_int, u_int, const struct grid_utf8 *);
1.269     nicm     1974: void    grid_view_clear_history(struct grid *);
1.1       nicm     1975: void    grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
                   1976: void    grid_view_scroll_region_up(struct grid *, u_int, u_int);
                   1977: void    grid_view_scroll_region_down(struct grid *, u_int, u_int);
                   1978: void    grid_view_insert_lines(struct grid *, u_int, u_int);
1.18      nicm     1979: void    grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1.1       nicm     1980: void    grid_view_delete_lines(struct grid *, u_int, u_int);
1.18      nicm     1981: void    grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1.1       nicm     1982: void    grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
                   1983: void    grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1.9       nicm     1984: char   *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1.1       nicm     1985:
                   1986: /* screen-write.c */
                   1987: void    screen_write_start(
1.192     nicm     1988:             struct screen_write_ctx *, struct window_pane *, struct screen *);
1.1       nicm     1989: void    screen_write_stop(struct screen_write_ctx *);
1.304     nicm     1990: void    screen_write_reset(struct screen_write_ctx *);
1.99      nicm     1991: size_t printflike2 screen_write_cstrlen(int, const char *, ...);
                   1992: void printflike5 screen_write_cnputs(struct screen_write_ctx *,
1.192     nicm     1993:             ssize_t, struct grid_cell *, int, const char *, ...);
1.4       nicm     1994: size_t printflike2 screen_write_strlen(int, const char *, ...);
1.3       nicm     1995: void printflike3 screen_write_puts(struct screen_write_ctx *,
1.192     nicm     1996:             struct grid_cell *, const char *, ...);
1.4       nicm     1997: void printflike5 screen_write_nputs(struct screen_write_ctx *,
1.192     nicm     1998:             ssize_t, struct grid_cell *, int, const char *, ...);
1.3       nicm     1999: void    screen_write_vnputs(struct screen_write_ctx *,
1.4       nicm     2000:             ssize_t, struct grid_cell *, int, const char *, va_list);
1.99      nicm     2001: void    screen_write_parsestyle(
1.192     nicm     2002:             struct grid_cell *, struct grid_cell *, const char *);
1.1       nicm     2003: void    screen_write_putc(
1.192     nicm     2004:             struct screen_write_ctx *, struct grid_cell *, u_char);
1.1       nicm     2005: void    screen_write_copy(struct screen_write_ctx *,
                   2006:             struct screen *, u_int, u_int, u_int, u_int);
1.136     nicm     2007: void    screen_write_backspace(struct screen_write_ctx *);
1.1       nicm     2008: void    screen_write_cursorup(struct screen_write_ctx *, u_int);
                   2009: void    screen_write_cursordown(struct screen_write_ctx *, u_int);
                   2010: void    screen_write_cursorright(struct screen_write_ctx *, u_int);
                   2011: void    screen_write_cursorleft(struct screen_write_ctx *, u_int);
1.5       nicm     2012: void    screen_write_alignmenttest(struct screen_write_ctx *);
1.1       nicm     2013: void    screen_write_insertcharacter(struct screen_write_ctx *, u_int);
                   2014: void    screen_write_deletecharacter(struct screen_write_ctx *, u_int);
                   2015: void    screen_write_insertline(struct screen_write_ctx *, u_int);
                   2016: void    screen_write_deleteline(struct screen_write_ctx *, u_int);
                   2017: void    screen_write_clearline(struct screen_write_ctx *);
                   2018: void    screen_write_clearendofline(struct screen_write_ctx *);
                   2019: void    screen_write_clearstartofline(struct screen_write_ctx *);
                   2020: void    screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
                   2021: void    screen_write_cursormode(struct screen_write_ctx *, int);
                   2022: void    screen_write_reverseindex(struct screen_write_ctx *);
                   2023: void    screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
                   2024: void    screen_write_insertmode(struct screen_write_ctx *, int);
1.263     nicm     2025: void    screen_write_utf8mousemode(struct screen_write_ctx *, int);
1.255     nicm     2026: void    screen_write_mousemode_on(struct screen_write_ctx *, int);
                   2027: void    screen_write_mousemode_off(struct screen_write_ctx *);
1.72      nicm     2028: void    screen_write_linefeed(struct screen_write_ctx *, int);
1.137     nicm     2029: void    screen_write_linefeedscreen(struct screen_write_ctx *, int);
1.1       nicm     2030: void    screen_write_carriagereturn(struct screen_write_ctx *);
                   2031: void    screen_write_kcursormode(struct screen_write_ctx *, int);
                   2032: void    screen_write_kkeypadmode(struct screen_write_ctx *, int);
                   2033: void    screen_write_clearendofscreen(struct screen_write_ctx *);
                   2034: void    screen_write_clearstartofscreen(struct screen_write_ctx *);
                   2035: void    screen_write_clearscreen(struct screen_write_ctx *);
1.297     nicm     2036: void    screen_write_clearhistory(struct screen_write_ctx *);
1.143     nicm     2037: void    screen_write_cell(struct screen_write_ctx *,
1.192     nicm     2038:             const struct grid_cell *, const struct utf8_data *);
1.286     nicm     2039: void    screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
1.273     nicm     2040: void    screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
1.317     nicm     2041: void    screen_write_bracketpaste(struct screen_write_ctx *, int);
1.1       nicm     2042:
                   2043: /* screen-redraw.c */
1.197     nicm     2044: void    screen_redraw_screen(struct client *, int, int);
1.1       nicm     2045: void    screen_redraw_pane(struct client *, struct window_pane *);
                   2046:
                   2047: /* screen.c */
                   2048: void    screen_init(struct screen *, u_int, u_int, u_int);
                   2049: void    screen_reinit(struct screen *);
                   2050: void    screen_free(struct screen *);
1.6       nicm     2051: void    screen_reset_tabs(struct screen *);
1.288     nicm     2052: void    screen_set_cursor_style(struct screen *, u_int);
1.287     nicm     2053: void    screen_set_cursor_colour(struct screen *, const char *);
1.1       nicm     2054: void    screen_set_title(struct screen *, const char *);
                   2055: void    screen_resize(struct screen *, u_int, u_int);
1.204     nicm     2056: void    screen_set_selection(struct screen *,
                   2057:             u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
1.1       nicm     2058: void    screen_clear_selection(struct screen *);
                   2059: int     screen_check_selection(struct screen *, u_int, u_int);
                   2060:
                   2061: /* window.c */
                   2062: extern struct windows windows;
1.274     nicm     2063: extern struct window_pane_tree all_window_panes;
1.1       nicm     2064: int             winlink_cmp(struct winlink *, struct winlink *);
                   2065: RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
1.274     nicm     2066: int             window_pane_cmp(struct window_pane *, struct window_pane *);
                   2067: RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
1.1       nicm     2068: struct winlink *winlink_find_by_index(struct winlinks *, int);
1.192     nicm     2069: struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
1.309     nicm     2070: struct winlink *winlink_find_by_window_id(struct winlinks *, u_int);
1.81      nicm     2071: int             winlink_next_index(struct winlinks *, int);
1.1       nicm     2072: u_int           winlink_count(struct winlinks *);
1.268     nicm     2073: struct winlink *winlink_add(struct winlinks *, int);
                   2074: void            winlink_set_window(struct winlink *, struct window *);
1.1       nicm     2075: void            winlink_remove(struct winlinks *, struct winlink *);
1.186     nicm     2076: struct winlink *winlink_next(struct winlink *);
                   2077: struct winlink *winlink_previous(struct winlink *);
1.235     nicm     2078: struct winlink *winlink_next_by_number(struct winlink *, struct session *,
                   2079:                     int);
                   2080: struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
                   2081:                     int);
1.1       nicm     2082: void            winlink_stack_push(struct winlink_stack *, struct winlink *);
                   2083: void            winlink_stack_remove(struct winlink_stack *, struct winlink *);
1.192     nicm     2084: int             window_index(struct window *, u_int *);
1.309     nicm     2085: struct window  *window_find_by_id(u_int);
1.1       nicm     2086: struct window  *window_create1(u_int, u_int);
1.73      nicm     2087: struct window  *window_create(const char *, const char *, const char *,
1.93      nicm     2088:                     const char *, struct environ *, struct termios *,
1.192     nicm     2089:                     u_int, u_int, u_int, char **);
1.1       nicm     2090: void            window_destroy(struct window *);
1.289     nicm     2091: struct window_pane *window_get_active_at(struct window *, u_int, u_int);
1.125     nicm     2092: void            window_set_active_at(struct window *, u_int, u_int);
1.289     nicm     2093: struct window_pane *window_find_string(struct window *, const char *);
1.1       nicm     2094: void            window_set_active_pane(struct window *, struct window_pane *);
1.51      nicm     2095: struct window_pane *window_add_pane(struct window *, u_int);
1.44      nicm     2096: void            window_resize(struct window *, u_int, u_int);
1.1       nicm     2097: void            window_remove_pane(struct window *, struct window_pane *);
                   2098: struct window_pane *window_pane_at_index(struct window *, u_int);
1.235     nicm     2099: struct window_pane *window_pane_next_by_number(struct window *,
                   2100:                        struct window_pane *, u_int);
                   2101: struct window_pane *window_pane_previous_by_number(struct window *,
                   2102:                        struct window_pane *, u_int);
1.298     nicm     2103: int             window_pane_index(struct window_pane *, u_int *);
1.1       nicm     2104: u_int           window_count_panes(struct window *);
                   2105: void            window_destroy_panes(struct window *);
1.274     nicm     2106: struct window_pane *window_pane_find_by_id(u_int);
1.1       nicm     2107: struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
                   2108: void            window_pane_destroy(struct window_pane *);
1.325     nicm     2109: void            window_pane_timer_start(struct window_pane *);
1.80      nicm     2110: int             window_pane_spawn(struct window_pane *, const char *,
1.93      nicm     2111:                     const char *, const char *, struct environ *,
                   2112:                     struct termios *, char **);
1.44      nicm     2113: void            window_pane_resize(struct window_pane *, u_int, u_int);
1.210     nicm     2114: void            window_pane_alternate_on(
                   2115:                     struct window_pane *, struct grid_cell *);
                   2116: void            window_pane_alternate_off(
                   2117:                     struct window_pane *, struct grid_cell *);
1.1       nicm     2118: int             window_pane_set_mode(
                   2119:                     struct window_pane *, const struct window_mode *);
                   2120: void            window_pane_reset_mode(struct window_pane *);
1.221     nicm     2121: void            window_pane_key(struct window_pane *, struct session *, int);
1.1       nicm     2122: void            window_pane_mouse(struct window_pane *,
1.221     nicm     2123:                     struct session *, struct mouse_event *);
1.28      nicm     2124: int             window_pane_visible(struct window_pane *);
1.10      nicm     2125: char           *window_pane_search(
1.192     nicm     2126:                     struct window_pane *, const char *, u_int *);
1.256     nicm     2127: char           *window_printable_flags(struct session *, struct winlink *);
1.211     nicm     2128: struct window_pane *window_pane_find_up(struct window_pane *);
                   2129: struct window_pane *window_pane_find_down(struct window_pane *);
                   2130: struct window_pane *window_pane_find_left(struct window_pane *);
                   2131: struct window_pane *window_pane_find_right(struct window_pane *);
1.311     nicm     2132: void            window_set_name(struct window *, const char *);
1.352   ! nicm     2133: void            window_remove_ref(struct window *);
1.345     nicm     2134: void            winlink_clear_flags(struct winlink *);
1.350     nicm     2135: void            window_mode_attrs(struct grid_cell *, struct options *);
1.1       nicm     2136:
                   2137: /* layout.c */
1.232     nicm     2138: u_int           layout_count_cells(struct layout_cell *);
1.39      nicm     2139: struct layout_cell *layout_create_cell(struct layout_cell *);
                   2140: void            layout_free_cell(struct layout_cell *);
                   2141: void            layout_print_cell(struct layout_cell *, const char *, u_int);
1.326     nicm     2142: void            layout_destroy_cell(
                   2143:                     struct layout_cell *, struct layout_cell **);
1.39      nicm     2144: void            layout_set_size(
                   2145:                     struct layout_cell *, u_int, u_int, u_int, u_int);
                   2146: void            layout_make_leaf(
                   2147:                     struct layout_cell *, struct window_pane *);
                   2148: void            layout_make_node(struct layout_cell *, enum layout_type);
                   2149: void            layout_fix_offsets(struct layout_cell *);
                   2150: void            layout_fix_panes(struct window *, u_int, u_int);
                   2151: u_int           layout_resize_check(struct layout_cell *, enum layout_type);
                   2152: void            layout_resize_adjust(
                   2153:                     struct layout_cell *, enum layout_type, int);
                   2154: void            layout_init(struct window *);
                   2155: void            layout_free(struct window *);
                   2156: void            layout_resize(struct window *, u_int, u_int);
                   2157: void            layout_resize_pane(
1.192     nicm     2158:                     struct window_pane *, enum layout_type, int);
1.284     nicm     2159: void            layout_resize_pane_mouse(
                   2160:                     struct client *c, struct mouse_event *mouse);
1.198     nicm     2161: void            layout_assign_pane(struct layout_cell *, struct window_pane *);
                   2162: struct layout_cell *layout_split_pane(
1.315     nicm     2163:                     struct window_pane *, enum layout_type, int, int);
1.39      nicm     2164: void            layout_close_pane(struct window_pane *);
1.326     nicm     2165: void            layout_list_add(struct window *);
                   2166: const char     *layout_list_redo(struct window *);
                   2167: const char     *layout_list_undo(struct window *);
1.39      nicm     2168:
1.232     nicm     2169: /* layout-custom.c */
                   2170: char           *layout_dump(struct window *);
                   2171: int             layout_parse(struct window *, const char *);
                   2172:
1.39      nicm     2173: /* layout-set.c */
                   2174: const char     *layout_set_name(u_int);
                   2175: int             layout_set_lookup(const char *);
                   2176: u_int           layout_set_select(struct window *, u_int);
                   2177: u_int           layout_set_next(struct window *);
                   2178: u_int           layout_set_previous(struct window *);
                   2179: void            layout_set_active_changed(struct window *);
1.1       nicm     2180:
                   2181: /* window-clock.c */
                   2182: extern const struct window_mode window_clock_mode;
                   2183:
                   2184: /* window-copy.c */
                   2185: extern const struct window_mode window_copy_mode;
1.216     nicm     2186: void            window_copy_init_from_pane(struct window_pane *);
                   2187: void            window_copy_init_for_output(struct window_pane *);
1.314     nicm     2188: void printflike2 window_copy_add(struct window_pane *, const char *, ...);
1.216     nicm     2189: void            window_copy_vadd(struct window_pane *, const char *, va_list);
1.192     nicm     2190: void            window_copy_pageup(struct window_pane *);
1.1       nicm     2191:
                   2192: /* window-choose.c */
                   2193: extern const struct window_mode window_choose_mode;
1.343     nicm     2194: void            window_choose_add(struct window_pane *,
                   2195:                         struct window_choose_data *);
1.1       nicm     2196: void            window_choose_ready(struct window_pane *,
1.343     nicm     2197:                     u_int, void (*)(struct window_choose_data *),
                   2198:                     void (*)(struct window_choose_data *));
1.344     nicm     2199: struct window_choose_data      *window_choose_data_create(struct cmd_ctx *);
1.343     nicm     2200: void            window_choose_ctx(struct window_choose_data *);
1.344     nicm     2201: struct window_choose_data      *window_choose_add_window(struct window_pane *,
                   2202:                        struct cmd_ctx *, struct session *, struct winlink *,
                   2203:                        const char *, char *, u_int);
                   2204: struct window_choose_data      *window_choose_add_session(struct window_pane *,
                   2205:                        struct cmd_ctx *, struct session *, const char *,
                   2206:                        char *, u_int);
1.1       nicm     2207:
                   2208: /* names.c */
1.168     nicm     2209: void            queue_window_name(struct window *);
1.192     nicm     2210: char           *default_window_name(struct window *);
1.219     nicm     2211:
                   2212: /* signal.c */
1.349     nicm     2213: void   set_signals(void(*)(int, short, void *));
                   2214: void   clear_signals(int);
1.342     nicm     2215:
                   2216: /* control.c */
1.349     nicm     2217: void   control_callback(struct client *, int, void*);
1.1       nicm     2218:
                   2219: /* session.c */
                   2220: extern struct sessions sessions;
1.101     nicm     2221: extern struct sessions dead_sessions;
1.124     nicm     2222: extern struct session_groups session_groups;
1.254     nicm     2223: int    session_cmp(struct session *, struct session *);
                   2224: RB_PROTOTYPE(sessions, session, entry, session_cmp);
1.251     nicm     2225: int             session_alive(struct session *);
1.1       nicm     2226: struct session *session_find(const char *);
1.254     nicm     2227: struct session *session_find_by_index(u_int);
1.80      nicm     2228: struct session *session_create(const char *, const char *, const char *,
1.81      nicm     2229:                     struct environ *, struct termios *, int, u_int, u_int,
                   2230:                     char **);
1.192     nicm     2231: void            session_destroy(struct session *);
1.279     nicm     2232: int             session_check_name(const char *);
1.259     nicm     2233: void            session_update_activity(struct session *);
1.239     nicm     2234: struct session *session_next_session(struct session *);
                   2235: struct session *session_previous_session(struct session *);
1.1       nicm     2236: struct winlink *session_new(struct session *,
1.192     nicm     2237:                     const char *, const char *, const char *, int, char **);
1.1       nicm     2238: struct winlink *session_attach(
1.192     nicm     2239:                     struct session *, struct window *, int, char **);
1.1       nicm     2240: int             session_detach(struct session *, struct winlink *);
1.226     nicm     2241: struct winlink*         session_has(struct session *, struct window *);
1.1       nicm     2242: int             session_next(struct session *, int);
                   2243: int             session_previous(struct session *, int);
                   2244: int             session_select(struct session *, int);
                   2245: int             session_last(struct session *);
1.124     nicm     2246: struct session_group *session_group_find(struct session *);
                   2247: u_int           session_group_index(struct session_group *);
                   2248: void            session_group_add(struct session *, struct session *);
                   2249: void            session_group_remove(struct session *);
                   2250: void            session_group_synchronize_to(struct session *);
                   2251: void            session_group_synchronize_from(struct session *);
                   2252: void            session_group_synchronize1(struct session *, struct session *);
1.330     nicm     2253: void            session_renumber_windows(struct session *);
1.1       nicm     2254:
                   2255: /* utf8.c */
                   2256: void   utf8_build(void);
1.143     nicm     2257: int    utf8_open(struct utf8_data *, u_char);
                   2258: int    utf8_append(struct utf8_data *, u_char);
1.263     nicm     2259: u_int  utf8_combine(const struct utf8_data *);
                   2260: u_int  utf8_split2(u_int, u_char *);
1.1       nicm     2261:
                   2262: /* procname.c */
                   2263: char   *get_proc_name(int, char *);
1.301     nicm     2264: char   *get_proc_cwd(pid_t);
1.1       nicm     2265:
                   2266: /* log.c */
1.339     nicm     2267: void            log_open(int, const char *);
1.1       nicm     2268: void            log_close(void);
                   2269: void printflike1 log_warn(const char *, ...);
                   2270: void printflike1 log_warnx(const char *, ...);
                   2271: void printflike1 log_info(const char *, ...);
                   2272: void printflike1 log_debug(const char *, ...);
                   2273: void printflike1 log_debug2(const char *, ...);
1.85      nicm     2274: __dead void printflike1 log_fatal(const char *, ...);
                   2275: __dead void printflike1 log_fatalx(const char *, ...);
1.1       nicm     2276:
                   2277: /* xmalloc.c */
                   2278: char           *xstrdup(const char *);
                   2279: void           *xcalloc(size_t, size_t);
                   2280: void           *xmalloc(size_t);
                   2281: void           *xrealloc(void *, size_t, size_t);
                   2282: int printflike2         xasprintf(char **, const char *, ...);
                   2283: int             xvasprintf(char **, const char *, va_list);
                   2284: int printflike3         xsnprintf(char *, size_t, const char *, ...);
                   2285: int             xvsnprintf(char *, size_t, const char *, va_list);
                   2286:
                   2287: #endif /* TMUX_H */