Add window-status-separator option, from Thomas Adam.
[tmux-openbsd.git] / tmux.h
blob160831a3ef3734c521873740658731515be00c7b
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
63 * Maximum sizes of strings in message data. Don't forget to bump
64 * PROTOCOL_VERSION if any of these change!
66 #define COMMAND_LENGTH 2048 /* packed argv size */
67 #define TERMINAL_LENGTH 128 /* length of TERM environment variable */
68 #define ENVIRON_LENGTH 1024 /* environment variable length */
71 * UTF-8 data size. This must be big enough to hold combined characters as well
72 * as single.
74 #define UTF8_SIZE 9
76 /* Fatal errors. */
77 #define fatal(msg) log_fatal("%s: %s", __func__, msg);
78 #define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
80 /* Definition to shut gcc up about unused arguments. */
81 #define unused __attribute__ ((unused))
83 /* Attribute to make gcc check printf-like arguments. */
84 #define printflike1 __attribute__ ((format (printf, 1, 2)))
85 #define printflike2 __attribute__ ((format (printf, 2, 3)))
86 #define printflike3 __attribute__ ((format (printf, 3, 4)))
87 #define printflike4 __attribute__ ((format (printf, 4, 5)))
88 #define printflike5 __attribute__ ((format (printf, 5, 6)))
90 /* Number of items in array. */
91 #ifndef nitems
92 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
93 #endif
95 /* Bell option values. */
96 #define BELL_NONE 0
97 #define BELL_ANY 1
98 #define BELL_CURRENT 2
100 /* Special key codes. */
101 #define KEYC_NONE 0xfff
102 #define KEYC_BASE 0x1000
104 /* Key modifier bits. */
105 #define KEYC_ESCAPE 0x2000
106 #define KEYC_CTRL 0x4000
107 #define KEYC_SHIFT 0x8000
108 #define KEYC_PREFIX 0x10000
110 /* Mask to obtain key w/o modifiers. */
111 #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_PREFIX)
112 #define KEYC_MASK_KEY (~KEYC_MASK_MOD)
114 /* Other key codes. */
115 enum key_code {
116 /* Mouse key. */
117 KEYC_MOUSE = KEYC_BASE,
119 /* Backspace key. */
120 KEYC_BSPACE,
122 /* Function keys. */
123 KEYC_F1,
124 KEYC_F2,
125 KEYC_F3,
126 KEYC_F4,
127 KEYC_F5,
128 KEYC_F6,
129 KEYC_F7,
130 KEYC_F8,
131 KEYC_F9,
132 KEYC_F10,
133 KEYC_F11,
134 KEYC_F12,
135 KEYC_F13,
136 KEYC_F14,
137 KEYC_F15,
138 KEYC_F16,
139 KEYC_F17,
140 KEYC_F18,
141 KEYC_F19,
142 KEYC_F20,
143 KEYC_IC,
144 KEYC_DC,
145 KEYC_HOME,
146 KEYC_END,
147 KEYC_NPAGE,
148 KEYC_PPAGE,
149 KEYC_BTAB,
151 /* Arrow keys. */
152 KEYC_UP,
153 KEYC_DOWN,
154 KEYC_LEFT,
155 KEYC_RIGHT,
157 /* Numeric keypad. */
158 KEYC_KP_SLASH,
159 KEYC_KP_STAR,
160 KEYC_KP_MINUS,
161 KEYC_KP_SEVEN,
162 KEYC_KP_EIGHT,
163 KEYC_KP_NINE,
164 KEYC_KP_PLUS,
165 KEYC_KP_FOUR,
166 KEYC_KP_FIVE,
167 KEYC_KP_SIX,
168 KEYC_KP_ONE,
169 KEYC_KP_TWO,
170 KEYC_KP_THREE,
171 KEYC_KP_ENTER,
172 KEYC_KP_ZERO,
173 KEYC_KP_PERIOD,
176 /* Termcap codes. */
177 enum tty_code_code {
178 TTYC_AX = 0,
179 TTYC_ACSC, /* acs_chars, ac */
180 TTYC_BEL, /* bell, bl */
181 TTYC_BLINK, /* enter_blink_mode, mb */
182 TTYC_BOLD, /* enter_bold_mode, md */
183 TTYC_CC, /* set colour cursor, Cc */
184 TTYC_CIVIS, /* cursor_invisible, vi */
185 TTYC_CLEAR, /* clear_screen, cl */
186 TTYC_CNORM, /* cursor_normal, ve */
187 TTYC_COLORS, /* max_colors, Co */
188 TTYC_CR, /* restore cursor colour, Cr */
189 TTYC_CS1, /* set cursor style, Cs */
190 TTYC_CSR, /* change_scroll_region, cs */
191 TTYC_CSR1, /* reset cursor style, Csr */
192 TTYC_CUB, /* parm_left_cursor, LE */
193 TTYC_CUB1, /* cursor_left, le */
194 TTYC_CUD, /* parm_down_cursor, DO */
195 TTYC_CUD1, /* cursor_down, do */
196 TTYC_CUF, /* parm_right_cursor, RI */
197 TTYC_CUF1, /* cursor_right, nd */
198 TTYC_CUP, /* cursor_address, cm */
199 TTYC_CUU, /* parm_up_cursor, UP */
200 TTYC_CUU1, /* cursor_up, up */
201 TTYC_DCH, /* parm_dch, DC */
202 TTYC_DCH1, /* delete_character, dc */
203 TTYC_DIM, /* enter_dim_mode, mh */
204 TTYC_DL, /* parm_delete_line, DL */
205 TTYC_DL1, /* delete_line, dl */
206 TTYC_E3,
207 TTYC_EL, /* clr_eol, ce */
208 TTYC_EL1, /* clr_bol, cb */
209 TTYC_ENACS, /* ena_acs, eA */
210 TTYC_FSL, /* from_status_line, fsl */
211 TTYC_HOME, /* cursor_home, ho */
212 TTYC_HPA, /* column_address, ch */
213 TTYC_ICH, /* parm_ich, IC */
214 TTYC_ICH1, /* insert_character, ic */
215 TTYC_IL, /* parm_insert_line, IL */
216 TTYC_IL1, /* insert_line, il */
217 TTYC_INVIS, /* enter_secure_mode, mk */
218 TTYC_IS1, /* init_1string, i1 */
219 TTYC_IS2, /* init_2string, i2 */
220 TTYC_IS3, /* init_3string, i3 */
221 TTYC_KCBT, /* key_btab, kB */
222 TTYC_KCUB1, /* key_left, kl */
223 TTYC_KCUD1, /* key_down, kd */
224 TTYC_KCUF1, /* key_right, kr */
225 TTYC_KCUU1, /* key_up, ku */
226 TTYC_KDC2,
227 TTYC_KDC3,
228 TTYC_KDC4,
229 TTYC_KDC5,
230 TTYC_KDC6,
231 TTYC_KDC7,
232 TTYC_KDCH1, /* key_dc, kD */
233 TTYC_KDN2,
234 TTYC_KDN3,
235 TTYC_KDN4,
236 TTYC_KDN5,
237 TTYC_KDN6,
238 TTYC_KDN7,
239 TTYC_KEND, /* key_end, ke */
240 TTYC_KEND2,
241 TTYC_KEND3,
242 TTYC_KEND4,
243 TTYC_KEND5,
244 TTYC_KEND6,
245 TTYC_KEND7,
246 TTYC_KF1, /* key_f1, k1 */
247 TTYC_KF10, /* key_f10, k; */
248 TTYC_KF11, /* key_f11, F1 */
249 TTYC_KF12, /* key_f12, F2 */
250 TTYC_KF13, /* key_f13, F3 */
251 TTYC_KF14, /* key_f14, F4 */
252 TTYC_KF15, /* key_f15, F5 */
253 TTYC_KF16, /* key_f16, F6 */
254 TTYC_KF17, /* key_f17, F7 */
255 TTYC_KF18, /* key_f18, F8 */
256 TTYC_KF19, /* key_f19, F9 */
257 TTYC_KF2, /* key_f2, k2 */
258 TTYC_KF20, /* key_f20, F10 */
259 TTYC_KF3, /* key_f3, k3 */
260 TTYC_KF4, /* key_f4, k4 */
261 TTYC_KF5, /* key_f5, k5 */
262 TTYC_KF6, /* key_f6, k6 */
263 TTYC_KF7, /* key_f7, k7 */
264 TTYC_KF8, /* key_f8, k8 */
265 TTYC_KF9, /* key_f9, k9 */
266 TTYC_KHOM2,
267 TTYC_KHOM3,
268 TTYC_KHOM4,
269 TTYC_KHOM5,
270 TTYC_KHOM6,
271 TTYC_KHOM7,
272 TTYC_KHOME, /* key_home, kh */
273 TTYC_KIC2,
274 TTYC_KIC3,
275 TTYC_KIC4,
276 TTYC_KIC5,
277 TTYC_KIC6,
278 TTYC_KIC7,
279 TTYC_KICH1, /* key_ic, kI */
280 TTYC_KLFT2,
281 TTYC_KLFT3,
282 TTYC_KLFT4,
283 TTYC_KLFT5,
284 TTYC_KLFT6,
285 TTYC_KLFT7,
286 TTYC_KMOUS, /* key_mouse, Km */
287 TTYC_KNP, /* key_npage, kN */
288 TTYC_KNXT2,
289 TTYC_KNXT3,
290 TTYC_KNXT4,
291 TTYC_KNXT5,
292 TTYC_KNXT6,
293 TTYC_KNXT7,
294 TTYC_KPP, /* key_ppage, kP */
295 TTYC_KPRV2,
296 TTYC_KPRV3,
297 TTYC_KPRV4,
298 TTYC_KPRV5,
299 TTYC_KPRV6,
300 TTYC_KPRV7,
301 TTYC_KRIT2,
302 TTYC_KRIT3,
303 TTYC_KRIT4,
304 TTYC_KRIT5,
305 TTYC_KRIT6,
306 TTYC_KRIT7,
307 TTYC_KUP2,
308 TTYC_KUP3,
309 TTYC_KUP4,
310 TTYC_KUP5,
311 TTYC_KUP6,
312 TTYC_KUP7,
313 TTYC_MS, /* modify xterm(1) selection */
314 TTYC_OP, /* orig_pair, op */
315 TTYC_REV, /* enter_reverse_mode, mr */
316 TTYC_RI, /* scroll_reverse, sr */
317 TTYC_RMACS, /* exit_alt_charset_mode */
318 TTYC_RMCUP, /* exit_ca_mode, te */
319 TTYC_RMIR, /* exit_insert_mode, ei */
320 TTYC_RMKX, /* keypad_local, ke */
321 TTYC_SETAB, /* set_a_background, AB */
322 TTYC_SETAF, /* set_a_foreground, AF */
323 TTYC_SGR0, /* exit_attribute_mode, me */
324 TTYC_SITM, /* enter_italics_mode, it */
325 TTYC_SMACS, /* enter_alt_charset_mode, as */
326 TTYC_SMCUP, /* enter_ca_mode, ti */
327 TTYC_SMIR, /* enter_insert_mode, im */
328 TTYC_SMKX, /* keypad_xmit, ks */
329 TTYC_SMSO, /* enter_standout_mode, so */
330 TTYC_SMUL, /* enter_underline_mode, us */
331 TTYC_TSL, /* to_status_line, tsl */
332 TTYC_VPA, /* row_address, cv */
333 TTYC_XENL, /* eat_newline_glitch, xn */
334 TTYC_XT, /* xterm(1)-compatible title, XT */
336 #define NTTYCODE (TTYC_XT + 1)
338 /* Termcap types. */
339 enum tty_code_type {
340 TTYCODE_NONE = 0,
341 TTYCODE_STRING,
342 TTYCODE_NUMBER,
343 TTYCODE_FLAG,
346 /* Termcap code. */
347 struct tty_code {
348 enum tty_code_type type;
349 union {
350 char *string;
351 int number;
352 int flag;
353 } value;
356 /* Entry in terminal code table. */
357 struct tty_term_code_entry {
358 enum tty_code_code code;
359 enum tty_code_type type;
360 const char *name;
363 /* Message codes. */
364 enum msgtype {
365 MSG_COMMAND,
366 MSG_DETACH,
367 MSG_ERROR,
368 MSG_EXIT,
369 MSG_EXITED,
370 MSG_EXITING,
371 MSG_IDENTIFY,
372 MSG_PRINT,
373 MSG_READY,
374 MSG_RESIZE,
375 MSG_SHUTDOWN,
376 MSG_SUSPEND,
377 MSG_VERSION,
378 MSG_WAKEUP,
379 MSG_ENVIRON,
380 MSG_UNLOCK,
381 MSG_LOCK,
382 MSG_SHELL,
383 MSG_STDERR,
384 MSG_STDOUT,
385 MSG_DETACHKILL
389 * Message data.
391 * Don't forget to bump PROTOCOL_VERSION if any of these change!
393 struct msg_command_data {
394 pid_t pid; /* PID from $TMUX or -1 */
395 int idx; /* index from $TMUX or -1 */
397 int argc;
398 char argv[COMMAND_LENGTH];
401 struct msg_identify_data {
402 char cwd[MAXPATHLEN];
404 char term[TERMINAL_LENGTH];
406 #define IDENTIFY_UTF8 0x1
407 #define IDENTIFY_256COLOURS 0x2
408 #define IDENTIFY_88COLOURS 0x4
409 int flags;
412 struct msg_lock_data {
413 char cmd[COMMAND_LENGTH];
416 struct msg_environ_data {
417 char var[ENVIRON_LENGTH];
420 struct msg_shell_data {
421 char shell[MAXPATHLEN];
424 struct msg_exit_data {
425 int retcode;
428 /* Mode key commands. */
429 enum mode_key_cmd {
430 MODEKEY_NONE,
431 MODEKEY_OTHER,
433 /* Editing keys. */
434 MODEKEYEDIT_BACKSPACE,
435 MODEKEYEDIT_CANCEL,
436 MODEKEYEDIT_COMPLETE,
437 MODEKEYEDIT_CURSORLEFT,
438 MODEKEYEDIT_CURSORRIGHT,
439 MODEKEYEDIT_DELETE,
440 MODEKEYEDIT_DELETELINE,
441 MODEKEYEDIT_DELETETOENDOFLINE,
442 MODEKEYEDIT_DELETEWORD,
443 MODEKEYEDIT_ENDOFLINE,
444 MODEKEYEDIT_ENTER,
445 MODEKEYEDIT_HISTORYDOWN,
446 MODEKEYEDIT_HISTORYUP,
447 MODEKEYEDIT_NEXTSPACE,
448 MODEKEYEDIT_NEXTSPACEEND,
449 MODEKEYEDIT_NEXTWORD,
450 MODEKEYEDIT_NEXTWORDEND,
451 MODEKEYEDIT_PASTE,
452 MODEKEYEDIT_PREVIOUSSPACE,
453 MODEKEYEDIT_PREVIOUSWORD,
454 MODEKEYEDIT_STARTOFLINE,
455 MODEKEYEDIT_SWITCHMODE,
456 MODEKEYEDIT_SWITCHMODEAPPEND,
457 MODEKEYEDIT_SWITCHMODEAPPENDLINE,
458 MODEKEYEDIT_SWITCHMODEBEGINLINE,
459 MODEKEYEDIT_TRANSPOSECHARS,
461 /* Menu (choice) keys. */
462 MODEKEYCHOICE_CANCEL,
463 MODEKEYCHOICE_CHOOSE,
464 MODEKEYCHOICE_DOWN,
465 MODEKEYCHOICE_PAGEDOWN,
466 MODEKEYCHOICE_PAGEUP,
467 MODEKEYCHOICE_SCROLLDOWN,
468 MODEKEYCHOICE_SCROLLUP,
469 MODEKEYCHOICE_UP,
471 /* Copy keys. */
472 MODEKEYCOPY_BACKTOINDENTATION,
473 MODEKEYCOPY_BOTTOMLINE,
474 MODEKEYCOPY_CANCEL,
475 MODEKEYCOPY_CLEARSELECTION,
476 MODEKEYCOPY_COPYLINE,
477 MODEKEYCOPY_COPYENDOFLINE,
478 MODEKEYCOPY_COPYSELECTION,
479 MODEKEYCOPY_DOWN,
480 MODEKEYCOPY_ENDOFLINE,
481 MODEKEYCOPY_GOTOLINE,
482 MODEKEYCOPY_HALFPAGEDOWN,
483 MODEKEYCOPY_HALFPAGEUP,
484 MODEKEYCOPY_HISTORYBOTTOM,
485 MODEKEYCOPY_HISTORYTOP,
486 MODEKEYCOPY_JUMP,
487 MODEKEYCOPY_JUMPAGAIN,
488 MODEKEYCOPY_JUMPREVERSE,
489 MODEKEYCOPY_JUMPBACK,
490 MODEKEYCOPY_JUMPTO,
491 MODEKEYCOPY_JUMPTOBACK,
492 MODEKEYCOPY_LEFT,
493 MODEKEYCOPY_MIDDLELINE,
494 MODEKEYCOPY_NEXTPAGE,
495 MODEKEYCOPY_NEXTSPACE,
496 MODEKEYCOPY_NEXTSPACEEND,
497 MODEKEYCOPY_NEXTWORD,
498 MODEKEYCOPY_NEXTWORDEND,
499 MODEKEYCOPY_PREVIOUSPAGE,
500 MODEKEYCOPY_PREVIOUSSPACE,
501 MODEKEYCOPY_PREVIOUSWORD,
502 MODEKEYCOPY_RECTANGLETOGGLE,
503 MODEKEYCOPY_RIGHT,
504 MODEKEYCOPY_SCROLLDOWN,
505 MODEKEYCOPY_SCROLLUP,
506 MODEKEYCOPY_SEARCHAGAIN,
507 MODEKEYCOPY_SEARCHDOWN,
508 MODEKEYCOPY_SEARCHREVERSE,
509 MODEKEYCOPY_SEARCHUP,
510 MODEKEYCOPY_SELECTLINE,
511 MODEKEYCOPY_STARTNUMBERPREFIX,
512 MODEKEYCOPY_STARTOFLINE,
513 MODEKEYCOPY_STARTSELECTION,
514 MODEKEYCOPY_TOPLINE,
515 MODEKEYCOPY_UP,
518 /* Entry in the default mode key tables. */
519 struct mode_key_entry {
520 int key;
523 * Editing mode for vi: 0 is edit mode, keys not in the table are
524 * returned as MODEKEY_OTHER; 1 is command mode, keys not in the table
525 * are returned as MODEKEY_NONE. This is also matched on, allowing some
526 * keys to be bound in edit mode.
528 int mode;
529 enum mode_key_cmd cmd;
532 /* Data required while mode keys are in use. */
533 struct mode_key_data {
534 struct mode_key_tree *tree;
535 int mode;
537 #define MODEKEY_EMACS 0
538 #define MODEKEY_VI 1
540 /* Binding between a key and a command. */
541 struct mode_key_binding {
542 int key;
544 int mode;
545 enum mode_key_cmd cmd;
547 RB_ENTRY(mode_key_binding) entry;
549 RB_HEAD(mode_key_tree, mode_key_binding);
551 /* Command to string mapping. */
552 struct mode_key_cmdstr {
553 enum mode_key_cmd cmd;
554 const char *name;
557 /* Named mode key table description. */
558 struct mode_key_table {
559 const char *name;
560 const struct mode_key_cmdstr *cmdstr;
561 struct mode_key_tree *tree;
562 const struct mode_key_entry *table; /* default entries */
565 /* Modes. */
566 #define MODE_CURSOR 0x1
567 #define MODE_INSERT 0x2
568 #define MODE_KCURSOR 0x4
569 #define MODE_KKEYPAD 0x8 /* set = application, clear = number */
570 #define MODE_WRAP 0x10 /* whether lines wrap */
571 #define MODE_MOUSE_STANDARD 0x20
572 #define MODE_MOUSE_BUTTON 0x40
573 #define MODE_MOUSE_ANY 0x80
574 #define MODE_MOUSE_UTF8 0x100
575 #define MODE_BRACKETPASTE 0x200
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 RB_ENTRY(options_entry) entry;
680 struct options {
681 RB_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
814 #define PANE_DROP 0x2
816 char *cmd;
817 char *shell;
818 char *cwd;
820 pid_t pid;
821 char tty[TTY_NAME_MAX];
823 u_int changes;
824 struct event changes_timer;
825 u_int changes_redraw;
827 int fd;
828 struct bufferevent *event;
830 struct input_ctx ictx;
832 int pipe_fd;
833 struct bufferevent *pipe_event;
834 size_t pipe_off;
836 struct screen *screen;
837 struct screen base;
839 /* Saved in alternative screen mode. */
840 u_int saved_cx;
841 u_int saved_cy;
842 struct grid *saved_grid;
843 struct grid_cell saved_cell;
845 const struct window_mode *mode;
846 void *modedata;
848 TAILQ_ENTRY(window_pane) entry;
849 RB_ENTRY(window_pane) tree_entry;
851 TAILQ_HEAD(window_panes, window_pane);
852 RB_HEAD(window_pane_tree, window_pane);
854 /* Window last layout. */
855 struct last_layout {
856 char *layout;
858 TAILQ_ENTRY(last_layout) entry;
861 /* Window structure. */
862 struct window {
863 u_int id;
864 char *name;
865 struct event name_timer;
866 struct timeval silence_timer;
868 struct window_pane *active;
869 struct window_pane *last;
870 struct window_panes panes;
872 int lastlayout;
873 struct layout_cell *layout_root;
874 TAILQ_HEAD(last_layouts, last_layout) layout_list;
875 u_int layout_list_size;
876 struct last_layout *layout_list_last;
878 u_int sx;
879 u_int sy;
881 int flags;
882 #define WINDOW_BELL 0x1
883 #define WINDOW_ACTIVITY 0x2
884 #define WINDOW_REDRAW 0x4
885 #define WINDOW_SILENCE 0x8
887 struct options options;
889 u_int references;
891 ARRAY_DECL(windows, struct window *);
893 /* Entry on local window list. */
894 struct winlink {
895 int idx;
896 struct window *window;
898 size_t status_width;
899 struct grid_cell status_cell;
900 char *status_text;
902 int flags;
903 #define WINLINK_BELL 0x1
904 #define WINLINK_ACTIVITY 0x2
905 #define WINLINK_CONTENT 0x4
906 #define WINLINK_SILENCE 0x8
907 #define WINLINK_ALERTFLAGS \
908 (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
910 RB_ENTRY(winlink) entry;
911 TAILQ_ENTRY(winlink) sentry;
913 RB_HEAD(winlinks, winlink);
914 TAILQ_HEAD(winlink_stack, winlink);
916 /* Layout direction. */
917 enum layout_type {
918 LAYOUT_LEFTRIGHT,
919 LAYOUT_TOPBOTTOM,
920 LAYOUT_WINDOWPANE
923 /* Layout cells queue. */
924 TAILQ_HEAD(layout_cells, layout_cell);
926 /* Layout cell. */
927 struct layout_cell {
928 enum layout_type type;
930 struct layout_cell *parent;
932 u_int sx;
933 u_int sy;
935 u_int xoff;
936 u_int yoff;
938 struct window_pane *wp;
939 struct layout_cells cells;
941 TAILQ_ENTRY(layout_cell) entry;
944 /* Paste buffer. */
945 struct paste_buffer {
946 char *data;
947 size_t size;
949 ARRAY_DECL(paste_stack, struct paste_buffer *);
951 /* Environment variable. */
952 struct environ_entry {
953 char *name;
954 char *value;
956 RB_ENTRY(environ_entry) entry;
958 RB_HEAD(environ, environ_entry);
960 /* Client session. */
961 struct session_group {
962 TAILQ_HEAD(, session) sessions;
964 TAILQ_ENTRY(session_group) entry;
966 TAILQ_HEAD(session_groups, session_group);
968 struct session {
969 u_int idx;
971 char *name;
972 char *cwd;
974 struct timeval creation_time;
975 struct timeval activity_time;
977 u_int sx;
978 u_int sy;
980 struct winlink *curw;
981 struct winlink_stack lastw;
982 struct winlinks windows;
984 struct options options;
986 #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
987 int flags;
989 struct termios *tio;
991 struct environ environ;
993 int references;
995 TAILQ_ENTRY(session) gentry;
996 RB_ENTRY(session) entry;
998 RB_HEAD(sessions, session);
999 ARRAY_DECL(sessionslist, struct session *);
1001 /* TTY information. */
1002 struct tty_key {
1003 char ch;
1004 int key;
1006 struct tty_key *left;
1007 struct tty_key *right;
1009 struct tty_key *next;
1012 struct tty_term {
1013 char *name;
1014 u_int references;
1016 char acs[UCHAR_MAX + 1][2];
1018 struct tty_code codes[NTTYCODE];
1020 #define TERM_256COLOURS 0x1
1021 #define TERM_88COLOURS 0x2
1022 #define TERM_EARLYWRAP 0x4
1023 int flags;
1025 LIST_ENTRY(tty_term) entry;
1027 LIST_HEAD(tty_terms, tty_term);
1029 struct tty {
1030 char *path;
1031 u_int xterm_version;
1033 u_int sx;
1034 u_int sy;
1036 u_int cx;
1037 u_int cy;
1038 u_int cstyle;
1039 char *ccolour;
1041 int mode;
1043 u_int rlower;
1044 u_int rupper;
1046 char *termname;
1047 struct tty_term *term;
1049 int fd;
1050 struct bufferevent *event;
1052 int log_fd;
1054 struct termios tio;
1056 struct grid_cell cell;
1058 #define TTY_NOCURSOR 0x1
1059 #define TTY_FREEZE 0x2
1060 #define TTY_ESCAPE 0x4
1061 #define TTY_UTF8 0x8
1062 #define TTY_STARTED 0x10
1063 #define TTY_OPENED 0x20
1064 int flags;
1066 int term_flags;
1068 void (*key_callback)(int, struct mouse_event *, void *);
1069 void *key_data;
1070 struct event key_timer;
1071 struct tty_key *key_tree;
1074 /* TTY command context and function pointer. */
1075 struct tty_ctx {
1076 struct window_pane *wp;
1078 const struct grid_cell *cell;
1079 const struct grid_utf8 *utf8;
1081 u_int num;
1082 void *ptr;
1085 * Cursor and region position before the screen was updated - this is
1086 * where the command should be applied; the values in the screen have
1087 * already been updated.
1089 u_int ocx;
1090 u_int ocy;
1092 u_int orupper;
1093 u_int orlower;
1095 u_int xoff;
1096 u_int yoff;
1098 /* Saved last cell on line. */
1099 struct grid_cell last_cell;
1100 struct grid_utf8 last_utf8;
1101 u_int last_width;
1105 * Mouse input. xterm mouse mode is fairly silly. Buttons are in the bottom two
1106 * bits: 0 = button 1; 1 = button 2; 2 = button 3; 3 = buttons released. Bits
1107 * 3, 4 and 5 are for keys. Bit 6 is set for dragging and 7 for mouse buttons 4
1108 * and 5.
1110 struct mouse_event {
1111 u_int b;
1112 #define MOUSE_1 0
1113 #define MOUSE_2 1
1114 #define MOUSE_3 2
1115 #define MOUSE_UP 3
1116 #define MOUSE_BUTTON 3
1117 #define MOUSE_SHIFT 4
1118 #define MOUSE_ESCAPE 8
1119 #define MOUSE_CTRL 16
1120 #define MOUSE_DRAG 32
1121 #define MOUSE_45 64
1122 #define MOUSE_RESIZE_PANE 128 /* marker for resizing */
1123 u_int x;
1124 u_int y;
1127 /* Saved message entry. */
1128 struct message_entry {
1129 char *msg;
1130 time_t msg_time;
1133 /* Status output data from a job. */
1134 struct status_out {
1135 char *cmd;
1136 char *out;
1138 RB_ENTRY(status_out) entry;
1140 RB_HEAD(status_out_tree, status_out);
1142 /* Client connection. */
1143 struct client {
1144 struct imsgbuf ibuf;
1145 struct event event;
1146 int retcode;
1148 struct timeval creation_time;
1149 struct timeval activity_time;
1151 struct environ environ;
1153 char *title;
1154 char *cwd;
1156 struct tty tty;
1158 int stdin_fd;
1159 void *stdin_data;
1160 void (*stdin_callback)(struct client *, void *);
1161 struct bufferevent *stdin_event;
1163 int stdout_fd;
1164 struct bufferevent *stdout_event;
1166 int stderr_fd;
1167 struct bufferevent *stderr_event;
1169 struct event repeat_timer;
1171 struct status_out_tree status_old;
1172 struct status_out_tree status_new;
1173 struct timeval status_timer;
1174 struct screen status;
1176 #define CLIENT_TERMINAL 0x1
1177 #define CLIENT_PREFIX 0x2
1178 #define CLIENT_EXIT 0x4
1179 #define CLIENT_REDRAW 0x8
1180 #define CLIENT_STATUS 0x10
1181 #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
1182 #define CLIENT_SUSPENDED 0x40
1183 #define CLIENT_BAD 0x80
1184 #define CLIENT_IDENTIFY 0x100
1185 #define CLIENT_DEAD 0x200
1186 #define CLIENT_BORDERS 0x400
1187 #define CLIENT_READONLY 0x800
1188 #define CLIENT_REDRAWWINDOW 0x1000
1189 int flags;
1191 struct event identify_timer;
1193 char *message_string;
1194 struct event message_timer;
1195 ARRAY_DECL(, struct message_entry) message_log;
1197 char *prompt_string;
1198 char *prompt_buffer;
1199 size_t prompt_index;
1200 int (*prompt_callbackfn)(void *, const char *);
1201 void (*prompt_freefn)(void *);
1202 void *prompt_data;
1203 u_int prompt_hindex;
1205 #define PROMPT_SINGLE 0x1
1206 int prompt_flags;
1208 struct mode_key_data prompt_mdata;
1210 struct session *session;
1211 struct session *last_session;
1213 struct mouse_event last_mouse;
1215 int wlmouse;
1217 int references;
1219 ARRAY_DECL(clients, struct client *);
1221 /* Parsed arguments. */
1222 struct args {
1223 bitstr_t *flags;
1224 char *values[SCHAR_MAX]; /* XXX This is awfully big. */
1226 int argc;
1227 char **argv;
1230 /* Key/command line command. */
1231 struct cmd_ctx {
1233 * curclient is the client where this command was executed if inside
1234 * tmux. This is NULL if the command came from the command-line.
1236 * cmdclient is the client which sent the MSG_COMMAND to the server, if
1237 * any. This is NULL unless the command came from the command-line.
1239 * cmdclient and curclient may both be NULL if the command is in the
1240 * configuration file.
1242 struct client *curclient;
1243 struct client *cmdclient;
1245 struct msg_command_data *msgdata;
1247 /* gcc2 doesn't understand attributes on function pointers... */
1248 #if defined(__GNUC__) && __GNUC__ >= 3
1249 void printflike2 (*print)(struct cmd_ctx *, const char *, ...);
1250 void printflike2 (*info)(struct cmd_ctx *, const char *, ...);
1251 void printflike2 (*error)(struct cmd_ctx *, const char *, ...);
1252 #else
1253 void (*print)(struct cmd_ctx *, const char *, ...);
1254 void (*info)(struct cmd_ctx *, const char *, ...);
1255 void (*error)(struct cmd_ctx *, const char *, ...);
1256 #endif
1259 struct cmd {
1260 const struct cmd_entry *entry;
1261 struct args *args;
1263 TAILQ_ENTRY(cmd) qentry;
1265 struct cmd_list {
1266 int references;
1267 TAILQ_HEAD(, cmd) list;
1270 struct cmd_entry {
1271 const char *name;
1272 const char *alias;
1274 const char *args_template;
1275 int args_lower;
1276 int args_upper;
1278 const char *usage;
1280 #define CMD_STARTSERVER 0x1
1281 #define CMD_CANTNEST 0x2
1282 #define CMD_SENDENVIRON 0x4
1283 #define CMD_READONLY 0x8
1284 int flags;
1286 void (*key_binding)(struct cmd *, int);
1287 int (*check)(struct args *);
1288 int (*exec)(struct cmd *, struct cmd_ctx *);
1291 /* Key binding. */
1292 struct key_binding {
1293 int key;
1294 struct cmd_list *cmdlist;
1295 int can_repeat;
1297 RB_ENTRY(key_binding) entry;
1299 RB_HEAD(key_bindings, key_binding);
1302 * Option table entries. The option table is the user-visible part of the
1303 * option, as opposed to the internal options (struct option) which are just
1304 * number or string.
1306 enum options_table_type {
1307 OPTIONS_TABLE_STRING,
1308 OPTIONS_TABLE_NUMBER,
1309 OPTIONS_TABLE_KEY,
1310 OPTIONS_TABLE_COLOUR,
1311 OPTIONS_TABLE_ATTRIBUTES,
1312 OPTIONS_TABLE_FLAG,
1313 OPTIONS_TABLE_CHOICE
1316 struct options_table_entry {
1317 const char *name;
1318 enum options_table_type type;
1320 u_int minimum;
1321 u_int maximum;
1322 const char **choices;
1324 const char *default_str;
1325 long long default_num;
1328 /* Tree of format entries. */
1329 struct format_entry {
1330 char *key;
1331 char *value;
1333 RB_ENTRY(format_entry) entry;
1335 RB_HEAD(format_tree, format_entry);
1337 /* List of configuration causes. */
1338 ARRAY_DECL(causelist, char *);
1340 /* Common command usages. */
1341 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1342 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1343 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1344 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1345 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1346 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1347 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1348 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1349 #define CMD_BUFFER_USAGE "[-b buffer-index]"
1351 /* tmux.c */
1352 extern struct options global_options;
1353 extern struct options global_s_options;
1354 extern struct options global_w_options;
1355 extern struct environ global_environ;
1356 extern struct event_base *ev_base;
1357 extern char *cfg_file;
1358 extern char *shell_cmd;
1359 extern int debug_level;
1360 extern time_t start_time;
1361 extern char socket_path[MAXPATHLEN];
1362 extern int login_shell;
1363 extern char *environ_path;
1364 extern pid_t environ_pid;
1365 extern int environ_idx;
1366 void logfile(const char *);
1367 const char *getshell(void);
1368 int checkshell(const char *);
1369 int areshell(const char *);
1370 const char* get_full_path(const char *, const char *);
1371 void setblocking(int, int);
1372 __dead void shell_exec(const char *, const char *);
1374 /* cfg.c */
1375 extern int cfg_finished;
1376 extern struct causelist cfg_causes;
1377 void printflike2 cfg_add_cause(struct causelist *, const char *, ...);
1378 int load_cfg(const char *, struct cmd_ctx *, struct causelist *);
1380 /* format.c */
1381 int format_cmp(struct format_entry *, struct format_entry *);
1382 RB_PROTOTYPE(format_tree, format_entry, entry, format_cmp);
1383 struct format_tree *format_create(void);
1384 void format_free(struct format_tree *);
1385 void printflike3 format_add(
1386 struct format_tree *, const char *, const char *, ...);
1387 const char *format_find(struct format_tree *, const char *);
1388 char *format_expand(struct format_tree *, const char *);
1389 void format_session(struct format_tree *, struct session *);
1390 void format_client(struct format_tree *, struct client *);
1391 void format_winlink(
1392 struct format_tree *, struct session *, struct winlink *);
1393 void format_window_pane(struct format_tree *, struct window_pane *);
1395 /* mode-key.c */
1396 extern const struct mode_key_table mode_key_tables[];
1397 extern struct mode_key_tree mode_key_tree_vi_edit;
1398 extern struct mode_key_tree mode_key_tree_vi_choice;
1399 extern struct mode_key_tree mode_key_tree_vi_copy;
1400 extern struct mode_key_tree mode_key_tree_emacs_edit;
1401 extern struct mode_key_tree mode_key_tree_emacs_choice;
1402 extern struct mode_key_tree mode_key_tree_emacs_copy;
1403 int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
1404 RB_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
1405 const char *mode_key_tostring(const struct mode_key_cmdstr *,
1406 enum mode_key_cmd);
1407 enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
1408 const char *);
1409 const struct mode_key_table *mode_key_findtable(const char *);
1410 void mode_key_init_trees(void);
1411 void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
1412 enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
1414 /* notify.c */
1415 void notify_window_layout_changed(struct window *);
1416 void notify_window_unlinked(struct session *, struct window *);
1417 void notify_window_linked(struct session *, struct window *);
1418 void notify_window_renamed(struct window *);
1419 void notify_attached_session_changed(struct client *);
1420 void notify_session_renamed(struct session *);
1421 void notify_session_created(struct session *);
1422 void notify_session_closed(struct session *);
1424 /* options.c */
1425 int options_cmp(struct options_entry *, struct options_entry *);
1426 RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
1427 void options_init(struct options *, struct options *);
1428 void options_free(struct options *);
1429 struct options_entry *options_find1(struct options *, const char *);
1430 struct options_entry *options_find(struct options *, const char *);
1431 void options_remove(struct options *, const char *);
1432 struct options_entry *printflike3 options_set_string(
1433 struct options *, const char *, const char *, ...);
1434 char *options_get_string(struct options *, const char *);
1435 struct options_entry *options_set_number(
1436 struct options *, const char *, long long);
1437 long long options_get_number(struct options *, const char *);
1439 /* options-table.c */
1440 extern const struct options_table_entry server_options_table[];
1441 extern const struct options_table_entry session_options_table[];
1442 extern const struct options_table_entry window_options_table[];
1443 void options_table_populate_tree(
1444 const struct options_table_entry *, struct options *);
1445 const char *options_table_print_entry(
1446 const struct options_table_entry *, struct options_entry *);
1447 int options_table_find(
1448 const char *, const struct options_table_entry **,
1449 const struct options_table_entry **);
1451 /* job.c */
1452 extern struct joblist all_jobs;
1453 struct job *job_run(
1454 const char *, void (*)(struct job *), void (*)(void *), void *);
1455 void job_free(struct job *);
1456 void job_died(struct job *, int);
1458 /* environ.c */
1459 int environ_cmp(struct environ_entry *, struct environ_entry *);
1460 RB_PROTOTYPE(environ, environ_entry, entry, environ_cmp);
1461 void environ_init(struct environ *);
1462 void environ_free(struct environ *);
1463 void environ_copy(struct environ *, struct environ *);
1464 struct environ_entry *environ_find(struct environ *, const char *);
1465 void environ_set(struct environ *, const char *, const char *);
1466 void environ_put(struct environ *, const char *);
1467 void environ_unset(struct environ *, const char *);
1468 void environ_update(const char *, struct environ *, struct environ *);
1469 void environ_push(struct environ *);
1471 /* tty.c */
1472 void tty_init_termios(int, struct termios *, struct bufferevent *);
1473 void tty_raw(struct tty *, const char *);
1474 void tty_attributes(struct tty *, const struct grid_cell *);
1475 void tty_reset(struct tty *);
1476 void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1477 void tty_region(struct tty *, u_int, u_int);
1478 void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int);
1479 void tty_cursor(struct tty *, u_int, u_int);
1480 void tty_putcode(struct tty *, enum tty_code_code);
1481 void tty_putcode1(struct tty *, enum tty_code_code, int);
1482 void tty_putcode2(struct tty *, enum tty_code_code, int, int);
1483 void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
1484 void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, const void *);
1485 void tty_puts(struct tty *, const char *);
1486 void tty_putc(struct tty *, u_char);
1487 void tty_pututf8(struct tty *, const struct grid_utf8 *);
1488 void tty_init(struct tty *, int, char *);
1489 int tty_resize(struct tty *);
1490 int tty_set_size(struct tty *, u_int, u_int);
1491 void tty_start_tty(struct tty *);
1492 void tty_set_version(struct tty *, u_int);
1493 void tty_stop_tty(struct tty *);
1494 void tty_set_title(struct tty *, const char *);
1495 void tty_update_mode(struct tty *, int, struct screen *);
1496 void tty_force_cursor_colour(struct tty *, const char *);
1497 void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int);
1498 int tty_open(struct tty *, const char *, char **);
1499 void tty_close(struct tty *);
1500 void tty_free(struct tty *);
1501 void tty_write(
1502 void (*)(struct tty *, const struct tty_ctx *), struct tty_ctx *);
1503 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
1504 void tty_cmd_cell(struct tty *, const struct tty_ctx *);
1505 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
1506 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
1507 void tty_cmd_clearline(struct tty *, const struct tty_ctx *);
1508 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
1509 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
1510 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
1511 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
1512 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
1513 void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *);
1514 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
1515 void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
1516 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
1517 void tty_cmd_utf8character(struct tty *, const struct tty_ctx *);
1518 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
1519 void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
1520 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
1521 void tty_bell(struct tty *);
1523 /* tty-term.c */
1524 extern struct tty_terms tty_terms;
1525 extern const struct tty_term_code_entry tty_term_codes[NTTYCODE];
1526 struct tty_term *tty_term_find(char *, int, const char *, char **);
1527 void tty_term_free(struct tty_term *);
1528 int tty_term_has(struct tty_term *, enum tty_code_code);
1529 const char *tty_term_string(struct tty_term *, enum tty_code_code);
1530 const char *tty_term_string1(struct tty_term *, enum tty_code_code, int);
1531 const char *tty_term_string2(
1532 struct tty_term *, enum tty_code_code, int, int);
1533 const char *tty_term_ptr1(
1534 struct tty_term *, enum tty_code_code, const void *);
1535 const char *tty_term_ptr2(
1536 struct tty_term *, enum tty_code_code, const void *, const void *);
1537 int tty_term_number(struct tty_term *, enum tty_code_code);
1538 int tty_term_flag(struct tty_term *, enum tty_code_code);
1540 /* tty-acs.c */
1541 const char *tty_acs_get(struct tty *, u_char);
1543 /* tty-keys.c */
1544 void tty_keys_init(struct tty *);
1545 void tty_keys_free(struct tty *);
1546 int tty_keys_next(struct tty *);
1548 /* paste.c */
1549 struct paste_buffer *paste_walk_stack(struct paste_stack *, u_int *);
1550 struct paste_buffer *paste_get_top(struct paste_stack *);
1551 struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
1552 int paste_free_top(struct paste_stack *);
1553 int paste_free_index(struct paste_stack *, u_int);
1554 void paste_add(struct paste_stack *, char *, size_t, u_int);
1555 int paste_replace(struct paste_stack *, u_int, char *, size_t);
1556 char *paste_print(struct paste_buffer *, size_t);
1558 /* clock.c */
1559 extern const char clock_table[14][5][5];
1560 void clock_draw(struct screen_write_ctx *, int, int);
1562 /* arguments.c */
1563 struct args *args_create(int, ...);
1564 struct args *args_parse(const char *, int, char **);
1565 void args_free(struct args *);
1566 size_t args_print(struct args *, char *, size_t);
1567 int args_has(struct args *, u_char);
1568 void args_set(struct args *, u_char, const char *);
1569 const char *args_get(struct args *, u_char);
1570 long long args_strtonum(
1571 struct args *, u_char, long long, long long, char **);
1573 /* cmd.c */
1574 int cmd_pack_argv(int, char **, char *, size_t);
1575 int cmd_unpack_argv(char *, size_t, int, char ***);
1576 char **cmd_copy_argv(int, char *const *);
1577 void cmd_free_argv(int, char **);
1578 struct cmd *cmd_parse(int, char **, char **);
1579 int cmd_exec(struct cmd *, struct cmd_ctx *);
1580 void cmd_free(struct cmd *);
1581 size_t cmd_print(struct cmd *, char *, size_t);
1582 struct session *cmd_current_session(struct cmd_ctx *, int);
1583 struct client *cmd_current_client(struct cmd_ctx *);
1584 struct client *cmd_find_client(struct cmd_ctx *, const char *);
1585 struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
1586 struct winlink *cmd_find_window(
1587 struct cmd_ctx *, const char *, struct session **);
1588 int cmd_find_index(
1589 struct cmd_ctx *, const char *, struct session **);
1590 struct winlink *cmd_find_pane(struct cmd_ctx *,
1591 const char *, struct session **, struct window_pane **);
1592 char *cmd_template_replace(char *, const char *, int);
1593 const char *cmd_get_default_path(struct cmd_ctx *, const char *);
1594 extern const struct cmd_entry *cmd_table[];
1595 extern const struct cmd_entry cmd_attach_session_entry;
1596 extern const struct cmd_entry cmd_bind_key_entry;
1597 extern const struct cmd_entry cmd_break_pane_entry;
1598 extern const struct cmd_entry cmd_capture_pane_entry;
1599 extern const struct cmd_entry cmd_choose_buffer_entry;
1600 extern const struct cmd_entry cmd_choose_client_entry;
1601 extern const struct cmd_entry cmd_choose_session_entry;
1602 extern const struct cmd_entry cmd_choose_window_entry;
1603 extern const struct cmd_entry cmd_clear_history_entry;
1604 extern const struct cmd_entry cmd_clock_mode_entry;
1605 extern const struct cmd_entry cmd_command_prompt_entry;
1606 extern const struct cmd_entry cmd_confirm_before_entry;
1607 extern const struct cmd_entry cmd_copy_mode_entry;
1608 extern const struct cmd_entry cmd_delete_buffer_entry;
1609 extern const struct cmd_entry cmd_detach_client_entry;
1610 extern const struct cmd_entry cmd_display_message_entry;
1611 extern const struct cmd_entry cmd_display_panes_entry;
1612 extern const struct cmd_entry cmd_down_pane_entry;
1613 extern const struct cmd_entry cmd_find_window_entry;
1614 extern const struct cmd_entry cmd_has_session_entry;
1615 extern const struct cmd_entry cmd_if_shell_entry;
1616 extern const struct cmd_entry cmd_join_pane_entry;
1617 extern const struct cmd_entry cmd_kill_pane_entry;
1618 extern const struct cmd_entry cmd_kill_server_entry;
1619 extern const struct cmd_entry cmd_kill_session_entry;
1620 extern const struct cmd_entry cmd_kill_window_entry;
1621 extern const struct cmd_entry cmd_last_pane_entry;
1622 extern const struct cmd_entry cmd_last_window_entry;
1623 extern const struct cmd_entry cmd_link_window_entry;
1624 extern const struct cmd_entry cmd_list_buffers_entry;
1625 extern const struct cmd_entry cmd_list_clients_entry;
1626 extern const struct cmd_entry cmd_list_commands_entry;
1627 extern const struct cmd_entry cmd_list_keys_entry;
1628 extern const struct cmd_entry cmd_list_panes_entry;
1629 extern const struct cmd_entry cmd_list_sessions_entry;
1630 extern const struct cmd_entry cmd_list_windows_entry;
1631 extern const struct cmd_entry cmd_load_buffer_entry;
1632 extern const struct cmd_entry cmd_lock_client_entry;
1633 extern const struct cmd_entry cmd_lock_server_entry;
1634 extern const struct cmd_entry cmd_lock_session_entry;
1635 extern const struct cmd_entry cmd_move_pane_entry;
1636 extern const struct cmd_entry cmd_move_window_entry;
1637 extern const struct cmd_entry cmd_new_session_entry;
1638 extern const struct cmd_entry cmd_new_window_entry;
1639 extern const struct cmd_entry cmd_next_layout_entry;
1640 extern const struct cmd_entry cmd_next_window_entry;
1641 extern const struct cmd_entry cmd_paste_buffer_entry;
1642 extern const struct cmd_entry cmd_pipe_pane_entry;
1643 extern const struct cmd_entry cmd_previous_layout_entry;
1644 extern const struct cmd_entry cmd_previous_window_entry;
1645 extern const struct cmd_entry cmd_refresh_client_entry;
1646 extern const struct cmd_entry cmd_rename_session_entry;
1647 extern const struct cmd_entry cmd_rename_window_entry;
1648 extern const struct cmd_entry cmd_resize_pane_entry;
1649 extern const struct cmd_entry cmd_respawn_pane_entry;
1650 extern const struct cmd_entry cmd_respawn_window_entry;
1651 extern const struct cmd_entry cmd_rotate_window_entry;
1652 extern const struct cmd_entry cmd_run_shell_entry;
1653 extern const struct cmd_entry cmd_save_buffer_entry;
1654 extern const struct cmd_entry cmd_select_layout_entry;
1655 extern const struct cmd_entry cmd_select_pane_entry;
1656 extern const struct cmd_entry cmd_select_window_entry;
1657 extern const struct cmd_entry cmd_send_keys_entry;
1658 extern const struct cmd_entry cmd_send_prefix_entry;
1659 extern const struct cmd_entry cmd_server_info_entry;
1660 extern const struct cmd_entry cmd_set_buffer_entry;
1661 extern const struct cmd_entry cmd_set_environment_entry;
1662 extern const struct cmd_entry cmd_set_option_entry;
1663 extern const struct cmd_entry cmd_set_window_option_entry;
1664 extern const struct cmd_entry cmd_show_buffer_entry;
1665 extern const struct cmd_entry cmd_show_environment_entry;
1666 extern const struct cmd_entry cmd_show_messages_entry;
1667 extern const struct cmd_entry cmd_show_options_entry;
1668 extern const struct cmd_entry cmd_show_window_options_entry;
1669 extern const struct cmd_entry cmd_source_file_entry;
1670 extern const struct cmd_entry cmd_split_window_entry;
1671 extern const struct cmd_entry cmd_start_server_entry;
1672 extern const struct cmd_entry cmd_suspend_client_entry;
1673 extern const struct cmd_entry cmd_swap_pane_entry;
1674 extern const struct cmd_entry cmd_swap_window_entry;
1675 extern const struct cmd_entry cmd_switch_client_entry;
1676 extern const struct cmd_entry cmd_unbind_key_entry;
1677 extern const struct cmd_entry cmd_unlink_window_entry;
1678 extern const struct cmd_entry cmd_up_pane_entry;
1680 /* cmd-list.c */
1681 struct cmd_list *cmd_list_parse(int, char **, char **);
1682 int cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
1683 void cmd_list_free(struct cmd_list *);
1684 size_t cmd_list_print(struct cmd_list *, char *, size_t);
1686 /* cmd-string.c */
1687 int cmd_string_parse(const char *, struct cmd_list **, char **);
1689 /* client.c */
1690 int client_main(int, char **, int);
1692 /* key-bindings.c */
1693 extern struct key_bindings key_bindings;
1694 int key_bindings_cmp(struct key_binding *, struct key_binding *);
1695 RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
1696 struct key_binding *key_bindings_lookup(int);
1697 void key_bindings_add(int, int, struct cmd_list *);
1698 void key_bindings_remove(int);
1699 void key_bindings_clean(void);
1700 void key_bindings_init(void);
1701 void key_bindings_dispatch(struct key_binding *, struct client *);
1702 void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
1703 void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
1704 void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
1706 /* key-string.c */
1707 int key_string_lookup_string(const char *);
1708 const char *key_string_lookup_key(int);
1710 /* server.c */
1711 extern struct clients clients;
1712 extern struct clients dead_clients;
1713 extern struct paste_stack global_buffers;
1714 int server_start(int, char *);
1715 void server_update_socket(void);
1716 void server_add_accept(int);
1718 /* server-client.c */
1719 void server_client_create(int);
1720 void server_client_lost(struct client *);
1721 void server_client_callback(int, short, void *);
1722 void server_client_status_timer(void);
1723 void server_client_loop(void);
1725 /* server-window.c */
1726 void server_window_loop(void);
1728 /* server-fn.c */
1729 void server_fill_environ(struct session *, struct environ *);
1730 void server_write_client(
1731 struct client *, enum msgtype, const void *, size_t);
1732 void server_write_session(
1733 struct session *, enum msgtype, const void *, size_t);
1734 void server_redraw_client(struct client *);
1735 void server_status_client(struct client *);
1736 void server_redraw_session(struct session *);
1737 void server_redraw_session_group(struct session *);
1738 void server_status_session(struct session *);
1739 void server_status_session_group(struct session *);
1740 void server_redraw_window(struct window *);
1741 void server_redraw_window_borders(struct window *);
1742 void server_status_window(struct window *);
1743 void server_lock(void);
1744 void server_lock_session(struct session *);
1745 void server_lock_client(struct client *);
1746 int server_unlock(const char *);
1747 void server_kill_window(struct window *);
1748 int server_link_window(struct session *,
1749 struct winlink *, struct session *, int, int, int, char **);
1750 void server_unlink_window(struct session *, struct winlink *);
1751 void server_destroy_pane(struct window_pane *);
1752 void server_destroy_session_group(struct session *);
1753 void server_destroy_session(struct session *);
1754 void server_check_unattached (void);
1755 void server_set_identify(struct client *);
1756 void server_clear_identify(struct client *);
1757 void server_update_event(struct client *);
1759 /* status.c */
1760 int status_out_cmp(struct status_out *, struct status_out *);
1761 RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
1762 int status_at_line(struct client *);
1763 void status_free_jobs(struct status_out_tree *);
1764 void status_update_jobs(struct client *);
1765 void status_set_window_at(struct client *, u_int);
1766 int status_redraw(struct client *);
1767 char *status_replace(struct client *, struct session *,
1768 struct winlink *, struct window_pane *, const char *, time_t, int);
1769 void printflike2 status_message_set(struct client *, const char *, ...);
1770 void status_message_clear(struct client *);
1771 int status_message_redraw(struct client *);
1772 void status_prompt_set(struct client *, const char *, const char *,
1773 int (*)(void *, const char *), void (*)(void *), void *, int);
1774 void status_prompt_clear(struct client *);
1775 int status_prompt_redraw(struct client *);
1776 void status_prompt_key(struct client *, int);
1777 void status_prompt_update(struct client *, const char *, const char *);
1779 /* resize.c */
1780 void recalculate_sizes(void);
1782 /* input.c */
1783 void input_init(struct window_pane *);
1784 void input_free(struct window_pane *);
1785 void input_parse(struct window_pane *);
1787 /* input-key.c */
1788 void input_key(struct window_pane *, int);
1789 void input_mouse(struct window_pane *, struct mouse_event *);
1791 /* xterm-keys.c */
1792 char *xterm_keys_lookup(int);
1793 int xterm_keys_find(const char *, size_t, size_t *, int *);
1795 /* colour.c */
1796 void colour_set_fg(struct grid_cell *, int);
1797 void colour_set_bg(struct grid_cell *, int);
1798 const char *colour_tostring(int);
1799 int colour_fromstring(const char *);
1800 u_char colour_256to16(u_char);
1801 u_char colour_256to88(u_char);
1803 /* attributes.c */
1804 const char *attributes_tostring(u_char);
1805 int attributes_fromstring(const char *);
1807 /* grid.c */
1808 extern const struct grid_cell grid_default_cell;
1809 struct grid *grid_create(u_int, u_int, u_int);
1810 void grid_destroy(struct grid *);
1811 int grid_compare(struct grid *, struct grid *);
1812 void grid_collect_history(struct grid *);
1813 void grid_scroll_history(struct grid *);
1814 void grid_scroll_history_region(struct grid *, u_int, u_int);
1815 void grid_expand_line(struct grid *, u_int, u_int);
1816 void grid_expand_line_utf8(struct grid *, u_int, u_int);
1817 const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
1818 struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
1819 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
1820 const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
1821 struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
1822 void grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
1823 void grid_clear(struct grid *, u_int, u_int, u_int, u_int);
1824 void grid_clear_lines(struct grid *, u_int, u_int);
1825 void grid_move_lines(struct grid *, u_int, u_int, u_int);
1826 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1827 char *grid_string_cells(struct grid *, u_int, u_int, u_int);
1828 void grid_duplicate_lines(
1829 struct grid *, u_int, struct grid *, u_int, u_int);
1831 /* grid-utf8.c */
1832 size_t grid_utf8_size(const struct grid_utf8 *);
1833 size_t grid_utf8_copy(const struct grid_utf8 *, char *, size_t);
1834 void grid_utf8_set(struct grid_utf8 *, const struct utf8_data *);
1835 int grid_utf8_append(struct grid_utf8 *, const struct utf8_data *);
1836 int grid_utf8_compare(const struct grid_utf8 *, const struct grid_utf8 *);
1838 /* grid-view.c */
1839 const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
1840 struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
1841 void grid_view_set_cell(
1842 struct grid *, u_int, u_int, const struct grid_cell *);
1843 const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
1844 struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
1845 void grid_view_set_utf8(
1846 struct grid *, u_int, u_int, const struct grid_utf8 *);
1847 void grid_view_clear_history(struct grid *);
1848 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
1849 void grid_view_scroll_region_up(struct grid *, u_int, u_int);
1850 void grid_view_scroll_region_down(struct grid *, u_int, u_int);
1851 void grid_view_insert_lines(struct grid *, u_int, u_int);
1852 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1853 void grid_view_delete_lines(struct grid *, u_int, u_int);
1854 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1855 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
1856 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1857 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1859 /* screen-write.c */
1860 void screen_write_start(
1861 struct screen_write_ctx *, struct window_pane *, struct screen *);
1862 void screen_write_stop(struct screen_write_ctx *);
1863 void screen_write_reset(struct screen_write_ctx *);
1864 size_t printflike2 screen_write_cstrlen(int, const char *, ...);
1865 void printflike5 screen_write_cnputs(struct screen_write_ctx *,
1866 ssize_t, struct grid_cell *, int, const char *, ...);
1867 size_t printflike2 screen_write_strlen(int, const char *, ...);
1868 void printflike3 screen_write_puts(struct screen_write_ctx *,
1869 struct grid_cell *, const char *, ...);
1870 void printflike5 screen_write_nputs(struct screen_write_ctx *,
1871 ssize_t, struct grid_cell *, int, const char *, ...);
1872 void screen_write_vnputs(struct screen_write_ctx *,
1873 ssize_t, struct grid_cell *, int, const char *, va_list);
1874 void screen_write_parsestyle(
1875 struct grid_cell *, struct grid_cell *, const char *);
1876 void screen_write_putc(
1877 struct screen_write_ctx *, struct grid_cell *, u_char);
1878 void screen_write_copy(struct screen_write_ctx *,
1879 struct screen *, u_int, u_int, u_int, u_int);
1880 void screen_write_backspace(struct screen_write_ctx *);
1881 void screen_write_cursorup(struct screen_write_ctx *, u_int);
1882 void screen_write_cursordown(struct screen_write_ctx *, u_int);
1883 void screen_write_cursorright(struct screen_write_ctx *, u_int);
1884 void screen_write_cursorleft(struct screen_write_ctx *, u_int);
1885 void screen_write_alignmenttest(struct screen_write_ctx *);
1886 void screen_write_insertcharacter(struct screen_write_ctx *, u_int);
1887 void screen_write_deletecharacter(struct screen_write_ctx *, u_int);
1888 void screen_write_insertline(struct screen_write_ctx *, u_int);
1889 void screen_write_deleteline(struct screen_write_ctx *, u_int);
1890 void screen_write_clearline(struct screen_write_ctx *);
1891 void screen_write_clearendofline(struct screen_write_ctx *);
1892 void screen_write_clearstartofline(struct screen_write_ctx *);
1893 void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
1894 void screen_write_cursormode(struct screen_write_ctx *, int);
1895 void screen_write_reverseindex(struct screen_write_ctx *);
1896 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
1897 void screen_write_insertmode(struct screen_write_ctx *, int);
1898 void screen_write_utf8mousemode(struct screen_write_ctx *, int);
1899 void screen_write_mousemode_on(struct screen_write_ctx *, int);
1900 void screen_write_mousemode_off(struct screen_write_ctx *);
1901 void screen_write_linefeed(struct screen_write_ctx *, int);
1902 void screen_write_linefeedscreen(struct screen_write_ctx *, int);
1903 void screen_write_carriagereturn(struct screen_write_ctx *);
1904 void screen_write_kcursormode(struct screen_write_ctx *, int);
1905 void screen_write_kkeypadmode(struct screen_write_ctx *, int);
1906 void screen_write_clearendofscreen(struct screen_write_ctx *);
1907 void screen_write_clearstartofscreen(struct screen_write_ctx *);
1908 void screen_write_clearscreen(struct screen_write_ctx *);
1909 void screen_write_clearhistory(struct screen_write_ctx *);
1910 void screen_write_cell(struct screen_write_ctx *,
1911 const struct grid_cell *, const struct utf8_data *);
1912 void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
1913 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
1914 void screen_write_bracketpaste(struct screen_write_ctx *, int);
1916 /* screen-redraw.c */
1917 void screen_redraw_screen(struct client *, int, int);
1918 void screen_redraw_pane(struct client *, struct window_pane *);
1920 /* screen.c */
1921 void screen_init(struct screen *, u_int, u_int, u_int);
1922 void screen_reinit(struct screen *);
1923 void screen_free(struct screen *);
1924 void screen_reset_tabs(struct screen *);
1925 void screen_set_cursor_style(struct screen *, u_int);
1926 void screen_set_cursor_colour(struct screen *, const char *);
1927 void screen_set_title(struct screen *, const char *);
1928 void screen_resize(struct screen *, u_int, u_int);
1929 void screen_set_selection(struct screen *,
1930 u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
1931 void screen_clear_selection(struct screen *);
1932 int screen_check_selection(struct screen *, u_int, u_int);
1934 /* window.c */
1935 extern struct windows windows;
1936 extern struct window_pane_tree all_window_panes;
1937 int winlink_cmp(struct winlink *, struct winlink *);
1938 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
1939 int window_pane_cmp(struct window_pane *, struct window_pane *);
1940 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
1941 struct winlink *winlink_find_by_index(struct winlinks *, int);
1942 struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
1943 struct winlink *winlink_find_by_window_id(struct winlinks *, u_int);
1944 int winlink_next_index(struct winlinks *, int);
1945 u_int winlink_count(struct winlinks *);
1946 struct winlink *winlink_add(struct winlinks *, int);
1947 void winlink_set_window(struct winlink *, struct window *);
1948 void winlink_remove(struct winlinks *, struct winlink *);
1949 struct winlink *winlink_next(struct winlink *);
1950 struct winlink *winlink_previous(struct winlink *);
1951 struct winlink *winlink_next_by_number(struct winlink *, struct session *,
1952 int);
1953 struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
1954 int);
1955 void winlink_stack_push(struct winlink_stack *, struct winlink *);
1956 void winlink_stack_remove(struct winlink_stack *, struct winlink *);
1957 int window_index(struct window *, u_int *);
1958 struct window *window_find_by_id(u_int);
1959 struct window *window_create1(u_int, u_int);
1960 struct window *window_create(const char *, const char *, const char *,
1961 const char *, struct environ *, struct termios *,
1962 u_int, u_int, u_int, char **);
1963 void window_destroy(struct window *);
1964 struct window_pane *window_get_active_at(struct window *, u_int, u_int);
1965 void window_set_active_at(struct window *, u_int, u_int);
1966 struct window_pane *window_find_string(struct window *, const char *);
1967 void window_set_active_pane(struct window *, struct window_pane *);
1968 struct window_pane *window_add_pane(struct window *, u_int);
1969 void window_resize(struct window *, u_int, u_int);
1970 void window_remove_pane(struct window *, struct window_pane *);
1971 struct window_pane *window_pane_at_index(struct window *, u_int);
1972 struct window_pane *window_pane_next_by_number(struct window *,
1973 struct window_pane *, u_int);
1974 struct window_pane *window_pane_previous_by_number(struct window *,
1975 struct window_pane *, u_int);
1976 int window_pane_index(struct window_pane *, u_int *);
1977 u_int window_count_panes(struct window *);
1978 void window_destroy_panes(struct window *);
1979 struct window_pane *window_pane_find_by_id(u_int);
1980 struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
1981 void window_pane_destroy(struct window_pane *);
1982 void window_pane_timer_start(struct window_pane *);
1983 int window_pane_spawn(struct window_pane *, const char *,
1984 const char *, const char *, struct environ *,
1985 struct termios *, char **);
1986 void window_pane_resize(struct window_pane *, u_int, u_int);
1987 void window_pane_alternate_on(
1988 struct window_pane *, struct grid_cell *);
1989 void window_pane_alternate_off(
1990 struct window_pane *, struct grid_cell *);
1991 int window_pane_set_mode(
1992 struct window_pane *, const struct window_mode *);
1993 void window_pane_reset_mode(struct window_pane *);
1994 void window_pane_key(struct window_pane *, struct session *, int);
1995 void window_pane_mouse(struct window_pane *,
1996 struct session *, struct mouse_event *);
1997 int window_pane_visible(struct window_pane *);
1998 char *window_pane_search(
1999 struct window_pane *, const char *, u_int *);
2000 char *window_printable_flags(struct session *, struct winlink *);
2001 struct window_pane *window_pane_find_up(struct window_pane *);
2002 struct window_pane *window_pane_find_down(struct window_pane *);
2003 struct window_pane *window_pane_find_left(struct window_pane *);
2004 struct window_pane *window_pane_find_right(struct window_pane *);
2005 void window_set_name(struct window *, const char *);
2007 /* layout.c */
2008 u_int layout_count_cells(struct layout_cell *);
2009 struct layout_cell *layout_create_cell(struct layout_cell *);
2010 void layout_free_cell(struct layout_cell *);
2011 void layout_print_cell(struct layout_cell *, const char *, u_int);
2012 void layout_destroy_cell(
2013 struct layout_cell *, struct layout_cell **);
2014 void layout_set_size(
2015 struct layout_cell *, u_int, u_int, u_int, u_int);
2016 void layout_make_leaf(
2017 struct layout_cell *, struct window_pane *);
2018 void layout_make_node(struct layout_cell *, enum layout_type);
2019 void layout_fix_offsets(struct layout_cell *);
2020 void layout_fix_panes(struct window *, u_int, u_int);
2021 u_int layout_resize_check(struct layout_cell *, enum layout_type);
2022 void layout_resize_adjust(
2023 struct layout_cell *, enum layout_type, int);
2024 void layout_init(struct window *);
2025 void layout_free(struct window *);
2026 void layout_resize(struct window *, u_int, u_int);
2027 void layout_resize_pane(
2028 struct window_pane *, enum layout_type, int);
2029 void layout_resize_pane_mouse(
2030 struct client *c, struct mouse_event *mouse);
2031 void layout_assign_pane(struct layout_cell *, struct window_pane *);
2032 struct layout_cell *layout_split_pane(
2033 struct window_pane *, enum layout_type, int, int);
2034 void layout_close_pane(struct window_pane *);
2035 void layout_list_add(struct window *);
2036 const char *layout_list_redo(struct window *);
2037 const char *layout_list_undo(struct window *);
2039 /* layout-custom.c */
2040 char *layout_dump(struct window *);
2041 int layout_parse(struct window *, const char *);
2043 /* layout-set.c */
2044 const char *layout_set_name(u_int);
2045 int layout_set_lookup(const char *);
2046 u_int layout_set_select(struct window *, u_int);
2047 u_int layout_set_next(struct window *);
2048 u_int layout_set_previous(struct window *);
2049 void layout_set_active_changed(struct window *);
2051 /* window-clock.c */
2052 extern const struct window_mode window_clock_mode;
2054 /* window-copy.c */
2055 extern const struct window_mode window_copy_mode;
2056 void window_copy_init_from_pane(struct window_pane *);
2057 void window_copy_init_for_output(struct window_pane *);
2058 void printflike2 window_copy_add(struct window_pane *, const char *, ...);
2059 void window_copy_vadd(struct window_pane *, const char *, va_list);
2060 void window_copy_pageup(struct window_pane *);
2062 /* window-choose.c */
2063 extern const struct window_mode window_choose_mode;
2064 void window_choose_vadd(
2065 struct window_pane *, int, const char *, va_list);
2066 void printflike3 window_choose_add(
2067 struct window_pane *, int, const char *, ...);
2068 void window_choose_ready(struct window_pane *,
2069 u_int, void (*)(void *, int), void (*)(void *), void *);
2071 /* names.c */
2072 void queue_window_name(struct window *);
2073 char *default_window_name(struct window *);
2075 /* signal.c */
2076 void set_signals(void(*)(int, short, void *));
2077 void clear_signals(int);
2079 /* session.c */
2080 extern struct sessions sessions;
2081 extern struct sessions dead_sessions;
2082 extern struct session_groups session_groups;
2083 int session_cmp(struct session *, struct session *);
2084 RB_PROTOTYPE(sessions, session, entry, session_cmp);
2085 int session_alive(struct session *);
2086 struct session *session_find(const char *);
2087 struct session *session_find_by_index(u_int);
2088 struct session *session_create(const char *, const char *, const char *,
2089 struct environ *, struct termios *, int, u_int, u_int,
2090 char **);
2091 void session_destroy(struct session *);
2092 int session_check_name(const char *);
2093 void session_update_activity(struct session *);
2094 struct session *session_next_session(struct session *);
2095 struct session *session_previous_session(struct session *);
2096 struct winlink *session_new(struct session *,
2097 const char *, const char *, const char *, int, char **);
2098 struct winlink *session_attach(
2099 struct session *, struct window *, int, char **);
2100 int session_detach(struct session *, struct winlink *);
2101 struct winlink* session_has(struct session *, struct window *);
2102 int session_next(struct session *, int);
2103 int session_previous(struct session *, int);
2104 int session_select(struct session *, int);
2105 int session_last(struct session *);
2106 struct session_group *session_group_find(struct session *);
2107 u_int session_group_index(struct session_group *);
2108 void session_group_add(struct session *, struct session *);
2109 void session_group_remove(struct session *);
2110 void session_group_synchronize_to(struct session *);
2111 void session_group_synchronize_from(struct session *);
2112 void session_group_synchronize1(struct session *, struct session *);
2114 /* utf8.c */
2115 void utf8_build(void);
2116 int utf8_open(struct utf8_data *, u_char);
2117 int utf8_append(struct utf8_data *, u_char);
2118 u_int utf8_combine(const struct utf8_data *);
2119 u_int utf8_split2(u_int, u_char *);
2121 /* procname.c */
2122 char *get_proc_name(int, char *);
2123 char *get_proc_cwd(pid_t);
2125 /* log.c */
2126 void log_open_tty(int);
2127 void log_open_file(int, const char *);
2128 void log_close(void);
2129 void printflike1 log_warn(const char *, ...);
2130 void printflike1 log_warnx(const char *, ...);
2131 void printflike1 log_info(const char *, ...);
2132 void printflike1 log_debug(const char *, ...);
2133 void printflike1 log_debug2(const char *, ...);
2134 __dead void printflike1 log_fatal(const char *, ...);
2135 __dead void printflike1 log_fatalx(const char *, ...);
2137 /* xmalloc.c */
2138 char *xstrdup(const char *);
2139 void *xcalloc(size_t, size_t);
2140 void *xmalloc(size_t);
2141 void *xrealloc(void *, size_t, size_t);
2142 void xfree(void *);
2143 int printflike2 xasprintf(char **, const char *, ...);
2144 int xvasprintf(char **, const char *, va_list);
2145 int printflike3 xsnprintf(char *, size_t, const char *, ...);
2146 int xvsnprintf(char *, size_t, const char *, va_list);
2148 #endif /* TMUX_H */