Change so that an empty session name always means the current sessions
[tmux-openbsd.git] / tmux.h
blob12f68085d8390ae9e5e74c5f3d0249b033fcacd9
1 /* $OpenBSD$ */
3 /*
4 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
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.
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.
19 #ifndef TMUX_H
20 #define TMUX_H
22 #define PROTOCOL_VERSION 6
24 #include <sys/param.h>
25 #include <sys/time.h>
26 #include <sys/queue.h>
27 #include <sys/tree.h>
28 #include <sys/uio.h>
30 #include <bitstring.h>
31 #include <event.h>
32 #include <getopt.h>
33 #include <imsg.h>
34 #include <limits.h>
35 #include <signal.h>
36 #include <stdarg.h>
37 #include <stdint.h>
38 #include <stdio.h>
39 #include <termios.h>
41 #include "array.h"
43 extern char *__progname;
44 extern char **environ;
46 /* Default configuration files. */
47 #define DEFAULT_CFG ".tmux.conf"
48 #define SYSTEM_CFG "/etc/tmux.conf"
50 /* Default prompt history length. */
51 #define PROMPT_HISTORY 100
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.
57 #define PANE_MINIMUM 2
59 /* Automatic name refresh interval, in milliseconds. */
60 #define NAME_INTERVAL 500
62 /* Maximum data to buffer for output before suspending writing to a tty. */
63 #define BACKOFF_THRESHOLD 16384
66 * Maximum sizes of strings in message data. Don't forget to bump
67 * PROTOCOL_VERSION if any of these change!
69 #define COMMAND_LENGTH 2048 /* packed argv size */
70 #define TERMINAL_LENGTH 128 /* length of TERM environment variable */
71 #define ENVIRON_LENGTH 1024 /* environment variable length */
74 * UTF-8 data size. This must be big enough to hold combined characters as well
75 * as single.
77 #define UTF8_SIZE 9
79 /* Fatal errors. */
80 #define fatal(msg) log_fatal("%s: %s", __func__, msg);
81 #define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
83 /* Definition to shut gcc up about unused arguments. */
84 #define unused __attribute__ ((unused))
86 /* Attribute to make gcc check printf-like arguments. */
87 #define printflike1 __attribute__ ((format (printf, 1, 2)))
88 #define printflike2 __attribute__ ((format (printf, 2, 3)))
89 #define printflike3 __attribute__ ((format (printf, 3, 4)))
90 #define printflike4 __attribute__ ((format (printf, 4, 5)))
91 #define printflike5 __attribute__ ((format (printf, 5, 6)))
93 /* Number of items in array. */
94 #ifndef nitems
95 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
96 #endif
98 /* Bell option values. */
99 #define BELL_NONE 0
100 #define BELL_ANY 1
101 #define BELL_CURRENT 2
103 /* Special key codes. */
104 #define KEYC_NONE 0xfff
105 #define KEYC_BASE 0x1000
107 /* Key modifier bits. */
108 #define KEYC_ESCAPE 0x2000
109 #define KEYC_CTRL 0x4000
110 #define KEYC_SHIFT 0x8000
111 #define KEYC_PREFIX 0x10000
113 /* Mask to obtain key w/o modifiers. */
114 #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_PREFIX)
115 #define KEYC_MASK_KEY (~KEYC_MASK_MOD)
117 /* Other key codes. */
118 enum key_code {
119 /* Mouse key. */
120 KEYC_MOUSE = KEYC_BASE,
122 /* Backspace key. */
123 KEYC_BSPACE,
125 /* Function keys. */
126 KEYC_F1,
127 KEYC_F2,
128 KEYC_F3,
129 KEYC_F4,
130 KEYC_F5,
131 KEYC_F6,
132 KEYC_F7,
133 KEYC_F8,
134 KEYC_F9,
135 KEYC_F10,
136 KEYC_F11,
137 KEYC_F12,
138 KEYC_F13,
139 KEYC_F14,
140 KEYC_F15,
141 KEYC_F16,
142 KEYC_F17,
143 KEYC_F18,
144 KEYC_F19,
145 KEYC_F20,
146 KEYC_IC,
147 KEYC_DC,
148 KEYC_HOME,
149 KEYC_END,
150 KEYC_NPAGE,
151 KEYC_PPAGE,
152 KEYC_BTAB,
154 /* Arrow keys. */
155 KEYC_UP,
156 KEYC_DOWN,
157 KEYC_LEFT,
158 KEYC_RIGHT,
160 /* Numeric keypad. */
161 KEYC_KP_SLASH,
162 KEYC_KP_STAR,
163 KEYC_KP_MINUS,
164 KEYC_KP_SEVEN,
165 KEYC_KP_EIGHT,
166 KEYC_KP_NINE,
167 KEYC_KP_PLUS,
168 KEYC_KP_FOUR,
169 KEYC_KP_FIVE,
170 KEYC_KP_SIX,
171 KEYC_KP_ONE,
172 KEYC_KP_TWO,
173 KEYC_KP_THREE,
174 KEYC_KP_ENTER,
175 KEYC_KP_ZERO,
176 KEYC_KP_PERIOD,
179 /* Termcap codes. */
180 enum tty_code_code {
181 TTYC_AX = 0,
182 TTYC_ACSC, /* acs_chars, ac */
183 TTYC_BEL, /* bell, bl */
184 TTYC_BLINK, /* enter_blink_mode, mb */
185 TTYC_BOLD, /* enter_bold_mode, md */
186 TTYC_CIVIS, /* cursor_invisible, vi */
187 TTYC_CLEAR, /* clear_screen, cl */
188 TTYC_CNORM, /* cursor_normal, ve */
189 TTYC_COLORS, /* max_colors, Co */
190 TTYC_CSR, /* change_scroll_region, cs */
191 TTYC_CUB, /* parm_left_cursor, LE */
192 TTYC_CUB1, /* cursor_left, le */
193 TTYC_CUD, /* parm_down_cursor, DO */
194 TTYC_CUD1, /* cursor_down, do */
195 TTYC_CUF, /* parm_right_cursor, RI */
196 TTYC_CUF1, /* cursor_right, nd */
197 TTYC_CUP, /* cursor_address, cm */
198 TTYC_CUU, /* parm_up_cursor, UP */
199 TTYC_CUU1, /* cursor_up, up */
200 TTYC_DCH, /* parm_dch, DC */
201 TTYC_DCH1, /* delete_character, dc */
202 TTYC_DIM, /* enter_dim_mode, mh */
203 TTYC_DL, /* parm_delete_line, DL */
204 TTYC_DL1, /* delete_line, dl */
205 TTYC_EL, /* clr_eol, ce */
206 TTYC_EL1, /* clr_bol, cb */
207 TTYC_ENACS, /* ena_acs, eA */
208 TTYC_HOME, /* cursor_home, ho */
209 TTYC_HPA, /* column_address, ch */
210 TTYC_ICH, /* parm_ich, IC */
211 TTYC_ICH1, /* insert_character, ic */
212 TTYC_IL, /* parm_insert_line, IL */
213 TTYC_IL1, /* insert_line, il */
214 TTYC_INVIS, /* enter_secure_mode, mk */
215 TTYC_IS1, /* init_1string, i1 */
216 TTYC_IS2, /* init_2string, i2 */
217 TTYC_IS3, /* init_3string, i3 */
218 TTYC_KCBT, /* key_btab, kB */
219 TTYC_KCUB1, /* key_left, kl */
220 TTYC_KCUD1, /* key_down, kd */
221 TTYC_KCUF1, /* key_right, kr */
222 TTYC_KCUU1, /* key_up, ku */
223 TTYC_KDC2,
224 TTYC_KDC3,
225 TTYC_KDC4,
226 TTYC_KDC5,
227 TTYC_KDC6,
228 TTYC_KDC7,
229 TTYC_KDCH1, /* key_dc, kD */
230 TTYC_KDN2,
231 TTYC_KDN3,
232 TTYC_KDN4,
233 TTYC_KDN5,
234 TTYC_KDN6,
235 TTYC_KDN7,
236 TTYC_KEND, /* key_end, ke */
237 TTYC_KEND2,
238 TTYC_KEND3,
239 TTYC_KEND4,
240 TTYC_KEND5,
241 TTYC_KEND6,
242 TTYC_KEND7,
243 TTYC_KF1, /* key_f1, k1 */
244 TTYC_KF10, /* key_f10, k; */
245 TTYC_KF11, /* key_f11, F1 */
246 TTYC_KF12, /* key_f12, F2 */
247 TTYC_KF13, /* key_f13, F3 */
248 TTYC_KF14, /* key_f14, F4 */
249 TTYC_KF15, /* key_f15, F5 */
250 TTYC_KF16, /* key_f16, F6 */
251 TTYC_KF17, /* key_f17, F7 */
252 TTYC_KF18, /* key_f18, F8 */
253 TTYC_KF19, /* key_f19, F9 */
254 TTYC_KF2, /* key_f2, k2 */
255 TTYC_KF20, /* key_f20, F10 */
256 TTYC_KF3, /* key_f3, k3 */
257 TTYC_KF4, /* key_f4, k4 */
258 TTYC_KF5, /* key_f5, k5 */
259 TTYC_KF6, /* key_f6, k6 */
260 TTYC_KF7, /* key_f7, k7 */
261 TTYC_KF8, /* key_f8, k8 */
262 TTYC_KF9, /* key_f9, k9 */
263 TTYC_KHOM2,
264 TTYC_KHOM3,
265 TTYC_KHOM4,
266 TTYC_KHOM5,
267 TTYC_KHOM6,
268 TTYC_KHOM7,
269 TTYC_KHOME, /* key_home, kh */
270 TTYC_KIC2,
271 TTYC_KIC3,
272 TTYC_KIC4,
273 TTYC_KIC5,
274 TTYC_KIC6,
275 TTYC_KIC7,
276 TTYC_KICH1, /* key_ic, kI */
277 TTYC_KLFT2,
278 TTYC_KLFT3,
279 TTYC_KLFT4,
280 TTYC_KLFT5,
281 TTYC_KLFT6,
282 TTYC_KLFT7,
283 TTYC_KMOUS, /* key_mouse, Km */
284 TTYC_KNP, /* key_npage, kN */
285 TTYC_KNXT2,
286 TTYC_KNXT3,
287 TTYC_KNXT4,
288 TTYC_KNXT5,
289 TTYC_KNXT6,
290 TTYC_KNXT7,
291 TTYC_KPP, /* key_ppage, kP */
292 TTYC_KPRV2,
293 TTYC_KPRV3,
294 TTYC_KPRV4,
295 TTYC_KPRV5,
296 TTYC_KPRV6,
297 TTYC_KPRV7,
298 TTYC_KRIT2,
299 TTYC_KRIT3,
300 TTYC_KRIT4,
301 TTYC_KRIT5,
302 TTYC_KRIT6,
303 TTYC_KRIT7,
304 TTYC_KUP2,
305 TTYC_KUP3,
306 TTYC_KUP4,
307 TTYC_KUP5,
308 TTYC_KUP6,
309 TTYC_KUP7,
310 TTYC_OP, /* orig_pair, op */
311 TTYC_REV, /* enter_reverse_mode, mr */
312 TTYC_RI, /* scroll_reverse, sr */
313 TTYC_RMACS, /* exit_alt_charset_mode */
314 TTYC_RMCUP, /* exit_ca_mode, te */
315 TTYC_RMIR, /* exit_insert_mode, ei */
316 TTYC_RMKX, /* keypad_local, ke */
317 TTYC_SETAB, /* set_a_background, AB */
318 TTYC_SETAF, /* set_a_foreground, AF */
319 TTYC_SGR0, /* exit_attribute_mode, me */
320 TTYC_SMACS, /* enter_alt_charset_mode, as */
321 TTYC_SMCUP, /* enter_ca_mode, ti */
322 TTYC_SMIR, /* enter_insert_mode, im */
323 TTYC_SMKX, /* keypad_xmit, ks */
324 TTYC_SMSO, /* enter_standout_mode, so */
325 TTYC_SMUL, /* enter_underline_mode, us */
326 TTYC_VPA, /* row_address, cv */
327 TTYC_XENL, /* eat_newline_glitch, xn */
329 #define NTTYCODE (TTYC_XENL + 1)
331 /* Termcap types. */
332 enum tty_code_type {
333 TTYCODE_NONE = 0,
334 TTYCODE_STRING,
335 TTYCODE_NUMBER,
336 TTYCODE_FLAG,
339 /* Termcap code. */
340 struct tty_code {
341 enum tty_code_type type;
342 union {
343 char *string;
344 int number;
345 int flag;
346 } value;
349 /* Entry in terminal code table. */
350 struct tty_term_code_entry {
351 enum tty_code_code code;
352 enum tty_code_type type;
353 const char *name;
356 /* Message codes. */
357 enum msgtype {
358 MSG_COMMAND,
359 MSG_DETACH,
360 MSG_ERROR,
361 MSG_EXIT,
362 MSG_EXITED,
363 MSG_EXITING,
364 MSG_IDENTIFY,
365 MSG_PRINT,
366 MSG_READY,
367 MSG_RESIZE,
368 MSG_SHUTDOWN,
369 MSG_SUSPEND,
370 MSG_VERSION,
371 MSG_WAKEUP,
372 MSG_ENVIRON,
373 MSG_UNLOCK,
374 MSG_LOCK,
375 MSG_SHELL,
376 MSG_STDERR,
377 MSG_STDOUT,
378 MSG_DETACHKILL
382 * Message data.
384 * Don't forget to bump PROTOCOL_VERSION if any of these change!
386 struct msg_command_data {
387 pid_t pid; /* PID from $TMUX or -1 */
388 int idx; /* index from $TMUX or -1 */
390 int argc;
391 char argv[COMMAND_LENGTH];
394 struct msg_identify_data {
395 char cwd[MAXPATHLEN];
397 char term[TERMINAL_LENGTH];
399 #define IDENTIFY_UTF8 0x1
400 #define IDENTIFY_256COLOURS 0x2
401 #define IDENTIFY_88COLOURS 0x4
402 int flags;
405 struct msg_lock_data {
406 char cmd[COMMAND_LENGTH];
409 struct msg_environ_data {
410 char var[ENVIRON_LENGTH];
413 struct msg_shell_data {
414 char shell[MAXPATHLEN];
417 struct msg_exit_data {
418 int retcode;
421 /* Mode key commands. */
422 enum mode_key_cmd {
423 MODEKEY_NONE,
424 MODEKEY_OTHER,
426 /* Editing keys. */
427 MODEKEYEDIT_BACKSPACE,
428 MODEKEYEDIT_CANCEL,
429 MODEKEYEDIT_COMPLETE,
430 MODEKEYEDIT_CURSORLEFT,
431 MODEKEYEDIT_CURSORRIGHT,
432 MODEKEYEDIT_DELETE,
433 MODEKEYEDIT_DELETELINE,
434 MODEKEYEDIT_DELETETOENDOFLINE,
435 MODEKEYEDIT_ENDOFLINE,
436 MODEKEYEDIT_ENTER,
437 MODEKEYEDIT_HISTORYDOWN,
438 MODEKEYEDIT_HISTORYUP,
439 MODEKEYEDIT_PASTE,
440 MODEKEYEDIT_STARTOFLINE,
441 MODEKEYEDIT_SWITCHMODE,
442 MODEKEYEDIT_SWITCHMODEAPPEND,
443 MODEKEYEDIT_TRANSPOSECHARS,
445 /* Menu (choice) keys. */
446 MODEKEYCHOICE_CANCEL,
447 MODEKEYCHOICE_CHOOSE,
448 MODEKEYCHOICE_DOWN,
449 MODEKEYCHOICE_PAGEDOWN,
450 MODEKEYCHOICE_PAGEUP,
451 MODEKEYCHOICE_SCROLLDOWN,
452 MODEKEYCHOICE_SCROLLUP,
453 MODEKEYCHOICE_UP,
455 /* Copy keys. */
456 MODEKEYCOPY_BACKTOINDENTATION,
457 MODEKEYCOPY_BOTTOMLINE,
458 MODEKEYCOPY_CANCEL,
459 MODEKEYCOPY_CLEARSELECTION,
460 MODEKEYCOPY_COPYSELECTION,
461 MODEKEYCOPY_DOWN,
462 MODEKEYCOPY_ENDOFLINE,
463 MODEKEYCOPY_GOTOLINE,
464 MODEKEYCOPY_HALFPAGEDOWN,
465 MODEKEYCOPY_HALFPAGEUP,
466 MODEKEYCOPY_HISTORYBOTTOM,
467 MODEKEYCOPY_HISTORYTOP,
468 MODEKEYCOPY_JUMP,
469 MODEKEYCOPY_JUMPAGAIN,
470 MODEKEYCOPY_JUMPREVERSE,
471 MODEKEYCOPY_JUMPBACK,
472 MODEKEYCOPY_LEFT,
473 MODEKEYCOPY_MIDDLELINE,
474 MODEKEYCOPY_NEXTPAGE,
475 MODEKEYCOPY_NEXTSPACE,
476 MODEKEYCOPY_NEXTSPACEEND,
477 MODEKEYCOPY_NEXTWORD,
478 MODEKEYCOPY_NEXTWORDEND,
479 MODEKEYCOPY_PREVIOUSPAGE,
480 MODEKEYCOPY_PREVIOUSSPACE,
481 MODEKEYCOPY_PREVIOUSWORD,
482 MODEKEYCOPY_RECTANGLETOGGLE,
483 MODEKEYCOPY_RIGHT,
484 MODEKEYCOPY_SCROLLDOWN,
485 MODEKEYCOPY_SCROLLUP,
486 MODEKEYCOPY_SEARCHAGAIN,
487 MODEKEYCOPY_SEARCHDOWN,
488 MODEKEYCOPY_SEARCHREVERSE,
489 MODEKEYCOPY_SEARCHUP,
490 MODEKEYCOPY_STARTNUMBERPREFIX,
491 MODEKEYCOPY_STARTOFLINE,
492 MODEKEYCOPY_STARTSELECTION,
493 MODEKEYCOPY_TOPLINE,
494 MODEKEYCOPY_UP,
497 /* Entry in the default mode key tables. */
498 struct mode_key_entry {
499 int key;
502 * Editing mode for vi: 0 is edit mode, keys not in the table are
503 * returned as MODEKEY_OTHER; 1 is command mode, keys not in the table
504 * are returned as MODEKEY_NONE. This is also matched on, allowing some
505 * keys to be bound in edit mode.
507 int mode;
508 enum mode_key_cmd cmd;
511 /* Data required while mode keys are in use. */
512 struct mode_key_data {
513 struct mode_key_tree *tree;
514 int mode;
516 #define MODEKEY_EMACS 0
517 #define MODEKEY_VI 1
519 /* Binding between a key and a command. */
520 struct mode_key_binding {
521 int key;
523 int mode;
524 enum mode_key_cmd cmd;
526 SPLAY_ENTRY(mode_key_binding) entry;
528 SPLAY_HEAD(mode_key_tree, mode_key_binding);
530 /* Command to string mapping. */
531 struct mode_key_cmdstr {
532 enum mode_key_cmd cmd;
533 const char *name;
536 /* Named mode key table description. */
537 struct mode_key_table {
538 const char *name;
539 const struct mode_key_cmdstr *cmdstr;
540 struct mode_key_tree *tree;
541 const struct mode_key_entry *table; /* default entries */
544 /* Modes. */
545 #define MODE_CURSOR 0x1
546 #define MODE_INSERT 0x2
547 #define MODE_KCURSOR 0x4
548 #define MODE_KKEYPAD 0x8 /* set = application, clear = number */
549 #define MODE_WRAP 0x10 /* whether lines wrap */
550 #define MODE_MOUSE_STANDARD 0x20
551 #define MODE_MOUSE_BUTTON 0x40
552 #define MODE_MOUSE_ANY 0x80
553 #define MODE_MOUSE_UTF8 0x100
555 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY)
558 * A single UTF-8 character.
560 * The data member in this must be UTF8_SIZE to allow screen_write_copy to
561 * reinject stored UTF-8 data back into screen_write_cell after combining (ugh
562 * XXX XXX).
564 struct utf8_data {
565 u_char data[UTF8_SIZE];
567 size_t have;
568 size_t size;
570 u_int width;
573 /* Grid output. */
574 #if defined(DEBUG) && \
575 ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
576 (defined(__GNUC__) && __GNUC__ >= 3))
577 #define GRID_DEBUG(gd, fmt, ...) log_debug2("%s: (sx=%u, sy=%u, hsize=%u) " \
578 fmt, __func__, (gd)->sx, (gd)->sy, (gd)->hsize, ## __VA_ARGS__)
579 #else
580 #define GRID_DEBUG(...)
581 #endif
583 /* Grid attributes. */
584 #define GRID_ATTR_BRIGHT 0x1
585 #define GRID_ATTR_DIM 0x2
586 #define GRID_ATTR_UNDERSCORE 0x4
587 #define GRID_ATTR_BLINK 0x8
588 #define GRID_ATTR_REVERSE 0x10
589 #define GRID_ATTR_HIDDEN 0x20
590 #define GRID_ATTR_ITALICS 0x40
591 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
593 /* Grid flags. */
594 #define GRID_FLAG_FG256 0x1
595 #define GRID_FLAG_BG256 0x2
596 #define GRID_FLAG_PADDING 0x4
597 #define GRID_FLAG_UTF8 0x8
599 /* Grid line flags. */
600 #define GRID_LINE_WRAPPED 0x1
602 /* Grid cell data. */
603 struct grid_cell {
604 u_char attr;
605 u_char flags;
606 u_char fg;
607 u_char bg;
608 u_char data;
609 } __packed;
611 /* Grid cell UTF-8 data. Used instead of data in grid_cell for UTF-8 cells. */
612 struct grid_utf8 {
613 u_char width;
614 u_char data[UTF8_SIZE];
615 } __packed;
617 /* Grid line. */
618 struct grid_line {
619 u_int cellsize;
620 struct grid_cell *celldata;
622 u_int utf8size;
623 struct grid_utf8 *utf8data;
625 int flags;
626 } __packed;
628 /* Entire grid of cells. */
629 struct grid {
630 int flags;
631 #define GRID_HISTORY 0x1 /* scroll lines into history */
633 u_int sx;
634 u_int sy;
636 u_int hsize;
637 u_int hlimit;
639 struct grid_line *linedata;
642 /* Option data structures. */
643 struct options_entry {
644 char *name;
646 enum {
647 OPTIONS_STRING,
648 OPTIONS_NUMBER,
649 OPTIONS_DATA,
650 } type;
652 char *str;
653 long long num;
654 void *data;
656 void (*freefn)(void *);
658 SPLAY_ENTRY(options_entry) entry;
661 struct options {
662 SPLAY_HEAD(options_tree, options_entry) tree;
663 struct options *parent;
666 /* Key list for prefix option. */
667 ARRAY_DECL(keylist, int);
669 /* Scheduled job. */
670 struct job {
671 char *cmd;
672 pid_t pid;
673 int status;
675 int fd;
676 struct bufferevent *event;
678 void (*callbackfn)(struct job *);
679 void (*freefn)(void *);
680 void *data;
682 LIST_ENTRY(job) lentry;
684 LIST_HEAD(joblist, job);
686 /* Screen selection. */
687 struct screen_sel {
688 int flag;
689 int rectflag;
691 u_int sx;
692 u_int sy;
694 u_int ex;
695 u_int ey;
697 struct grid_cell cell;
700 /* Virtual screen. */
701 struct screen {
702 char *title;
704 struct grid *grid; /* grid data */
706 u_int cx; /* cursor x */
707 u_int cy; /* cursor y */
709 u_int rupper; /* scroll region top */
710 u_int rlower; /* scroll region bottom */
712 int mode;
714 bitstr_t *tabs;
716 struct screen_sel sel;
719 /* Screen write context. */
720 struct screen_write_ctx {
721 struct window_pane *wp;
722 struct screen *s;
725 /* Screen size. */
726 #define screen_size_x(s) ((s)->grid->sx)
727 #define screen_size_y(s) ((s)->grid->sy)
728 #define screen_hsize(s) ((s)->grid->hsize)
729 #define screen_hlimit(s) ((s)->grid->hlimit)
731 /* Input parser context. */
732 struct input_ctx {
733 struct window_pane *wp;
734 struct screen_write_ctx ctx;
736 struct grid_cell cell;
738 struct grid_cell old_cell;
739 u_int old_cx;
740 u_int old_cy;
742 u_char interm_buf[4];
743 size_t interm_len;
745 u_char param_buf[64];
746 size_t param_len;
748 u_char input_buf[256];
749 size_t input_len;
751 int param_list[24]; /* -1 not present */
752 u_int param_list_len;
754 struct utf8_data utf8data;
756 int ch;
757 int flags;
758 #define INPUT_DISCARD 0x1
760 const struct input_state *state;
764 * Window mode. Windows can be in several modes and this is used to call the
765 * right function to handle input and output.
767 struct session;
768 struct window;
769 struct mouse_event;
770 struct window_mode {
771 struct screen *(*init)(struct window_pane *);
772 void (*free)(struct window_pane *);
773 void (*resize)(struct window_pane *, u_int, u_int);
774 void (*key)(struct window_pane *, struct session *, int);
775 void (*mouse)(struct window_pane *,
776 struct session *, struct mouse_event *);
777 void (*timer)(struct window_pane *);
780 /* Child window structure. */
781 struct window_pane {
782 u_int id;
784 struct window *window;
785 struct layout_cell *layout_cell;
787 u_int sx;
788 u_int sy;
790 u_int xoff;
791 u_int yoff;
793 int flags;
794 #define PANE_REDRAW 0x1
795 #define PANE_FREEZE 0x2
797 char *cmd;
798 char *shell;
799 char *cwd;
801 pid_t pid;
802 char tty[TTY_NAME_MAX];
804 int fd;
805 struct bufferevent *event;
807 struct input_ctx ictx;
809 int pipe_fd;
810 struct bufferevent *pipe_event;
811 size_t pipe_off;
813 struct screen *screen;
814 struct screen base;
816 /* Saved in alternative screen mode. */
817 u_int saved_cx;
818 u_int saved_cy;
819 struct grid *saved_grid;
820 struct grid_cell saved_cell;
822 const struct window_mode *mode;
823 void *modedata;
825 TAILQ_ENTRY(window_pane) entry;
826 RB_ENTRY(window_pane) tree_entry;
828 TAILQ_HEAD(window_panes, window_pane);
829 RB_HEAD(window_pane_tree, window_pane);
831 /* Window structure. */
832 struct window {
833 char *name;
834 struct event name_timer;
835 struct timeval silence_timer;
837 struct window_pane *active;
838 struct window_pane *last;
839 struct window_panes panes;
841 int lastlayout;
842 struct layout_cell *layout_root;
844 u_int sx;
845 u_int sy;
847 int flags;
848 #define WINDOW_BELL 0x1
849 #define WINDOW_ACTIVITY 0x2
850 #define WINDOW_REDRAW 0x4
851 #define WINDOW_SILENCE 0x8
853 struct options options;
855 u_int references;
857 ARRAY_DECL(windows, struct window *);
859 /* Entry on local window list. */
860 struct winlink {
861 int idx;
862 struct window *window;
864 size_t status_width;
865 struct grid_cell status_cell;
866 char *status_text;
868 int flags;
869 #define WINLINK_BELL 0x1
870 #define WINLINK_ACTIVITY 0x2
871 #define WINLINK_CONTENT 0x4
872 #define WINLINK_SILENCE 0x8
873 #define WINLINK_ALERTFLAGS \
874 (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
876 RB_ENTRY(winlink) entry;
877 TAILQ_ENTRY(winlink) sentry;
879 RB_HEAD(winlinks, winlink);
880 TAILQ_HEAD(winlink_stack, winlink);
882 /* Layout direction. */
883 enum layout_type {
884 LAYOUT_LEFTRIGHT,
885 LAYOUT_TOPBOTTOM,
886 LAYOUT_WINDOWPANE
889 /* Layout cells queue. */
890 TAILQ_HEAD(layout_cells, layout_cell);
892 /* Layout cell. */
893 struct layout_cell {
894 enum layout_type type;
896 struct layout_cell *parent;
898 u_int sx;
899 u_int sy;
901 u_int xoff;
902 u_int yoff;
904 struct window_pane *wp;
905 struct layout_cells cells;
907 TAILQ_ENTRY(layout_cell) entry;
910 /* Paste buffer. */
911 struct paste_buffer {
912 char *data;
913 size_t size;
915 ARRAY_DECL(paste_stack, struct paste_buffer *);
917 /* Environment variable. */
918 struct environ_entry {
919 char *name;
920 char *value;
922 RB_ENTRY(environ_entry) entry;
924 RB_HEAD(environ, environ_entry);
926 /* Client session. */
927 struct session_group {
928 TAILQ_HEAD(, session) sessions;
930 TAILQ_ENTRY(session_group) entry;
932 TAILQ_HEAD(session_groups, session_group);
934 struct session {
935 u_int idx;
937 char *name;
938 char *cwd;
940 struct timeval creation_time;
941 struct timeval activity_time;
943 u_int sx;
944 u_int sy;
946 struct winlink *curw;
947 struct winlink_stack lastw;
948 struct winlinks windows;
950 struct options options;
952 #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
953 int flags;
955 struct termios *tio;
957 struct environ environ;
959 int references;
961 TAILQ_ENTRY(session) gentry;
962 RB_ENTRY(session) entry;
964 RB_HEAD(sessions, session);
965 ARRAY_DECL(sessionslist, struct session *);
967 /* TTY information. */
968 struct tty_key {
969 char ch;
970 int key;
972 struct tty_key *left;
973 struct tty_key *right;
975 struct tty_key *next;
978 struct tty_term {
979 char *name;
980 u_int references;
982 char acs[UCHAR_MAX + 1][2];
984 struct tty_code codes[NTTYCODE];
986 #define TERM_256COLOURS 0x1
987 #define TERM_88COLOURS 0x2
988 #define TERM_EARLYWRAP 0x4
989 int flags;
991 LIST_ENTRY(tty_term) entry;
993 LIST_HEAD(tty_terms, tty_term);
995 struct tty {
996 char *path;
998 u_int sx;
999 u_int sy;
1001 u_int cx;
1002 u_int cy;
1004 int mode;
1006 u_int rlower;
1007 u_int rupper;
1009 char *termname;
1010 struct tty_term *term;
1012 int fd;
1013 struct bufferevent *event;
1015 int log_fd;
1017 struct termios tio;
1019 struct grid_cell cell;
1021 #define TTY_NOCURSOR 0x1
1022 #define TTY_FREEZE 0x2
1023 #define TTY_ESCAPE 0x4
1024 #define TTY_UTF8 0x8
1025 #define TTY_STARTED 0x10
1026 #define TTY_OPENED 0x20
1027 #define TTY_BACKOFF 0x40
1028 int flags;
1030 int term_flags;
1032 void (*key_callback)(int, struct mouse_event *, void *);
1033 void *key_data;
1034 struct event key_timer;
1035 struct tty_key *key_tree;
1038 /* TTY command context and function pointer. */
1039 struct tty_ctx {
1040 struct window_pane *wp;
1042 const struct grid_cell *cell;
1043 const struct grid_utf8 *utf8;
1045 u_int num;
1046 void *ptr;
1049 * Cursor and region position before the screen was updated - this is
1050 * where the command should be applied; the values in the screen have
1051 * already been updated.
1053 u_int ocx;
1054 u_int ocy;
1056 u_int orupper;
1057 u_int orlower;
1059 /* Saved last cell on line. */
1060 struct grid_cell last_cell;
1061 struct grid_utf8 last_utf8;
1062 u_int last_width;
1066 * xterm mouse mode is fairly silly. Buttons are in the bottom two
1067 * bits: 0 button 1; 1 button 2; 2 button 3; 3 buttons released.
1069 * Bit 3 is shift; bit 4 is meta; bit 5 control.
1071 * Bit 6 is added for mouse buttons 4 and 5.
1073 /* Mouse input. */
1074 struct mouse_event {
1075 u_int b;
1076 #define MOUSE_1 0
1077 #define MOUSE_2 1
1078 #define MOUSE_3 2
1079 #define MOUSE_UP 3
1080 #define MOUSE_BUTTON 3
1081 #define MOUSE_45 64
1082 u_int x;
1083 u_int y;
1086 /* Saved message entry. */
1087 struct message_entry {
1088 char *msg;
1089 time_t msg_time;
1092 /* Status output data from a job. */
1093 struct status_out {
1094 char *cmd;
1095 char *out;
1097 RB_ENTRY(status_out) entry;
1099 RB_HEAD(status_out_tree, status_out);
1101 /* Client connection. */
1102 struct client {
1103 struct imsgbuf ibuf;
1104 struct event event;
1105 int retcode;
1107 struct timeval creation_time;
1108 struct timeval activity_time;
1110 struct environ environ;
1112 char *title;
1113 char *cwd;
1115 struct tty tty;
1117 int stdin_fd;
1118 void *stdin_data;
1119 void (*stdin_callback)(struct client *, void *);
1120 struct bufferevent *stdin_event;
1122 int stdout_fd;
1123 struct bufferevent *stdout_event;
1125 int stderr_fd;
1126 struct bufferevent *stderr_event;
1128 struct event repeat_timer;
1130 struct status_out_tree status_old;
1131 struct status_out_tree status_new;
1132 struct timeval status_timer;
1133 struct screen status;
1135 #define CLIENT_TERMINAL 0x1
1136 #define CLIENT_PREFIX 0x2
1137 #define CLIENT_EXIT 0x4
1138 #define CLIENT_REDRAW 0x8
1139 #define CLIENT_STATUS 0x10
1140 #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
1141 #define CLIENT_SUSPENDED 0x40
1142 #define CLIENT_BAD 0x80
1143 #define CLIENT_IDENTIFY 0x100
1144 #define CLIENT_DEAD 0x200
1145 #define CLIENT_BORDERS 0x400
1146 #define CLIENT_READONLY 0x800
1147 #define CLIENT_BACKOFF 0x1000
1148 #define CLIENT_REDRAWWINDOW 0x2000
1149 int flags;
1151 struct event identify_timer;
1153 char *message_string;
1154 struct event message_timer;
1155 ARRAY_DECL(, struct message_entry) message_log;
1157 char *prompt_string;
1158 char *prompt_buffer;
1159 size_t prompt_index;
1160 int (*prompt_callbackfn)(void *, const char *);
1161 void (*prompt_freefn)(void *);
1162 void *prompt_data;
1163 u_int prompt_hindex;
1165 #define PROMPT_SINGLE 0x1
1166 int prompt_flags;
1168 struct mode_key_data prompt_mdata;
1170 struct session *session;
1171 struct session *last_session;
1173 int references;
1175 ARRAY_DECL(clients, struct client *);
1177 /* Parsed arguments. */
1178 struct args {
1179 bitstr_t *flags;
1180 char *values[SCHAR_MAX]; /* XXX This is awfully big. */
1182 int argc;
1183 char **argv;
1186 /* Key/command line command. */
1187 struct cmd_ctx {
1189 * curclient is the client where this command was executed if inside
1190 * tmux. This is NULL if the command came from the command-line.
1192 * cmdclient is the client which sent the MSG_COMMAND to the server, if
1193 * any. This is NULL unless the command came from the command-line.
1195 * cmdclient and curclient may both be NULL if the command is in the
1196 * configuration file.
1198 struct client *curclient;
1199 struct client *cmdclient;
1201 struct msg_command_data *msgdata;
1203 /* gcc2 doesn't understand attributes on function pointers... */
1204 #if defined(__GNUC__) && __GNUC__ >= 3
1205 void printflike2 (*print)(struct cmd_ctx *, const char *, ...);
1206 void printflike2 (*info)(struct cmd_ctx *, const char *, ...);
1207 void printflike2 (*error)(struct cmd_ctx *, const char *, ...);
1208 #else
1209 void (*print)(struct cmd_ctx *, const char *, ...);
1210 void (*info)(struct cmd_ctx *, const char *, ...);
1211 void (*error)(struct cmd_ctx *, const char *, ...);
1212 #endif
1215 struct cmd {
1216 const struct cmd_entry *entry;
1217 struct args *args;
1219 TAILQ_ENTRY(cmd) qentry;
1221 struct cmd_list {
1222 int references;
1223 TAILQ_HEAD(, cmd) list;
1226 struct cmd_entry {
1227 const char *name;
1228 const char *alias;
1230 const char *args_template;
1231 int args_lower;
1232 int args_upper;
1234 const char *usage;
1236 #define CMD_STARTSERVER 0x1
1237 #define CMD_CANTNEST 0x2
1238 #define CMD_SENDENVIRON 0x4
1239 #define CMD_READONLY 0x8
1240 int flags;
1242 void (*key_binding)(struct cmd *, int);
1243 int (*check)(struct args *);
1244 int (*exec)(struct cmd *, struct cmd_ctx *);
1247 /* Key binding. */
1248 struct key_binding {
1249 int key;
1250 struct cmd_list *cmdlist;
1251 int can_repeat;
1253 SPLAY_ENTRY(key_binding) entry;
1255 SPLAY_HEAD(key_bindings, key_binding);
1258 * Option table entries. The option table is the user-visible part of the
1259 * option, as opposed to the internal options (struct option) which are just
1260 * number or string.
1262 enum options_table_type {
1263 OPTIONS_TABLE_STRING,
1264 OPTIONS_TABLE_NUMBER,
1265 OPTIONS_TABLE_KEYS,
1266 OPTIONS_TABLE_COLOUR,
1267 OPTIONS_TABLE_ATTRIBUTES,
1268 OPTIONS_TABLE_FLAG,
1269 OPTIONS_TABLE_CHOICE
1272 struct options_table_entry {
1273 const char *name;
1274 enum options_table_type type;
1276 u_int minimum;
1277 u_int maximum;
1278 const char **choices;
1280 const char *default_str;
1281 long long default_num;
1284 /* List of configuration causes. */
1285 ARRAY_DECL(causelist, char *);
1287 /* Common command usages. */
1288 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1289 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1290 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1291 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1292 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1293 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1294 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1295 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1296 #define CMD_BUFFER_USAGE "[-b buffer-index]"
1298 /* tmux.c */
1299 extern struct options global_options;
1300 extern struct options global_s_options;
1301 extern struct options global_w_options;
1302 extern struct environ global_environ;
1303 extern struct event_base *ev_base;
1304 extern char *cfg_file;
1305 extern char *shell_cmd;
1306 extern int debug_level;
1307 extern time_t start_time;
1308 extern char socket_path[MAXPATHLEN];
1309 extern int login_shell;
1310 extern char *environ_path;
1311 extern pid_t environ_pid;
1312 extern int environ_idx;
1313 void logfile(const char *);
1314 const char *getshell(void);
1315 int checkshell(const char *);
1316 int areshell(const char *);
1317 void setblocking(int, int);
1318 __dead void shell_exec(const char *, const char *);
1320 /* cfg.c */
1321 extern int cfg_finished;
1322 extern struct causelist cfg_causes;
1323 void printflike2 cfg_add_cause(struct causelist *, const char *, ...);
1324 int load_cfg(const char *, struct cmd_ctx *, struct causelist *);
1326 /* mode-key.c */
1327 extern const struct mode_key_table mode_key_tables[];
1328 extern struct mode_key_tree mode_key_tree_vi_edit;
1329 extern struct mode_key_tree mode_key_tree_vi_choice;
1330 extern struct mode_key_tree mode_key_tree_vi_copy;
1331 extern struct mode_key_tree mode_key_tree_emacs_edit;
1332 extern struct mode_key_tree mode_key_tree_emacs_choice;
1333 extern struct mode_key_tree mode_key_tree_emacs_copy;
1334 int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
1335 SPLAY_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
1336 const char *mode_key_tostring(const struct mode_key_cmdstr *,
1337 enum mode_key_cmd);
1338 enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
1339 const char *);
1340 const struct mode_key_table *mode_key_findtable(const char *);
1341 void mode_key_init_trees(void);
1342 void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
1343 enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
1345 /* options.c */
1346 int options_cmp(struct options_entry *, struct options_entry *);
1347 SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
1348 void options_init(struct options *, struct options *);
1349 void options_free(struct options *);
1350 struct options_entry *options_find1(struct options *, const char *);
1351 struct options_entry *options_find(struct options *, const char *);
1352 void options_remove(struct options *, const char *);
1353 struct options_entry *printflike3 options_set_string(
1354 struct options *, const char *, const char *, ...);
1355 char *options_get_string(struct options *, const char *);
1356 struct options_entry *options_set_number(
1357 struct options *, const char *, long long);
1358 long long options_get_number(struct options *, const char *);
1359 struct options_entry *options_set_data(
1360 struct options *, const char *, void *, void (*)(void *));
1361 void *options_get_data(struct options *, const char *);
1363 /* options-table.c */
1364 extern const struct options_table_entry server_options_table[];
1365 extern const struct options_table_entry session_options_table[];
1366 extern const struct options_table_entry window_options_table[];
1367 void options_table_populate_tree(
1368 const struct options_table_entry *, struct options *);
1369 const char *options_table_print_entry(
1370 const struct options_table_entry *, struct options_entry *);
1372 /* job.c */
1373 extern struct joblist all_jobs;
1374 struct job *job_run(
1375 const char *, void (*)(struct job *), void (*)(void *), void *);
1376 void job_free(struct job *);
1377 void job_died(struct job *, int);
1379 /* environ.c */
1380 int environ_cmp(struct environ_entry *, struct environ_entry *);
1381 RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp);
1382 void environ_init(struct environ *);
1383 void environ_free(struct environ *);
1384 void environ_copy(struct environ *, struct environ *);
1385 struct environ_entry *environ_find(struct environ *, const char *);
1386 void environ_set(struct environ *, const char *, const char *);
1387 void environ_put(struct environ *, const char *);
1388 void environ_unset(struct environ *, const char *);
1389 void environ_update(const char *, struct environ *, struct environ *);
1390 void environ_push(struct environ *);
1392 /* tty.c */
1393 void tty_raw(struct tty *, const char *);
1394 void tty_attributes(struct tty *, const struct grid_cell *);
1395 void tty_reset(struct tty *);
1396 void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1397 void tty_region(struct tty *, u_int, u_int);
1398 void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1399 void tty_cursor(struct tty *, u_int, u_int);
1400 void tty_putcode(struct tty *, enum tty_code_code);
1401 void tty_putcode1(struct tty *, enum tty_code_code, int);
1402 void tty_putcode2(struct tty *, enum tty_code_code, int, int);
1403 void tty_puts(struct tty *, const char *);
1404 void tty_putc(struct tty *, u_char);
1405 void tty_pututf8(struct tty *, const struct grid_utf8 *);
1406 void tty_init(struct tty *, int, char *);
1407 int tty_resize(struct tty *);
1408 void tty_start_tty(struct tty *);
1409 void tty_stop_tty(struct tty *);
1410 void tty_set_title(struct tty *, const char *);
1411 void tty_update_mode(struct tty *, int);
1412 void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
1413 int tty_open(struct tty *, const char *, char **);
1414 void tty_close(struct tty *);
1415 void tty_free(struct tty *);
1416 void tty_write(void (*)(
1417 struct tty *, const struct tty_ctx *), const struct tty_ctx *);
1418 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
1419 void tty_cmd_cell(struct tty *, const struct tty_ctx *);
1420 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
1421 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
1422 void tty_cmd_clearline(struct tty *, const struct tty_ctx *);
1423 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
1424 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
1425 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
1426 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
1427 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
1428 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
1429 void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
1430 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
1431 void tty_cmd_utf8character(struct tty *, const struct tty_ctx *);
1432 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
1433 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
1435 /* tty-term.c */
1436 extern struct tty_terms tty_terms;
1437 extern const struct tty_term_code_entry tty_term_codes[NTTYCODE];
1438 struct tty_term *tty_term_find(char *, int, const char *, char **);
1439 void tty_term_free(struct tty_term *);
1440 int tty_term_has(struct tty_term *, enum tty_code_code);
1441 const char *tty_term_string(struct tty_term *, enum tty_code_code);
1442 const char *tty_term_string1(struct tty_term *, enum tty_code_code, int);
1443 const char *tty_term_string2(
1444 struct tty_term *, enum tty_code_code, int, int);
1445 int tty_term_number(struct tty_term *, enum tty_code_code);
1446 int tty_term_flag(struct tty_term *, enum tty_code_code);
1448 /* tty-acs.c */
1449 const char *tty_acs_get(struct tty *, u_char);
1451 /* tty-keys.c */
1452 void tty_keys_init(struct tty *);
1453 void tty_keys_free(struct tty *);
1454 int tty_keys_next(struct tty *);
1456 /* paste.c */
1457 struct paste_buffer *paste_walk_stack(struct paste_stack *, u_int *);
1458 struct paste_buffer *paste_get_top(struct paste_stack *);
1459 struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
1460 int paste_free_top(struct paste_stack *);
1461 int paste_free_index(struct paste_stack *, u_int);
1462 void paste_add(struct paste_stack *, char *, size_t, u_int);
1463 int paste_replace(struct paste_stack *, u_int, char *, size_t);
1464 char *paste_print(struct paste_buffer *, size_t);
1466 /* clock.c */
1467 extern const char clock_table[14][5][5];
1468 void clock_draw(struct screen_write_ctx *, int, int);
1470 /* arguments.c */
1471 struct args *args_create(int, ...);
1472 struct args *args_parse(const char *, int, char **);
1473 void args_free(struct args *);
1474 size_t args_print(struct args *, char *, size_t);
1475 int args_has(struct args *, u_char);
1476 void args_set(struct args *, u_char, const char *);
1477 const char *args_get(struct args *, u_char);
1478 long long args_strtonum(
1479 struct args *, u_char, long long, long long, char **);
1481 /* cmd.c */
1482 int cmd_pack_argv(int, char **, char *, size_t);
1483 int cmd_unpack_argv(char *, size_t, int, char ***);
1484 char **cmd_copy_argv(int, char *const *);
1485 void cmd_free_argv(int, char **);
1486 struct cmd *cmd_parse(int, char **, char **);
1487 int cmd_exec(struct cmd *, struct cmd_ctx *);
1488 void cmd_free(struct cmd *);
1489 size_t cmd_print(struct cmd *, char *, size_t);
1490 struct session *cmd_current_session(struct cmd_ctx *, int);
1491 struct client *cmd_current_client(struct cmd_ctx *);
1492 struct client *cmd_find_client(struct cmd_ctx *, const char *);
1493 struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
1494 struct winlink *cmd_find_window(
1495 struct cmd_ctx *, const char *, struct session **);
1496 int cmd_find_index(
1497 struct cmd_ctx *, const char *, struct session **);
1498 struct winlink *cmd_find_pane(struct cmd_ctx *,
1499 const char *, struct session **, struct window_pane **);
1500 char *cmd_template_replace(char *, const char *, int);
1501 extern const struct cmd_entry *cmd_table[];
1502 extern const struct cmd_entry cmd_attach_session_entry;
1503 extern const struct cmd_entry cmd_bind_key_entry;
1504 extern const struct cmd_entry cmd_break_pane_entry;
1505 extern const struct cmd_entry cmd_capture_pane_entry;
1506 extern const struct cmd_entry cmd_choose_buffer_entry;
1507 extern const struct cmd_entry cmd_choose_client_entry;
1508 extern const struct cmd_entry cmd_choose_session_entry;
1509 extern const struct cmd_entry cmd_choose_window_entry;
1510 extern const struct cmd_entry cmd_clear_history_entry;
1511 extern const struct cmd_entry cmd_clock_mode_entry;
1512 extern const struct cmd_entry cmd_command_prompt_entry;
1513 extern const struct cmd_entry cmd_confirm_before_entry;
1514 extern const struct cmd_entry cmd_copy_mode_entry;
1515 extern const struct cmd_entry cmd_delete_buffer_entry;
1516 extern const struct cmd_entry cmd_detach_client_entry;
1517 extern const struct cmd_entry cmd_display_message_entry;
1518 extern const struct cmd_entry cmd_display_panes_entry;
1519 extern const struct cmd_entry cmd_down_pane_entry;
1520 extern const struct cmd_entry cmd_find_window_entry;
1521 extern const struct cmd_entry cmd_has_session_entry;
1522 extern const struct cmd_entry cmd_if_shell_entry;
1523 extern const struct cmd_entry cmd_join_pane_entry;
1524 extern const struct cmd_entry cmd_kill_pane_entry;
1525 extern const struct cmd_entry cmd_kill_server_entry;
1526 extern const struct cmd_entry cmd_kill_session_entry;
1527 extern const struct cmd_entry cmd_kill_window_entry;
1528 extern const struct cmd_entry cmd_last_pane_entry;
1529 extern const struct cmd_entry cmd_last_window_entry;
1530 extern const struct cmd_entry cmd_link_window_entry;
1531 extern const struct cmd_entry cmd_list_buffers_entry;
1532 extern const struct cmd_entry cmd_list_clients_entry;
1533 extern const struct cmd_entry cmd_list_commands_entry;
1534 extern const struct cmd_entry cmd_list_keys_entry;
1535 extern const struct cmd_entry cmd_list_panes_entry;
1536 extern const struct cmd_entry cmd_list_sessions_entry;
1537 extern const struct cmd_entry cmd_list_windows_entry;
1538 extern const struct cmd_entry cmd_load_buffer_entry;
1539 extern const struct cmd_entry cmd_lock_client_entry;
1540 extern const struct cmd_entry cmd_lock_server_entry;
1541 extern const struct cmd_entry cmd_lock_session_entry;
1542 extern const struct cmd_entry cmd_move_window_entry;
1543 extern const struct cmd_entry cmd_new_session_entry;
1544 extern const struct cmd_entry cmd_new_window_entry;
1545 extern const struct cmd_entry cmd_next_layout_entry;
1546 extern const struct cmd_entry cmd_next_window_entry;
1547 extern const struct cmd_entry cmd_paste_buffer_entry;
1548 extern const struct cmd_entry cmd_pipe_pane_entry;
1549 extern const struct cmd_entry cmd_previous_layout_entry;
1550 extern const struct cmd_entry cmd_previous_window_entry;
1551 extern const struct cmd_entry cmd_refresh_client_entry;
1552 extern const struct cmd_entry cmd_rename_session_entry;
1553 extern const struct cmd_entry cmd_rename_window_entry;
1554 extern const struct cmd_entry cmd_resize_pane_entry;
1555 extern const struct cmd_entry cmd_respawn_window_entry;
1556 extern const struct cmd_entry cmd_rotate_window_entry;
1557 extern const struct cmd_entry cmd_run_shell_entry;
1558 extern const struct cmd_entry cmd_save_buffer_entry;
1559 extern const struct cmd_entry cmd_select_layout_entry;
1560 extern const struct cmd_entry cmd_select_pane_entry;
1561 extern const struct cmd_entry cmd_select_window_entry;
1562 extern const struct cmd_entry cmd_send_keys_entry;
1563 extern const struct cmd_entry cmd_send_prefix_entry;
1564 extern const struct cmd_entry cmd_server_info_entry;
1565 extern const struct cmd_entry cmd_set_buffer_entry;
1566 extern const struct cmd_entry cmd_set_environment_entry;
1567 extern const struct cmd_entry cmd_set_option_entry;
1568 extern const struct cmd_entry cmd_set_window_option_entry;
1569 extern const struct cmd_entry cmd_show_buffer_entry;
1570 extern const struct cmd_entry cmd_show_environment_entry;
1571 extern const struct cmd_entry cmd_show_messages_entry;
1572 extern const struct cmd_entry cmd_show_options_entry;
1573 extern const struct cmd_entry cmd_show_window_options_entry;
1574 extern const struct cmd_entry cmd_source_file_entry;
1575 extern const struct cmd_entry cmd_split_window_entry;
1576 extern const struct cmd_entry cmd_start_server_entry;
1577 extern const struct cmd_entry cmd_suspend_client_entry;
1578 extern const struct cmd_entry cmd_swap_pane_entry;
1579 extern const struct cmd_entry cmd_swap_window_entry;
1580 extern const struct cmd_entry cmd_switch_client_entry;
1581 extern const struct cmd_entry cmd_unbind_key_entry;
1582 extern const struct cmd_entry cmd_unlink_window_entry;
1583 extern const struct cmd_entry cmd_up_pane_entry;
1585 /* cmd-list.c */
1586 struct cmd_list *cmd_list_parse(int, char **, char **);
1587 int cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
1588 void cmd_list_free(struct cmd_list *);
1589 size_t cmd_list_print(struct cmd_list *, char *, size_t);
1591 /* cmd-string.c */
1592 int cmd_string_parse(const char *, struct cmd_list **, char **);
1594 /* client.c */
1595 int client_main(int, char **, int);
1597 /* key-bindings.c */
1598 extern struct key_bindings key_bindings;
1599 int key_bindings_cmp(struct key_binding *, struct key_binding *);
1600 SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
1601 struct key_binding *key_bindings_lookup(int);
1602 void key_bindings_add(int, int, struct cmd_list *);
1603 void key_bindings_remove(int);
1604 void key_bindings_clean(void);
1605 void key_bindings_init(void);
1606 void key_bindings_dispatch(struct key_binding *, struct client *);
1607 void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
1608 void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
1609 void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
1611 /* key-string.c */
1612 int key_string_lookup_string(const char *);
1613 const char *key_string_lookup_key(int);
1615 /* server.c */
1616 extern struct clients clients;
1617 extern struct clients dead_clients;
1618 extern struct paste_stack global_buffers;
1619 int server_start(void);
1620 void server_update_socket(void);
1622 /* server-client.c */
1623 void server_client_create(int);
1624 void server_client_lost(struct client *);
1625 void server_client_callback(int, short, void *);
1626 void server_client_status_timer(void);
1627 void server_client_loop(void);
1629 /* server-window.c */
1630 void server_window_loop(void);
1632 /* server-fn.c */
1633 void server_fill_environ(struct session *, struct environ *);
1634 void server_write_client(
1635 struct client *, enum msgtype, const void *, size_t);
1636 void server_write_session(
1637 struct session *, enum msgtype, const void *, size_t);
1638 void server_redraw_client(struct client *);
1639 void server_status_client(struct client *);
1640 void server_redraw_session(struct session *);
1641 void server_redraw_session_group(struct session *);
1642 void server_status_session(struct session *);
1643 void server_status_session_group(struct session *);
1644 void server_redraw_window(struct window *);
1645 void server_redraw_window_borders(struct window *);
1646 void server_status_window(struct window *);
1647 void server_lock(void);
1648 void server_lock_session(struct session *);
1649 void server_lock_client(struct client *);
1650 int server_unlock(const char *);
1651 void server_kill_window(struct window *);
1652 int server_link_window(struct session *,
1653 struct winlink *, struct session *, int, int, int, char **);
1654 void server_unlink_window(struct session *, struct winlink *);
1655 void server_destroy_pane(struct window_pane *);
1656 void server_destroy_session_group(struct session *);
1657 void server_destroy_session(struct session *);
1658 void server_check_unattached (void);
1659 void server_set_identify(struct client *);
1660 void server_clear_identify(struct client *);
1661 void server_update_event(struct client *);
1663 /* status.c */
1664 int status_out_cmp(struct status_out *, struct status_out *);
1665 RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
1666 void status_free_jobs(struct status_out_tree *);
1667 void status_update_jobs(struct client *);
1668 int status_redraw(struct client *);
1669 char *status_replace(struct client *, struct session *,
1670 struct winlink *, struct window_pane *, const char *, time_t, int);
1671 void printflike2 status_message_set(struct client *, const char *, ...);
1672 void status_message_clear(struct client *);
1673 int status_message_redraw(struct client *);
1674 void status_prompt_set(struct client *, const char *,
1675 int (*)(void *, const char *), void (*)(void *), void *, int);
1676 void status_prompt_clear(struct client *);
1677 int status_prompt_redraw(struct client *);
1678 void status_prompt_key(struct client *, int);
1679 void status_prompt_update(struct client *, const char *);
1681 /* resize.c */
1682 void recalculate_sizes(void);
1684 /* input.c */
1685 void input_init(struct window_pane *);
1686 void input_free(struct window_pane *);
1687 void input_parse(struct window_pane *);
1689 /* input-key.c */
1690 void input_key(struct window_pane *, int);
1691 void input_mouse(struct window_pane *, struct mouse_event *);
1693 /* xterm-keys.c */
1694 char *xterm_keys_lookup(int);
1695 int xterm_keys_find(const char *, size_t, size_t *, int *);
1697 /* colour.c */
1698 void colour_set_fg(struct grid_cell *, int);
1699 void colour_set_bg(struct grid_cell *, int);
1700 const char *colour_tostring(int);
1701 int colour_fromstring(const char *);
1702 u_char colour_256to16(u_char);
1703 u_char colour_256to88(u_char);
1705 /* attributes.c */
1706 const char *attributes_tostring(u_char);
1707 int attributes_fromstring(const char *);
1709 /* grid.c */
1710 extern const struct grid_cell grid_default_cell;
1711 struct grid *grid_create(u_int, u_int, u_int);
1712 void grid_destroy(struct grid *);
1713 int grid_compare(struct grid *, struct grid *);
1714 void grid_collect_history(struct grid *);
1715 void grid_scroll_history(struct grid *);
1716 void grid_scroll_history_region(struct grid *, u_int, u_int);
1717 void grid_expand_line(struct grid *, u_int, u_int);
1718 void grid_expand_line_utf8(struct grid *, u_int, u_int);
1719 const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
1720 struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
1721 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
1722 const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
1723 struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
1724 void grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
1725 void grid_clear(struct grid *, u_int, u_int, u_int, u_int);
1726 void grid_clear_lines(struct grid *, u_int, u_int);
1727 void grid_move_lines(struct grid *, u_int, u_int, u_int);
1728 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1729 char *grid_string_cells(struct grid *, u_int, u_int, u_int);
1730 void grid_duplicate_lines(
1731 struct grid *, u_int, struct grid *, u_int, u_int);
1733 /* grid-utf8.c */
1734 size_t grid_utf8_size(const struct grid_utf8 *);
1735 size_t grid_utf8_copy(const struct grid_utf8 *, char *, size_t);
1736 void grid_utf8_set(struct grid_utf8 *, const struct utf8_data *);
1737 int grid_utf8_append(struct grid_utf8 *, const struct utf8_data *);
1738 int grid_utf8_compare(const struct grid_utf8 *, const struct grid_utf8 *);
1740 /* grid-view.c */
1741 const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
1742 struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
1743 void grid_view_set_cell(
1744 struct grid *, u_int, u_int, const struct grid_cell *);
1745 const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
1746 struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
1747 void grid_view_set_utf8(
1748 struct grid *, u_int, u_int, const struct grid_utf8 *);
1749 void grid_view_clear_history(struct grid *);
1750 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
1751 void grid_view_scroll_region_up(struct grid *, u_int, u_int);
1752 void grid_view_scroll_region_down(struct grid *, u_int, u_int);
1753 void grid_view_insert_lines(struct grid *, u_int, u_int);
1754 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1755 void grid_view_delete_lines(struct grid *, u_int, u_int);
1756 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1757 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
1758 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1759 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1761 /* screen-write.c */
1762 void screen_write_start(
1763 struct screen_write_ctx *, struct window_pane *, struct screen *);
1764 void screen_write_stop(struct screen_write_ctx *);
1765 size_t printflike2 screen_write_cstrlen(int, const char *, ...);
1766 void printflike5 screen_write_cnputs(struct screen_write_ctx *,
1767 ssize_t, struct grid_cell *, int, const char *, ...);
1768 size_t printflike2 screen_write_strlen(int, const char *, ...);
1769 void printflike3 screen_write_puts(struct screen_write_ctx *,
1770 struct grid_cell *, const char *, ...);
1771 void printflike5 screen_write_nputs(struct screen_write_ctx *,
1772 ssize_t, struct grid_cell *, int, const char *, ...);
1773 void screen_write_vnputs(struct screen_write_ctx *,
1774 ssize_t, struct grid_cell *, int, const char *, va_list);
1775 void screen_write_parsestyle(
1776 struct grid_cell *, struct grid_cell *, const char *);
1777 void screen_write_putc(
1778 struct screen_write_ctx *, struct grid_cell *, u_char);
1779 void screen_write_copy(struct screen_write_ctx *,
1780 struct screen *, u_int, u_int, u_int, u_int);
1781 void screen_write_backspace(struct screen_write_ctx *);
1782 void screen_write_cursorup(struct screen_write_ctx *, u_int);
1783 void screen_write_cursordown(struct screen_write_ctx *, u_int);
1784 void screen_write_cursorright(struct screen_write_ctx *, u_int);
1785 void screen_write_cursorleft(struct screen_write_ctx *, u_int);
1786 void screen_write_alignmenttest(struct screen_write_ctx *);
1787 void screen_write_insertcharacter(struct screen_write_ctx *, u_int);
1788 void screen_write_deletecharacter(struct screen_write_ctx *, u_int);
1789 void screen_write_insertline(struct screen_write_ctx *, u_int);
1790 void screen_write_deleteline(struct screen_write_ctx *, u_int);
1791 void screen_write_clearline(struct screen_write_ctx *);
1792 void screen_write_clearendofline(struct screen_write_ctx *);
1793 void screen_write_clearstartofline(struct screen_write_ctx *);
1794 void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
1795 void screen_write_cursormode(struct screen_write_ctx *, int);
1796 void screen_write_reverseindex(struct screen_write_ctx *);
1797 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
1798 void screen_write_insertmode(struct screen_write_ctx *, int);
1799 void screen_write_utf8mousemode(struct screen_write_ctx *, int);
1800 void screen_write_mousemode_on(struct screen_write_ctx *, int);
1801 void screen_write_mousemode_off(struct screen_write_ctx *);
1802 void screen_write_linefeed(struct screen_write_ctx *, int);
1803 void screen_write_linefeedscreen(struct screen_write_ctx *, int);
1804 void screen_write_carriagereturn(struct screen_write_ctx *);
1805 void screen_write_kcursormode(struct screen_write_ctx *, int);
1806 void screen_write_kkeypadmode(struct screen_write_ctx *, int);
1807 void screen_write_clearendofscreen(struct screen_write_ctx *);
1808 void screen_write_clearstartofscreen(struct screen_write_ctx *);
1809 void screen_write_clearscreen(struct screen_write_ctx *);
1810 void screen_write_cell(struct screen_write_ctx *,
1811 const struct grid_cell *, const struct utf8_data *);
1812 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
1814 /* screen-redraw.c */
1815 void screen_redraw_screen(struct client *, int, int);
1816 void screen_redraw_pane(struct client *, struct window_pane *);
1818 /* screen.c */
1819 void screen_init(struct screen *, u_int, u_int, u_int);
1820 void screen_reinit(struct screen *);
1821 void screen_free(struct screen *);
1822 void screen_reset_tabs(struct screen *);
1823 void screen_set_title(struct screen *, const char *);
1824 void screen_resize(struct screen *, u_int, u_int);
1825 void screen_set_selection(struct screen *,
1826 u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
1827 void screen_clear_selection(struct screen *);
1828 int screen_check_selection(struct screen *, u_int, u_int);
1830 /* window.c */
1831 extern struct windows windows;
1832 extern struct window_pane_tree all_window_panes;
1833 int winlink_cmp(struct winlink *, struct winlink *);
1834 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
1835 int window_pane_cmp(struct window_pane *, struct window_pane *);
1836 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
1837 struct winlink *winlink_find_by_index(struct winlinks *, int);
1838 struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
1839 int winlink_next_index(struct winlinks *, int);
1840 u_int winlink_count(struct winlinks *);
1841 struct winlink *winlink_add(struct winlinks *, int);
1842 void winlink_set_window(struct winlink *, struct window *);
1843 void winlink_remove(struct winlinks *, struct winlink *);
1844 struct winlink *winlink_next(struct winlink *);
1845 struct winlink *winlink_previous(struct winlink *);
1846 struct winlink *winlink_next_by_number(struct winlink *, struct session *,
1847 int);
1848 struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
1849 int);
1850 void winlink_stack_push(struct winlink_stack *, struct winlink *);
1851 void winlink_stack_remove(struct winlink_stack *, struct winlink *);
1852 int window_index(struct window *, u_int *);
1853 struct window *window_create1(u_int, u_int);
1854 struct window *window_create(const char *, const char *, const char *,
1855 const char *, struct environ *, struct termios *,
1856 u_int, u_int, u_int, char **);
1857 void window_destroy(struct window *);
1858 void window_set_active_at(struct window *, u_int, u_int);
1859 void window_set_active_pane(struct window *, struct window_pane *);
1860 struct window_pane *window_add_pane(struct window *, u_int);
1861 void window_resize(struct window *, u_int, u_int);
1862 void window_remove_pane(struct window *, struct window_pane *);
1863 struct window_pane *window_pane_at_index(struct window *, u_int);
1864 struct window_pane *window_pane_next_by_number(struct window *,
1865 struct window_pane *, u_int);
1866 struct window_pane *window_pane_previous_by_number(struct window *,
1867 struct window_pane *, u_int);
1868 u_int window_pane_index(struct window *, struct window_pane *);
1869 u_int window_count_panes(struct window *);
1870 void window_destroy_panes(struct window *);
1871 struct window_pane *window_pane_find_by_id(u_int);
1872 struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
1873 void window_pane_destroy(struct window_pane *);
1874 int window_pane_spawn(struct window_pane *, const char *,
1875 const char *, const char *, struct environ *,
1876 struct termios *, char **);
1877 void window_pane_resize(struct window_pane *, u_int, u_int);
1878 void window_pane_alternate_on(
1879 struct window_pane *, struct grid_cell *);
1880 void window_pane_alternate_off(
1881 struct window_pane *, struct grid_cell *);
1882 int window_pane_set_mode(
1883 struct window_pane *, const struct window_mode *);
1884 void window_pane_reset_mode(struct window_pane *);
1885 void window_pane_key(struct window_pane *, struct session *, int);
1886 void window_pane_mouse(struct window_pane *,
1887 struct session *, struct mouse_event *);
1888 int window_pane_visible(struct window_pane *);
1889 char *window_pane_search(
1890 struct window_pane *, const char *, u_int *);
1891 char *window_printable_flags(struct session *, struct winlink *);
1893 struct window_pane *window_pane_find_up(struct window_pane *);
1894 struct window_pane *window_pane_find_down(struct window_pane *);
1895 struct window_pane *window_pane_find_left(struct window_pane *);
1896 struct window_pane *window_pane_find_right(struct window_pane *);
1898 /* layout.c */
1899 u_int layout_count_cells(struct layout_cell *);
1900 struct layout_cell *layout_create_cell(struct layout_cell *);
1901 void layout_free_cell(struct layout_cell *);
1902 void layout_print_cell(struct layout_cell *, const char *, u_int);
1903 void layout_destroy_cell(struct layout_cell *, struct layout_cell **);
1904 void layout_set_size(
1905 struct layout_cell *, u_int, u_int, u_int, u_int);
1906 void layout_make_leaf(
1907 struct layout_cell *, struct window_pane *);
1908 void layout_make_node(struct layout_cell *, enum layout_type);
1909 void layout_fix_offsets(struct layout_cell *);
1910 void layout_fix_panes(struct window *, u_int, u_int);
1911 u_int layout_resize_check(struct layout_cell *, enum layout_type);
1912 void layout_resize_adjust(
1913 struct layout_cell *, enum layout_type, int);
1914 void layout_init(struct window *);
1915 void layout_free(struct window *);
1916 void layout_resize(struct window *, u_int, u_int);
1917 void layout_resize_pane(
1918 struct window_pane *, enum layout_type, int);
1919 void layout_assign_pane(struct layout_cell *, struct window_pane *);
1920 struct layout_cell *layout_split_pane(
1921 struct window_pane *, enum layout_type, int);
1922 void layout_close_pane(struct window_pane *);
1924 /* layout-custom.c */
1925 char *layout_dump(struct window *);
1926 int layout_parse(struct window *, const char *);
1928 /* layout-set.c */
1929 const char *layout_set_name(u_int);
1930 int layout_set_lookup(const char *);
1931 u_int layout_set_select(struct window *, u_int);
1932 u_int layout_set_next(struct window *);
1933 u_int layout_set_previous(struct window *);
1934 void layout_set_active_changed(struct window *);
1936 /* layout-string.c */
1937 struct layout_cell *layout_find_string(struct window *, const char *);
1938 struct layout_cell *layout_find_bottomright(struct layout_cell *);
1940 /* window-clock.c */
1941 extern const struct window_mode window_clock_mode;
1943 /* window-copy.c */
1944 extern const struct window_mode window_copy_mode;
1945 void window_copy_init_from_pane(struct window_pane *);
1946 void window_copy_init_for_output(struct window_pane *);
1947 void window_copy_add(struct window_pane *, const char *, ...);
1948 void window_copy_vadd(struct window_pane *, const char *, va_list);
1949 void window_copy_pageup(struct window_pane *);
1951 /* window-choose.c */
1952 extern const struct window_mode window_choose_mode;
1953 void window_choose_vadd(
1954 struct window_pane *, int, const char *, va_list);
1955 void printflike3 window_choose_add(
1956 struct window_pane *, int, const char *, ...);
1957 void window_choose_ready(struct window_pane *,
1958 u_int, void (*)(void *, int), void (*)(void *), void *);
1960 /* names.c */
1961 void queue_window_name(struct window *);
1962 char *default_window_name(struct window *);
1964 /* signal.c */
1965 void set_signals(void(*)(int, short, void *));
1966 void clear_signals(int);
1968 /* session.c */
1969 extern struct sessions sessions;
1970 extern struct sessions dead_sessions;
1971 extern struct session_groups session_groups;
1972 int session_cmp(struct session *, struct session *);
1973 RB_PROTOTYPE(sessions, session, entry, session_cmp);
1974 int session_alive(struct session *);
1975 struct session *session_find(const char *);
1976 struct session *session_find_by_index(u_int);
1977 struct session *session_create(const char *, const char *, const char *,
1978 struct environ *, struct termios *, int, u_int, u_int,
1979 char **);
1980 void session_destroy(struct session *);
1981 int session_check_name(const char *);
1982 void session_update_activity(struct session *);
1983 struct session *session_next_session(struct session *);
1984 struct session *session_previous_session(struct session *);
1985 struct winlink *session_new(struct session *,
1986 const char *, const char *, const char *, int, char **);
1987 struct winlink *session_attach(
1988 struct session *, struct window *, int, char **);
1989 int session_detach(struct session *, struct winlink *);
1990 struct winlink* session_has(struct session *, struct window *);
1991 int session_next(struct session *, int);
1992 int session_previous(struct session *, int);
1993 int session_select(struct session *, int);
1994 int session_last(struct session *);
1995 struct session_group *session_group_find(struct session *);
1996 u_int session_group_index(struct session_group *);
1997 void session_group_add(struct session *, struct session *);
1998 void session_group_remove(struct session *);
1999 void session_group_synchronize_to(struct session *);
2000 void session_group_synchronize_from(struct session *);
2001 void session_group_synchronize1(struct session *, struct session *);
2003 /* utf8.c */
2004 void utf8_build(void);
2005 int utf8_open(struct utf8_data *, u_char);
2006 int utf8_append(struct utf8_data *, u_char);
2007 u_int utf8_combine(const struct utf8_data *);
2008 u_int utf8_split2(u_int, u_char *);
2010 /* procname.c */
2011 char *get_proc_name(int, char *);
2013 /* log.c */
2014 void log_open_tty(int);
2015 void log_open_file(int, const char *);
2016 void log_close(void);
2017 void printflike1 log_warn(const char *, ...);
2018 void printflike1 log_warnx(const char *, ...);
2019 void printflike1 log_info(const char *, ...);
2020 void printflike1 log_debug(const char *, ...);
2021 void printflike1 log_debug2(const char *, ...);
2022 __dead void printflike1 log_fatal(const char *, ...);
2023 __dead void printflike1 log_fatalx(const char *, ...);
2025 /* xmalloc.c */
2026 char *xstrdup(const char *);
2027 void *xcalloc(size_t, size_t);
2028 void *xmalloc(size_t);
2029 void *xrealloc(void *, size_t, size_t);
2030 void xfree(void *);
2031 int printflike2 xasprintf(char **, const char *, ...);
2032 int xvasprintf(char **, const char *, va_list);
2033 int printflike3 xsnprintf(char *, size_t, const char *, ...);
2034 int xvsnprintf(char *, size_t, const char *, va_list);
2036 #endif /* TMUX_H */