Add strings to allow the aixterm bright colours to be used when
[tmux-openbsd.git] / tmux.h
blob617741d7093906bc9d66046718a2ae103cd405ad
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;
676 void *data;
678 void (*freefn)(void *);
680 SPLAY_ENTRY(options_entry) entry;
683 struct options {
684 SPLAY_HEAD(options_tree, options_entry) tree;
685 struct options *parent;
688 /* Key list for prefix option. */
689 ARRAY_DECL(keylist, int);
691 /* Scheduled job. */
692 struct job {
693 char *cmd;
694 pid_t pid;
695 int status;
697 int fd;
698 struct bufferevent *event;
700 void (*callbackfn)(struct job *);
701 void (*freefn)(void *);
702 void *data;
704 LIST_ENTRY(job) lentry;
706 LIST_HEAD(joblist, job);
708 /* Screen selection. */
709 struct screen_sel {
710 int flag;
711 int rectflag;
713 u_int sx;
714 u_int sy;
716 u_int ex;
717 u_int ey;
719 struct grid_cell cell;
722 /* Virtual screen. */
723 struct screen {
724 char *title;
726 struct grid *grid; /* grid data */
728 u_int cx; /* cursor x */
729 u_int cy; /* cursor y */
731 u_int cstyle; /* cursor style */
732 char *ccolour; /* cursor colour string */
734 u_int rupper; /* scroll region top */
735 u_int rlower; /* scroll region bottom */
737 int mode;
739 bitstr_t *tabs;
741 struct screen_sel sel;
744 /* Screen write context. */
745 struct screen_write_ctx {
746 struct window_pane *wp;
747 struct screen *s;
750 /* Screen size. */
751 #define screen_size_x(s) ((s)->grid->sx)
752 #define screen_size_y(s) ((s)->grid->sy)
753 #define screen_hsize(s) ((s)->grid->hsize)
754 #define screen_hlimit(s) ((s)->grid->hlimit)
756 /* Input parser context. */
757 struct input_ctx {
758 struct window_pane *wp;
759 struct screen_write_ctx ctx;
761 struct grid_cell cell;
763 struct grid_cell old_cell;
764 u_int old_cx;
765 u_int old_cy;
767 u_char interm_buf[4];
768 size_t interm_len;
770 u_char param_buf[64];
771 size_t param_len;
773 u_char input_buf[256];
774 size_t input_len;
776 int param_list[24]; /* -1 not present */
777 u_int param_list_len;
779 struct utf8_data utf8data;
781 int ch;
782 int flags;
783 #define INPUT_DISCARD 0x1
785 const struct input_state *state;
789 * Window mode. Windows can be in several modes and this is used to call the
790 * right function to handle input and output.
792 struct session;
793 struct window;
794 struct mouse_event;
795 struct window_mode {
796 struct screen *(*init)(struct window_pane *);
797 void (*free)(struct window_pane *);
798 void (*resize)(struct window_pane *, u_int, u_int);
799 void (*key)(struct window_pane *, struct session *, int);
800 void (*mouse)(struct window_pane *,
801 struct session *, struct mouse_event *);
802 void (*timer)(struct window_pane *);
805 /* Child window structure. */
806 struct window_pane {
807 u_int id;
809 struct window *window;
810 struct layout_cell *layout_cell;
812 u_int sx;
813 u_int sy;
815 u_int xoff;
816 u_int yoff;
818 int flags;
819 #define PANE_REDRAW 0x1
821 char *cmd;
822 char *shell;
823 char *cwd;
825 pid_t pid;
826 char tty[TTY_NAME_MAX];
828 int fd;
829 struct bufferevent *event;
831 struct input_ctx ictx;
833 int pipe_fd;
834 struct bufferevent *pipe_event;
835 size_t pipe_off;
837 struct screen *screen;
838 struct screen base;
840 /* Saved in alternative screen mode. */
841 u_int saved_cx;
842 u_int saved_cy;
843 struct grid *saved_grid;
844 struct grid_cell saved_cell;
846 const struct window_mode *mode;
847 void *modedata;
849 TAILQ_ENTRY(window_pane) entry;
850 RB_ENTRY(window_pane) tree_entry;
852 TAILQ_HEAD(window_panes, window_pane);
853 RB_HEAD(window_pane_tree, window_pane);
855 /* Window structure. */
856 struct window {
857 char *name;
858 struct event name_timer;
859 struct timeval silence_timer;
861 struct window_pane *active;
862 struct window_pane *last;
863 struct window_panes panes;
865 int lastlayout;
866 struct layout_cell *layout_root;
868 u_int sx;
869 u_int sy;
871 int flags;
872 #define WINDOW_BELL 0x1
873 #define WINDOW_ACTIVITY 0x2
874 #define WINDOW_REDRAW 0x4
875 #define WINDOW_SILENCE 0x8
877 struct options options;
879 u_int references;
881 ARRAY_DECL(windows, struct window *);
883 /* Entry on local window list. */
884 struct winlink {
885 int idx;
886 struct window *window;
888 size_t status_width;
889 struct grid_cell status_cell;
890 char *status_text;
892 int flags;
893 #define WINLINK_BELL 0x1
894 #define WINLINK_ACTIVITY 0x2
895 #define WINLINK_CONTENT 0x4
896 #define WINLINK_SILENCE 0x8
897 #define WINLINK_ALERTFLAGS \
898 (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
900 RB_ENTRY(winlink) entry;
901 TAILQ_ENTRY(winlink) sentry;
903 RB_HEAD(winlinks, winlink);
904 TAILQ_HEAD(winlink_stack, winlink);
906 /* Layout direction. */
907 enum layout_type {
908 LAYOUT_LEFTRIGHT,
909 LAYOUT_TOPBOTTOM,
910 LAYOUT_WINDOWPANE
913 /* Layout cells queue. */
914 TAILQ_HEAD(layout_cells, layout_cell);
916 /* Layout cell. */
917 struct layout_cell {
918 enum layout_type type;
920 struct layout_cell *parent;
922 u_int sx;
923 u_int sy;
925 u_int xoff;
926 u_int yoff;
928 struct window_pane *wp;
929 struct layout_cells cells;
931 TAILQ_ENTRY(layout_cell) entry;
934 /* Paste buffer. */
935 struct paste_buffer {
936 char *data;
937 size_t size;
939 ARRAY_DECL(paste_stack, struct paste_buffer *);
941 /* Environment variable. */
942 struct environ_entry {
943 char *name;
944 char *value;
946 RB_ENTRY(environ_entry) entry;
948 RB_HEAD(environ, environ_entry);
950 /* Client session. */
951 struct session_group {
952 TAILQ_HEAD(, session) sessions;
954 TAILQ_ENTRY(session_group) entry;
956 TAILQ_HEAD(session_groups, session_group);
958 struct session {
959 u_int idx;
961 char *name;
962 char *cwd;
964 struct timeval creation_time;
965 struct timeval activity_time;
967 u_int sx;
968 u_int sy;
970 struct winlink *curw;
971 struct winlink_stack lastw;
972 struct winlinks windows;
974 struct options options;
976 #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
977 int flags;
979 struct termios *tio;
981 struct environ environ;
983 int wlmouse;
985 int references;
987 TAILQ_ENTRY(session) gentry;
988 RB_ENTRY(session) entry;
990 RB_HEAD(sessions, session);
991 ARRAY_DECL(sessionslist, struct session *);
993 /* TTY information. */
994 struct tty_key {
995 char ch;
996 int key;
998 struct tty_key *left;
999 struct tty_key *right;
1001 struct tty_key *next;
1004 struct tty_term {
1005 char *name;
1006 u_int references;
1008 char acs[UCHAR_MAX + 1][2];
1010 struct tty_code codes[NTTYCODE];
1012 #define TERM_256COLOURS 0x1
1013 #define TERM_88COLOURS 0x2
1014 #define TERM_EARLYWRAP 0x4
1015 int flags;
1017 LIST_ENTRY(tty_term) entry;
1019 LIST_HEAD(tty_terms, tty_term);
1021 struct tty {
1022 char *path;
1024 u_int sx;
1025 u_int sy;
1027 u_int cx;
1028 u_int cy;
1029 u_int cstyle;
1030 char *ccolour;
1032 int mode;
1034 u_int rlower;
1035 u_int rupper;
1037 char *termname;
1038 struct tty_term *term;
1040 int fd;
1041 struct bufferevent *event;
1043 int log_fd;
1045 struct termios tio;
1047 struct grid_cell cell;
1049 #define TTY_NOCURSOR 0x1
1050 #define TTY_FREEZE 0x2
1051 #define TTY_ESCAPE 0x4
1052 #define TTY_UTF8 0x8
1053 #define TTY_STARTED 0x10
1054 #define TTY_OPENED 0x20
1055 #define TTY_BACKOFF 0x40
1056 int flags;
1058 int term_flags;
1060 void (*key_callback)(int, struct mouse_event *, void *);
1061 void *key_data;
1062 struct event key_timer;
1063 struct tty_key *key_tree;
1066 /* TTY command context and function pointer. */
1067 struct tty_ctx {
1068 struct window_pane *wp;
1070 const struct grid_cell *cell;
1071 const struct grid_utf8 *utf8;
1073 u_int num;
1074 void *ptr;
1077 * Cursor and region position before the screen was updated - this is
1078 * where the command should be applied; the values in the screen have
1079 * already been updated.
1081 u_int ocx;
1082 u_int ocy;
1084 u_int orupper;
1085 u_int orlower;
1087 /* Saved last cell on line. */
1088 struct grid_cell last_cell;
1089 struct grid_utf8 last_utf8;
1090 u_int last_width;
1094 * xterm mouse mode is fairly silly. Buttons are in the bottom two
1095 * bits: 0 button 1; 1 button 2; 2 button 3; 3 buttons released.
1097 * Bit 3 is shift; bit 4 is meta; bit 5 control.
1099 * Bit 6 is added for mouse buttons 4 and 5.
1101 /* Mouse input. */
1102 struct mouse_event {
1103 u_int b;
1104 #define MOUSE_1 0
1105 #define MOUSE_2 1
1106 #define MOUSE_3 2
1107 #define MOUSE_UP 3
1108 #define MOUSE_BUTTON 3
1109 #define MOUSE_DRAG 32
1110 #define MOUSE_45 64
1111 #define MOUSE_RESIZE_PANE 128 /* marker for resizing */
1112 u_int x;
1113 u_int y;
1116 /* Saved message entry. */
1117 struct message_entry {
1118 char *msg;
1119 time_t msg_time;
1122 /* Status output data from a job. */
1123 struct status_out {
1124 char *cmd;
1125 char *out;
1127 RB_ENTRY(status_out) entry;
1129 RB_HEAD(status_out_tree, status_out);
1131 /* Client connection. */
1132 struct client {
1133 struct imsgbuf ibuf;
1134 struct event event;
1135 int retcode;
1137 struct timeval creation_time;
1138 struct timeval activity_time;
1140 struct environ environ;
1142 char *title;
1143 char *cwd;
1145 struct tty tty;
1147 int stdin_fd;
1148 void *stdin_data;
1149 void (*stdin_callback)(struct client *, void *);
1150 struct bufferevent *stdin_event;
1152 int stdout_fd;
1153 struct bufferevent *stdout_event;
1155 int stderr_fd;
1156 struct bufferevent *stderr_event;
1158 struct event repeat_timer;
1160 struct status_out_tree status_old;
1161 struct status_out_tree status_new;
1162 struct timeval status_timer;
1163 struct screen status;
1165 #define CLIENT_TERMINAL 0x1
1166 #define CLIENT_PREFIX 0x2
1167 #define CLIENT_EXIT 0x4
1168 #define CLIENT_REDRAW 0x8
1169 #define CLIENT_STATUS 0x10
1170 #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
1171 #define CLIENT_SUSPENDED 0x40
1172 #define CLIENT_BAD 0x80
1173 #define CLIENT_IDENTIFY 0x100
1174 #define CLIENT_DEAD 0x200
1175 #define CLIENT_BORDERS 0x400
1176 #define CLIENT_READONLY 0x800
1177 #define CLIENT_BACKOFF 0x1000
1178 #define CLIENT_REDRAWWINDOW 0x2000
1179 int flags;
1181 struct event identify_timer;
1183 char *message_string;
1184 struct event message_timer;
1185 ARRAY_DECL(, struct message_entry) message_log;
1187 char *prompt_string;
1188 char *prompt_buffer;
1189 size_t prompt_index;
1190 int (*prompt_callbackfn)(void *, const char *);
1191 void (*prompt_freefn)(void *);
1192 void *prompt_data;
1193 u_int prompt_hindex;
1195 #define PROMPT_SINGLE 0x1
1196 int prompt_flags;
1198 struct mode_key_data prompt_mdata;
1200 struct session *session;
1201 struct session *last_session;
1203 struct mouse_event last_mouse;
1205 int references;
1207 ARRAY_DECL(clients, struct client *);
1209 /* Parsed arguments. */
1210 struct args {
1211 bitstr_t *flags;
1212 char *values[SCHAR_MAX]; /* XXX This is awfully big. */
1214 int argc;
1215 char **argv;
1218 /* Key/command line command. */
1219 struct cmd_ctx {
1221 * curclient is the client where this command was executed if inside
1222 * tmux. This is NULL if the command came from the command-line.
1224 * cmdclient is the client which sent the MSG_COMMAND to the server, if
1225 * any. This is NULL unless the command came from the command-line.
1227 * cmdclient and curclient may both be NULL if the command is in the
1228 * configuration file.
1230 struct client *curclient;
1231 struct client *cmdclient;
1233 struct msg_command_data *msgdata;
1235 /* gcc2 doesn't understand attributes on function pointers... */
1236 #if defined(__GNUC__) && __GNUC__ >= 3
1237 void printflike2 (*print)(struct cmd_ctx *, const char *, ...);
1238 void printflike2 (*info)(struct cmd_ctx *, const char *, ...);
1239 void printflike2 (*error)(struct cmd_ctx *, const char *, ...);
1240 #else
1241 void (*print)(struct cmd_ctx *, const char *, ...);
1242 void (*info)(struct cmd_ctx *, const char *, ...);
1243 void (*error)(struct cmd_ctx *, const char *, ...);
1244 #endif
1247 struct cmd {
1248 const struct cmd_entry *entry;
1249 struct args *args;
1251 TAILQ_ENTRY(cmd) qentry;
1253 struct cmd_list {
1254 int references;
1255 TAILQ_HEAD(, cmd) list;
1258 struct cmd_entry {
1259 const char *name;
1260 const char *alias;
1262 const char *args_template;
1263 int args_lower;
1264 int args_upper;
1266 const char *usage;
1268 #define CMD_STARTSERVER 0x1
1269 #define CMD_CANTNEST 0x2
1270 #define CMD_SENDENVIRON 0x4
1271 #define CMD_READONLY 0x8
1272 int flags;
1274 void (*key_binding)(struct cmd *, int);
1275 int (*check)(struct args *);
1276 int (*exec)(struct cmd *, struct cmd_ctx *);
1279 /* Key binding. */
1280 struct key_binding {
1281 int key;
1282 struct cmd_list *cmdlist;
1283 int can_repeat;
1285 SPLAY_ENTRY(key_binding) entry;
1287 SPLAY_HEAD(key_bindings, key_binding);
1290 * Option table entries. The option table is the user-visible part of the
1291 * option, as opposed to the internal options (struct option) which are just
1292 * number or string.
1294 enum options_table_type {
1295 OPTIONS_TABLE_STRING,
1296 OPTIONS_TABLE_NUMBER,
1297 OPTIONS_TABLE_KEYS,
1298 OPTIONS_TABLE_COLOUR,
1299 OPTIONS_TABLE_ATTRIBUTES,
1300 OPTIONS_TABLE_FLAG,
1301 OPTIONS_TABLE_CHOICE
1304 struct options_table_entry {
1305 const char *name;
1306 enum options_table_type type;
1308 u_int minimum;
1309 u_int maximum;
1310 const char **choices;
1312 const char *default_str;
1313 long long default_num;
1316 /* Tree of format entries. */
1317 struct format_entry {
1318 char *key;
1319 char *value;
1321 RB_ENTRY(format_entry) entry;
1323 RB_HEAD(format_tree, format_entry);
1325 /* List of configuration causes. */
1326 ARRAY_DECL(causelist, char *);
1328 /* Common command usages. */
1329 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1330 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1331 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1332 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1333 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1334 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1335 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1336 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1337 #define CMD_BUFFER_USAGE "[-b buffer-index]"
1339 /* tmux.c */
1340 extern struct options global_options;
1341 extern struct options global_s_options;
1342 extern struct options global_w_options;
1343 extern struct environ global_environ;
1344 extern struct event_base *ev_base;
1345 extern char *cfg_file;
1346 extern char *shell_cmd;
1347 extern int debug_level;
1348 extern time_t start_time;
1349 extern char socket_path[MAXPATHLEN];
1350 extern int login_shell;
1351 extern char *environ_path;
1352 extern pid_t environ_pid;
1353 extern int environ_idx;
1354 void logfile(const char *);
1355 const char *getshell(void);
1356 int checkshell(const char *);
1357 int areshell(const char *);
1358 const char* get_full_path(const char *, const char *);
1359 void setblocking(int, int);
1360 __dead void shell_exec(const char *, const char *);
1362 /* cfg.c */
1363 extern int cfg_finished;
1364 extern struct causelist cfg_causes;
1365 void printflike2 cfg_add_cause(struct causelist *, const char *, ...);
1366 int load_cfg(const char *, struct cmd_ctx *, struct causelist *);
1368 /* format.c */
1369 int format_cmp(struct format_entry *, struct format_entry *);
1370 RB_PROTOTYPE(format_tree, format_entry, entry, format_cmp);
1371 struct format_tree *format_create(void);
1372 void format_free(struct format_tree *);
1373 void format_add(
1374 struct format_tree *, const char *, const char *, ...);
1375 const char *format_find(struct format_tree *, const char *);
1376 char *format_expand(struct format_tree *, const char *);
1377 void format_session(struct format_tree *, struct session *);
1378 void format_client(struct format_tree *, struct client *);
1379 void format_winlink(
1380 struct format_tree *, struct session *, struct winlink *);
1381 void format_window_pane(struct format_tree *, struct window_pane *);
1383 /* mode-key.c */
1384 extern const struct mode_key_table mode_key_tables[];
1385 extern struct mode_key_tree mode_key_tree_vi_edit;
1386 extern struct mode_key_tree mode_key_tree_vi_choice;
1387 extern struct mode_key_tree mode_key_tree_vi_copy;
1388 extern struct mode_key_tree mode_key_tree_emacs_edit;
1389 extern struct mode_key_tree mode_key_tree_emacs_choice;
1390 extern struct mode_key_tree mode_key_tree_emacs_copy;
1391 int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
1392 SPLAY_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
1393 const char *mode_key_tostring(const struct mode_key_cmdstr *,
1394 enum mode_key_cmd);
1395 enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
1396 const char *);
1397 const struct mode_key_table *mode_key_findtable(const char *);
1398 void mode_key_init_trees(void);
1399 void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
1400 enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
1402 /* options.c */
1403 int options_cmp(struct options_entry *, struct options_entry *);
1404 SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
1405 void options_init(struct options *, struct options *);
1406 void options_free(struct options *);
1407 struct options_entry *options_find1(struct options *, const char *);
1408 struct options_entry *options_find(struct options *, const char *);
1409 void options_remove(struct options *, const char *);
1410 struct options_entry *printflike3 options_set_string(
1411 struct options *, const char *, const char *, ...);
1412 char *options_get_string(struct options *, const char *);
1413 struct options_entry *options_set_number(
1414 struct options *, const char *, long long);
1415 long long options_get_number(struct options *, const char *);
1416 struct options_entry *options_set_data(
1417 struct options *, const char *, void *, void (*)(void *));
1418 void *options_get_data(struct options *, const char *);
1420 /* options-table.c */
1421 extern const struct options_table_entry server_options_table[];
1422 extern const struct options_table_entry session_options_table[];
1423 extern const struct options_table_entry window_options_table[];
1424 void options_table_populate_tree(
1425 const struct options_table_entry *, struct options *);
1426 const char *options_table_print_entry(
1427 const struct options_table_entry *, struct options_entry *);
1429 /* job.c */
1430 extern struct joblist all_jobs;
1431 struct job *job_run(
1432 const char *, void (*)(struct job *), void (*)(void *), void *);
1433 void job_free(struct job *);
1434 void job_died(struct job *, int);
1436 /* environ.c */
1437 int environ_cmp(struct environ_entry *, struct environ_entry *);
1438 RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp);
1439 void environ_init(struct environ *);
1440 void environ_free(struct environ *);
1441 void environ_copy(struct environ *, struct environ *);
1442 struct environ_entry *environ_find(struct environ *, const char *);
1443 void environ_set(struct environ *, const char *, const char *);
1444 void environ_put(struct environ *, const char *);
1445 void environ_unset(struct environ *, const char *);
1446 void environ_update(const char *, struct environ *, struct environ *);
1447 void environ_push(struct environ *);
1449 /* tty.c */
1450 void tty_raw(struct tty *, const char *);
1451 void tty_attributes(struct tty *, const struct grid_cell *);
1452 void tty_reset(struct tty *);
1453 void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1454 void tty_region(struct tty *, u_int, u_int);
1455 void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1456 void tty_cursor(struct tty *, u_int, u_int);
1457 void tty_putcode(struct tty *, enum tty_code_code);
1458 void tty_putcode1(struct tty *, enum tty_code_code, int);
1459 void tty_putcode2(struct tty *, enum tty_code_code, int, int);
1460 void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
1461 void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const void *);
1462 void tty_puts(struct tty *, const char *);
1463 void tty_putc(struct tty *, u_char);
1464 void tty_pututf8(struct tty *, const struct grid_utf8 *);
1465 void tty_init(struct tty *, int, char *);
1466 int tty_resize(struct tty *);
1467 void tty_start_tty(struct tty *);
1468 void tty_stop_tty(struct tty *);
1469 void tty_set_title(struct tty *, const char *);
1470 void tty_update_mode(struct tty *, int, struct screen *);
1471 void tty_force_cursor_colour(struct tty *, const char *);
1472 void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
1473 int tty_open(struct tty *, const char *, char **);
1474 void tty_close(struct tty *);
1475 void tty_free(struct tty *);
1476 void tty_write(void (*)(
1477 struct tty *, const struct tty_ctx *), const struct tty_ctx *);
1478 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
1479 void tty_cmd_cell(struct tty *, const struct tty_ctx *);
1480 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
1481 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
1482 void tty_cmd_clearline(struct tty *, const struct tty_ctx *);
1483 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
1484 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
1485 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
1486 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
1487 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
1488 void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *);
1489 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
1490 void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
1491 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
1492 void tty_cmd_utf8character(struct tty *, const struct tty_ctx *);
1493 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
1494 void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
1495 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
1496 void tty_bell(struct tty *);
1498 /* tty-term.c */
1499 extern struct tty_terms tty_terms;
1500 extern const struct tty_term_code_entry tty_term_codes[NTTYCODE];
1501 struct tty_term *tty_term_find(char *, int, const char *, char **);
1502 void tty_term_free(struct tty_term *);
1503 int tty_term_has(struct tty_term *, enum tty_code_code);
1504 const char *tty_term_string(struct tty_term *, enum tty_code_code);
1505 const char *tty_term_string1(struct tty_term *, enum tty_code_code, int);
1506 const char *tty_term_string2(
1507 struct tty_term *, enum tty_code_code, int, int);
1508 const char *tty_term_ptr1(
1509 struct tty_term *, enum tty_code_code, const void *);
1510 const char *tty_term_ptr2(
1511 struct tty_term *, enum tty_code_code, const void *, const void *);
1512 int tty_term_number(struct tty_term *, enum tty_code_code);
1513 int tty_term_flag(struct tty_term *, enum tty_code_code);
1515 /* tty-acs.c */
1516 const char *tty_acs_get(struct tty *, u_char);
1518 /* tty-keys.c */
1519 void tty_keys_init(struct tty *);
1520 void tty_keys_free(struct tty *);
1521 int tty_keys_next(struct tty *);
1523 /* paste.c */
1524 struct paste_buffer *paste_walk_stack(struct paste_stack *, u_int *);
1525 struct paste_buffer *paste_get_top(struct paste_stack *);
1526 struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
1527 int paste_free_top(struct paste_stack *);
1528 int paste_free_index(struct paste_stack *, u_int);
1529 void paste_add(struct paste_stack *, char *, size_t, u_int);
1530 int paste_replace(struct paste_stack *, u_int, char *, size_t);
1531 char *paste_print(struct paste_buffer *, size_t);
1533 /* clock.c */
1534 extern const char clock_table[14][5][5];
1535 void clock_draw(struct screen_write_ctx *, int, int);
1537 /* arguments.c */
1538 struct args *args_create(int, ...);
1539 struct args *args_parse(const char *, int, char **);
1540 void args_free(struct args *);
1541 size_t args_print(struct args *, char *, size_t);
1542 int args_has(struct args *, u_char);
1543 void args_set(struct args *, u_char, const char *);
1544 const char *args_get(struct args *, u_char);
1545 long long args_strtonum(
1546 struct args *, u_char, long long, long long, char **);
1548 /* cmd.c */
1549 int cmd_pack_argv(int, char **, char *, size_t);
1550 int cmd_unpack_argv(char *, size_t, int, char ***);
1551 char **cmd_copy_argv(int, char *const *);
1552 void cmd_free_argv(int, char **);
1553 struct cmd *cmd_parse(int, char **, char **);
1554 int cmd_exec(struct cmd *, struct cmd_ctx *);
1555 void cmd_free(struct cmd *);
1556 size_t cmd_print(struct cmd *, char *, size_t);
1557 struct session *cmd_current_session(struct cmd_ctx *, int);
1558 struct client *cmd_current_client(struct cmd_ctx *);
1559 struct client *cmd_find_client(struct cmd_ctx *, const char *);
1560 struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
1561 struct winlink *cmd_find_window(
1562 struct cmd_ctx *, const char *, struct session **);
1563 int cmd_find_index(
1564 struct cmd_ctx *, const char *, struct session **);
1565 struct winlink *cmd_find_pane(struct cmd_ctx *,
1566 const char *, struct session **, struct window_pane **);
1567 char *cmd_template_replace(char *, const char *, int);
1568 const char *cmd_get_default_path(struct cmd_ctx *ctx);
1569 extern const struct cmd_entry *cmd_table[];
1570 extern const struct cmd_entry cmd_attach_session_entry;
1571 extern const struct cmd_entry cmd_bind_key_entry;
1572 extern const struct cmd_entry cmd_break_pane_entry;
1573 extern const struct cmd_entry cmd_capture_pane_entry;
1574 extern const struct cmd_entry cmd_choose_buffer_entry;
1575 extern const struct cmd_entry cmd_choose_client_entry;
1576 extern const struct cmd_entry cmd_choose_session_entry;
1577 extern const struct cmd_entry cmd_choose_window_entry;
1578 extern const struct cmd_entry cmd_clear_history_entry;
1579 extern const struct cmd_entry cmd_clock_mode_entry;
1580 extern const struct cmd_entry cmd_command_prompt_entry;
1581 extern const struct cmd_entry cmd_confirm_before_entry;
1582 extern const struct cmd_entry cmd_copy_mode_entry;
1583 extern const struct cmd_entry cmd_delete_buffer_entry;
1584 extern const struct cmd_entry cmd_detach_client_entry;
1585 extern const struct cmd_entry cmd_display_message_entry;
1586 extern const struct cmd_entry cmd_display_panes_entry;
1587 extern const struct cmd_entry cmd_down_pane_entry;
1588 extern const struct cmd_entry cmd_find_window_entry;
1589 extern const struct cmd_entry cmd_has_session_entry;
1590 extern const struct cmd_entry cmd_if_shell_entry;
1591 extern const struct cmd_entry cmd_join_pane_entry;
1592 extern const struct cmd_entry cmd_kill_pane_entry;
1593 extern const struct cmd_entry cmd_kill_server_entry;
1594 extern const struct cmd_entry cmd_kill_session_entry;
1595 extern const struct cmd_entry cmd_kill_window_entry;
1596 extern const struct cmd_entry cmd_last_pane_entry;
1597 extern const struct cmd_entry cmd_last_window_entry;
1598 extern const struct cmd_entry cmd_link_window_entry;
1599 extern const struct cmd_entry cmd_list_buffers_entry;
1600 extern const struct cmd_entry cmd_list_clients_entry;
1601 extern const struct cmd_entry cmd_list_commands_entry;
1602 extern const struct cmd_entry cmd_list_keys_entry;
1603 extern const struct cmd_entry cmd_list_panes_entry;
1604 extern const struct cmd_entry cmd_list_sessions_entry;
1605 extern const struct cmd_entry cmd_list_windows_entry;
1606 extern const struct cmd_entry cmd_load_buffer_entry;
1607 extern const struct cmd_entry cmd_lock_client_entry;
1608 extern const struct cmd_entry cmd_lock_server_entry;
1609 extern const struct cmd_entry cmd_lock_session_entry;
1610 extern const struct cmd_entry cmd_move_window_entry;
1611 extern const struct cmd_entry cmd_new_session_entry;
1612 extern const struct cmd_entry cmd_new_window_entry;
1613 extern const struct cmd_entry cmd_next_layout_entry;
1614 extern const struct cmd_entry cmd_next_window_entry;
1615 extern const struct cmd_entry cmd_paste_buffer_entry;
1616 extern const struct cmd_entry cmd_pipe_pane_entry;
1617 extern const struct cmd_entry cmd_previous_layout_entry;
1618 extern const struct cmd_entry cmd_previous_window_entry;
1619 extern const struct cmd_entry cmd_refresh_client_entry;
1620 extern const struct cmd_entry cmd_rename_session_entry;
1621 extern const struct cmd_entry cmd_rename_window_entry;
1622 extern const struct cmd_entry cmd_resize_pane_entry;
1623 extern const struct cmd_entry cmd_respawn_pane_entry;
1624 extern const struct cmd_entry cmd_respawn_window_entry;
1625 extern const struct cmd_entry cmd_rotate_window_entry;
1626 extern const struct cmd_entry cmd_run_shell_entry;
1627 extern const struct cmd_entry cmd_save_buffer_entry;
1628 extern const struct cmd_entry cmd_select_layout_entry;
1629 extern const struct cmd_entry cmd_select_pane_entry;
1630 extern const struct cmd_entry cmd_select_window_entry;
1631 extern const struct cmd_entry cmd_send_keys_entry;
1632 extern const struct cmd_entry cmd_send_prefix_entry;
1633 extern const struct cmd_entry cmd_server_info_entry;
1634 extern const struct cmd_entry cmd_set_buffer_entry;
1635 extern const struct cmd_entry cmd_set_environment_entry;
1636 extern const struct cmd_entry cmd_set_option_entry;
1637 extern const struct cmd_entry cmd_set_window_option_entry;
1638 extern const struct cmd_entry cmd_show_buffer_entry;
1639 extern const struct cmd_entry cmd_show_environment_entry;
1640 extern const struct cmd_entry cmd_show_messages_entry;
1641 extern const struct cmd_entry cmd_show_options_entry;
1642 extern const struct cmd_entry cmd_show_window_options_entry;
1643 extern const struct cmd_entry cmd_source_file_entry;
1644 extern const struct cmd_entry cmd_split_window_entry;
1645 extern const struct cmd_entry cmd_start_server_entry;
1646 extern const struct cmd_entry cmd_suspend_client_entry;
1647 extern const struct cmd_entry cmd_swap_pane_entry;
1648 extern const struct cmd_entry cmd_swap_window_entry;
1649 extern const struct cmd_entry cmd_switch_client_entry;
1650 extern const struct cmd_entry cmd_unbind_key_entry;
1651 extern const struct cmd_entry cmd_unlink_window_entry;
1652 extern const struct cmd_entry cmd_up_pane_entry;
1654 /* cmd-list.c */
1655 struct cmd_list *cmd_list_parse(int, char **, char **);
1656 int cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
1657 void cmd_list_free(struct cmd_list *);
1658 size_t cmd_list_print(struct cmd_list *, char *, size_t);
1660 /* cmd-string.c */
1661 int cmd_string_parse(const char *, struct cmd_list **, char **);
1663 /* client.c */
1664 int client_main(int, char **, int);
1666 /* key-bindings.c */
1667 extern struct key_bindings key_bindings;
1668 int key_bindings_cmp(struct key_binding *, struct key_binding *);
1669 SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
1670 struct key_binding *key_bindings_lookup(int);
1671 void key_bindings_add(int, int, struct cmd_list *);
1672 void key_bindings_remove(int);
1673 void key_bindings_clean(void);
1674 void key_bindings_init(void);
1675 void key_bindings_dispatch(struct key_binding *, struct client *);
1676 void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
1677 void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
1678 void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
1680 /* key-string.c */
1681 int key_string_lookup_string(const char *);
1682 const char *key_string_lookup_key(int);
1684 /* server.c */
1685 extern struct clients clients;
1686 extern struct clients dead_clients;
1687 extern struct paste_stack global_buffers;
1688 int server_start(void);
1689 void server_update_socket(void);
1691 /* server-client.c */
1692 void server_client_create(int);
1693 void server_client_lost(struct client *);
1694 void server_client_callback(int, short, void *);
1695 void server_client_status_timer(void);
1696 void server_client_loop(void);
1698 /* server-window.c */
1699 void server_window_loop(void);
1701 /* server-fn.c */
1702 void server_fill_environ(struct session *, struct environ *);
1703 void server_write_client(
1704 struct client *, enum msgtype, const void *, size_t);
1705 void server_write_session(
1706 struct session *, enum msgtype, const void *, size_t);
1707 void server_redraw_client(struct client *);
1708 void server_status_client(struct client *);
1709 void server_redraw_session(struct session *);
1710 void server_redraw_session_group(struct session *);
1711 void server_status_session(struct session *);
1712 void server_status_session_group(struct session *);
1713 void server_redraw_window(struct window *);
1714 void server_redraw_window_borders(struct window *);
1715 void server_status_window(struct window *);
1716 void server_lock(void);
1717 void server_lock_session(struct session *);
1718 void server_lock_client(struct client *);
1719 int server_unlock(const char *);
1720 void server_kill_window(struct window *);
1721 int server_link_window(struct session *,
1722 struct winlink *, struct session *, int, int, int, char **);
1723 void server_unlink_window(struct session *, struct winlink *);
1724 void server_destroy_pane(struct window_pane *);
1725 void server_destroy_session_group(struct session *);
1726 void server_destroy_session(struct session *);
1727 void server_check_unattached (void);
1728 void server_set_identify(struct client *);
1729 void server_clear_identify(struct client *);
1730 void server_update_event(struct client *);
1732 /* status.c */
1733 int status_out_cmp(struct status_out *, struct status_out *);
1734 RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
1735 void status_free_jobs(struct status_out_tree *);
1736 void status_update_jobs(struct client *);
1737 void status_set_window_at(struct client *, u_int);
1738 int status_redraw(struct client *);
1739 char *status_replace(struct client *, struct session *,
1740 struct winlink *, struct window_pane *, const char *, time_t, int);
1741 void printflike2 status_message_set(struct client *, const char *, ...);
1742 void status_message_clear(struct client *);
1743 int status_message_redraw(struct client *);
1744 void status_prompt_set(struct client *, const char *, const char *,
1745 int (*)(void *, const char *), void (*)(void *), void *, int);
1746 void status_prompt_clear(struct client *);
1747 int status_prompt_redraw(struct client *);
1748 void status_prompt_key(struct client *, int);
1749 void status_prompt_update(struct client *, const char *, const char *);
1751 /* resize.c */
1752 void recalculate_sizes(void);
1754 /* input.c */
1755 void input_init(struct window_pane *);
1756 void input_free(struct window_pane *);
1757 void input_parse(struct window_pane *);
1759 /* input-key.c */
1760 void input_key(struct window_pane *, int);
1761 void input_mouse(struct window_pane *, struct mouse_event *);
1763 /* xterm-keys.c */
1764 char *xterm_keys_lookup(int);
1765 int xterm_keys_find(const char *, size_t, size_t *, int *);
1767 /* colour.c */
1768 void colour_set_fg(struct grid_cell *, int);
1769 void colour_set_bg(struct grid_cell *, int);
1770 const char *colour_tostring(int);
1771 int colour_fromstring(const char *);
1772 u_char colour_256to16(u_char);
1773 u_char colour_256to88(u_char);
1775 /* attributes.c */
1776 const char *attributes_tostring(u_char);
1777 int attributes_fromstring(const char *);
1779 /* grid.c */
1780 extern const struct grid_cell grid_default_cell;
1781 struct grid *grid_create(u_int, u_int, u_int);
1782 void grid_destroy(struct grid *);
1783 int grid_compare(struct grid *, struct grid *);
1784 void grid_collect_history(struct grid *);
1785 void grid_scroll_history(struct grid *);
1786 void grid_scroll_history_region(struct grid *, u_int, u_int);
1787 void grid_expand_line(struct grid *, u_int, u_int);
1788 void grid_expand_line_utf8(struct grid *, u_int, u_int);
1789 const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
1790 struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
1791 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
1792 const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
1793 struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
1794 void grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
1795 void grid_clear(struct grid *, u_int, u_int, u_int, u_int);
1796 void grid_clear_lines(struct grid *, u_int, u_int);
1797 void grid_move_lines(struct grid *, u_int, u_int, u_int);
1798 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1799 char *grid_string_cells(struct grid *, u_int, u_int, u_int);
1800 void grid_duplicate_lines(
1801 struct grid *, u_int, struct grid *, u_int, u_int);
1803 /* grid-utf8.c */
1804 size_t grid_utf8_size(const struct grid_utf8 *);
1805 size_t grid_utf8_copy(const struct grid_utf8 *, char *, size_t);
1806 void grid_utf8_set(struct grid_utf8 *, const struct utf8_data *);
1807 int grid_utf8_append(struct grid_utf8 *, const struct utf8_data *);
1808 int grid_utf8_compare(const struct grid_utf8 *, const struct grid_utf8 *);
1810 /* grid-view.c */
1811 const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
1812 struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
1813 void grid_view_set_cell(
1814 struct grid *, u_int, u_int, const struct grid_cell *);
1815 const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
1816 struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
1817 void grid_view_set_utf8(
1818 struct grid *, u_int, u_int, const struct grid_utf8 *);
1819 void grid_view_clear_history(struct grid *);
1820 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
1821 void grid_view_scroll_region_up(struct grid *, u_int, u_int);
1822 void grid_view_scroll_region_down(struct grid *, u_int, u_int);
1823 void grid_view_insert_lines(struct grid *, u_int, u_int);
1824 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1825 void grid_view_delete_lines(struct grid *, u_int, u_int);
1826 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1827 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
1828 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1829 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1831 /* screen-write.c */
1832 void screen_write_start(
1833 struct screen_write_ctx *, struct window_pane *, struct screen *);
1834 void screen_write_stop(struct screen_write_ctx *);
1835 void screen_write_reset(struct screen_write_ctx *);
1836 size_t printflike2 screen_write_cstrlen(int, const char *, ...);
1837 void printflike5 screen_write_cnputs(struct screen_write_ctx *,
1838 ssize_t, struct grid_cell *, int, const char *, ...);
1839 size_t printflike2 screen_write_strlen(int, const char *, ...);
1840 void printflike3 screen_write_puts(struct screen_write_ctx *,
1841 struct grid_cell *, const char *, ...);
1842 void printflike5 screen_write_nputs(struct screen_write_ctx *,
1843 ssize_t, struct grid_cell *, int, const char *, ...);
1844 void screen_write_vnputs(struct screen_write_ctx *,
1845 ssize_t, struct grid_cell *, int, const char *, va_list);
1846 void screen_write_parsestyle(
1847 struct grid_cell *, struct grid_cell *, const char *);
1848 void screen_write_putc(
1849 struct screen_write_ctx *, struct grid_cell *, u_char);
1850 void screen_write_copy(struct screen_write_ctx *,
1851 struct screen *, u_int, u_int, u_int, u_int);
1852 void screen_write_backspace(struct screen_write_ctx *);
1853 void screen_write_cursorup(struct screen_write_ctx *, u_int);
1854 void screen_write_cursordown(struct screen_write_ctx *, u_int);
1855 void screen_write_cursorright(struct screen_write_ctx *, u_int);
1856 void screen_write_cursorleft(struct screen_write_ctx *, u_int);
1857 void screen_write_alignmenttest(struct screen_write_ctx *);
1858 void screen_write_insertcharacter(struct screen_write_ctx *, u_int);
1859 void screen_write_deletecharacter(struct screen_write_ctx *, u_int);
1860 void screen_write_insertline(struct screen_write_ctx *, u_int);
1861 void screen_write_deleteline(struct screen_write_ctx *, u_int);
1862 void screen_write_clearline(struct screen_write_ctx *);
1863 void screen_write_clearendofline(struct screen_write_ctx *);
1864 void screen_write_clearstartofline(struct screen_write_ctx *);
1865 void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
1866 void screen_write_cursormode(struct screen_write_ctx *, int);
1867 void screen_write_reverseindex(struct screen_write_ctx *);
1868 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
1869 void screen_write_insertmode(struct screen_write_ctx *, int);
1870 void screen_write_utf8mousemode(struct screen_write_ctx *, int);
1871 void screen_write_mousemode_on(struct screen_write_ctx *, int);
1872 void screen_write_mousemode_off(struct screen_write_ctx *);
1873 void screen_write_linefeed(struct screen_write_ctx *, int);
1874 void screen_write_linefeedscreen(struct screen_write_ctx *, int);
1875 void screen_write_carriagereturn(struct screen_write_ctx *);
1876 void screen_write_kcursormode(struct screen_write_ctx *, int);
1877 void screen_write_kkeypadmode(struct screen_write_ctx *, int);
1878 void screen_write_clearendofscreen(struct screen_write_ctx *);
1879 void screen_write_clearstartofscreen(struct screen_write_ctx *);
1880 void screen_write_clearscreen(struct screen_write_ctx *);
1881 void screen_write_clearhistory(struct screen_write_ctx *);
1882 void screen_write_cell(struct screen_write_ctx *,
1883 const struct grid_cell *, const struct utf8_data *);
1884 void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
1885 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
1887 /* screen-redraw.c */
1888 void screen_redraw_screen(struct client *, int, int);
1889 void screen_redraw_pane(struct client *, struct window_pane *);
1891 /* screen.c */
1892 void screen_init(struct screen *, u_int, u_int, u_int);
1893 void screen_reinit(struct screen *);
1894 void screen_free(struct screen *);
1895 void screen_reset_tabs(struct screen *);
1896 void screen_set_cursor_style(struct screen *, u_int);
1897 void screen_set_cursor_colour(struct screen *, const char *);
1898 void screen_set_title(struct screen *, const char *);
1899 void screen_resize(struct screen *, u_int, u_int);
1900 void screen_set_selection(struct screen *,
1901 u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
1902 void screen_clear_selection(struct screen *);
1903 int screen_check_selection(struct screen *, u_int, u_int);
1905 /* window.c */
1906 extern struct windows windows;
1907 extern struct window_pane_tree all_window_panes;
1908 int winlink_cmp(struct winlink *, struct winlink *);
1909 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
1910 int window_pane_cmp(struct window_pane *, struct window_pane *);
1911 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
1912 struct winlink *winlink_find_by_index(struct winlinks *, int);
1913 struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
1914 int winlink_next_index(struct winlinks *, int);
1915 u_int winlink_count(struct winlinks *);
1916 struct winlink *winlink_add(struct winlinks *, int);
1917 void winlink_set_window(struct winlink *, struct window *);
1918 void winlink_remove(struct winlinks *, struct winlink *);
1919 struct winlink *winlink_next(struct winlink *);
1920 struct winlink *winlink_previous(struct winlink *);
1921 struct winlink *winlink_next_by_number(struct winlink *, struct session *,
1922 int);
1923 struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
1924 int);
1925 void winlink_stack_push(struct winlink_stack *, struct winlink *);
1926 void winlink_stack_remove(struct winlink_stack *, struct winlink *);
1927 int window_index(struct window *, u_int *);
1928 struct window *window_create1(u_int, u_int);
1929 struct window *window_create(const char *, const char *, const char *,
1930 const char *, struct environ *, struct termios *,
1931 u_int, u_int, u_int, char **);
1932 void window_destroy(struct window *);
1933 struct window_pane *window_get_active_at(struct window *, u_int, u_int);
1934 void window_set_active_at(struct window *, u_int, u_int);
1935 struct window_pane *window_find_string(struct window *, const char *);
1936 void window_set_active_pane(struct window *, struct window_pane *);
1937 struct window_pane *window_add_pane(struct window *, u_int);
1938 void window_resize(struct window *, u_int, u_int);
1939 void window_remove_pane(struct window *, struct window_pane *);
1940 struct window_pane *window_pane_at_index(struct window *, u_int);
1941 struct window_pane *window_pane_next_by_number(struct window *,
1942 struct window_pane *, u_int);
1943 struct window_pane *window_pane_previous_by_number(struct window *,
1944 struct window_pane *, u_int);
1945 int window_pane_index(struct window_pane *, u_int *);
1946 u_int window_count_panes(struct window *);
1947 void window_destroy_panes(struct window *);
1948 struct window_pane *window_pane_find_by_id(u_int);
1949 struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
1950 void window_pane_destroy(struct window_pane *);
1951 int window_pane_spawn(struct window_pane *, const char *,
1952 const char *, const char *, struct environ *,
1953 struct termios *, char **);
1954 void window_pane_resize(struct window_pane *, u_int, u_int);
1955 void window_pane_alternate_on(
1956 struct window_pane *, struct grid_cell *);
1957 void window_pane_alternate_off(
1958 struct window_pane *, struct grid_cell *);
1959 int window_pane_set_mode(
1960 struct window_pane *, const struct window_mode *);
1961 void window_pane_reset_mode(struct window_pane *);
1962 void window_pane_key(struct window_pane *, struct session *, int);
1963 void window_pane_mouse(struct window_pane *,
1964 struct session *, struct mouse_event *);
1965 int window_pane_visible(struct window_pane *);
1966 char *window_pane_search(
1967 struct window_pane *, const char *, u_int *);
1968 char *window_printable_flags(struct session *, struct winlink *);
1970 struct window_pane *window_pane_find_up(struct window_pane *);
1971 struct window_pane *window_pane_find_down(struct window_pane *);
1972 struct window_pane *window_pane_find_left(struct window_pane *);
1973 struct window_pane *window_pane_find_right(struct window_pane *);
1975 /* layout.c */
1976 u_int layout_count_cells(struct layout_cell *);
1977 struct layout_cell *layout_create_cell(struct layout_cell *);
1978 void layout_free_cell(struct layout_cell *);
1979 void layout_print_cell(struct layout_cell *, const char *, u_int);
1980 void layout_destroy_cell(struct layout_cell *, struct layout_cell **);
1981 void layout_set_size(
1982 struct layout_cell *, u_int, u_int, u_int, u_int);
1983 void layout_make_leaf(
1984 struct layout_cell *, struct window_pane *);
1985 void layout_make_node(struct layout_cell *, enum layout_type);
1986 void layout_fix_offsets(struct layout_cell *);
1987 void layout_fix_panes(struct window *, u_int, u_int);
1988 u_int layout_resize_check(struct layout_cell *, enum layout_type);
1989 void layout_resize_adjust(
1990 struct layout_cell *, enum layout_type, int);
1991 void layout_init(struct window *);
1992 void layout_free(struct window *);
1993 void layout_resize(struct window *, u_int, u_int);
1994 void layout_resize_pane(
1995 struct window_pane *, enum layout_type, int);
1996 void layout_resize_pane_mouse(
1997 struct client *c, struct mouse_event *mouse);
1998 void layout_assign_pane(struct layout_cell *, struct window_pane *);
1999 struct layout_cell *layout_split_pane(
2000 struct window_pane *, enum layout_type, int);
2001 void layout_close_pane(struct window_pane *);
2003 /* layout-custom.c */
2004 char *layout_dump(struct window *);
2005 int layout_parse(struct window *, const char *);
2007 /* layout-set.c */
2008 const char *layout_set_name(u_int);
2009 int layout_set_lookup(const char *);
2010 u_int layout_set_select(struct window *, u_int);
2011 u_int layout_set_next(struct window *);
2012 u_int layout_set_previous(struct window *);
2013 void layout_set_active_changed(struct window *);
2015 /* window-clock.c */
2016 extern const struct window_mode window_clock_mode;
2018 /* window-copy.c */
2019 extern const struct window_mode window_copy_mode;
2020 void window_copy_init_from_pane(struct window_pane *);
2021 void window_copy_init_for_output(struct window_pane *);
2022 void window_copy_add(struct window_pane *, const char *, ...);
2023 void window_copy_vadd(struct window_pane *, const char *, va_list);
2024 void window_copy_pageup(struct window_pane *);
2026 /* window-choose.c */
2027 extern const struct window_mode window_choose_mode;
2028 void window_choose_vadd(
2029 struct window_pane *, int, const char *, va_list);
2030 void printflike3 window_choose_add(
2031 struct window_pane *, int, const char *, ...);
2032 void window_choose_ready(struct window_pane *,
2033 u_int, void (*)(void *, int), void (*)(void *), void *);
2035 /* names.c */
2036 void queue_window_name(struct window *);
2037 char *default_window_name(struct window *);
2039 /* signal.c */
2040 void set_signals(void(*)(int, short, void *));
2041 void clear_signals(int);
2043 /* session.c */
2044 extern struct sessions sessions;
2045 extern struct sessions dead_sessions;
2046 extern struct session_groups session_groups;
2047 int session_cmp(struct session *, struct session *);
2048 RB_PROTOTYPE(sessions, session, entry, session_cmp);
2049 int session_alive(struct session *);
2050 struct session *session_find(const char *);
2051 struct session *session_find_by_index(u_int);
2052 struct session *session_create(const char *, const char *, const char *,
2053 struct environ *, struct termios *, int, u_int, u_int,
2054 char **);
2055 void session_destroy(struct session *);
2056 int session_check_name(const char *);
2057 void session_update_activity(struct session *);
2058 struct session *session_next_session(struct session *);
2059 struct session *session_previous_session(struct session *);
2060 struct winlink *session_new(struct session *,
2061 const char *, const char *, const char *, int, char **);
2062 struct winlink *session_attach(
2063 struct session *, struct window *, int, char **);
2064 int session_detach(struct session *, struct winlink *);
2065 struct winlink* session_has(struct session *, struct window *);
2066 int session_next(struct session *, int);
2067 int session_previous(struct session *, int);
2068 int session_select(struct session *, int);
2069 int session_last(struct session *);
2070 struct session_group *session_group_find(struct session *);
2071 u_int session_group_index(struct session_group *);
2072 void session_group_add(struct session *, struct session *);
2073 void session_group_remove(struct session *);
2074 void session_group_synchronize_to(struct session *);
2075 void session_group_synchronize_from(struct session *);
2076 void session_group_synchronize1(struct session *, struct session *);
2078 /* utf8.c */
2079 void utf8_build(void);
2080 int utf8_open(struct utf8_data *, u_char);
2081 int utf8_append(struct utf8_data *, u_char);
2082 u_int utf8_combine(const struct utf8_data *);
2083 u_int utf8_split2(u_int, u_char *);
2085 /* procname.c */
2086 char *get_proc_name(int, char *);
2087 char *get_proc_cwd(pid_t);
2089 /* log.c */
2090 void log_open_tty(int);
2091 void log_open_file(int, const char *);
2092 void log_close(void);
2093 void printflike1 log_warn(const char *, ...);
2094 void printflike1 log_warnx(const char *, ...);
2095 void printflike1 log_info(const char *, ...);
2096 void printflike1 log_debug(const char *, ...);
2097 void printflike1 log_debug2(const char *, ...);
2098 __dead void printflike1 log_fatal(const char *, ...);
2099 __dead void printflike1 log_fatalx(const char *, ...);
2101 /* xmalloc.c */
2102 char *xstrdup(const char *);
2103 void *xcalloc(size_t, size_t);
2104 void *xmalloc(size_t);
2105 void *xrealloc(void *, size_t, size_t);
2106 void xfree(void *);
2107 int printflike2 xasprintf(char **, const char *, ...);
2108 int xvasprintf(char **, const char *, va_list);
2109 int printflike3 xsnprintf(char *, size_t, const char *, ...);
2110 int xvsnprintf(char *, size_t, const char *, va_list);
2112 #endif /* TMUX_H */