Drop the ability to have a list of keys in the prefix in favour of two
[tmux-openbsd.git] / tmux.h
blobdba364fa79595fd85e5ac11081696fb4e31dedd2
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_CC, /* set colour cursor, Cc */
187 TTYC_CIVIS, /* cursor_invisible, vi */
188 TTYC_CLEAR, /* clear_screen, cl */
189 TTYC_CNORM, /* cursor_normal, ve */
190 TTYC_COLORS, /* max_colors, Co */
191 TTYC_CR, /* restore cursor colour, Cr */
192 TTYC_CS1, /* set cursor style, Cs */
193 TTYC_CSR, /* change_scroll_region, cs */
194 TTYC_CSR1, /* reset cursor style, Csr */
195 TTYC_CUB, /* parm_left_cursor, LE */
196 TTYC_CUB1, /* cursor_left, le */
197 TTYC_CUD, /* parm_down_cursor, DO */
198 TTYC_CUD1, /* cursor_down, do */
199 TTYC_CUF, /* parm_right_cursor, RI */
200 TTYC_CUF1, /* cursor_right, nd */
201 TTYC_CUP, /* cursor_address, cm */
202 TTYC_CUU, /* parm_up_cursor, UP */
203 TTYC_CUU1, /* cursor_up, up */
204 TTYC_DCH, /* parm_dch, DC */
205 TTYC_DCH1, /* delete_character, dc */
206 TTYC_DIM, /* enter_dim_mode, mh */
207 TTYC_DL, /* parm_delete_line, DL */
208 TTYC_DL1, /* delete_line, dl */
209 TTYC_E3,
210 TTYC_EL, /* clr_eol, ce */
211 TTYC_EL1, /* clr_bol, cb */
212 TTYC_ENACS, /* ena_acs, eA */
213 TTYC_FSL, /* from_status_line, fsl */
214 TTYC_HOME, /* cursor_home, ho */
215 TTYC_HPA, /* column_address, ch */
216 TTYC_ICH, /* parm_ich, IC */
217 TTYC_ICH1, /* insert_character, ic */
218 TTYC_IL, /* parm_insert_line, IL */
219 TTYC_IL1, /* insert_line, il */
220 TTYC_INVIS, /* enter_secure_mode, mk */
221 TTYC_IS1, /* init_1string, i1 */
222 TTYC_IS2, /* init_2string, i2 */
223 TTYC_IS3, /* init_3string, i3 */
224 TTYC_KCBT, /* key_btab, kB */
225 TTYC_KCUB1, /* key_left, kl */
226 TTYC_KCUD1, /* key_down, kd */
227 TTYC_KCUF1, /* key_right, kr */
228 TTYC_KCUU1, /* key_up, ku */
229 TTYC_KDC2,
230 TTYC_KDC3,
231 TTYC_KDC4,
232 TTYC_KDC5,
233 TTYC_KDC6,
234 TTYC_KDC7,
235 TTYC_KDCH1, /* key_dc, kD */
236 TTYC_KDN2,
237 TTYC_KDN3,
238 TTYC_KDN4,
239 TTYC_KDN5,
240 TTYC_KDN6,
241 TTYC_KDN7,
242 TTYC_KEND, /* key_end, ke */
243 TTYC_KEND2,
244 TTYC_KEND3,
245 TTYC_KEND4,
246 TTYC_KEND5,
247 TTYC_KEND6,
248 TTYC_KEND7,
249 TTYC_KF1, /* key_f1, k1 */
250 TTYC_KF10, /* key_f10, k; */
251 TTYC_KF11, /* key_f11, F1 */
252 TTYC_KF12, /* key_f12, F2 */
253 TTYC_KF13, /* key_f13, F3 */
254 TTYC_KF14, /* key_f14, F4 */
255 TTYC_KF15, /* key_f15, F5 */
256 TTYC_KF16, /* key_f16, F6 */
257 TTYC_KF17, /* key_f17, F7 */
258 TTYC_KF18, /* key_f18, F8 */
259 TTYC_KF19, /* key_f19, F9 */
260 TTYC_KF2, /* key_f2, k2 */
261 TTYC_KF20, /* key_f20, F10 */
262 TTYC_KF3, /* key_f3, k3 */
263 TTYC_KF4, /* key_f4, k4 */
264 TTYC_KF5, /* key_f5, k5 */
265 TTYC_KF6, /* key_f6, k6 */
266 TTYC_KF7, /* key_f7, k7 */
267 TTYC_KF8, /* key_f8, k8 */
268 TTYC_KF9, /* key_f9, k9 */
269 TTYC_KHOM2,
270 TTYC_KHOM3,
271 TTYC_KHOM4,
272 TTYC_KHOM5,
273 TTYC_KHOM6,
274 TTYC_KHOM7,
275 TTYC_KHOME, /* key_home, kh */
276 TTYC_KIC2,
277 TTYC_KIC3,
278 TTYC_KIC4,
279 TTYC_KIC5,
280 TTYC_KIC6,
281 TTYC_KIC7,
282 TTYC_KICH1, /* key_ic, kI */
283 TTYC_KLFT2,
284 TTYC_KLFT3,
285 TTYC_KLFT4,
286 TTYC_KLFT5,
287 TTYC_KLFT6,
288 TTYC_KLFT7,
289 TTYC_KMOUS, /* key_mouse, Km */
290 TTYC_KNP, /* key_npage, kN */
291 TTYC_KNXT2,
292 TTYC_KNXT3,
293 TTYC_KNXT4,
294 TTYC_KNXT5,
295 TTYC_KNXT6,
296 TTYC_KNXT7,
297 TTYC_KPP, /* key_ppage, kP */
298 TTYC_KPRV2,
299 TTYC_KPRV3,
300 TTYC_KPRV4,
301 TTYC_KPRV5,
302 TTYC_KPRV6,
303 TTYC_KPRV7,
304 TTYC_KRIT2,
305 TTYC_KRIT3,
306 TTYC_KRIT4,
307 TTYC_KRIT5,
308 TTYC_KRIT6,
309 TTYC_KRIT7,
310 TTYC_KUP2,
311 TTYC_KUP3,
312 TTYC_KUP4,
313 TTYC_KUP5,
314 TTYC_KUP6,
315 TTYC_KUP7,
316 TTYC_MS, /* modify xterm(1) selection */
317 TTYC_OP, /* orig_pair, op */
318 TTYC_REV, /* enter_reverse_mode, mr */
319 TTYC_RI, /* scroll_reverse, sr */
320 TTYC_RMACS, /* exit_alt_charset_mode */
321 TTYC_RMCUP, /* exit_ca_mode, te */
322 TTYC_RMIR, /* exit_insert_mode, ei */
323 TTYC_RMKX, /* keypad_local, ke */
324 TTYC_SETAB, /* set_a_background, AB */
325 TTYC_SETAF, /* set_a_foreground, AF */
326 TTYC_SGR0, /* exit_attribute_mode, me */
327 TTYC_SITM, /* enter_italics_mode, it */
328 TTYC_SMACS, /* enter_alt_charset_mode, as */
329 TTYC_SMCUP, /* enter_ca_mode, ti */
330 TTYC_SMIR, /* enter_insert_mode, im */
331 TTYC_SMKX, /* keypad_xmit, ks */
332 TTYC_SMSO, /* enter_standout_mode, so */
333 TTYC_SMUL, /* enter_underline_mode, us */
334 TTYC_TSL, /* to_status_line, tsl */
335 TTYC_VPA, /* row_address, cv */
336 TTYC_XENL, /* eat_newline_glitch, xn */
337 TTYC_XT, /* xterm(1)-compatible title, XT */
339 #define NTTYCODE (TTYC_XT + 1)
341 /* Termcap types. */
342 enum tty_code_type {
343 TTYCODE_NONE = 0,
344 TTYCODE_STRING,
345 TTYCODE_NUMBER,
346 TTYCODE_FLAG,
349 /* Termcap code. */
350 struct tty_code {
351 enum tty_code_type type;
352 union {
353 char *string;
354 int number;
355 int flag;
356 } value;
359 /* Entry in terminal code table. */
360 struct tty_term_code_entry {
361 enum tty_code_code code;
362 enum tty_code_type type;
363 const char *name;
366 /* Message codes. */
367 enum msgtype {
368 MSG_COMMAND,
369 MSG_DETACH,
370 MSG_ERROR,
371 MSG_EXIT,
372 MSG_EXITED,
373 MSG_EXITING,
374 MSG_IDENTIFY,
375 MSG_PRINT,
376 MSG_READY,
377 MSG_RESIZE,
378 MSG_SHUTDOWN,
379 MSG_SUSPEND,
380 MSG_VERSION,
381 MSG_WAKEUP,
382 MSG_ENVIRON,
383 MSG_UNLOCK,
384 MSG_LOCK,
385 MSG_SHELL,
386 MSG_STDERR,
387 MSG_STDOUT,
388 MSG_DETACHKILL
392 * Message data.
394 * Don't forget to bump PROTOCOL_VERSION if any of these change!
396 struct msg_command_data {
397 pid_t pid; /* PID from $TMUX or -1 */
398 int idx; /* index from $TMUX or -1 */
400 int argc;
401 char argv[COMMAND_LENGTH];
404 struct msg_identify_data {
405 char cwd[MAXPATHLEN];
407 char term[TERMINAL_LENGTH];
409 #define IDENTIFY_UTF8 0x1
410 #define IDENTIFY_256COLOURS 0x2
411 #define IDENTIFY_88COLOURS 0x4
412 int flags;
415 struct msg_lock_data {
416 char cmd[COMMAND_LENGTH];
419 struct msg_environ_data {
420 char var[ENVIRON_LENGTH];
423 struct msg_shell_data {
424 char shell[MAXPATHLEN];
427 struct msg_exit_data {
428 int retcode;
431 /* Mode key commands. */
432 enum mode_key_cmd {
433 MODEKEY_NONE,
434 MODEKEY_OTHER,
436 /* Editing keys. */
437 MODEKEYEDIT_BACKSPACE,
438 MODEKEYEDIT_CANCEL,
439 MODEKEYEDIT_COMPLETE,
440 MODEKEYEDIT_CURSORLEFT,
441 MODEKEYEDIT_CURSORRIGHT,
442 MODEKEYEDIT_DELETE,
443 MODEKEYEDIT_DELETELINE,
444 MODEKEYEDIT_DELETETOENDOFLINE,
445 MODEKEYEDIT_DELETEWORD,
446 MODEKEYEDIT_ENDOFLINE,
447 MODEKEYEDIT_ENTER,
448 MODEKEYEDIT_HISTORYDOWN,
449 MODEKEYEDIT_HISTORYUP,
450 MODEKEYEDIT_NEXTSPACE,
451 MODEKEYEDIT_NEXTSPACEEND,
452 MODEKEYEDIT_NEXTWORD,
453 MODEKEYEDIT_NEXTWORDEND,
454 MODEKEYEDIT_PASTE,
455 MODEKEYEDIT_PREVIOUSSPACE,
456 MODEKEYEDIT_PREVIOUSWORD,
457 MODEKEYEDIT_STARTOFLINE,
458 MODEKEYEDIT_SWITCHMODE,
459 MODEKEYEDIT_SWITCHMODEAPPEND,
460 MODEKEYEDIT_TRANSPOSECHARS,
462 /* Menu (choice) keys. */
463 MODEKEYCHOICE_CANCEL,
464 MODEKEYCHOICE_CHOOSE,
465 MODEKEYCHOICE_DOWN,
466 MODEKEYCHOICE_PAGEDOWN,
467 MODEKEYCHOICE_PAGEUP,
468 MODEKEYCHOICE_SCROLLDOWN,
469 MODEKEYCHOICE_SCROLLUP,
470 MODEKEYCHOICE_UP,
472 /* Copy keys. */
473 MODEKEYCOPY_BACKTOINDENTATION,
474 MODEKEYCOPY_BOTTOMLINE,
475 MODEKEYCOPY_CANCEL,
476 MODEKEYCOPY_CLEARSELECTION,
477 MODEKEYCOPY_COPYLINE,
478 MODEKEYCOPY_COPYENDOFLINE,
479 MODEKEYCOPY_COPYSELECTION,
480 MODEKEYCOPY_DOWN,
481 MODEKEYCOPY_ENDOFLINE,
482 MODEKEYCOPY_GOTOLINE,
483 MODEKEYCOPY_HALFPAGEDOWN,
484 MODEKEYCOPY_HALFPAGEUP,
485 MODEKEYCOPY_HISTORYBOTTOM,
486 MODEKEYCOPY_HISTORYTOP,
487 MODEKEYCOPY_JUMP,
488 MODEKEYCOPY_JUMPAGAIN,
489 MODEKEYCOPY_JUMPREVERSE,
490 MODEKEYCOPY_JUMPBACK,
491 MODEKEYCOPY_JUMPTO,
492 MODEKEYCOPY_JUMPTOBACK,
493 MODEKEYCOPY_LEFT,
494 MODEKEYCOPY_MIDDLELINE,
495 MODEKEYCOPY_NEXTPAGE,
496 MODEKEYCOPY_NEXTSPACE,
497 MODEKEYCOPY_NEXTSPACEEND,
498 MODEKEYCOPY_NEXTWORD,
499 MODEKEYCOPY_NEXTWORDEND,
500 MODEKEYCOPY_PREVIOUSPAGE,
501 MODEKEYCOPY_PREVIOUSSPACE,
502 MODEKEYCOPY_PREVIOUSWORD,
503 MODEKEYCOPY_RECTANGLETOGGLE,
504 MODEKEYCOPY_RIGHT,
505 MODEKEYCOPY_SCROLLDOWN,
506 MODEKEYCOPY_SCROLLUP,
507 MODEKEYCOPY_SEARCHAGAIN,
508 MODEKEYCOPY_SEARCHDOWN,
509 MODEKEYCOPY_SEARCHREVERSE,
510 MODEKEYCOPY_SEARCHUP,
511 MODEKEYCOPY_SELECTLINE,
512 MODEKEYCOPY_STARTNUMBERPREFIX,
513 MODEKEYCOPY_STARTOFLINE,
514 MODEKEYCOPY_STARTSELECTION,
515 MODEKEYCOPY_TOPLINE,
516 MODEKEYCOPY_UP,
519 /* Entry in the default mode key tables. */
520 struct mode_key_entry {
521 int key;
524 * Editing mode for vi: 0 is edit mode, keys not in the table are
525 * returned as MODEKEY_OTHER; 1 is command mode, keys not in the table
526 * are returned as MODEKEY_NONE. This is also matched on, allowing some
527 * keys to be bound in edit mode.
529 int mode;
530 enum mode_key_cmd cmd;
533 /* Data required while mode keys are in use. */
534 struct mode_key_data {
535 struct mode_key_tree *tree;
536 int mode;
538 #define MODEKEY_EMACS 0
539 #define MODEKEY_VI 1
541 /* Binding between a key and a command. */
542 struct mode_key_binding {
543 int key;
545 int mode;
546 enum mode_key_cmd cmd;
548 SPLAY_ENTRY(mode_key_binding) entry;
550 SPLAY_HEAD(mode_key_tree, mode_key_binding);
552 /* Command to string mapping. */
553 struct mode_key_cmdstr {
554 enum mode_key_cmd cmd;
555 const char *name;
558 /* Named mode key table description. */
559 struct mode_key_table {
560 const char *name;
561 const struct mode_key_cmdstr *cmdstr;
562 struct mode_key_tree *tree;
563 const struct mode_key_entry *table; /* default entries */
566 /* Modes. */
567 #define MODE_CURSOR 0x1
568 #define MODE_INSERT 0x2
569 #define MODE_KCURSOR 0x4
570 #define MODE_KKEYPAD 0x8 /* set = application, clear = number */
571 #define MODE_WRAP 0x10 /* whether lines wrap */
572 #define MODE_MOUSE_STANDARD 0x20
573 #define MODE_MOUSE_BUTTON 0x40
574 #define MODE_MOUSE_ANY 0x80
575 #define MODE_MOUSE_UTF8 0x100
577 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY)
580 * A single UTF-8 character.
582 * The data member in this must be UTF8_SIZE to allow screen_write_copy to
583 * reinject stored UTF-8 data back into screen_write_cell after combining (ugh
584 * XXX XXX).
586 struct utf8_data {
587 u_char data[UTF8_SIZE];
589 size_t have;
590 size_t size;
592 u_int width;
595 /* Grid output. */
596 #if defined(DEBUG) && \
597 ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
598 (defined(__GNUC__) && __GNUC__ >= 3))
599 #define GRID_DEBUG(gd, fmt, ...) log_debug2("%s: (sx=%u, sy=%u, hsize=%u) " \
600 fmt, __func__, (gd)->sx, (gd)->sy, (gd)->hsize, ## __VA_ARGS__)
601 #else
602 #define GRID_DEBUG(...)
603 #endif
605 /* Grid attributes. */
606 #define GRID_ATTR_BRIGHT 0x1
607 #define GRID_ATTR_DIM 0x2
608 #define GRID_ATTR_UNDERSCORE 0x4
609 #define GRID_ATTR_BLINK 0x8
610 #define GRID_ATTR_REVERSE 0x10
611 #define GRID_ATTR_HIDDEN 0x20
612 #define GRID_ATTR_ITALICS 0x40
613 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
615 /* Grid flags. */
616 #define GRID_FLAG_FG256 0x1
617 #define GRID_FLAG_BG256 0x2
618 #define GRID_FLAG_PADDING 0x4
619 #define GRID_FLAG_UTF8 0x8
621 /* Grid line flags. */
622 #define GRID_LINE_WRAPPED 0x1
624 /* Grid cell data. */
625 struct grid_cell {
626 u_char attr;
627 u_char flags;
628 u_char fg;
629 u_char bg;
630 u_char data;
631 } __packed;
633 /* Grid cell UTF-8 data. Used instead of data in grid_cell for UTF-8 cells. */
634 struct grid_utf8 {
635 u_char width;
636 u_char data[UTF8_SIZE];
637 } __packed;
639 /* Grid line. */
640 struct grid_line {
641 u_int cellsize;
642 struct grid_cell *celldata;
644 u_int utf8size;
645 struct grid_utf8 *utf8data;
647 int flags;
648 } __packed;
650 /* Entire grid of cells. */
651 struct grid {
652 int flags;
653 #define GRID_HISTORY 0x1 /* scroll lines into history */
655 u_int sx;
656 u_int sy;
658 u_int hsize;
659 u_int hlimit;
661 struct grid_line *linedata;
664 /* Option data structures. */
665 struct options_entry {
666 char *name;
668 enum {
669 OPTIONS_STRING,
670 OPTIONS_NUMBER,
671 OPTIONS_DATA,
672 } type;
674 char *str;
675 long long num;
677 SPLAY_ENTRY(options_entry) entry;
680 struct options {
681 SPLAY_HEAD(options_tree, options_entry) tree;
682 struct options *parent;
685 /* Scheduled job. */
686 struct job {
687 char *cmd;
688 pid_t pid;
689 int status;
691 int fd;
692 struct bufferevent *event;
694 void (*callbackfn)(struct job *);
695 void (*freefn)(void *);
696 void *data;
698 LIST_ENTRY(job) lentry;
700 LIST_HEAD(joblist, job);
702 /* Screen selection. */
703 struct screen_sel {
704 int flag;
705 int rectflag;
707 u_int sx;
708 u_int sy;
710 u_int ex;
711 u_int ey;
713 struct grid_cell cell;
716 /* Virtual screen. */
717 struct screen {
718 char *title;
720 struct grid *grid; /* grid data */
722 u_int cx; /* cursor x */
723 u_int cy; /* cursor y */
725 u_int cstyle; /* cursor style */
726 char *ccolour; /* cursor colour string */
728 u_int rupper; /* scroll region top */
729 u_int rlower; /* scroll region bottom */
731 int mode;
733 bitstr_t *tabs;
735 struct screen_sel sel;
738 /* Screen write context. */
739 struct screen_write_ctx {
740 struct window_pane *wp;
741 struct screen *s;
744 /* Screen size. */
745 #define screen_size_x(s) ((s)->grid->sx)
746 #define screen_size_y(s) ((s)->grid->sy)
747 #define screen_hsize(s) ((s)->grid->hsize)
748 #define screen_hlimit(s) ((s)->grid->hlimit)
750 /* Input parser context. */
751 struct input_ctx {
752 struct window_pane *wp;
753 struct screen_write_ctx ctx;
755 struct grid_cell cell;
757 struct grid_cell old_cell;
758 u_int old_cx;
759 u_int old_cy;
761 u_char interm_buf[4];
762 size_t interm_len;
764 u_char param_buf[64];
765 size_t param_len;
767 u_char input_buf[256];
768 size_t input_len;
770 int param_list[24]; /* -1 not present */
771 u_int param_list_len;
773 struct utf8_data utf8data;
775 int ch;
776 int flags;
777 #define INPUT_DISCARD 0x1
779 const struct input_state *state;
783 * Window mode. Windows can be in several modes and this is used to call the
784 * right function to handle input and output.
786 struct session;
787 struct window;
788 struct mouse_event;
789 struct window_mode {
790 struct screen *(*init)(struct window_pane *);
791 void (*free)(struct window_pane *);
792 void (*resize)(struct window_pane *, u_int, u_int);
793 void (*key)(struct window_pane *, struct session *, int);
794 void (*mouse)(struct window_pane *,
795 struct session *, struct mouse_event *);
796 void (*timer)(struct window_pane *);
799 /* Child window structure. */
800 struct window_pane {
801 u_int id;
803 struct window *window;
804 struct layout_cell *layout_cell;
806 u_int sx;
807 u_int sy;
809 u_int xoff;
810 u_int yoff;
812 int flags;
813 #define PANE_REDRAW 0x1
815 char *cmd;
816 char *shell;
817 char *cwd;
819 pid_t pid;
820 char tty[TTY_NAME_MAX];
822 int fd;
823 struct bufferevent *event;
825 struct input_ctx ictx;
827 int pipe_fd;
828 struct bufferevent *pipe_event;
829 size_t pipe_off;
831 struct screen *screen;
832 struct screen base;
834 /* Saved in alternative screen mode. */
835 u_int saved_cx;
836 u_int saved_cy;
837 struct grid *saved_grid;
838 struct grid_cell saved_cell;
840 const struct window_mode *mode;
841 void *modedata;
843 TAILQ_ENTRY(window_pane) entry;
844 RB_ENTRY(window_pane) tree_entry;
846 TAILQ_HEAD(window_panes, window_pane);
847 RB_HEAD(window_pane_tree, window_pane);
849 /* Window structure. */
850 struct window {
851 char *name;
852 struct event name_timer;
853 struct timeval silence_timer;
855 struct window_pane *active;
856 struct window_pane *last;
857 struct window_panes panes;
859 int lastlayout;
860 struct layout_cell *layout_root;
862 u_int sx;
863 u_int sy;
865 int flags;
866 #define WINDOW_BELL 0x1
867 #define WINDOW_ACTIVITY 0x2
868 #define WINDOW_REDRAW 0x4
869 #define WINDOW_SILENCE 0x8
871 struct options options;
873 u_int references;
875 ARRAY_DECL(windows, struct window *);
877 /* Entry on local window list. */
878 struct winlink {
879 int idx;
880 struct window *window;
882 size_t status_width;
883 struct grid_cell status_cell;
884 char *status_text;
886 int flags;
887 #define WINLINK_BELL 0x1
888 #define WINLINK_ACTIVITY 0x2
889 #define WINLINK_CONTENT 0x4
890 #define WINLINK_SILENCE 0x8
891 #define WINLINK_ALERTFLAGS \
892 (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
894 RB_ENTRY(winlink) entry;
895 TAILQ_ENTRY(winlink) sentry;
897 RB_HEAD(winlinks, winlink);
898 TAILQ_HEAD(winlink_stack, winlink);
900 /* Layout direction. */
901 enum layout_type {
902 LAYOUT_LEFTRIGHT,
903 LAYOUT_TOPBOTTOM,
904 LAYOUT_WINDOWPANE
907 /* Layout cells queue. */
908 TAILQ_HEAD(layout_cells, layout_cell);
910 /* Layout cell. */
911 struct layout_cell {
912 enum layout_type type;
914 struct layout_cell *parent;
916 u_int sx;
917 u_int sy;
919 u_int xoff;
920 u_int yoff;
922 struct window_pane *wp;
923 struct layout_cells cells;
925 TAILQ_ENTRY(layout_cell) entry;
928 /* Paste buffer. */
929 struct paste_buffer {
930 char *data;
931 size_t size;
933 ARRAY_DECL(paste_stack, struct paste_buffer *);
935 /* Environment variable. */
936 struct environ_entry {
937 char *name;
938 char *value;
940 RB_ENTRY(environ_entry) entry;
942 RB_HEAD(environ, environ_entry);
944 /* Client session. */
945 struct session_group {
946 TAILQ_HEAD(, session) sessions;
948 TAILQ_ENTRY(session_group) entry;
950 TAILQ_HEAD(session_groups, session_group);
952 struct session {
953 u_int idx;
955 char *name;
956 char *cwd;
958 struct timeval creation_time;
959 struct timeval activity_time;
961 u_int sx;
962 u_int sy;
964 struct winlink *curw;
965 struct winlink_stack lastw;
966 struct winlinks windows;
968 struct options options;
970 #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
971 int flags;
973 struct termios *tio;
975 struct environ environ;
977 int wlmouse;
979 int references;
981 TAILQ_ENTRY(session) gentry;
982 RB_ENTRY(session) entry;
984 RB_HEAD(sessions, session);
985 ARRAY_DECL(sessionslist, struct session *);
987 /* TTY information. */
988 struct tty_key {
989 char ch;
990 int key;
992 struct tty_key *left;
993 struct tty_key *right;
995 struct tty_key *next;
998 struct tty_term {
999 char *name;
1000 u_int references;
1002 char acs[UCHAR_MAX + 1][2];
1004 struct tty_code codes[NTTYCODE];
1006 #define TERM_256COLOURS 0x1
1007 #define TERM_88COLOURS 0x2
1008 #define TERM_EARLYWRAP 0x4
1009 int flags;
1011 LIST_ENTRY(tty_term) entry;
1013 LIST_HEAD(tty_terms, tty_term);
1015 struct tty {
1016 char *path;
1018 u_int sx;
1019 u_int sy;
1021 u_int cx;
1022 u_int cy;
1023 u_int cstyle;
1024 char *ccolour;
1026 int mode;
1028 u_int rlower;
1029 u_int rupper;
1031 char *termname;
1032 struct tty_term *term;
1034 int fd;
1035 struct bufferevent *event;
1037 int log_fd;
1039 struct termios tio;
1041 struct grid_cell cell;
1043 #define TTY_NOCURSOR 0x1
1044 #define TTY_FREEZE 0x2
1045 #define TTY_ESCAPE 0x4
1046 #define TTY_UTF8 0x8
1047 #define TTY_STARTED 0x10
1048 #define TTY_OPENED 0x20
1049 #define TTY_BACKOFF 0x40
1050 int flags;
1052 int term_flags;
1054 void (*key_callback)(int, struct mouse_event *, void *);
1055 void *key_data;
1056 struct event key_timer;
1057 struct tty_key *key_tree;
1060 /* TTY command context and function pointer. */
1061 struct tty_ctx {
1062 struct window_pane *wp;
1064 const struct grid_cell *cell;
1065 const struct grid_utf8 *utf8;
1067 u_int num;
1068 void *ptr;
1071 * Cursor and region position before the screen was updated - this is
1072 * where the command should be applied; the values in the screen have
1073 * already been updated.
1075 u_int ocx;
1076 u_int ocy;
1078 u_int orupper;
1079 u_int orlower;
1081 /* Saved last cell on line. */
1082 struct grid_cell last_cell;
1083 struct grid_utf8 last_utf8;
1084 u_int last_width;
1088 * xterm mouse mode is fairly silly. Buttons are in the bottom two
1089 * bits: 0 button 1; 1 button 2; 2 button 3; 3 buttons released.
1091 * Bit 3 is shift; bit 4 is meta; bit 5 control.
1093 * Bit 6 is added for mouse buttons 4 and 5.
1095 /* Mouse input. */
1096 struct mouse_event {
1097 u_int b;
1098 #define MOUSE_1 0
1099 #define MOUSE_2 1
1100 #define MOUSE_3 2
1101 #define MOUSE_UP 3
1102 #define MOUSE_BUTTON 3
1103 #define MOUSE_DRAG 32
1104 #define MOUSE_45 64
1105 #define MOUSE_RESIZE_PANE 128 /* marker for resizing */
1106 u_int x;
1107 u_int y;
1110 /* Saved message entry. */
1111 struct message_entry {
1112 char *msg;
1113 time_t msg_time;
1116 /* Status output data from a job. */
1117 struct status_out {
1118 char *cmd;
1119 char *out;
1121 RB_ENTRY(status_out) entry;
1123 RB_HEAD(status_out_tree, status_out);
1125 /* Client connection. */
1126 struct client {
1127 struct imsgbuf ibuf;
1128 struct event event;
1129 int retcode;
1131 struct timeval creation_time;
1132 struct timeval activity_time;
1134 struct environ environ;
1136 char *title;
1137 char *cwd;
1139 struct tty tty;
1141 int stdin_fd;
1142 void *stdin_data;
1143 void (*stdin_callback)(struct client *, void *);
1144 struct bufferevent *stdin_event;
1146 int stdout_fd;
1147 struct bufferevent *stdout_event;
1149 int stderr_fd;
1150 struct bufferevent *stderr_event;
1152 struct event repeat_timer;
1154 struct status_out_tree status_old;
1155 struct status_out_tree status_new;
1156 struct timeval status_timer;
1157 struct screen status;
1159 #define CLIENT_TERMINAL 0x1
1160 #define CLIENT_PREFIX 0x2
1161 #define CLIENT_EXIT 0x4
1162 #define CLIENT_REDRAW 0x8
1163 #define CLIENT_STATUS 0x10
1164 #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
1165 #define CLIENT_SUSPENDED 0x40
1166 #define CLIENT_BAD 0x80
1167 #define CLIENT_IDENTIFY 0x100
1168 #define CLIENT_DEAD 0x200
1169 #define CLIENT_BORDERS 0x400
1170 #define CLIENT_READONLY 0x800
1171 #define CLIENT_BACKOFF 0x1000
1172 #define CLIENT_REDRAWWINDOW 0x2000
1173 int flags;
1175 struct event identify_timer;
1177 char *message_string;
1178 struct event message_timer;
1179 ARRAY_DECL(, struct message_entry) message_log;
1181 char *prompt_string;
1182 char *prompt_buffer;
1183 size_t prompt_index;
1184 int (*prompt_callbackfn)(void *, const char *);
1185 void (*prompt_freefn)(void *);
1186 void *prompt_data;
1187 u_int prompt_hindex;
1189 #define PROMPT_SINGLE 0x1
1190 int prompt_flags;
1192 struct mode_key_data prompt_mdata;
1194 struct session *session;
1195 struct session *last_session;
1197 struct mouse_event last_mouse;
1199 int references;
1201 ARRAY_DECL(clients, struct client *);
1203 /* Parsed arguments. */
1204 struct args {
1205 bitstr_t *flags;
1206 char *values[SCHAR_MAX]; /* XXX This is awfully big. */
1208 int argc;
1209 char **argv;
1212 /* Key/command line command. */
1213 struct cmd_ctx {
1215 * curclient is the client where this command was executed if inside
1216 * tmux. This is NULL if the command came from the command-line.
1218 * cmdclient is the client which sent the MSG_COMMAND to the server, if
1219 * any. This is NULL unless the command came from the command-line.
1221 * cmdclient and curclient may both be NULL if the command is in the
1222 * configuration file.
1224 struct client *curclient;
1225 struct client *cmdclient;
1227 struct msg_command_data *msgdata;
1229 /* gcc2 doesn't understand attributes on function pointers... */
1230 #if defined(__GNUC__) && __GNUC__ >= 3
1231 void printflike2 (*print)(struct cmd_ctx *, const char *, ...);
1232 void printflike2 (*info)(struct cmd_ctx *, const char *, ...);
1233 void printflike2 (*error)(struct cmd_ctx *, const char *, ...);
1234 #else
1235 void (*print)(struct cmd_ctx *, const char *, ...);
1236 void (*info)(struct cmd_ctx *, const char *, ...);
1237 void (*error)(struct cmd_ctx *, const char *, ...);
1238 #endif
1241 struct cmd {
1242 const struct cmd_entry *entry;
1243 struct args *args;
1245 TAILQ_ENTRY(cmd) qentry;
1247 struct cmd_list {
1248 int references;
1249 TAILQ_HEAD(, cmd) list;
1252 struct cmd_entry {
1253 const char *name;
1254 const char *alias;
1256 const char *args_template;
1257 int args_lower;
1258 int args_upper;
1260 const char *usage;
1262 #define CMD_STARTSERVER 0x1
1263 #define CMD_CANTNEST 0x2
1264 #define CMD_SENDENVIRON 0x4
1265 #define CMD_READONLY 0x8
1266 int flags;
1268 void (*key_binding)(struct cmd *, int);
1269 int (*check)(struct args *);
1270 int (*exec)(struct cmd *, struct cmd_ctx *);
1273 /* Key binding. */
1274 struct key_binding {
1275 int key;
1276 struct cmd_list *cmdlist;
1277 int can_repeat;
1279 SPLAY_ENTRY(key_binding) entry;
1281 SPLAY_HEAD(key_bindings, key_binding);
1284 * Option table entries. The option table is the user-visible part of the
1285 * option, as opposed to the internal options (struct option) which are just
1286 * number or string.
1288 enum options_table_type {
1289 OPTIONS_TABLE_STRING,
1290 OPTIONS_TABLE_NUMBER,
1291 OPTIONS_TABLE_KEY,
1292 OPTIONS_TABLE_COLOUR,
1293 OPTIONS_TABLE_ATTRIBUTES,
1294 OPTIONS_TABLE_FLAG,
1295 OPTIONS_TABLE_CHOICE
1298 struct options_table_entry {
1299 const char *name;
1300 enum options_table_type type;
1302 u_int minimum;
1303 u_int maximum;
1304 const char **choices;
1306 const char *default_str;
1307 long long default_num;
1310 /* Tree of format entries. */
1311 struct format_entry {
1312 char *key;
1313 char *value;
1315 RB_ENTRY(format_entry) entry;
1317 RB_HEAD(format_tree, format_entry);
1319 /* List of configuration causes. */
1320 ARRAY_DECL(causelist, char *);
1322 /* Common command usages. */
1323 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1324 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1325 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1326 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1327 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1328 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1329 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1330 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1331 #define CMD_BUFFER_USAGE "[-b buffer-index]"
1333 /* tmux.c */
1334 extern struct options global_options;
1335 extern struct options global_s_options;
1336 extern struct options global_w_options;
1337 extern struct environ global_environ;
1338 extern struct event_base *ev_base;
1339 extern char *cfg_file;
1340 extern char *shell_cmd;
1341 extern int debug_level;
1342 extern time_t start_time;
1343 extern char socket_path[MAXPATHLEN];
1344 extern int login_shell;
1345 extern char *environ_path;
1346 extern pid_t environ_pid;
1347 extern int environ_idx;
1348 void logfile(const char *);
1349 const char *getshell(void);
1350 int checkshell(const char *);
1351 int areshell(const char *);
1352 const char* get_full_path(const char *, const char *);
1353 void setblocking(int, int);
1354 __dead void shell_exec(const char *, const char *);
1356 /* cfg.c */
1357 extern int cfg_finished;
1358 extern struct causelist cfg_causes;
1359 void printflike2 cfg_add_cause(struct causelist *, const char *, ...);
1360 int load_cfg(const char *, struct cmd_ctx *, struct causelist *);
1362 /* format.c */
1363 int format_cmp(struct format_entry *, struct format_entry *);
1364 RB_PROTOTYPE(format_tree, format_entry, entry, format_cmp);
1365 struct format_tree *format_create(void);
1366 void format_free(struct format_tree *);
1367 void format_add(
1368 struct format_tree *, const char *, const char *, ...);
1369 const char *format_find(struct format_tree *, const char *);
1370 char *format_expand(struct format_tree *, const char *);
1371 void format_session(struct format_tree *, struct session *);
1372 void format_client(struct format_tree *, struct client *);
1373 void format_winlink(
1374 struct format_tree *, struct session *, struct winlink *);
1375 void format_window_pane(struct format_tree *, struct window_pane *);
1377 /* mode-key.c */
1378 extern const struct mode_key_table mode_key_tables[];
1379 extern struct mode_key_tree mode_key_tree_vi_edit;
1380 extern struct mode_key_tree mode_key_tree_vi_choice;
1381 extern struct mode_key_tree mode_key_tree_vi_copy;
1382 extern struct mode_key_tree mode_key_tree_emacs_edit;
1383 extern struct mode_key_tree mode_key_tree_emacs_choice;
1384 extern struct mode_key_tree mode_key_tree_emacs_copy;
1385 int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
1386 SPLAY_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
1387 const char *mode_key_tostring(const struct mode_key_cmdstr *,
1388 enum mode_key_cmd);
1389 enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
1390 const char *);
1391 const struct mode_key_table *mode_key_findtable(const char *);
1392 void mode_key_init_trees(void);
1393 void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
1394 enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
1396 /* options.c */
1397 int options_cmp(struct options_entry *, struct options_entry *);
1398 SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
1399 void options_init(struct options *, struct options *);
1400 void options_free(struct options *);
1401 struct options_entry *options_find1(struct options *, const char *);
1402 struct options_entry *options_find(struct options *, const char *);
1403 void options_remove(struct options *, const char *);
1404 struct options_entry *printflike3 options_set_string(
1405 struct options *, const char *, const char *, ...);
1406 char *options_get_string(struct options *, const char *);
1407 struct options_entry *options_set_number(
1408 struct options *, const char *, long long);
1409 long long options_get_number(struct options *, const char *);
1411 /* options-table.c */
1412 extern const struct options_table_entry server_options_table[];
1413 extern const struct options_table_entry session_options_table[];
1414 extern const struct options_table_entry window_options_table[];
1415 void options_table_populate_tree(
1416 const struct options_table_entry *, struct options *);
1417 const char *options_table_print_entry(
1418 const struct options_table_entry *, struct options_entry *);
1420 /* job.c */
1421 extern struct joblist all_jobs;
1422 struct job *job_run(
1423 const char *, void (*)(struct job *), void (*)(void *), void *);
1424 void job_free(struct job *);
1425 void job_died(struct job *, int);
1427 /* environ.c */
1428 int environ_cmp(struct environ_entry *, struct environ_entry *);
1429 RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp);
1430 void environ_init(struct environ *);
1431 void environ_free(struct environ *);
1432 void environ_copy(struct environ *, struct environ *);
1433 struct environ_entry *environ_find(struct environ *, const char *);
1434 void environ_set(struct environ *, const char *, const char *);
1435 void environ_put(struct environ *, const char *);
1436 void environ_unset(struct environ *, const char *);
1437 void environ_update(const char *, struct environ *, struct environ *);
1438 void environ_push(struct environ *);
1440 /* tty.c */
1441 void tty_raw(struct tty *, const char *);
1442 void tty_attributes(struct tty *, const struct grid_cell *);
1443 void tty_reset(struct tty *);
1444 void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1445 void tty_region(struct tty *, u_int, u_int);
1446 void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1447 void tty_cursor(struct tty *, u_int, u_int);
1448 void tty_putcode(struct tty *, enum tty_code_code);
1449 void tty_putcode1(struct tty *, enum tty_code_code, int);
1450 void tty_putcode2(struct tty *, enum tty_code_code, int, int);
1451 void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
1452 void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const void *);
1453 void tty_puts(struct tty *, const char *);
1454 void tty_putc(struct tty *, u_char);
1455 void tty_pututf8(struct tty *, const struct grid_utf8 *);
1456 void tty_init(struct tty *, int, char *);
1457 int tty_resize(struct tty *);
1458 void tty_start_tty(struct tty *);
1459 void tty_stop_tty(struct tty *);
1460 void tty_set_title(struct tty *, const char *);
1461 void tty_update_mode(struct tty *, int, struct screen *);
1462 void tty_force_cursor_colour(struct tty *, const char *);
1463 void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
1464 int tty_open(struct tty *, const char *, char **);
1465 void tty_close(struct tty *);
1466 void tty_free(struct tty *);
1467 void tty_write(void (*)(
1468 struct tty *, const struct tty_ctx *), const struct tty_ctx *);
1469 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
1470 void tty_cmd_cell(struct tty *, const struct tty_ctx *);
1471 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
1472 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
1473 void tty_cmd_clearline(struct tty *, const struct tty_ctx *);
1474 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
1475 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
1476 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
1477 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
1478 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
1479 void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *);
1480 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
1481 void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
1482 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
1483 void tty_cmd_utf8character(struct tty *, const struct tty_ctx *);
1484 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
1485 void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
1486 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
1487 void tty_bell(struct tty *);
1489 /* tty-term.c */
1490 extern struct tty_terms tty_terms;
1491 extern const struct tty_term_code_entry tty_term_codes[NTTYCODE];
1492 struct tty_term *tty_term_find(char *, int, const char *, char **);
1493 void tty_term_free(struct tty_term *);
1494 int tty_term_has(struct tty_term *, enum tty_code_code);
1495 const char *tty_term_string(struct tty_term *, enum tty_code_code);
1496 const char *tty_term_string1(struct tty_term *, enum tty_code_code, int);
1497 const char *tty_term_string2(
1498 struct tty_term *, enum tty_code_code, int, int);
1499 const char *tty_term_ptr1(
1500 struct tty_term *, enum tty_code_code, const void *);
1501 const char *tty_term_ptr2(
1502 struct tty_term *, enum tty_code_code, const void *, const void *);
1503 int tty_term_number(struct tty_term *, enum tty_code_code);
1504 int tty_term_flag(struct tty_term *, enum tty_code_code);
1506 /* tty-acs.c */
1507 const char *tty_acs_get(struct tty *, u_char);
1509 /* tty-keys.c */
1510 void tty_keys_init(struct tty *);
1511 void tty_keys_free(struct tty *);
1512 int tty_keys_next(struct tty *);
1514 /* paste.c */
1515 struct paste_buffer *paste_walk_stack(struct paste_stack *, u_int *);
1516 struct paste_buffer *paste_get_top(struct paste_stack *);
1517 struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
1518 int paste_free_top(struct paste_stack *);
1519 int paste_free_index(struct paste_stack *, u_int);
1520 void paste_add(struct paste_stack *, char *, size_t, u_int);
1521 int paste_replace(struct paste_stack *, u_int, char *, size_t);
1522 char *paste_print(struct paste_buffer *, size_t);
1524 /* clock.c */
1525 extern const char clock_table[14][5][5];
1526 void clock_draw(struct screen_write_ctx *, int, int);
1528 /* arguments.c */
1529 struct args *args_create(int, ...);
1530 struct args *args_parse(const char *, int, char **);
1531 void args_free(struct args *);
1532 size_t args_print(struct args *, char *, size_t);
1533 int args_has(struct args *, u_char);
1534 void args_set(struct args *, u_char, const char *);
1535 const char *args_get(struct args *, u_char);
1536 long long args_strtonum(
1537 struct args *, u_char, long long, long long, char **);
1539 /* cmd.c */
1540 int cmd_pack_argv(int, char **, char *, size_t);
1541 int cmd_unpack_argv(char *, size_t, int, char ***);
1542 char **cmd_copy_argv(int, char *const *);
1543 void cmd_free_argv(int, char **);
1544 struct cmd *cmd_parse(int, char **, char **);
1545 int cmd_exec(struct cmd *, struct cmd_ctx *);
1546 void cmd_free(struct cmd *);
1547 size_t cmd_print(struct cmd *, char *, size_t);
1548 struct session *cmd_current_session(struct cmd_ctx *, int);
1549 struct client *cmd_current_client(struct cmd_ctx *);
1550 struct client *cmd_find_client(struct cmd_ctx *, const char *);
1551 struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
1552 struct winlink *cmd_find_window(
1553 struct cmd_ctx *, const char *, struct session **);
1554 int cmd_find_index(
1555 struct cmd_ctx *, const char *, struct session **);
1556 struct winlink *cmd_find_pane(struct cmd_ctx *,
1557 const char *, struct session **, struct window_pane **);
1558 char *cmd_template_replace(char *, const char *, int);
1559 const char *cmd_get_default_path(struct cmd_ctx *ctx);
1560 extern const struct cmd_entry *cmd_table[];
1561 extern const struct cmd_entry cmd_attach_session_entry;
1562 extern const struct cmd_entry cmd_bind_key_entry;
1563 extern const struct cmd_entry cmd_break_pane_entry;
1564 extern const struct cmd_entry cmd_capture_pane_entry;
1565 extern const struct cmd_entry cmd_choose_buffer_entry;
1566 extern const struct cmd_entry cmd_choose_client_entry;
1567 extern const struct cmd_entry cmd_choose_session_entry;
1568 extern const struct cmd_entry cmd_choose_window_entry;
1569 extern const struct cmd_entry cmd_clear_history_entry;
1570 extern const struct cmd_entry cmd_clock_mode_entry;
1571 extern const struct cmd_entry cmd_command_prompt_entry;
1572 extern const struct cmd_entry cmd_confirm_before_entry;
1573 extern const struct cmd_entry cmd_copy_mode_entry;
1574 extern const struct cmd_entry cmd_delete_buffer_entry;
1575 extern const struct cmd_entry cmd_detach_client_entry;
1576 extern const struct cmd_entry cmd_display_message_entry;
1577 extern const struct cmd_entry cmd_display_panes_entry;
1578 extern const struct cmd_entry cmd_down_pane_entry;
1579 extern const struct cmd_entry cmd_find_window_entry;
1580 extern const struct cmd_entry cmd_has_session_entry;
1581 extern const struct cmd_entry cmd_if_shell_entry;
1582 extern const struct cmd_entry cmd_join_pane_entry;
1583 extern const struct cmd_entry cmd_kill_pane_entry;
1584 extern const struct cmd_entry cmd_kill_server_entry;
1585 extern const struct cmd_entry cmd_kill_session_entry;
1586 extern const struct cmd_entry cmd_kill_window_entry;
1587 extern const struct cmd_entry cmd_last_pane_entry;
1588 extern const struct cmd_entry cmd_last_window_entry;
1589 extern const struct cmd_entry cmd_link_window_entry;
1590 extern const struct cmd_entry cmd_list_buffers_entry;
1591 extern const struct cmd_entry cmd_list_clients_entry;
1592 extern const struct cmd_entry cmd_list_commands_entry;
1593 extern const struct cmd_entry cmd_list_keys_entry;
1594 extern const struct cmd_entry cmd_list_panes_entry;
1595 extern const struct cmd_entry cmd_list_sessions_entry;
1596 extern const struct cmd_entry cmd_list_windows_entry;
1597 extern const struct cmd_entry cmd_load_buffer_entry;
1598 extern const struct cmd_entry cmd_lock_client_entry;
1599 extern const struct cmd_entry cmd_lock_server_entry;
1600 extern const struct cmd_entry cmd_lock_session_entry;
1601 extern const struct cmd_entry cmd_move_window_entry;
1602 extern const struct cmd_entry cmd_new_session_entry;
1603 extern const struct cmd_entry cmd_new_window_entry;
1604 extern const struct cmd_entry cmd_next_layout_entry;
1605 extern const struct cmd_entry cmd_next_window_entry;
1606 extern const struct cmd_entry cmd_paste_buffer_entry;
1607 extern const struct cmd_entry cmd_pipe_pane_entry;
1608 extern const struct cmd_entry cmd_previous_layout_entry;
1609 extern const struct cmd_entry cmd_previous_window_entry;
1610 extern const struct cmd_entry cmd_refresh_client_entry;
1611 extern const struct cmd_entry cmd_rename_session_entry;
1612 extern const struct cmd_entry cmd_rename_window_entry;
1613 extern const struct cmd_entry cmd_resize_pane_entry;
1614 extern const struct cmd_entry cmd_respawn_pane_entry;
1615 extern const struct cmd_entry cmd_respawn_window_entry;
1616 extern const struct cmd_entry cmd_rotate_window_entry;
1617 extern const struct cmd_entry cmd_run_shell_entry;
1618 extern const struct cmd_entry cmd_save_buffer_entry;
1619 extern const struct cmd_entry cmd_select_layout_entry;
1620 extern const struct cmd_entry cmd_select_pane_entry;
1621 extern const struct cmd_entry cmd_select_window_entry;
1622 extern const struct cmd_entry cmd_send_keys_entry;
1623 extern const struct cmd_entry cmd_send_prefix_entry;
1624 extern const struct cmd_entry cmd_server_info_entry;
1625 extern const struct cmd_entry cmd_set_buffer_entry;
1626 extern const struct cmd_entry cmd_set_environment_entry;
1627 extern const struct cmd_entry cmd_set_option_entry;
1628 extern const struct cmd_entry cmd_set_window_option_entry;
1629 extern const struct cmd_entry cmd_show_buffer_entry;
1630 extern const struct cmd_entry cmd_show_environment_entry;
1631 extern const struct cmd_entry cmd_show_messages_entry;
1632 extern const struct cmd_entry cmd_show_options_entry;
1633 extern const struct cmd_entry cmd_show_window_options_entry;
1634 extern const struct cmd_entry cmd_source_file_entry;
1635 extern const struct cmd_entry cmd_split_window_entry;
1636 extern const struct cmd_entry cmd_start_server_entry;
1637 extern const struct cmd_entry cmd_suspend_client_entry;
1638 extern const struct cmd_entry cmd_swap_pane_entry;
1639 extern const struct cmd_entry cmd_swap_window_entry;
1640 extern const struct cmd_entry cmd_switch_client_entry;
1641 extern const struct cmd_entry cmd_unbind_key_entry;
1642 extern const struct cmd_entry cmd_unlink_window_entry;
1643 extern const struct cmd_entry cmd_up_pane_entry;
1645 /* cmd-list.c */
1646 struct cmd_list *cmd_list_parse(int, char **, char **);
1647 int cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
1648 void cmd_list_free(struct cmd_list *);
1649 size_t cmd_list_print(struct cmd_list *, char *, size_t);
1651 /* cmd-string.c */
1652 int cmd_string_parse(const char *, struct cmd_list **, char **);
1654 /* client.c */
1655 int client_main(int, char **, int);
1657 /* key-bindings.c */
1658 extern struct key_bindings key_bindings;
1659 int key_bindings_cmp(struct key_binding *, struct key_binding *);
1660 SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
1661 struct key_binding *key_bindings_lookup(int);
1662 void key_bindings_add(int, int, struct cmd_list *);
1663 void key_bindings_remove(int);
1664 void key_bindings_clean(void);
1665 void key_bindings_init(void);
1666 void key_bindings_dispatch(struct key_binding *, struct client *);
1667 void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
1668 void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
1669 void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
1671 /* key-string.c */
1672 int key_string_lookup_string(const char *);
1673 const char *key_string_lookup_key(int);
1675 /* server.c */
1676 extern struct clients clients;
1677 extern struct clients dead_clients;
1678 extern struct paste_stack global_buffers;
1679 int server_start(void);
1680 void server_update_socket(void);
1682 /* server-client.c */
1683 void server_client_create(int);
1684 void server_client_lost(struct client *);
1685 void server_client_callback(int, short, void *);
1686 void server_client_status_timer(void);
1687 void server_client_loop(void);
1689 /* server-window.c */
1690 void server_window_loop(void);
1692 /* server-fn.c */
1693 void server_fill_environ(struct session *, struct environ *);
1694 void server_write_client(
1695 struct client *, enum msgtype, const void *, size_t);
1696 void server_write_session(
1697 struct session *, enum msgtype, const void *, size_t);
1698 void server_redraw_client(struct client *);
1699 void server_status_client(struct client *);
1700 void server_redraw_session(struct session *);
1701 void server_redraw_session_group(struct session *);
1702 void server_status_session(struct session *);
1703 void server_status_session_group(struct session *);
1704 void server_redraw_window(struct window *);
1705 void server_redraw_window_borders(struct window *);
1706 void server_status_window(struct window *);
1707 void server_lock(void);
1708 void server_lock_session(struct session *);
1709 void server_lock_client(struct client *);
1710 int server_unlock(const char *);
1711 void server_kill_window(struct window *);
1712 int server_link_window(struct session *,
1713 struct winlink *, struct session *, int, int, int, char **);
1714 void server_unlink_window(struct session *, struct winlink *);
1715 void server_destroy_pane(struct window_pane *);
1716 void server_destroy_session_group(struct session *);
1717 void server_destroy_session(struct session *);
1718 void server_check_unattached (void);
1719 void server_set_identify(struct client *);
1720 void server_clear_identify(struct client *);
1721 void server_update_event(struct client *);
1723 /* status.c */
1724 int status_out_cmp(struct status_out *, struct status_out *);
1725 RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
1726 void status_free_jobs(struct status_out_tree *);
1727 void status_update_jobs(struct client *);
1728 void status_set_window_at(struct client *, u_int);
1729 int status_redraw(struct client *);
1730 char *status_replace(struct client *, struct session *,
1731 struct winlink *, struct window_pane *, const char *, time_t, int);
1732 void printflike2 status_message_set(struct client *, const char *, ...);
1733 void status_message_clear(struct client *);
1734 int status_message_redraw(struct client *);
1735 void status_prompt_set(struct client *, const char *, const char *,
1736 int (*)(void *, const char *), void (*)(void *), void *, int);
1737 void status_prompt_clear(struct client *);
1738 int status_prompt_redraw(struct client *);
1739 void status_prompt_key(struct client *, int);
1740 void status_prompt_update(struct client *, const char *, const char *);
1742 /* resize.c */
1743 void recalculate_sizes(void);
1745 /* input.c */
1746 void input_init(struct window_pane *);
1747 void input_free(struct window_pane *);
1748 void input_parse(struct window_pane *);
1750 /* input-key.c */
1751 void input_key(struct window_pane *, int);
1752 void input_mouse(struct window_pane *, struct mouse_event *);
1754 /* xterm-keys.c */
1755 char *xterm_keys_lookup(int);
1756 int xterm_keys_find(const char *, size_t, size_t *, int *);
1758 /* colour.c */
1759 void colour_set_fg(struct grid_cell *, int);
1760 void colour_set_bg(struct grid_cell *, int);
1761 const char *colour_tostring(int);
1762 int colour_fromstring(const char *);
1763 u_char colour_256to16(u_char);
1764 u_char colour_256to88(u_char);
1766 /* attributes.c */
1767 const char *attributes_tostring(u_char);
1768 int attributes_fromstring(const char *);
1770 /* grid.c */
1771 extern const struct grid_cell grid_default_cell;
1772 struct grid *grid_create(u_int, u_int, u_int);
1773 void grid_destroy(struct grid *);
1774 int grid_compare(struct grid *, struct grid *);
1775 void grid_collect_history(struct grid *);
1776 void grid_scroll_history(struct grid *);
1777 void grid_scroll_history_region(struct grid *, u_int, u_int);
1778 void grid_expand_line(struct grid *, u_int, u_int);
1779 void grid_expand_line_utf8(struct grid *, u_int, u_int);
1780 const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
1781 struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
1782 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
1783 const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
1784 struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
1785 void grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
1786 void grid_clear(struct grid *, u_int, u_int, u_int, u_int);
1787 void grid_clear_lines(struct grid *, u_int, u_int);
1788 void grid_move_lines(struct grid *, u_int, u_int, u_int);
1789 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1790 char *grid_string_cells(struct grid *, u_int, u_int, u_int);
1791 void grid_duplicate_lines(
1792 struct grid *, u_int, struct grid *, u_int, u_int);
1794 /* grid-utf8.c */
1795 size_t grid_utf8_size(const struct grid_utf8 *);
1796 size_t grid_utf8_copy(const struct grid_utf8 *, char *, size_t);
1797 void grid_utf8_set(struct grid_utf8 *, const struct utf8_data *);
1798 int grid_utf8_append(struct grid_utf8 *, const struct utf8_data *);
1799 int grid_utf8_compare(const struct grid_utf8 *, const struct grid_utf8 *);
1801 /* grid-view.c */
1802 const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
1803 struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
1804 void grid_view_set_cell(
1805 struct grid *, u_int, u_int, const struct grid_cell *);
1806 const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
1807 struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
1808 void grid_view_set_utf8(
1809 struct grid *, u_int, u_int, const struct grid_utf8 *);
1810 void grid_view_clear_history(struct grid *);
1811 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
1812 void grid_view_scroll_region_up(struct grid *, u_int, u_int);
1813 void grid_view_scroll_region_down(struct grid *, u_int, u_int);
1814 void grid_view_insert_lines(struct grid *, u_int, u_int);
1815 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1816 void grid_view_delete_lines(struct grid *, u_int, u_int);
1817 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1818 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
1819 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1820 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1822 /* screen-write.c */
1823 void screen_write_start(
1824 struct screen_write_ctx *, struct window_pane *, struct screen *);
1825 void screen_write_stop(struct screen_write_ctx *);
1826 void screen_write_reset(struct screen_write_ctx *);
1827 size_t printflike2 screen_write_cstrlen(int, const char *, ...);
1828 void printflike5 screen_write_cnputs(struct screen_write_ctx *,
1829 ssize_t, struct grid_cell *, int, const char *, ...);
1830 size_t printflike2 screen_write_strlen(int, const char *, ...);
1831 void printflike3 screen_write_puts(struct screen_write_ctx *,
1832 struct grid_cell *, const char *, ...);
1833 void printflike5 screen_write_nputs(struct screen_write_ctx *,
1834 ssize_t, struct grid_cell *, int, const char *, ...);
1835 void screen_write_vnputs(struct screen_write_ctx *,
1836 ssize_t, struct grid_cell *, int, const char *, va_list);
1837 void screen_write_parsestyle(
1838 struct grid_cell *, struct grid_cell *, const char *);
1839 void screen_write_putc(
1840 struct screen_write_ctx *, struct grid_cell *, u_char);
1841 void screen_write_copy(struct screen_write_ctx *,
1842 struct screen *, u_int, u_int, u_int, u_int);
1843 void screen_write_backspace(struct screen_write_ctx *);
1844 void screen_write_cursorup(struct screen_write_ctx *, u_int);
1845 void screen_write_cursordown(struct screen_write_ctx *, u_int);
1846 void screen_write_cursorright(struct screen_write_ctx *, u_int);
1847 void screen_write_cursorleft(struct screen_write_ctx *, u_int);
1848 void screen_write_alignmenttest(struct screen_write_ctx *);
1849 void screen_write_insertcharacter(struct screen_write_ctx *, u_int);
1850 void screen_write_deletecharacter(struct screen_write_ctx *, u_int);
1851 void screen_write_insertline(struct screen_write_ctx *, u_int);
1852 void screen_write_deleteline(struct screen_write_ctx *, u_int);
1853 void screen_write_clearline(struct screen_write_ctx *);
1854 void screen_write_clearendofline(struct screen_write_ctx *);
1855 void screen_write_clearstartofline(struct screen_write_ctx *);
1856 void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
1857 void screen_write_cursormode(struct screen_write_ctx *, int);
1858 void screen_write_reverseindex(struct screen_write_ctx *);
1859 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
1860 void screen_write_insertmode(struct screen_write_ctx *, int);
1861 void screen_write_utf8mousemode(struct screen_write_ctx *, int);
1862 void screen_write_mousemode_on(struct screen_write_ctx *, int);
1863 void screen_write_mousemode_off(struct screen_write_ctx *);
1864 void screen_write_linefeed(struct screen_write_ctx *, int);
1865 void screen_write_linefeedscreen(struct screen_write_ctx *, int);
1866 void screen_write_carriagereturn(struct screen_write_ctx *);
1867 void screen_write_kcursormode(struct screen_write_ctx *, int);
1868 void screen_write_kkeypadmode(struct screen_write_ctx *, int);
1869 void screen_write_clearendofscreen(struct screen_write_ctx *);
1870 void screen_write_clearstartofscreen(struct screen_write_ctx *);
1871 void screen_write_clearscreen(struct screen_write_ctx *);
1872 void screen_write_clearhistory(struct screen_write_ctx *);
1873 void screen_write_cell(struct screen_write_ctx *,
1874 const struct grid_cell *, const struct utf8_data *);
1875 void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
1876 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
1878 /* screen-redraw.c */
1879 void screen_redraw_screen(struct client *, int, int);
1880 void screen_redraw_pane(struct client *, struct window_pane *);
1882 /* screen.c */
1883 void screen_init(struct screen *, u_int, u_int, u_int);
1884 void screen_reinit(struct screen *);
1885 void screen_free(struct screen *);
1886 void screen_reset_tabs(struct screen *);
1887 void screen_set_cursor_style(struct screen *, u_int);
1888 void screen_set_cursor_colour(struct screen *, const char *);
1889 void screen_set_title(struct screen *, const char *);
1890 void screen_resize(struct screen *, u_int, u_int);
1891 void screen_set_selection(struct screen *,
1892 u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
1893 void screen_clear_selection(struct screen *);
1894 int screen_check_selection(struct screen *, u_int, u_int);
1896 /* window.c */
1897 extern struct windows windows;
1898 extern struct window_pane_tree all_window_panes;
1899 int winlink_cmp(struct winlink *, struct winlink *);
1900 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
1901 int window_pane_cmp(struct window_pane *, struct window_pane *);
1902 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
1903 struct winlink *winlink_find_by_index(struct winlinks *, int);
1904 struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
1905 int winlink_next_index(struct winlinks *, int);
1906 u_int winlink_count(struct winlinks *);
1907 struct winlink *winlink_add(struct winlinks *, int);
1908 void winlink_set_window(struct winlink *, struct window *);
1909 void winlink_remove(struct winlinks *, struct winlink *);
1910 struct winlink *winlink_next(struct winlink *);
1911 struct winlink *winlink_previous(struct winlink *);
1912 struct winlink *winlink_next_by_number(struct winlink *, struct session *,
1913 int);
1914 struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
1915 int);
1916 void winlink_stack_push(struct winlink_stack *, struct winlink *);
1917 void winlink_stack_remove(struct winlink_stack *, struct winlink *);
1918 int window_index(struct window *, u_int *);
1919 struct window *window_create1(u_int, u_int);
1920 struct window *window_create(const char *, const char *, const char *,
1921 const char *, struct environ *, struct termios *,
1922 u_int, u_int, u_int, char **);
1923 void window_destroy(struct window *);
1924 struct window_pane *window_get_active_at(struct window *, u_int, u_int);
1925 void window_set_active_at(struct window *, u_int, u_int);
1926 struct window_pane *window_find_string(struct window *, const char *);
1927 void window_set_active_pane(struct window *, struct window_pane *);
1928 struct window_pane *window_add_pane(struct window *, u_int);
1929 void window_resize(struct window *, u_int, u_int);
1930 void window_remove_pane(struct window *, struct window_pane *);
1931 struct window_pane *window_pane_at_index(struct window *, u_int);
1932 struct window_pane *window_pane_next_by_number(struct window *,
1933 struct window_pane *, u_int);
1934 struct window_pane *window_pane_previous_by_number(struct window *,
1935 struct window_pane *, u_int);
1936 int window_pane_index(struct window_pane *, u_int *);
1937 u_int window_count_panes(struct window *);
1938 void window_destroy_panes(struct window *);
1939 struct window_pane *window_pane_find_by_id(u_int);
1940 struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
1941 void window_pane_destroy(struct window_pane *);
1942 int window_pane_spawn(struct window_pane *, const char *,
1943 const char *, const char *, struct environ *,
1944 struct termios *, char **);
1945 void window_pane_resize(struct window_pane *, u_int, u_int);
1946 void window_pane_alternate_on(
1947 struct window_pane *, struct grid_cell *);
1948 void window_pane_alternate_off(
1949 struct window_pane *, struct grid_cell *);
1950 int window_pane_set_mode(
1951 struct window_pane *, const struct window_mode *);
1952 void window_pane_reset_mode(struct window_pane *);
1953 void window_pane_key(struct window_pane *, struct session *, int);
1954 void window_pane_mouse(struct window_pane *,
1955 struct session *, struct mouse_event *);
1956 int window_pane_visible(struct window_pane *);
1957 char *window_pane_search(
1958 struct window_pane *, const char *, u_int *);
1959 char *window_printable_flags(struct session *, struct winlink *);
1961 struct window_pane *window_pane_find_up(struct window_pane *);
1962 struct window_pane *window_pane_find_down(struct window_pane *);
1963 struct window_pane *window_pane_find_left(struct window_pane *);
1964 struct window_pane *window_pane_find_right(struct window_pane *);
1966 /* layout.c */
1967 u_int layout_count_cells(struct layout_cell *);
1968 struct layout_cell *layout_create_cell(struct layout_cell *);
1969 void layout_free_cell(struct layout_cell *);
1970 void layout_print_cell(struct layout_cell *, const char *, u_int);
1971 void layout_destroy_cell(struct layout_cell *, struct layout_cell **);
1972 void layout_set_size(
1973 struct layout_cell *, u_int, u_int, u_int, u_int);
1974 void layout_make_leaf(
1975 struct layout_cell *, struct window_pane *);
1976 void layout_make_node(struct layout_cell *, enum layout_type);
1977 void layout_fix_offsets(struct layout_cell *);
1978 void layout_fix_panes(struct window *, u_int, u_int);
1979 u_int layout_resize_check(struct layout_cell *, enum layout_type);
1980 void layout_resize_adjust(
1981 struct layout_cell *, enum layout_type, int);
1982 void layout_init(struct window *);
1983 void layout_free(struct window *);
1984 void layout_resize(struct window *, u_int, u_int);
1985 void layout_resize_pane(
1986 struct window_pane *, enum layout_type, int);
1987 void layout_resize_pane_mouse(
1988 struct client *c, struct mouse_event *mouse);
1989 void layout_assign_pane(struct layout_cell *, struct window_pane *);
1990 struct layout_cell *layout_split_pane(
1991 struct window_pane *, enum layout_type, int);
1992 void layout_close_pane(struct window_pane *);
1994 /* layout-custom.c */
1995 char *layout_dump(struct window *);
1996 int layout_parse(struct window *, const char *);
1998 /* layout-set.c */
1999 const char *layout_set_name(u_int);
2000 int layout_set_lookup(const char *);
2001 u_int layout_set_select(struct window *, u_int);
2002 u_int layout_set_next(struct window *);
2003 u_int layout_set_previous(struct window *);
2004 void layout_set_active_changed(struct window *);
2006 /* window-clock.c */
2007 extern const struct window_mode window_clock_mode;
2009 /* window-copy.c */
2010 extern const struct window_mode window_copy_mode;
2011 void window_copy_init_from_pane(struct window_pane *);
2012 void window_copy_init_for_output(struct window_pane *);
2013 void window_copy_add(struct window_pane *, const char *, ...);
2014 void window_copy_vadd(struct window_pane *, const char *, va_list);
2015 void window_copy_pageup(struct window_pane *);
2017 /* window-choose.c */
2018 extern const struct window_mode window_choose_mode;
2019 void window_choose_vadd(
2020 struct window_pane *, int, const char *, va_list);
2021 void printflike3 window_choose_add(
2022 struct window_pane *, int, const char *, ...);
2023 void window_choose_ready(struct window_pane *,
2024 u_int, void (*)(void *, int), void (*)(void *), void *);
2026 /* names.c */
2027 void queue_window_name(struct window *);
2028 char *default_window_name(struct window *);
2030 /* signal.c */
2031 void set_signals(void(*)(int, short, void *));
2032 void clear_signals(int);
2034 /* session.c */
2035 extern struct sessions sessions;
2036 extern struct sessions dead_sessions;
2037 extern struct session_groups session_groups;
2038 int session_cmp(struct session *, struct session *);
2039 RB_PROTOTYPE(sessions, session, entry, session_cmp);
2040 int session_alive(struct session *);
2041 struct session *session_find(const char *);
2042 struct session *session_find_by_index(u_int);
2043 struct session *session_create(const char *, const char *, const char *,
2044 struct environ *, struct termios *, int, u_int, u_int,
2045 char **);
2046 void session_destroy(struct session *);
2047 int session_check_name(const char *);
2048 void session_update_activity(struct session *);
2049 struct session *session_next_session(struct session *);
2050 struct session *session_previous_session(struct session *);
2051 struct winlink *session_new(struct session *,
2052 const char *, const char *, const char *, int, char **);
2053 struct winlink *session_attach(
2054 struct session *, struct window *, int, char **);
2055 int session_detach(struct session *, struct winlink *);
2056 struct winlink* session_has(struct session *, struct window *);
2057 int session_next(struct session *, int);
2058 int session_previous(struct session *, int);
2059 int session_select(struct session *, int);
2060 int session_last(struct session *);
2061 struct session_group *session_group_find(struct session *);
2062 u_int session_group_index(struct session_group *);
2063 void session_group_add(struct session *, struct session *);
2064 void session_group_remove(struct session *);
2065 void session_group_synchronize_to(struct session *);
2066 void session_group_synchronize_from(struct session *);
2067 void session_group_synchronize1(struct session *, struct session *);
2069 /* utf8.c */
2070 void utf8_build(void);
2071 int utf8_open(struct utf8_data *, u_char);
2072 int utf8_append(struct utf8_data *, u_char);
2073 u_int utf8_combine(const struct utf8_data *);
2074 u_int utf8_split2(u_int, u_char *);
2076 /* procname.c */
2077 char *get_proc_name(int, char *);
2078 char *get_proc_cwd(pid_t);
2080 /* log.c */
2081 void log_open_tty(int);
2082 void log_open_file(int, const char *);
2083 void log_close(void);
2084 void printflike1 log_warn(const char *, ...);
2085 void printflike1 log_warnx(const char *, ...);
2086 void printflike1 log_info(const char *, ...);
2087 void printflike1 log_debug(const char *, ...);
2088 void printflike1 log_debug2(const char *, ...);
2089 __dead void printflike1 log_fatal(const char *, ...);
2090 __dead void printflike1 log_fatalx(const char *, ...);
2092 /* xmalloc.c */
2093 char *xstrdup(const char *);
2094 void *xcalloc(size_t, size_t);
2095 void *xmalloc(size_t);
2096 void *xrealloc(void *, size_t, size_t);
2097 void xfree(void *);
2098 int printflike2 xasprintf(char **, const char *, ...);
2099 int xvasprintf(char **, const char *, va_list);
2100 int printflike3 xsnprintf(char *, size_t, const char *, ...);
2101 int xvsnprintf(char *, size_t, const char *, va_list);
2103 #endif /* TMUX_H */