1/* $OpenBSD$ */
2
3/*
4 * Copyright (c) 2007 Nicholas Marriott <[email protected]>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#ifndef TMUX_H
20#define TMUX_H
21
22#include <sys/time.h>
23#include <sys/uio.h>
24
25#include <event.h>
26#include <limits.h>
27#include <stdarg.h>
28#include <stdio.h>
29#include <termios.h>
30#include <wchar.h>
31
32#ifdef HAVE_UTEMPTER
33#include <utempter.h>
34#endif
35
36#include "compat.h"
37#include "xmalloc.h"
38
39extern char **environ;
40
41struct args;
42struct args_value;
43struct client;
44struct cmd_find_state;
45struct cmdq_item;
46struct cmdq_list;
47struct environ;
48struct format_job_tree;
49struct format_tree;
50struct input_ctx;
51struct job;
52struct mode_tree_data;
53struct mouse_event;
54struct options;
55struct options_entry;
56struct options_array_item;
57struct session;
58struct tmuxpeer;
59struct tmuxproc;
60struct winlink;
61
62/* Client-server protocol version. */
63#define PROTOCOL_VERSION 8
64
65/* Default configuration files. */
66#ifndef TMUX_CONF
67#define TMUX_CONF "/etc/tmux.conf:~/.tmux.conf"
68#endif
69
70/* Minimum layout cell size, NOT including border lines. */
71#define PANE_MINIMUM 1
72
73/* Minimum and maximum window size. */
74#define WINDOW_MINIMUM PANE_MINIMUM
75#define WINDOW_MAXIMUM 10000
76
77/* Automatic name refresh interval, in microseconds. Must be < 1 second. */
78#define NAME_INTERVAL 500000
79
80/* Maximum size of data to hold from a pane. */
81#define READ_SIZE 4096
82
83/* Default pixel cell sizes. */
84#define DEFAULT_XPIXEL 16
85#define DEFAULT_YPIXEL 32
86
87/* Attribute to make GCC check printf-like arguments. */
88#define printflike(a, b) __attribute__ ((format (printf, a, b)))
89
90/* Number of items in array. */
91#ifndef nitems
92#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
93#endif
94
95/* Alert option values. */
96#define ALERT_NONE 0
97#define ALERT_ANY 1
98#define ALERT_CURRENT 2
99#define ALERT_OTHER 3
100
101/* Visual option values. */
102#define VISUAL_OFF 0
103#define VISUAL_ON 1
104#define VISUAL_BOTH 2
105
106/* Special key codes. */
107#define KEYC_NONE 0xffff00000000ULL
108#define KEYC_UNKNOWN 0xfffe00000000ULL
109#define KEYC_BASE 0x000010000000ULL
110#define KEYC_USER 0x000020000000ULL
111
112/* Available user keys. */
113#define KEYC_NUSER 1000
114
115/* Key modifier bits. */
116#define KEYC_ESCAPE 0x200000000000ULL
117#define KEYC_CTRL 0x400000000000ULL
118#define KEYC_SHIFT 0x800000000000ULL
119#define KEYC_XTERM 0x1000000000000ULL
120#define KEYC_LITERAL 0x2000000000000ULL
121
122/* Mask to obtain key w/o modifiers. */
123#define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_XTERM|KEYC_LITERAL)
124#define KEYC_MASK_KEY (~KEYC_MASK_MOD)
125
126/* Is this a mouse key? */
127#define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \
128 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
129
130/* Multiple click timeout. */
131#define KEYC_CLICK_TIMEOUT 300
132
133/* Mouse key codes. */
134#define KEYC_MOUSE_KEY(name) \
135 KEYC_ ## name ## _PANE, \
136 KEYC_ ## name ## _STATUS, \
137 KEYC_ ## name ## _STATUS_LEFT, \
138 KEYC_ ## name ## _STATUS_RIGHT, \
139 KEYC_ ## name ## _STATUS_DEFAULT, \
140 KEYC_ ## name ## _BORDER
141#define KEYC_MOUSE_STRING(name, s) \
142 { #s "Pane", KEYC_ ## name ## _PANE }, \
143 { #s "Status", KEYC_ ## name ## _STATUS }, \
144 { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \
145 { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \
146 { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \
147 { #s "Border", KEYC_ ## name ## _BORDER }
148
149/*
150 * A single key. This can be ASCII or Unicode or one of the keys starting at
151 * KEYC_BASE.
152 */
153typedef unsigned long long key_code;
154
155/* Special key codes. */
156enum {
157 /* Focus events. */
158 KEYC_FOCUS_IN = KEYC_BASE,
159 KEYC_FOCUS_OUT,
160
161 /* "Any" key, used if not found in key table. */
162 KEYC_ANY,
163
164 /* Paste brackets. */
165 KEYC_PASTE_START,
166 KEYC_PASTE_END,
167
168 /* Mouse keys. */
169 KEYC_MOUSE, /* unclassified mouse event */
170 KEYC_DRAGGING, /* dragging in progress */
171 KEYC_MOUSE_KEY(MOUSEMOVE),
172 KEYC_MOUSE_KEY(MOUSEDOWN1),
173 KEYC_MOUSE_KEY(MOUSEDOWN2),
174 KEYC_MOUSE_KEY(MOUSEDOWN3),
175 KEYC_MOUSE_KEY(MOUSEUP1),
176 KEYC_MOUSE_KEY(MOUSEUP2),
177 KEYC_MOUSE_KEY(MOUSEUP3),
178 KEYC_MOUSE_KEY(MOUSEDRAG1),
179 KEYC_MOUSE_KEY(MOUSEDRAG2),
180 KEYC_MOUSE_KEY(MOUSEDRAG3),
181 KEYC_MOUSE_KEY(MOUSEDRAGEND1),
182 KEYC_MOUSE_KEY(MOUSEDRAGEND2),
183 KEYC_MOUSE_KEY(MOUSEDRAGEND3),
184 KEYC_MOUSE_KEY(WHEELUP),
185 KEYC_MOUSE_KEY(WHEELDOWN),
186 KEYC_MOUSE_KEY(DOUBLECLICK1),
187 KEYC_MOUSE_KEY(DOUBLECLICK2),
188 KEYC_MOUSE_KEY(DOUBLECLICK3),
189 KEYC_MOUSE_KEY(TRIPLECLICK1),
190 KEYC_MOUSE_KEY(TRIPLECLICK2),
191 KEYC_MOUSE_KEY(TRIPLECLICK3),
192
193 /* Backspace key. */
194 KEYC_BSPACE,
195
196 /* Function keys. */
197 KEYC_F1,
198 KEYC_F2,
199 KEYC_F3,
200 KEYC_F4,
201 KEYC_F5,
202 KEYC_F6,
203 KEYC_F7,
204 KEYC_F8,
205 KEYC_F9,
206 KEYC_F10,
207 KEYC_F11,
208 KEYC_F12,
209 KEYC_IC,
210 KEYC_DC,
211 KEYC_HOME,
212 KEYC_END,
213 KEYC_NPAGE,
214 KEYC_PPAGE,
215 KEYC_BTAB,
216
217 /* Arrow keys. */
218 KEYC_UP,
219 KEYC_DOWN,
220 KEYC_LEFT,
221 KEYC_RIGHT,
222
223 /* Numeric keypad. */
224 KEYC_KP_SLASH,
225 KEYC_KP_STAR,
226 KEYC_KP_MINUS,
227 KEYC_KP_SEVEN,
228 KEYC_KP_EIGHT,
229 KEYC_KP_NINE,
230 KEYC_KP_PLUS,
231 KEYC_KP_FOUR,
232 KEYC_KP_FIVE,
233 KEYC_KP_SIX,
234 KEYC_KP_ONE,
235 KEYC_KP_TWO,
236 KEYC_KP_THREE,
237 KEYC_KP_ENTER,
238 KEYC_KP_ZERO,
239 KEYC_KP_PERIOD,
240};
241
242/* Termcap codes. */
243enum tty_code_code {
244 TTYC_ACSC,
245 TTYC_AX,
246 TTYC_BCE,
247 TTYC_BEL,
248 TTYC_BLINK,
249 TTYC_BOLD,
250 TTYC_CIVIS,
251 TTYC_CLEAR,
252 TTYC_CNORM,
253 TTYC_COLORS,
254 TTYC_CR,
255 TTYC_CS,
256 TTYC_CSR,
257 TTYC_CUB,
258 TTYC_CUB1,
259 TTYC_CUD,
260 TTYC_CUD1,
261 TTYC_CUF,
262 TTYC_CUF1,
263 TTYC_CUP,
264 TTYC_CUU,
265 TTYC_CUU1,
266 TTYC_CVVIS,
267 TTYC_DCH,
268 TTYC_DCH1,
269 TTYC_DIM,
270 TTYC_DL,
271 TTYC_DL1,
272 TTYC_E3,
273 TTYC_ECH,
274 TTYC_ED,
275 TTYC_EL,
276 TTYC_EL1,
277 TTYC_ENACS,
278 TTYC_FSL,
279 TTYC_HOME,
280 TTYC_HPA,
281 TTYC_ICH,
282 TTYC_ICH1,
283 TTYC_IL,
284 TTYC_IL1,
285 TTYC_INDN,
286 TTYC_INVIS,
287 TTYC_KCBT,
288 TTYC_KCUB1,
289 TTYC_KCUD1,
290 TTYC_KCUF1,
291 TTYC_KCUU1,
292 TTYC_KDC2,
293 TTYC_KDC3,
294 TTYC_KDC4,
295 TTYC_KDC5,
296 TTYC_KDC6,
297 TTYC_KDC7,
298 TTYC_KDCH1,
299 TTYC_KDN2,
300 TTYC_KDN3,
301 TTYC_KDN4,
302 TTYC_KDN5,
303 TTYC_KDN6,
304 TTYC_KDN7,
305 TTYC_KEND,
306 TTYC_KEND2,
307 TTYC_KEND3,
308 TTYC_KEND4,
309 TTYC_KEND5,
310 TTYC_KEND6,
311 TTYC_KEND7,
312 TTYC_KF1,
313 TTYC_KF10,
314 TTYC_KF11,
315 TTYC_KF12,
316 TTYC_KF13,
317 TTYC_KF14,
318 TTYC_KF15,
319 TTYC_KF16,
320 TTYC_KF17,
321 TTYC_KF18,
322 TTYC_KF19,
323 TTYC_KF2,
324 TTYC_KF20,
325 TTYC_KF21,
326 TTYC_KF22,
327 TTYC_KF23,
328 TTYC_KF24,
329 TTYC_KF25,
330 TTYC_KF26,
331 TTYC_KF27,
332 TTYC_KF28,
333 TTYC_KF29,
334 TTYC_KF3,
335 TTYC_KF30,
336 TTYC_KF31,
337 TTYC_KF32,
338 TTYC_KF33,
339 TTYC_KF34,
340 TTYC_KF35,
341 TTYC_KF36,
342 TTYC_KF37,
343 TTYC_KF38,
344 TTYC_KF39,
345 TTYC_KF4,
346 TTYC_KF40,
347 TTYC_KF41,
348 TTYC_KF42,
349 TTYC_KF43,
350 TTYC_KF44,
351 TTYC_KF45,
352 TTYC_KF46,
353 TTYC_KF47,
354 TTYC_KF48,
355 TTYC_KF49,
356 TTYC_KF5,
357 TTYC_KF50,
358 TTYC_KF51,
359 TTYC_KF52,
360 TTYC_KF53,
361 TTYC_KF54,
362 TTYC_KF55,
363 TTYC_KF56,
364 TTYC_KF57,
365 TTYC_KF58,
366 TTYC_KF59,
367 TTYC_KF6,
368 TTYC_KF60,
369 TTYC_KF61,
370 TTYC_KF62,
371 TTYC_KF63,
372 TTYC_KF7,
373 TTYC_KF8,
374 TTYC_KF9,
375 TTYC_KHOM2,
376 TTYC_KHOM3,
377 TTYC_KHOM4,
378 TTYC_KHOM5,
379 TTYC_KHOM6,
380 TTYC_KHOM7,
381 TTYC_KHOME,
382 TTYC_KIC2,
383 TTYC_KIC3,
384 TTYC_KIC4,
385 TTYC_KIC5,
386 TTYC_KIC6,
387 TTYC_KIC7,
388 TTYC_KICH1,
389 TTYC_KIND,
390 TTYC_KLFT2,
391 TTYC_KLFT3,
392 TTYC_KLFT4,
393 TTYC_KLFT5,
394 TTYC_KLFT6,
395 TTYC_KLFT7,
396 TTYC_KMOUS,
397 TTYC_KNP,
398 TTYC_KNXT2,
399 TTYC_KNXT3,
400 TTYC_KNXT4,
401 TTYC_KNXT5,
402 TTYC_KNXT6,
403 TTYC_KNXT7,
404 TTYC_KPP,
405 TTYC_KPRV2,
406 TTYC_KPRV3,
407 TTYC_KPRV4,
408 TTYC_KPRV5,
409 TTYC_KPRV6,
410 TTYC_KPRV7,
411 TTYC_KRI,
412 TTYC_KRIT2,
413 TTYC_KRIT3,
414 TTYC_KRIT4,
415 TTYC_KRIT5,
416 TTYC_KRIT6,
417 TTYC_KRIT7,
418 TTYC_KUP2,
419 TTYC_KUP3,
420 TTYC_KUP4,
421 TTYC_KUP5,
422 TTYC_KUP6,
423 TTYC_KUP7,
424 TTYC_MS,
425 TTYC_OP,
426 TTYC_REV,
427 TTYC_RGB,
428 TTYC_RI,
429 TTYC_RIN,
430 TTYC_RMACS,
431 TTYC_RMCUP,
432 TTYC_RMKX,
433 TTYC_SE,
434 TTYC_SETAB,
435 TTYC_SETAF,
436 TTYC_SETRGBB,
437 TTYC_SETRGBF,
438 TTYC_SETULC,
439 TTYC_SGR0,
440 TTYC_SITM,
441 TTYC_SMACS,
442 TTYC_SMCUP,
443 TTYC_SMOL,
444 TTYC_SMKX,
445 TTYC_SMSO,
446 TTYC_SMULX,
447 TTYC_SMUL,
448 TTYC_SMXX,
449 TTYC_SS,
450 TTYC_TC,
451 TTYC_TSL,
452 TTYC_U8,
453 TTYC_VPA,
454 TTYC_XENL,
455 TTYC_XT,
456};
457
458/* Message codes. */
459enum msgtype {
460 MSG_VERSION = 12,
461
462 MSG_IDENTIFY_FLAGS = 100,
463 MSG_IDENTIFY_TERM,
464 MSG_IDENTIFY_TTYNAME,
465 MSG_IDENTIFY_OLDCWD, /* unused */
466 MSG_IDENTIFY_STDIN,
467 MSG_IDENTIFY_ENVIRON,
468 MSG_IDENTIFY_DONE,
469 MSG_IDENTIFY_CLIENTPID,
470 MSG_IDENTIFY_CWD,
471
472 MSG_COMMAND = 200,
473 MSG_DETACH,
474 MSG_DETACHKILL,
475 MSG_EXIT,
476 MSG_EXITED,
477 MSG_EXITING,
478 MSG_LOCK,
479 MSG_READY,
480 MSG_RESIZE,
481 MSG_SHELL,
482 MSG_SHUTDOWN,
483 MSG_OLDSTDERR, /* unused */
484 MSG_OLDSTDIN, /* unused */
485 MSG_OLDSTDOUT, /* unused */
486 MSG_SUSPEND,
487 MSG_UNLOCK,
488 MSG_WAKEUP,
489 MSG_EXEC,
490
491 MSG_READ_OPEN = 300,
492 MSG_READ,
493 MSG_READ_DONE,
494 MSG_WRITE_OPEN,
495 MSG_WRITE,
496 MSG_WRITE_READY,
497 MSG_WRITE_CLOSE
498};
499
500/*
501 * Message data.
502 *
503 * Don't forget to bump PROTOCOL_VERSION if any of these change!
504 */
505struct msg_command {
506 int argc;
507}; /* followed by packed argv */
508
509struct msg_read_open {
510 int stream;
511 int fd;
512}; /* followed by path */
513
514struct msg_read_data {
515 int stream;
516};
517
518struct msg_read_done {
519 int stream;
520 int error;
521};
522
523struct msg_write_open {
524 int stream;
525 int fd;
526 int flags;
527}; /* followed by path */
528
529struct msg_write_data {
530 int stream;
531}; /* followed by data */
532
533struct msg_write_ready {
534 int stream;
535 int error;
536};
537
538struct msg_write_close {
539 int stream;
540};
541
542/* Mode keys. */
543#define MODEKEY_EMACS 0
544#define MODEKEY_VI 1
545
546/* Modes. */
547#define MODE_CURSOR 0x1
548#define MODE_INSERT 0x2
549#define MODE_KCURSOR 0x4
550#define MODE_KKEYPAD 0x8 /* set = application, clear = number */
551#define MODE_WRAP 0x10 /* whether lines wrap */
552#define MODE_MOUSE_STANDARD 0x20
553#define MODE_MOUSE_BUTTON 0x40
554#define MODE_BLINKING 0x80
555#define MODE_MOUSE_UTF8 0x100
556#define MODE_MOUSE_SGR 0x200
557#define MODE_BRACKETPASTE 0x400
558#define MODE_FOCUSON 0x800
559#define MODE_MOUSE_ALL 0x1000
560#define MODE_ORIGIN 0x2000
561#define MODE_CRLF 0x4000
562
563#define ALL_MODES 0xffffff
564#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
565
566/*
567 * A single UTF-8 character. UTF8_SIZE must be big enough to hold
568 * combining characters as well, currently at most five (of three
569 * bytes) are supported.
570*/
571#define UTF8_SIZE 18
572struct utf8_data {
573 u_char data[UTF8_SIZE];
574
575 u_char have;
576 u_char size;
577
578 u_char width; /* 0xff if invalid */
579} __packed;
580enum utf8_state {
581 UTF8_MORE,
582 UTF8_DONE,
583 UTF8_ERROR
584};
585
586/* Colour flags. */
587#define COLOUR_FLAG_256 0x01000000
588#define COLOUR_FLAG_RGB 0x02000000
589
590/* Special colours. */
591#define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
592
593/* Grid attributes. Anything above 0xff is stored in an extended cell. */
594#define GRID_ATTR_BRIGHT 0x1
595#define GRID_ATTR_DIM 0x2
596#define GRID_ATTR_UNDERSCORE 0x4
597#define GRID_ATTR_BLINK 0x8
598#define GRID_ATTR_REVERSE 0x10
599#define GRID_ATTR_HIDDEN 0x20
600#define GRID_ATTR_ITALICS 0x40
601#define GRID_ATTR_CHARSET 0x80 /* alternative character set */
602#define GRID_ATTR_STRIKETHROUGH 0x100
603#define GRID_ATTR_UNDERSCORE_2 0x200
604#define GRID_ATTR_UNDERSCORE_3 0x400
605#define GRID_ATTR_UNDERSCORE_4 0x800
606#define GRID_ATTR_UNDERSCORE_5 0x1000
607#define GRID_ATTR_OVERLINE 0x2000
608
609/* All underscore attributes. */
610#define GRID_ATTR_ALL_UNDERSCORE \
611 (GRID_ATTR_UNDERSCORE| \
612 GRID_ATTR_UNDERSCORE_2| \
613 GRID_ATTR_UNDERSCORE_3| \
614 GRID_ATTR_UNDERSCORE_4| \
615 GRID_ATTR_UNDERSCORE_5)
616
617/* Grid flags. */
618#define GRID_FLAG_FG256 0x1
619#define GRID_FLAG_BG256 0x2
620#define GRID_FLAG_PADDING 0x4
621#define GRID_FLAG_EXTENDED 0x8
622#define GRID_FLAG_SELECTED 0x10
623#define GRID_FLAG_NOPALETTE 0x20
624#define GRID_FLAG_CLEARED 0x40
625
626/* Grid line flags. */
627#define GRID_LINE_WRAPPED 0x1
628#define GRID_LINE_EXTENDED 0x2
629#define GRID_LINE_DEAD 0x4
630
631/* Grid cell data. */
632struct grid_cell {
633 struct utf8_data data; /* 21 bytes */
634 u_short attr;
635 u_char flags;
636 int fg;
637 int bg;
638 int us;
639} __packed;
640struct grid_cell_entry {
641 u_char flags;
642 union {
643 u_int offset;
644 struct {
645 u_char attr;
646 u_char fg;
647 u_char bg;
648 u_char data;
649 } data;
650 };
651} __packed;
652
653/* Grid line. */
654struct grid_line {
655 u_int cellused;
656 u_int cellsize;
657 struct grid_cell_entry *celldata;
658
659 u_int extdsize;
660 struct grid_cell *extddata;
661
662 int flags;
663} __packed;
664
665/* Entire grid of cells. */
666struct grid {
667 int flags;
668#define GRID_HISTORY 0x1 /* scroll lines into history */
669
670 u_int sx;
671 u_int sy;
672
673 u_int hscrolled;
674 u_int hsize;
675 u_int hlimit;
676
677 struct grid_line *linedata;
678};
679
680/* Style alignment. */
681enum style_align {
682 STYLE_ALIGN_DEFAULT,
683 STYLE_ALIGN_LEFT,
684 STYLE_ALIGN_CENTRE,
685 STYLE_ALIGN_RIGHT
686};
687
688/* Style list. */
689enum style_list {
690 STYLE_LIST_OFF,
691 STYLE_LIST_ON,
692 STYLE_LIST_FOCUS,
693 STYLE_LIST_LEFT_MARKER,
694 STYLE_LIST_RIGHT_MARKER,
695};
696
697/* Style range. */
698enum style_range_type {
699 STYLE_RANGE_NONE,
700 STYLE_RANGE_LEFT,
701 STYLE_RANGE_RIGHT,
702 STYLE_RANGE_WINDOW
703};
704struct style_range {
705 enum style_range_type type;
706 u_int argument;
707
708 u_int start;
709 u_int end; /* not included */
710
711 TAILQ_ENTRY(style_range) entry;
712};
713TAILQ_HEAD(style_ranges, style_range);
714
715/* Style default. */
716enum style_default_type {
717 STYLE_DEFAULT_BASE,
718 STYLE_DEFAULT_PUSH,
719 STYLE_DEFAULT_POP
720};
721
722/* Style option. */
723struct style {
724 struct grid_cell gc;
725
726 int fill;
727 enum style_align align;
728 enum style_list list;
729
730 enum style_range_type range_type;
731 u_int range_argument;
732
733 enum style_default_type default_type;
734};
735
736/* Virtual screen. */
737struct screen_sel;
738struct screen_titles;
739struct screen {
740 char *title;
741 char *path;
742 struct screen_titles *titles;
743
744 struct grid *grid; /* grid data */
745
746 u_int cx; /* cursor x */
747 u_int cy; /* cursor y */
748
749 u_int cstyle; /* cursor style */
750 char *ccolour; /* cursor colour string */
751
752 u_int rupper; /* scroll region top */
753 u_int rlower; /* scroll region bottom */
754
755 int mode;
756
757 bitstr_t *tabs;
758
759 struct screen_sel *sel;
760};
761
762/* Screen write context. */
763struct screen_write_collect_item;
764struct screen_write_collect_line;
765struct screen_write_ctx {
766 struct window_pane *wp;
767 struct screen *s;
768
769 struct screen_write_collect_item *item;
770 struct screen_write_collect_line *list;
771 u_int scrolled;
772 u_int bg;
773
774 u_int cells;
775 u_int written;
776 u_int skipped;
777};
778
779/* Screen redraw context. */
780struct screen_redraw_ctx {
781 struct client *c;
782
783 u_int statuslines;
784 int statustop;
785
786 int pane_status;
787
788 u_int sx;
789 u_int sy;
790 u_int ox;
791 u_int oy;
792};
793
794/* Screen size. */
795#define screen_size_x(s) ((s)->grid->sx)
796#define screen_size_y(s) ((s)->grid->sy)
797#define screen_hsize(s) ((s)->grid->hsize)
798#define screen_hlimit(s) ((s)->grid->hlimit)
799
800/* Menu. */
801struct menu_item {
802 const char *name;
803 key_code key;
804 const char *command;
805};
806struct menu {
807 const char *title;
808 struct menu_item *items;
809 u_int count;
810 u_int width;
811};
812typedef void (*menu_choice_cb)(struct menu *, u_int, key_code, void *);
813#define MENU_NOMOUSE 0x1
814
815/*
816 * Window mode. Windows can be in several modes and this is used to call the
817 * right function to handle input and output.
818 */
819struct window_mode_entry;
820struct window_mode {
821 const char *name;
822 const char *default_format;
823
824 struct screen *(*init)(struct window_mode_entry *,
825 struct cmd_find_state *, struct args *);
826 void (*free)(struct window_mode_entry *);
827 void (*resize)(struct window_mode_entry *, u_int, u_int);
828 void (*key)(struct window_mode_entry *, struct client *,
829 struct session *, struct winlink *, key_code,
830 struct mouse_event *);
831
832 const char *(*key_table)(struct window_mode_entry *);
833 void (*command)(struct window_mode_entry *, struct client *,
834 struct session *, struct winlink *, struct args *,
835 struct mouse_event *);
836 void (*formats)(struct window_mode_entry *,
837 struct format_tree *);
838};
839#define WINDOW_MODE_TIMEOUT 180
840
841/* Active window mode. */
842struct window_mode_entry {
843 struct window_pane *wp;
844
845 const struct window_mode *mode;
846 void *data;
847
848 struct screen *screen;
849 u_int prefix;
850
851 TAILQ_ENTRY (window_mode_entry) entry;
852};
853
854/* Child window structure. */
855struct window_pane {
856 u_int id;
857 u_int active_point;
858
859 struct window *window;
860 struct options *options;
861
862 struct layout_cell *layout_cell;
863 struct layout_cell *saved_layout_cell;
864
865 u_int sx;
866 u_int sy;
867
868 u_int osx;
869 u_int osy;
870
871 u_int xoff;
872 u_int yoff;
873
874 int flags;
875#define PANE_REDRAW 0x1
876#define PANE_DROP 0x2
877#define PANE_FOCUSED 0x4
878#define PANE_RESIZE 0x8
879#define PANE_RESIZEFORCE 0x10
880#define PANE_FOCUSPUSH 0x20
881#define PANE_INPUTOFF 0x40
882#define PANE_CHANGED 0x80
883#define PANE_EXITED 0x100
884#define PANE_STATUSREADY 0x200
885#define PANE_STATUSDRAWN 0x400
886#define PANE_EMPTY 0x800
887#define PANE_STYLECHANGED 0x1000
888#define PANE_RESIZED 0x2000
889
890 int argc;
891 char **argv;
892 char *shell;
893 char *cwd;
894
895 pid_t pid;
896 char tty[TTY_NAME_MAX];
897 int status;
898
899 int fd;
900 struct bufferevent *event;
901 u_int disabled;
902
903 struct event resize_timer;
904
905 struct input_ctx *ictx;
906
907 struct style cached_style;
908 struct style cached_active_style;
909 int *palette;
910
911 int pipe_fd;
912 struct bufferevent *pipe_event;
913 size_t pipe_off;
914
915 struct screen *screen;
916 struct screen base;
917
918 struct screen status_screen;
919 size_t status_size;
920
921 /* Saved in alternative screen mode. */
922 u_int saved_cx;
923 u_int saved_cy;
924 struct grid *saved_grid;
925 struct grid_cell saved_cell;
926
927 TAILQ_HEAD (, window_mode_entry) modes;
928 struct event modetimer;
929 time_t modelast;
930
931 char *searchstr;
932 int searchregex;
933
934 TAILQ_ENTRY(window_pane) entry;
935 RB_ENTRY(window_pane) tree_entry;
936};
937TAILQ_HEAD(window_panes, window_pane);
938RB_HEAD(window_pane_tree, window_pane);
939
940/* Window structure. */
941struct window {
942 u_int id;
943 void *latest;
944
945 char *name;
946 struct event name_event;
947 struct timeval name_time;
948
949 struct event alerts_timer;
950 struct event offset_timer;
951
952 struct timeval activity_time;
953
954 struct window_pane *active;
955 struct window_pane *last;
956 struct window_panes panes;
957
958 int lastlayout;
959 struct layout_cell *layout_root;
960 struct layout_cell *saved_layout_root;
961 char *old_layout;
962
963 u_int sx;
964 u_int sy;
965 u_int xpixel;
966 u_int ypixel;
967
968 int flags;
969#define WINDOW_BELL 0x1
970#define WINDOW_ACTIVITY 0x2
971#define WINDOW_SILENCE 0x4
972#define WINDOW_ZOOMED 0x8
973#define WINDOW_WASZOOMED 0x10
974#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
975
976 int alerts_queued;
977 TAILQ_ENTRY(window) alerts_entry;
978
979 struct options *options;
980
981 u_int references;
982 TAILQ_HEAD(, winlink) winlinks;
983
984 RB_ENTRY(window) entry;
985};
986RB_HEAD(windows, window);
987
988/* Entry on local window list. */
989struct winlink {
990 int idx;
991 struct session *session;
992 struct window *window;
993
994 int flags;
995#define WINLINK_BELL 0x1
996#define WINLINK_ACTIVITY 0x2
997#define WINLINK_SILENCE 0x4
998#define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
999
1000 RB_ENTRY(winlink) entry;
1001 TAILQ_ENTRY(winlink) wentry;
1002 TAILQ_ENTRY(winlink) sentry;
1003};
1004RB_HEAD(winlinks, winlink);
1005TAILQ_HEAD(winlink_stack, winlink);
1006
1007/* Window size option. */
1008#define WINDOW_SIZE_LARGEST 0
1009#define WINDOW_SIZE_SMALLEST 1
1010#define WINDOW_SIZE_MANUAL 2
1011#define WINDOW_SIZE_LATEST 3
1012
1013/* Pane border status option. */
1014#define PANE_STATUS_OFF 0
1015#define PANE_STATUS_TOP 1
1016#define PANE_STATUS_BOTTOM 2
1017
1018/* Layout direction. */
1019enum layout_type {
1020 LAYOUT_LEFTRIGHT,
1021 LAYOUT_TOPBOTTOM,
1022 LAYOUT_WINDOWPANE
1023};
1024
1025/* Layout cells queue. */
1026TAILQ_HEAD(layout_cells, layout_cell);
1027
1028/* Layout cell. */
1029struct layout_cell {
1030 enum layout_type type;
1031
1032 struct layout_cell *parent;
1033
1034 u_int sx;
1035 u_int sy;
1036
1037 u_int xoff;
1038 u_int yoff;
1039
1040 struct window_pane *wp;
1041 struct layout_cells cells;
1042
1043 TAILQ_ENTRY(layout_cell) entry;
1044};
1045
1046/* Environment variable. */
1047struct environ_entry {
1048 char *name;
1049 char *value;
1050
1051 RB_ENTRY(environ_entry) entry;
1052};
1053
1054/* Client session. */
1055struct session_group {
1056 const char *name;
1057 TAILQ_HEAD(, session) sessions;
1058
1059 RB_ENTRY(session_group) entry;
1060};
1061RB_HEAD(session_groups, session_group);
1062
1063struct session {
1064 u_int id;
1065
1066 char *name;
1067 const char *cwd;
1068
1069 struct timeval creation_time;
1070 struct timeval last_attached_time;
1071 struct timeval activity_time;
1072 struct timeval last_activity_time;
1073
1074 struct event lock_timer;
1075
1076 struct winlink *curw;
1077 struct winlink_stack lastw;
1078 struct winlinks windows;
1079
1080 int statusat;
1081 u_int statuslines;
1082
1083 struct options *options;
1084
1085#define SESSION_PASTING 0x1
1086#define SESSION_ALERTED 0x2
1087 int flags;
1088
1089 u_int attached;
1090
1091 struct termios *tio;
1092
1093 struct environ *environ;
1094
1095 int references;
1096
1097 TAILQ_ENTRY(session) gentry;
1098 RB_ENTRY(session) entry;
1099};
1100RB_HEAD(sessions, session);
1101
1102/* Mouse button masks. */
1103#define MOUSE_MASK_BUTTONS 3
1104#define MOUSE_MASK_SHIFT 4
1105#define MOUSE_MASK_META 8
1106#define MOUSE_MASK_CTRL 16
1107#define MOUSE_MASK_DRAG 32
1108#define MOUSE_MASK_WHEEL 64
1109
1110/* Mouse wheel states. */
1111#define MOUSE_WHEEL_UP 0
1112#define MOUSE_WHEEL_DOWN 1
1113
1114/* Mouse helpers. */
1115#define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
1116#define MOUSE_WHEEL(b) ((b) & MOUSE_MASK_WHEEL)
1117#define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
1118#define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
1119
1120/* Mouse input. */
1121struct mouse_event {
1122 int valid;
1123
1124 key_code key;
1125
1126 int statusat;
1127 u_int statuslines;
1128
1129 u_int x;
1130 u_int y;
1131 u_int b;
1132
1133 u_int lx;
1134 u_int ly;
1135 u_int lb;
1136
1137 u_int ox;
1138 u_int oy;
1139
1140 int s;
1141 int w;
1142 int wp;
1143
1144 u_int sgr_type;
1145 u_int sgr_b;
1146};
1147
1148/* Key event. */
1149struct key_event {
1150 key_code key;
1151 struct mouse_event m;
1152};
1153
1154/* TTY information. */
1155struct tty_key {
1156 char ch;
1157 key_code key;
1158
1159 struct tty_key *left;
1160 struct tty_key *right;
1161
1162 struct tty_key *next;
1163};
1164
1165struct tty_code;
1166struct tty_term {
1167 char *name;
1168 u_int references;
1169
1170 char acs[UCHAR_MAX + 1][2];
1171
1172 struct tty_code *codes;
1173
1174#define TERM_256COLOURS 0x1
1175#define TERM_NOXENL 0x2
1176#define TERM_DECSLRM 0x4
1177#define TERM_DECFRA 0x8
1178#define TERM_RGBCOLOURS 0x10
1179 int flags;
1180
1181 LIST_ENTRY(tty_term) entry;
1182};
1183LIST_HEAD(tty_terms, tty_term);
1184
1185struct tty {
1186 struct client *client;
1187 struct event start_timer;
1188
1189 u_int sx;
1190 u_int sy;
1191 u_int xpixel;
1192 u_int ypixel;
1193
1194 u_int cx;
1195 u_int cy;
1196 u_int cstyle;
1197 char *ccolour;
1198
1199 int oflag;
1200 u_int oox;
1201 u_int ooy;
1202 u_int osx;
1203 u_int osy;
1204
1205 int mode;
1206
1207 u_int rlower;
1208 u_int rupper;
1209
1210 u_int rleft;
1211 u_int rright;
1212
1213 int fd;
1214 struct event event_in;
1215 struct evbuffer *in;
1216 struct event event_out;
1217 struct evbuffer *out;
1218 struct event timer;
1219 size_t discarded;
1220
1221 struct termios tio;
1222
1223 struct grid_cell cell;
1224
1225 int last_wp;
1226 struct grid_cell last_cell;
1227
1228#define TTY_NOCURSOR 0x1
1229#define TTY_FREEZE 0x2
1230#define TTY_TIMER 0x4
1231#define TTY_UTF8 0x8
1232#define TTY_STARTED 0x10
1233#define TTY_OPENED 0x20
1234#define TTY_FOCUS 0x40
1235#define TTY_BLOCK 0x80
1236#define TTY_HAVEDA 0x100
1237#define TTY_HAVEDSR 0x200
1238 int flags;
1239
1240 struct tty_term *term;
1241 char *term_name;
1242 int term_flags;
1243
1244 u_int mouse_last_x;
1245 u_int mouse_last_y;
1246 u_int mouse_last_b;
1247 int mouse_drag_flag;
1248 void (*mouse_drag_update)(struct client *,
1249 struct mouse_event *);
1250 void (*mouse_drag_release)(struct client *,
1251 struct mouse_event *);
1252
1253 struct event key_timer;
1254 struct tty_key *key_tree;
1255};
1256
1257/* TTY command context. */
1258struct tty_ctx {
1259 struct window_pane *wp;
1260
1261 const struct grid_cell *cell;
1262 int wrapped;
1263
1264 u_int num;
1265 void *ptr;
1266
1267 /*
1268 * Cursor and region position before the screen was updated - this is
1269 * where the command should be applied; the values in the screen have
1270 * already been updated.
1271 */
1272 u_int ocx;
1273 u_int ocy;
1274
1275 u_int orupper;
1276 u_int orlower;
1277
1278 /* Pane offset. */
1279 u_int xoff;
1280 u_int yoff;
1281
1282 /* The background colour used for clearing (erasing). */
1283 u_int bg;
1284
1285 /* Window offset and size. */
1286 int bigger;
1287 u_int ox;
1288 u_int oy;
1289 u_int sx;
1290 u_int sy;
1291};
1292
1293/* Saved message entry. */
1294struct message_entry {
1295 char *msg;
1296 u_int msg_num;
1297 time_t msg_time;
1298 TAILQ_ENTRY(message_entry) entry;
1299};
1300
1301/* Parsed arguments structures. */
1302struct args_entry;
1303RB_HEAD(args_tree, args_entry);
1304struct args {
1305 struct args_tree tree;
1306 int argc;
1307 char **argv;
1308};
1309
1310/* Command find structures. */
1311enum cmd_find_type {
1312 CMD_FIND_PANE,
1313 CMD_FIND_WINDOW,
1314 CMD_FIND_SESSION,
1315};
1316struct cmd_find_state {
1317 int flags;
1318 struct cmd_find_state *current;
1319
1320 struct session *s;
1321 struct winlink *wl;
1322 struct window *w;
1323 struct window_pane *wp;
1324 int idx;
1325};
1326
1327/* Command find flags. */
1328#define CMD_FIND_PREFER_UNATTACHED 0x1
1329#define CMD_FIND_QUIET 0x2
1330#define CMD_FIND_WINDOW_INDEX 0x4
1331#define CMD_FIND_DEFAULT_MARKED 0x8
1332#define CMD_FIND_EXACT_SESSION 0x10
1333#define CMD_FIND_EXACT_WINDOW 0x20
1334#define CMD_FIND_CANFAIL 0x40
1335
1336/* Command and list of commands. */
1337struct cmd {
1338 const struct cmd_entry *entry;
1339 struct args *args;
1340 u_int group;
1341
1342 char *file;
1343 u_int line;
1344
1345 char *alias;
1346 int argc;
1347 char **argv;
1348
1349 TAILQ_ENTRY(cmd) qentry;
1350};
1351TAILQ_HEAD(cmds, cmd);
1352
1353struct cmd_list {
1354 int references;
1355 u_int group;
1356 struct cmds list;
1357};
1358
1359/* Command return values. */
1360enum cmd_retval {
1361 CMD_RETURN_ERROR = -1,
1362 CMD_RETURN_NORMAL = 0,
1363 CMD_RETURN_WAIT,
1364 CMD_RETURN_STOP
1365};
1366
1367/* Command parse result. */
1368enum cmd_parse_status {
1369 CMD_PARSE_EMPTY,
1370 CMD_PARSE_ERROR,
1371 CMD_PARSE_SUCCESS
1372};
1373struct cmd_parse_result {
1374 enum cmd_parse_status status;
1375 struct cmd_list *cmdlist;
1376 char *error;
1377};
1378struct cmd_parse_input {
1379 int flags;
1380#define CMD_PARSE_QUIET 0x1
1381#define CMD_PARSE_PARSEONLY 0x2
1382#define CMD_PARSE_NOALIAS 0x4
1383#define CMD_PARSE_VERBOSE 0x8
1384
1385 const char *file;
1386 u_int line;
1387
1388 struct cmdq_item *item;
1389 struct client *c;
1390 struct cmd_find_state fs;
1391};
1392
1393/* Command queue item type. */
1394enum cmdq_type {
1395 CMDQ_COMMAND,
1396 CMDQ_CALLBACK,
1397};
1398
1399/* Command queue item shared state. */
1400struct cmdq_shared {
1401 int references;
1402
1403 int flags;
1404#define CMDQ_SHARED_REPEAT 0x1
1405#define CMDQ_SHARED_CONTROL 0x2
1406
1407 struct format_tree *formats;
1408
1409 struct mouse_event mouse;
1410 struct cmd_find_state current;
1411};
1412
1413/* Command queue item. */
1414typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
1415struct cmdq_item {
1416 char *name;
1417 struct cmdq_list *queue;
1418 struct cmdq_item *next;
1419
1420 struct client *client;
1421
1422 enum cmdq_type type;
1423 u_int group;
1424
1425 u_int number;
1426 time_t time;
1427
1428 int flags;
1429#define CMDQ_FIRED 0x1
1430#define CMDQ_WAITING 0x2
1431#define CMDQ_NOHOOKS 0x4
1432
1433 struct cmdq_shared *shared;
1434 struct cmd_find_state source;
1435 struct cmd_find_state target;
1436
1437 struct cmd_list *cmdlist;
1438 struct cmd *cmd;
1439
1440 cmdq_cb cb;
1441 void *data;
1442
1443 TAILQ_ENTRY(cmdq_item) entry;
1444};
1445TAILQ_HEAD(cmdq_list, cmdq_item);
1446
1447/* Command definition flag. */
1448struct cmd_entry_flag {
1449 char flag;
1450 enum cmd_find_type type;
1451 int flags;
1452};
1453
1454/* Command definition. */
1455struct cmd_entry {
1456 const char *name;
1457 const char *alias;
1458
1459 struct {
1460 const char *template;
1461 int lower;
1462 int upper;
1463 } args;
1464 const char *usage;
1465
1466 struct cmd_entry_flag source;
1467 struct cmd_entry_flag target;
1468
1469#define CMD_STARTSERVER 0x1
1470#define CMD_READONLY 0x2
1471#define CMD_AFTERHOOK 0x4
1472 int flags;
1473
1474 enum cmd_retval (*exec)(struct cmd *, struct cmdq_item *);
1475};
1476
1477/* Status line. */
1478#define STATUS_LINES_LIMIT 5
1479struct status_line_entry {
1480 char *expanded;
1481 struct style_ranges ranges;
1482};
1483struct status_line {
1484 struct event timer;
1485
1486 struct screen screen;
1487 struct screen *active;
1488 int references;
1489
1490 struct grid_cell style;
1491 struct status_line_entry entries[STATUS_LINES_LIMIT];
1492};
1493
1494/* File in client. */
1495typedef void (*client_file_cb) (struct client *, const char *, int, int,
1496 struct evbuffer *, void *);
1497struct client_file {
1498 struct client *c;
1499 int references;
1500 int stream;
1501
1502 char *path;
1503 struct evbuffer *buffer;
1504 struct bufferevent *event;
1505
1506 int fd;
1507 int error;
1508 int closed;
1509
1510 client_file_cb cb;
1511 void *data;
1512
1513 RB_ENTRY (client_file) entry;
1514};
1515RB_HEAD(client_files, client_file);
1516
1517/* Client connection. */
1518typedef int (*prompt_input_cb)(struct client *, void *, const char *, int);
1519typedef void (*prompt_free_cb)(void *);
1520typedef void (*overlay_draw_cb)(struct client *, struct screen_redraw_ctx *);
1521typedef int (*overlay_key_cb)(struct client *, struct key_event *);
1522typedef void (*overlay_free_cb)(struct client *);
1523struct client {
1524 const char *name;
1525 struct tmuxpeer *peer;
1526 struct cmdq_list queue;
1527
1528 pid_t pid;
1529 int fd;
1530 struct event event;
1531 int retval;
1532
1533 struct timeval creation_time;
1534 struct timeval activity_time;
1535
1536 struct environ *environ;
1537 struct format_job_tree *jobs;
1538
1539 char *title;
1540 const char *cwd;
1541
1542 char *term;
1543 char *ttyname;
1544 struct tty tty;
1545
1546 size_t written;
1547 size_t discarded;
1548 size_t redraw;
1549
1550 struct event repeat_timer;
1551
1552 struct event click_timer;
1553 u_int click_button;
1554
1555 struct status_line status;
1556
1557#define CLIENT_TERMINAL 0x1
1558#define CLIENT_LOGIN 0x2
1559#define CLIENT_EXIT 0x4
1560#define CLIENT_REDRAWWINDOW 0x8
1561#define CLIENT_REDRAWSTATUS 0x10
1562#define CLIENT_REPEAT 0x20
1563#define CLIENT_SUSPENDED 0x40
1564#define CLIENT_ATTACHED 0x80
1565#define CLIENT_EXITED 0x100
1566#define CLIENT_DEAD 0x200
1567#define CLIENT_REDRAWBORDERS 0x400
1568#define CLIENT_READONLY 0x800
1569#define CLIENT_DETACHING 0x1000
1570#define CLIENT_CONTROL 0x2000
1571#define CLIENT_CONTROLCONTROL 0x4000
1572#define CLIENT_FOCUSED 0x8000
1573#define CLIENT_UTF8 0x10000
1574#define CLIENT_256COLOURS 0x20000
1575#define CLIENT_IDENTIFIED 0x40000
1576#define CLIENT_STATUSFORCE 0x80000
1577#define CLIENT_DOUBLECLICK 0x100000
1578#define CLIENT_TRIPLECLICK 0x200000
1579#define CLIENT_SIZECHANGED 0x400000
1580#define CLIENT_STATUSOFF 0x800000
1581#define CLIENT_REDRAWSTATUSALWAYS 0x1000000
1582#define CLIENT_REDRAWOVERLAY 0x2000000
1583#define CLIENT_CONTROL_NOOUTPUT 0x4000000
1584#define CLIENT_ALLREDRAWFLAGS \
1585 (CLIENT_REDRAWWINDOW| \
1586 CLIENT_REDRAWSTATUS| \
1587 CLIENT_REDRAWSTATUSALWAYS| \
1588 CLIENT_REDRAWBORDERS| \
1589 CLIENT_REDRAWOVERLAY)
1590#define CLIENT_UNATTACHEDFLAGS \
1591 (CLIENT_DEAD| \
1592 CLIENT_SUSPENDED| \
1593 CLIENT_DETACHING)
1594#define CLIENT_NOSIZEFLAGS \
1595 (CLIENT_DEAD| \
1596 CLIENT_SUSPENDED| \
1597 CLIENT_DETACHING)
1598 int flags;
1599 struct key_table *keytable;
1600
1601 char *message_string;
1602 struct event message_timer;
1603 u_int message_next;
1604 TAILQ_HEAD(, message_entry) message_log;
1605
1606 char *prompt_string;
1607 struct utf8_data *prompt_buffer;
1608 size_t prompt_index;
1609 prompt_input_cb prompt_inputcb;
1610 prompt_free_cb prompt_freecb;
1611 void *prompt_data;
1612 u_int prompt_hindex;
1613 enum { PROMPT_ENTRY, PROMPT_COMMAND } prompt_mode;
1614 struct utf8_data *prompt_saved;
1615
1616#define PROMPT_SINGLE 0x1
1617#define PROMPT_NUMERIC 0x2
1618#define PROMPT_INCREMENTAL 0x4
1619#define PROMPT_NOFORMAT 0x8
1620#define PROMPT_KEY 0x10
1621 int prompt_flags;
1622
1623 struct session *session;
1624 struct session *last_session;
1625
1626 int references;
1627
1628 void *pan_window;
1629 u_int pan_ox;
1630 u_int pan_oy;
1631
1632 overlay_draw_cb overlay_draw;
1633 overlay_key_cb overlay_key;
1634 overlay_free_cb overlay_free;
1635 void *overlay_data;
1636 struct event overlay_timer;
1637
1638 struct client_files files;
1639
1640 TAILQ_ENTRY(client) entry;
1641};
1642TAILQ_HEAD(clients, client);
1643
1644/* Key binding and key table. */
1645struct key_binding {
1646 key_code key;
1647 struct cmd_list *cmdlist;
1648 const char *note;
1649
1650 int flags;
1651#define KEY_BINDING_REPEAT 0x1
1652
1653 RB_ENTRY(key_binding) entry;
1654};
1655RB_HEAD(key_bindings, key_binding);
1656
1657struct key_table {
1658 const char *name;
1659 struct key_bindings key_bindings;
1660
1661 u_int references;
1662
1663 RB_ENTRY(key_table) entry;
1664};
1665RB_HEAD(key_tables, key_table);
1666
1667/* Option data. */
1668RB_HEAD(options_array, options_array_item);
1669union options_value {
1670 char *string;
1671 long long number;
1672 struct style style;
1673 struct options_array array;
1674 struct cmd_list *cmdlist;
1675};
1676
1677/* Option table entries. */
1678enum options_table_type {
1679 OPTIONS_TABLE_STRING,
1680 OPTIONS_TABLE_NUMBER,
1681 OPTIONS_TABLE_KEY,
1682 OPTIONS_TABLE_COLOUR,
1683 OPTIONS_TABLE_FLAG,
1684 OPTIONS_TABLE_CHOICE,
1685 OPTIONS_TABLE_STYLE,
1686 OPTIONS_TABLE_COMMAND
1687};
1688
1689#define OPTIONS_TABLE_NONE 0
1690#define OPTIONS_TABLE_SERVER 0x1
1691#define OPTIONS_TABLE_SESSION 0x2
1692#define OPTIONS_TABLE_WINDOW 0x4
1693#define OPTIONS_TABLE_PANE 0x8
1694
1695#define OPTIONS_TABLE_IS_ARRAY 0x1
1696#define OPTIONS_TABLE_IS_HOOK 0x2
1697
1698struct options_table_entry {
1699 const char *name;
1700 enum options_table_type type;
1701 int scope;
1702 int flags;
1703
1704 u_int minimum;
1705 u_int maximum;
1706 const char **choices;
1707
1708 const char *default_str;
1709 long long default_num;
1710 const char **default_arr;
1711
1712 const char *separator;
1713 const char *pattern;
1714};
1715
1716/* Common command usages. */
1717#define CMD_TARGET_PANE_USAGE "[-t target-pane]"
1718#define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1719#define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1720#define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1721#define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
1722#define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1723#define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1724#define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1725#define CMD_BUFFER_USAGE "[-b buffer-name]"
1726
1727/* Spawn common context. */
1728struct spawn_context {
1729 struct cmdq_item *item;
1730
1731 struct session *s;
1732 struct winlink *wl;
1733 struct client *c;
1734
1735 struct window_pane *wp0;
1736 struct layout_cell *lc;
1737
1738 const char *name;
1739 char **argv;
1740 int argc;
1741 struct environ *environ;
1742
1743 int idx;
1744 const char *cwd;
1745
1746 int flags;
1747#define SPAWN_KILL 0x1
1748#define SPAWN_DETACHED 0x2
1749#define SPAWN_RESPAWN 0x4
1750#define SPAWN_BEFORE 0x8
1751#define SPAWN_NONOTIFY 0x10
1752#define SPAWN_FULLSIZE 0x20
1753#define SPAWN_EMPTY 0x40
1754};
1755
1756/* Mode tree sort order. */
1757struct mode_tree_sort_criteria {
1758 u_int field;
1759 int reversed;
1760};
1761
1762/* tmux.c */
1763extern struct options *global_options;
1764extern struct options *global_s_options;
1765extern struct options *global_w_options;
1766extern struct environ *global_environ;
1767extern struct timeval start_time;
1768extern const char *socket_path;
1769extern const char *shell_command;
1770extern int ptm_fd;
1771extern const char *shell_command;
1772int areshell(const char *);
1773void setblocking(int, int);
1774const char *find_cwd(void);
1775const char *find_home(void);
1776const char *getversion(void);
1777
1778/* proc.c */
1779struct imsg;
1780int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t);
1781struct tmuxproc *proc_start(const char *);
1782void proc_loop(struct tmuxproc *, int (*)(void));
1783void proc_exit(struct tmuxproc *);
1784void proc_set_signals(struct tmuxproc *, void(*)(int));
1785void proc_clear_signals(struct tmuxproc *, int);
1786struct tmuxpeer *proc_add_peer(struct tmuxproc *, int,
1787 void (*)(struct imsg *, void *), void *);
1788void proc_remove_peer(struct tmuxpeer *);
1789void proc_kill_peer(struct tmuxpeer *);
1790void proc_toggle_log(struct tmuxproc *);
1791
1792/* cfg.c */
1793extern int cfg_finished;
1794extern struct client *cfg_client;
1795void start_cfg(void);
1796int load_cfg(const char *, struct client *, struct cmdq_item *, int,
1797 struct cmdq_item **);
1798int load_cfg_from_buffer(const void *, size_t, const char *,
1799 struct client *, struct cmdq_item *, int, struct cmdq_item **);
1800void set_cfg_file(const char *);
1801void printflike(1, 2) cfg_add_cause(const char *, ...);
1802void cfg_print_causes(struct cmdq_item *);
1803void cfg_show_causes(struct session *);
1804
1805/* paste.c */
1806struct paste_buffer;
1807const char *paste_buffer_name(struct paste_buffer *);
1808u_int paste_buffer_order(struct paste_buffer *);
1809time_t paste_buffer_created(struct paste_buffer *);
1810const char *paste_buffer_data(struct paste_buffer *, size_t *);
1811struct paste_buffer *paste_walk(struct paste_buffer *);
1812struct paste_buffer *paste_get_top(const char **);
1813struct paste_buffer *paste_get_name(const char *);
1814void paste_free(struct paste_buffer *);
1815void paste_add(const char *, char *, size_t);
1816int paste_rename(const char *, const char *, char **);
1817int paste_set(char *, size_t, const char *, char **);
1818char *paste_make_sample(struct paste_buffer *);
1819
1820/* format.c */
1821#define FORMAT_STATUS 0x1
1822#define FORMAT_FORCE 0x2
1823#define FORMAT_NOJOBS 0x4
1824#define FORMAT_VERBOSE 0x8
1825#define FORMAT_NONE 0
1826#define FORMAT_PANE 0x80000000U
1827#define FORMAT_WINDOW 0x40000000U
1828struct format_tree;
1829const char *format_skip(const char *, const char *);
1830int format_true(const char *);
1831struct format_tree *format_create(struct client *, struct cmdq_item *, int,
1832 int);
1833void format_free(struct format_tree *);
1834void printflike(3, 4) format_add(struct format_tree *, const char *,
1835 const char *, ...);
1836void format_each(struct format_tree *, void (*)(const char *,
1837 const char *, void *), void *);
1838char *format_expand_time(struct format_tree *, const char *);
1839char *format_expand(struct format_tree *, const char *);
1840char *format_single(struct cmdq_item *, const char *,
1841 struct client *, struct session *, struct winlink *,
1842 struct window_pane *);
1843void format_defaults(struct format_tree *, struct client *,
1844 struct session *, struct winlink *, struct window_pane *);
1845void format_defaults_window(struct format_tree *, struct window *);
1846void format_defaults_pane(struct format_tree *,
1847 struct window_pane *);
1848void format_defaults_paste_buffer(struct format_tree *,
1849 struct paste_buffer *);
1850void format_lost_client(struct client *);
1851char *format_grid_word(struct grid *, u_int, u_int);
1852char *format_grid_line(struct grid *, u_int);
1853
1854/* format-draw.c */
1855void format_draw(struct screen_write_ctx *,
1856 const struct grid_cell *, u_int, const char *,
1857 struct style_ranges *);
1858u_int format_width(const char *);
1859char *format_trim_left(const char *, u_int);
1860char *format_trim_right(const char *, u_int);
1861
1862/* notify.c */
1863void notify_hook(struct cmdq_item *, const char *);
1864void notify_input(struct window_pane *, const u_char *, size_t);
1865void notify_client(const char *, struct client *);
1866void notify_session(const char *, struct session *);
1867void notify_winlink(const char *, struct winlink *);
1868void notify_session_window(const char *, struct session *, struct window *);
1869void notify_window(const char *, struct window *);
1870void notify_pane(const char *, struct window_pane *);
1871
1872/* options.c */
1873struct options *options_create(struct options *);
1874void options_free(struct options *);
1875void options_set_parent(struct options *, struct options *);
1876struct options_entry *options_first(struct options *);
1877struct options_entry *options_next(struct options_entry *);
1878struct options_entry *options_empty(struct options *,
1879 const struct options_table_entry *);
1880struct options_entry *options_default(struct options *,
1881 const struct options_table_entry *);
1882const char *options_name(struct options_entry *);
1883const struct options_table_entry *options_table_entry(struct options_entry *);
1884struct options_entry *options_get_only(struct options *, const char *);
1885struct options_entry *options_get(struct options *, const char *);
1886void options_remove(struct options_entry *);
1887void options_array_clear(struct options_entry *);
1888union options_value *options_array_get(struct options_entry *, u_int);
1889int options_array_set(struct options_entry *, u_int, const char *,
1890 int, char **);
1891int options_array_assign(struct options_entry *, const char *,
1892 char **);
1893struct options_array_item *options_array_first(struct options_entry *);
1894struct options_array_item *options_array_next(struct options_array_item *);
1895u_int options_array_item_index(struct options_array_item *);
1896union options_value *options_array_item_value(struct options_array_item *);
1897int options_isarray(struct options_entry *);
1898int options_isstring(struct options_entry *);
1899char *options_tostring(struct options_entry *, int, int);
1900char *options_parse(const char *, int *);
1901struct options_entry *options_parse_get(struct options *, const char *, int *,
1902 int);
1903char *options_match(const char *, int *, int *);
1904struct options_entry *options_match_get(struct options *, const char *, int *,
1905 int, int *);
1906const char *options_get_string(struct options *, const char *);
1907long long options_get_number(struct options *, const char *);
1908struct style *options_get_style(struct options *, const char *);
1909struct options_entry * printflike(4, 5) options_set_string(struct options *,
1910 const char *, int, const char *, ...);
1911struct options_entry *options_set_number(struct options *, const char *,
1912 long long);
1913struct options_entry *options_set_style(struct options *, const char *, int,
1914 const char *);
1915int options_scope_from_name(struct args *, int,
1916 const char *, struct cmd_find_state *, struct options **,
1917 char **);
1918int options_scope_from_flags(struct args *, int,
1919 struct cmd_find_state *, struct options **, char **);
1920
1921/* options-table.c */
1922extern const struct options_table_entry options_table[];
1923
1924/* job.c */
1925typedef void (*job_update_cb) (struct job *);
1926typedef void (*job_complete_cb) (struct job *);
1927typedef void (*job_free_cb) (void *);
1928#define JOB_NOWAIT 0x1
1929struct job *job_run(const char *, struct session *, const char *,
1930 job_update_cb, job_complete_cb, job_free_cb, void *, int);
1931void job_free(struct job *);
1932void job_check_died(pid_t, int);
1933int job_get_status(struct job *);
1934void *job_get_data(struct job *);
1935struct bufferevent *job_get_event(struct job *);
1936void job_kill_all(void);
1937int job_still_running(void);
1938void job_print_summary(struct cmdq_item *, int);
1939
1940/* environ.c */
1941struct environ *environ_create(void);
1942void environ_free(struct environ *);
1943struct environ_entry *environ_first(struct environ *);
1944struct environ_entry *environ_next(struct environ_entry *);
1945void environ_copy(struct environ *, struct environ *);
1946struct environ_entry *environ_find(struct environ *, const char *);
1947void printflike(3, 4) environ_set(struct environ *, const char *, const char *,
1948 ...);
1949void environ_clear(struct environ *, const char *);
1950void environ_put(struct environ *, const char *);
1951void environ_unset(struct environ *, const char *);
1952void environ_update(struct options *, struct environ *, struct environ *);
1953void environ_push(struct environ *);
1954void printflike(2, 3) environ_log(struct environ *, const char *, ...);
1955struct environ *environ_for_session(struct session *, int);
1956
1957/* tty.c */
1958void tty_create_log(void);
1959int tty_window_bigger(struct tty *);
1960int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *);
1961void tty_update_window_offset(struct window *);
1962void tty_update_client_offset(struct client *);
1963void tty_raw(struct tty *, const char *);
1964void tty_attributes(struct tty *, const struct grid_cell *,
1965 struct window_pane *);
1966void tty_reset(struct tty *);
1967void tty_region_off(struct tty *);
1968void tty_margin_off(struct tty *);
1969void tty_cursor(struct tty *, u_int, u_int);
1970void tty_putcode(struct tty *, enum tty_code_code);
1971void tty_putcode1(struct tty *, enum tty_code_code, int);
1972void tty_putcode2(struct tty *, enum tty_code_code, int, int);
1973void tty_putcode3(struct tty *, enum tty_code_code, int, int, int);
1974void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *);
1975void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *,
1976 const void *);
1977void tty_puts(struct tty *, const char *);
1978void tty_putc(struct tty *, u_char);
1979void tty_putn(struct tty *, const void *, size_t, u_int);
1980int tty_init(struct tty *, struct client *, int, char *);
1981void tty_resize(struct tty *);
1982void tty_set_size(struct tty *, u_int, u_int, u_int, u_int);
1983void tty_start_tty(struct tty *);
1984void tty_stop_tty(struct tty *);
1985void tty_set_title(struct tty *, const char *);
1986void tty_update_mode(struct tty *, int, struct screen *);
1987void tty_draw_line(struct tty *, struct window_pane *, struct screen *,
1988 u_int, u_int, u_int, u_int, u_int);
1989int tty_open(struct tty *, char **);
1990void tty_close(struct tty *);
1991void tty_free(struct tty *);
1992void tty_set_flags(struct tty *, int);
1993void tty_write(void (*)(struct tty *, const struct tty_ctx *),
1994 struct tty_ctx *);
1995void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
1996void tty_cmd_cell(struct tty *, const struct tty_ctx *);
1997void tty_cmd_cells(struct tty *, const struct tty_ctx *);
1998void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
1999void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
2000void tty_cmd_clearline(struct tty *, const struct tty_ctx *);
2001void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
2002void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
2003void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
2004void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
2005void tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *);
2006void tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
2007void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *);
2008void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
2009void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
2010void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
2011void tty_cmd_scrollup(struct tty *, const struct tty_ctx *);
2012void tty_cmd_scrolldown(struct tty *, const struct tty_ctx *);
2013void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
2014void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
2015void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
2016
2017/* tty-term.c */
2018extern struct tty_terms tty_terms;
2019u_int tty_term_ncodes(void);
2020struct tty_term *tty_term_find(char *, int, char **);
2021void tty_term_free(struct tty_term *);
2022int tty_term_has(struct tty_term *, enum tty_code_code);
2023const char *tty_term_string(struct tty_term *, enum tty_code_code);
2024const char *tty_term_string1(struct tty_term *, enum tty_code_code, int);
2025const char *tty_term_string2(struct tty_term *, enum tty_code_code, int,
2026 int);
2027const char *tty_term_string3(struct tty_term *, enum tty_code_code, int,
2028 int, int);
2029const char *tty_term_ptr1(struct tty_term *, enum tty_code_code,
2030 const void *);
2031const char *tty_term_ptr2(struct tty_term *, enum tty_code_code,
2032 const void *, const void *);
2033int tty_term_number(struct tty_term *, enum tty_code_code);
2034int tty_term_flag(struct tty_term *, enum tty_code_code);
2035const char *tty_term_describe(struct tty_term *, enum tty_code_code);
2036
2037/* tty-acs.c */
2038int tty_acs_needed(struct tty *);
2039const char *tty_acs_get(struct tty *, u_char);
2040
2041/* tty-keys.c */
2042void tty_keys_build(struct tty *);
2043void tty_keys_free(struct tty *);
2044int tty_keys_next(struct tty *);
2045
2046/* arguments.c */
2047void args_set(struct args *, u_char, const char *);
2048struct args *args_parse(const char *, int, char **);
2049void args_free(struct args *);
2050char *args_print(struct args *);
2051char *args_escape(const char *);
2052int args_has(struct args *, u_char);
2053const char *args_get(struct args *, u_char);
2054const char *args_first_value(struct args *, u_char, struct args_value **);
2055const char *args_next_value(struct args_value **);
2056long long args_strtonum(struct args *, u_char, long long, long long,
2057 char **);
2058
2059/* cmd-find.c */
2060int cmd_find_target(struct cmd_find_state *, struct cmdq_item *,
2061 const char *, enum cmd_find_type, int);
2062struct client *cmd_find_best_client(struct session *);
2063struct client *cmd_find_client(struct cmdq_item *, const char *, int);
2064void cmd_find_clear_state(struct cmd_find_state *, int);
2065int cmd_find_empty_state(struct cmd_find_state *);
2066int cmd_find_valid_state(struct cmd_find_state *);
2067void cmd_find_copy_state(struct cmd_find_state *,
2068 struct cmd_find_state *);
2069void cmd_find_from_session(struct cmd_find_state *,
2070 struct session *, int);
2071void cmd_find_from_winlink(struct cmd_find_state *,
2072 struct winlink *, int);
2073int cmd_find_from_session_window(struct cmd_find_state *,
2074 struct session *, struct window *, int);
2075int cmd_find_from_window(struct cmd_find_state *, struct window *,
2076 int);
2077void cmd_find_from_winlink_pane(struct cmd_find_state *,
2078 struct winlink *, struct window_pane *, int);
2079int cmd_find_from_pane(struct cmd_find_state *,
2080 struct window_pane *, int);
2081int cmd_find_from_client(struct cmd_find_state *, struct client *,
2082 int);
2083int cmd_find_from_mouse(struct cmd_find_state *,
2084 struct mouse_event *, int);
2085int cmd_find_from_nothing(struct cmd_find_state *, int);
2086
2087/* cmd.c */
2088void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
2089void cmd_prepend_argv(int *, char ***, char *);
2090void cmd_append_argv(int *, char ***, char *);
2091int cmd_pack_argv(int, char **, char *, size_t);
2092int cmd_unpack_argv(char *, size_t, int, char ***);
2093char **cmd_copy_argv(int, char **);
2094void cmd_free_argv(int, char **);
2095char *cmd_stringify_argv(int, char **);
2096char *cmd_get_alias(const char *);
2097struct cmd *cmd_parse(int, char **, const char *, u_int, char **);
2098void cmd_free(struct cmd *);
2099char *cmd_print(struct cmd *);
2100int cmd_mouse_at(struct window_pane *, struct mouse_event *,
2101 u_int *, u_int *, int);
2102struct winlink *cmd_mouse_window(struct mouse_event *, struct session **);
2103struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **,
2104 struct winlink **);
2105char *cmd_template_replace(const char *, const char *, int);
2106extern const struct cmd_entry *cmd_table[];
2107
2108/* cmd-attach-session.c */
2109enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int,
2110 int, const char *, int);
2111
2112/* cmd-parse.c */
2113void cmd_parse_empty(struct cmd_parse_input *);
2114struct cmd_parse_result *cmd_parse_from_file(FILE *, struct cmd_parse_input *);
2115struct cmd_parse_result *cmd_parse_from_string(const char *,
2116 struct cmd_parse_input *);
2117struct cmd_parse_result *cmd_parse_from_buffer(const void *, size_t,
2118 struct cmd_parse_input *);
2119struct cmd_parse_result *cmd_parse_from_arguments(int, char **,
2120 struct cmd_parse_input *);
2121
2122/* cmd-list.c */
2123struct cmd_list *cmd_list_new(void);
2124void cmd_list_append(struct cmd_list *, struct cmd *);
2125void cmd_list_move(struct cmd_list *, struct cmd_list *);
2126void cmd_list_free(struct cmd_list *);
2127char *cmd_list_print(struct cmd_list *, int);
2128
2129/* cmd-queue.c */
2130struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *,
2131 struct mouse_event *, int);
2132#define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
2133struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *);
2134struct cmdq_item *cmdq_get_error(const char *);
2135struct cmdq_item *cmdq_insert_after(struct cmdq_item *, struct cmdq_item *);
2136struct cmdq_item *cmdq_append(struct client *, struct cmdq_item *);
2137void cmdq_insert_hook(struct session *, struct cmdq_item *,
2138 struct cmd_find_state *, const char *, ...);
2139void cmdq_continue(struct cmdq_item *);
2140void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *,
2141 const char *, ...);
2142u_int cmdq_next(struct client *);
2143void cmdq_guard(struct cmdq_item *, const char *, int);
2144void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
2145void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
2146
2147/* cmd-wait-for.c */
2148void cmd_wait_for_flush(void);
2149
2150/* client.c */
2151int client_main(struct event_base *, int, char **, int);
2152
2153/* key-bindings.c */
2154struct key_table *key_bindings_get_table(const char *, int);
2155struct key_table *key_bindings_first_table(void);
2156struct key_table *key_bindings_next_table(struct key_table *);
2157void key_bindings_unref_table(struct key_table *);
2158struct key_binding *key_bindings_get(struct key_table *, key_code);
2159struct key_binding *key_bindings_first(struct key_table *);
2160struct key_binding *key_bindings_next(struct key_table *, struct key_binding *);
2161void key_bindings_add(const char *, key_code, const char *, int,
2162 struct cmd_list *);
2163void key_bindings_remove(const char *, key_code);
2164void key_bindings_remove_table(const char *);
2165void key_bindings_init(void);
2166struct cmdq_item *key_bindings_dispatch(struct key_binding *,
2167 struct cmdq_item *, struct client *, struct mouse_event *,
2168 struct cmd_find_state *);
2169
2170/* key-string.c */
2171key_code key_string_lookup_string(const char *);
2172const char *key_string_lookup_key(key_code);
2173
2174/* alerts.c */
2175void alerts_reset_all(void);
2176void alerts_queue(struct window *, int);
2177void alerts_check_session(struct session *);
2178
2179/* file.c */
2180int file_cmp(struct client_file *, struct client_file *);
2181RB_PROTOTYPE(client_files, client_file, entry, file_cmp);
2182struct client_file *file_create(struct client *, int, client_file_cb, void *);
2183void file_free(struct client_file *);
2184void file_fire_done(struct client_file *);
2185void file_fire_read(struct client_file *);
2186int file_can_print(struct client *);
2187void printflike(2, 3) file_print(struct client *, const char *, ...);
2188void file_vprint(struct client *, const char *, va_list);
2189void file_print_buffer(struct client *, void *, size_t);
2190void printflike(2, 3) file_error(struct client *, const char *, ...);
2191void file_write(struct client *, const char *, int, const void *, size_t,
2192 client_file_cb, void *);
2193void file_read(struct client *, const char *, client_file_cb, void *);
2194void file_push(struct client_file *);
2195
2196/* server.c */
2197extern struct tmuxproc *server_proc;
2198extern struct clients clients;
2199extern struct cmd_find_state marked_pane;
2200void server_set_marked(struct session *, struct winlink *,
2201 struct window_pane *);
2202void server_clear_marked(void);
2203int server_is_marked(struct session *, struct winlink *,
2204 struct window_pane *);
2205int server_check_marked(void);
2206int server_start(struct tmuxproc *, struct event_base *, int, char *);
2207void server_update_socket(void);
2208void server_add_accept(int);
2209
2210/* server-client.c */
2211u_int server_client_how_many(void);
2212void server_client_set_overlay(struct client *, u_int, overlay_draw_cb,
2213 overlay_key_cb, overlay_free_cb, void *);
2214void server_client_set_key_table(struct client *, const char *);
2215const char *server_client_get_key_table(struct client *);
2216int server_client_check_nested(struct client *);
2217int server_client_handle_key(struct client *, struct key_event *);
2218struct client *server_client_create(int);
2219int server_client_open(struct client *, char **);
2220void server_client_unref(struct client *);
2221void server_client_lost(struct client *);
2222void server_client_suspend(struct client *);
2223void server_client_detach(struct client *, enum msgtype);
2224void server_client_exec(struct client *, const char *);
2225void server_client_loop(void);
2226void server_client_push_stdout(struct client *);
2227void server_client_push_stderr(struct client *);
2228void printflike(2, 3) server_client_add_message(struct client *, const char *,
2229 ...);
2230const char *server_client_get_cwd(struct client *, struct session *);
2231
2232/* server-fn.c */
2233void server_redraw_client(struct client *);
2234void server_status_client(struct client *);
2235void server_redraw_session(struct session *);
2236void server_redraw_session_group(struct session *);
2237void server_status_session(struct session *);
2238void server_status_session_group(struct session *);
2239void server_redraw_window(struct window *);
2240void server_redraw_window_borders(struct window *);
2241void server_status_window(struct window *);
2242void server_lock(void);
2243void server_lock_session(struct session *);
2244void server_lock_client(struct client *);
2245void server_kill_pane(struct window_pane *);
2246void server_kill_window(struct window *);
2247int server_link_window(struct session *,
2248 struct winlink *, struct session *, int, int, int, char **);
2249void server_unlink_window(struct session *, struct winlink *);
2250void server_destroy_pane(struct window_pane *, int);
2251void server_destroy_session(struct session *);
2252void server_check_unattached(void);
2253void server_unzoom_window(struct window *);
2254
2255/* status.c */
2256void status_timer_start(struct client *);
2257void status_timer_start_all(void);
2258void status_update_cache(struct session *);
2259int status_at_line(struct client *);
2260u_int status_line_size(struct client *);
2261struct style_range *status_get_range(struct client *, u_int, u_int);
2262void status_init(struct client *);
2263void status_free(struct client *);
2264int status_redraw(struct client *);
2265void printflike(2, 3) status_message_set(struct client *, const char *, ...);
2266void status_message_clear(struct client *);
2267int status_message_redraw(struct client *);
2268void status_prompt_set(struct client *, const char *, const char *,
2269 prompt_input_cb, prompt_free_cb, void *, int);
2270void status_prompt_clear(struct client *);
2271int status_prompt_redraw(struct client *);
2272int status_prompt_key(struct client *, key_code);
2273void status_prompt_update(struct client *, const char *, const char *);
2274void status_prompt_load_history(void);
2275void status_prompt_save_history(void);
2276
2277/* resize.c */
2278void resize_window(struct window *, u_int, u_int, int, int);
2279void default_window_size(struct client *, struct session *, struct window *,
2280 u_int *, u_int *, u_int *, u_int *, int);
2281void recalculate_size(struct window *);
2282void recalculate_sizes(void);
2283
2284/* input.c */
2285void input_init(struct window_pane *);
2286void input_free(struct window_pane *);
2287void input_reset(struct window_pane *, int);
2288struct evbuffer *input_pending(struct window_pane *);
2289void input_parse(struct window_pane *);
2290void input_parse_buffer(struct window_pane *, u_char *, size_t);
2291
2292/* input-key.c */
2293int input_key(struct window_pane *, key_code, struct mouse_event *);
2294
2295/* xterm-keys.c */
2296char *xterm_keys_lookup(key_code);
2297int xterm_keys_find(const char *, size_t, size_t *, key_code *);
2298
2299/* colour.c */
2300int colour_find_rgb(u_char, u_char, u_char);
2301int colour_join_rgb(u_char, u_char, u_char);
2302void colour_split_rgb(int, u_char *, u_char *, u_char *);
2303const char *colour_tostring(int);
2304int colour_fromstring(const char *s);
2305int colour_256toRGB(int);
2306int colour_256to16(int);
2307
2308/* attributes.c */
2309const char *attributes_tostring(int);
2310int attributes_fromstring(const char *);
2311
2312/* grid.c */
2313extern const struct grid_cell grid_default_cell;
2314int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
2315struct grid *grid_create(u_int, u_int, u_int);
2316void grid_destroy(struct grid *);
2317int grid_compare(struct grid *, struct grid *);
2318void grid_collect_history(struct grid *);
2319void grid_scroll_history(struct grid *, u_int);
2320void grid_scroll_history_region(struct grid *, u_int, u_int, u_int);
2321void grid_clear_history(struct grid *);
2322const struct grid_line *grid_peek_line(struct grid *, u_int);
2323void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
2324void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
2325void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *,
2326 const char *, size_t);
2327struct grid_line *grid_get_line(struct grid *, u_int);
2328void grid_adjust_lines(struct grid *, u_int);
2329void grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
2330void grid_clear_lines(struct grid *, u_int, u_int, u_int);
2331void grid_move_lines(struct grid *, u_int, u_int, u_int, u_int);
2332void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int);
2333char *grid_string_cells(struct grid *, u_int, u_int, u_int,
2334 struct grid_cell **, int, int, int);
2335void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
2336 u_int);
2337void grid_reflow(struct grid *, u_int);
2338void grid_wrap_position(struct grid *, u_int, u_int, u_int *, u_int *);
2339void grid_unwrap_position(struct grid *, u_int *, u_int *, u_int, u_int);
2340u_int grid_line_length(struct grid *, u_int);
2341
2342/* grid-view.c */
2343void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
2344void grid_view_set_cell(struct grid *, u_int, u_int,
2345 const struct grid_cell *);
2346void grid_view_set_cells(struct grid *, u_int, u_int,
2347 const struct grid_cell *, const char *, size_t);
2348void grid_view_clear_history(struct grid *, u_int);
2349void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
2350void grid_view_scroll_region_up(struct grid *, u_int, u_int, u_int);
2351void grid_view_scroll_region_down(struct grid *, u_int, u_int, u_int);
2352void grid_view_insert_lines(struct grid *, u_int, u_int, u_int);
2353void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int,
2354 u_int);
2355void grid_view_delete_lines(struct grid *, u_int, u_int, u_int);
2356void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int,
2357 u_int);
2358void grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int);
2359void grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int);
2360char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
2361
2362/* screen-write.c */
2363void screen_write_start(struct screen_write_ctx *, struct window_pane *,
2364 struct screen *);
2365void screen_write_stop(struct screen_write_ctx *);
2366void screen_write_reset(struct screen_write_ctx *);
2367size_t printflike(1, 2) screen_write_strlen(const char *, ...);
2368void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
2369 const struct grid_cell *, const char *, ...);
2370void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *,
2371 ssize_t, const struct grid_cell *, const char *, ...);
2372void screen_write_vnputs(struct screen_write_ctx *, ssize_t,
2373 const struct grid_cell *, const char *, va_list);
2374void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *,
2375 u_char);
2376void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int,
2377 u_int, u_int, u_int, bitstr_t *, const struct grid_cell *);
2378void screen_write_fast_copy(struct screen_write_ctx *, struct screen *,
2379 u_int, u_int, u_int, u_int);
2380void screen_write_hline(struct screen_write_ctx *, u_int, int, int);
2381void screen_write_vline(struct screen_write_ctx *, u_int, int, int);
2382void screen_write_menu(struct screen_write_ctx *, struct menu *, int);
2383void screen_write_box(struct screen_write_ctx *, u_int, u_int);
2384void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int,
2385 u_int);
2386void screen_write_backspace(struct screen_write_ctx *);
2387void screen_write_mode_set(struct screen_write_ctx *, int);
2388void screen_write_mode_clear(struct screen_write_ctx *, int);
2389void screen_write_cursorup(struct screen_write_ctx *, u_int);
2390void screen_write_cursordown(struct screen_write_ctx *, u_int);
2391void screen_write_cursorright(struct screen_write_ctx *, u_int);
2392void screen_write_cursorleft(struct screen_write_ctx *, u_int);
2393void screen_write_alignmenttest(struct screen_write_ctx *);
2394void screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int);
2395void screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int);
2396void screen_write_clearcharacter(struct screen_write_ctx *, u_int, u_int);
2397void screen_write_insertline(struct screen_write_ctx *, u_int, u_int);
2398void screen_write_deleteline(struct screen_write_ctx *, u_int, u_int);
2399void screen_write_clearline(struct screen_write_ctx *, u_int);
2400void screen_write_clearendofline(struct screen_write_ctx *, u_int);
2401void screen_write_clearstartofline(struct screen_write_ctx *, u_int);
2402void screen_write_cursormove(struct screen_write_ctx *, int, int, int);
2403void screen_write_reverseindex(struct screen_write_ctx *, u_int);
2404void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
2405void screen_write_linefeed(struct screen_write_ctx *, int, u_int);
2406void screen_write_scrollup(struct screen_write_ctx *, u_int, u_int);
2407void screen_write_scrolldown(struct screen_write_ctx *, u_int, u_int);
2408void screen_write_carriagereturn(struct screen_write_ctx *);
2409void screen_write_clearendofscreen(struct screen_write_ctx *, u_int);
2410void screen_write_clearstartofscreen(struct screen_write_ctx *, u_int);
2411void screen_write_clearscreen(struct screen_write_ctx *, u_int);
2412void screen_write_clearhistory(struct screen_write_ctx *);
2413void screen_write_collect_end(struct screen_write_ctx *);
2414void screen_write_collect_add(struct screen_write_ctx *,
2415 const struct grid_cell *);
2416void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *);
2417void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
2418void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
2419
2420/* screen-redraw.c */
2421void screen_redraw_screen(struct client *);
2422void screen_redraw_pane(struct client *, struct window_pane *);
2423
2424/* screen.c */
2425void screen_init(struct screen *, u_int, u_int, u_int);
2426void screen_reinit(struct screen *);
2427void screen_free(struct screen *);
2428void screen_reset_tabs(struct screen *);
2429void screen_set_cursor_style(struct screen *, u_int);
2430void screen_set_cursor_colour(struct screen *, const char *);
2431int screen_set_title(struct screen *, const char *);
2432void screen_set_path(struct screen *, const char *);
2433void screen_push_title(struct screen *);
2434void screen_pop_title(struct screen *);
2435void screen_resize(struct screen *, u_int, u_int, int);
2436void screen_set_selection(struct screen *, u_int, u_int, u_int, u_int,
2437 u_int, int, struct grid_cell *);
2438void screen_clear_selection(struct screen *);
2439void screen_hide_selection(struct screen *);
2440int screen_check_selection(struct screen *, u_int, u_int);
2441void screen_select_cell(struct screen *, struct grid_cell *,
2442 const struct grid_cell *);
2443
2444/* window.c */
2445extern struct windows windows;
2446extern struct window_pane_tree all_window_panes;
2447extern const struct window_mode *all_window_modes[];
2448int window_cmp(struct window *, struct window *);
2449RB_PROTOTYPE(windows, window, entry, window_cmp);
2450int winlink_cmp(struct winlink *, struct winlink *);
2451RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
2452int window_pane_cmp(struct window_pane *, struct window_pane *);
2453RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
2454struct winlink *winlink_find_by_index(struct winlinks *, int);
2455struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
2456struct winlink *winlink_find_by_window_id(struct winlinks *, u_int);
2457u_int winlink_count(struct winlinks *);
2458struct winlink *winlink_add(struct winlinks *, int);
2459void winlink_set_window(struct winlink *, struct window *);
2460void winlink_remove(struct winlinks *, struct winlink *);
2461struct winlink *winlink_next(struct winlink *);
2462struct winlink *winlink_previous(struct winlink *);
2463struct winlink *winlink_next_by_number(struct winlink *, struct session *,
2464 int);
2465struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
2466 int);
2467void winlink_stack_push(struct winlink_stack *, struct winlink *);
2468void winlink_stack_remove(struct winlink_stack *, struct winlink *);
2469struct window *window_find_by_id_str(const char *);
2470struct window *window_find_by_id(u_int);
2471void window_update_activity(struct window *);
2472struct window *window_create(u_int, u_int, u_int, u_int);
2473void window_pane_set_event(struct window_pane *);
2474struct window_pane *window_get_active_at(struct window *, u_int, u_int);
2475struct window_pane *window_find_string(struct window *, const char *);
2476int window_has_pane(struct window *, struct window_pane *);
2477int window_set_active_pane(struct window *, struct window_pane *,
2478 int);
2479void window_redraw_active_switch(struct window *,
2480 struct window_pane *);
2481struct window_pane *window_add_pane(struct window *, struct window_pane *,
2482 u_int, int);
2483void window_resize(struct window *, u_int, u_int, int, int);
2484void window_pane_send_resize(struct window_pane *, int);
2485int window_zoom(struct window_pane *);
2486int window_unzoom(struct window *);
2487int window_push_zoom(struct window *, int);
2488int window_pop_zoom(struct window *);
2489void window_lost_pane(struct window *, struct window_pane *);
2490void window_remove_pane(struct window *, struct window_pane *);
2491struct window_pane *window_pane_at_index(struct window *, u_int);
2492struct window_pane *window_pane_next_by_number(struct window *,
2493 struct window_pane *, u_int);
2494struct window_pane *window_pane_previous_by_number(struct window *,
2495 struct window_pane *, u_int);
2496int window_pane_index(struct window_pane *, u_int *);
2497u_int window_count_panes(struct window *);
2498void window_destroy_panes(struct window *);
2499struct window_pane *window_pane_find_by_id_str(const char *);
2500struct window_pane *window_pane_find_by_id(u_int);
2501int window_pane_destroy_ready(struct window_pane *);
2502void window_pane_resize(struct window_pane *, u_int, u_int);
2503void window_pane_alternate_on(struct window_pane *,
2504 struct grid_cell *, int);
2505void window_pane_alternate_off(struct window_pane *,
2506 struct grid_cell *, int);
2507void window_pane_set_palette(struct window_pane *, u_int, int);
2508void window_pane_unset_palette(struct window_pane *, u_int);
2509void window_pane_reset_palette(struct window_pane *);
2510int window_pane_get_palette(struct window_pane *, int);
2511int window_pane_set_mode(struct window_pane *,
2512 const struct window_mode *, struct cmd_find_state *,
2513 struct args *);
2514void window_pane_reset_mode(struct window_pane *);
2515void window_pane_reset_mode_all(struct window_pane *);
2516int window_pane_key(struct window_pane *, struct client *,
2517 struct session *, struct winlink *, key_code,
2518 struct mouse_event *);
2519int window_pane_visible(struct window_pane *);
2520u_int window_pane_search(struct window_pane *, const char *, int,
2521 int);
2522const char *window_printable_flags(struct winlink *);
2523struct window_pane *window_pane_find_up(struct window_pane *);
2524struct window_pane *window_pane_find_down(struct window_pane *);
2525struct window_pane *window_pane_find_left(struct window_pane *);
2526struct window_pane *window_pane_find_right(struct window_pane *);
2527void window_set_name(struct window *, const char *);
2528void window_add_ref(struct window *, const char *);
2529void window_remove_ref(struct window *, const char *);
2530void winlink_clear_flags(struct winlink *);
2531int winlink_shuffle_up(struct session *, struct winlink *);
2532int window_pane_start_input(struct window_pane *,
2533 struct cmdq_item *, char **);
2534
2535/* layout.c */
2536u_int layout_count_cells(struct layout_cell *);
2537struct layout_cell *layout_create_cell(struct layout_cell *);
2538void layout_free_cell(struct layout_cell *);
2539void layout_print_cell(struct layout_cell *, const char *, u_int);
2540void layout_destroy_cell(struct window *, struct layout_cell *,
2541 struct layout_cell **);
2542void layout_resize_layout(struct window *, struct layout_cell *,
2543 enum layout_type, int, int);
2544struct layout_cell *layout_search_by_border(struct layout_cell *, u_int, u_int);
2545void layout_set_size(struct layout_cell *, u_int, u_int, u_int,
2546 u_int);
2547void layout_make_leaf(struct layout_cell *, struct window_pane *);
2548void layout_make_node(struct layout_cell *, enum layout_type);
2549void layout_fix_offsets(struct window *);
2550void layout_fix_panes(struct window *);
2551void layout_resize_adjust(struct window *, struct layout_cell *,
2552 enum layout_type, int);
2553void layout_init(struct window *, struct window_pane *);
2554void layout_free(struct window *);
2555void layout_resize(struct window *, u_int, u_int);
2556void layout_resize_pane(struct window_pane *, enum layout_type,
2557 int, int);
2558void layout_resize_pane_to(struct window_pane *, enum layout_type,
2559 u_int);
2560void layout_assign_pane(struct layout_cell *, struct window_pane *);
2561struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type,
2562 int, int);
2563void layout_close_pane(struct window_pane *);
2564int layout_spread_cell(struct window *, struct layout_cell *);
2565void layout_spread_out(struct window_pane *);
2566
2567/* layout-custom.c */
2568char *layout_dump(struct layout_cell *);
2569int layout_parse(struct window *, const char *);
2570
2571/* layout-set.c */
2572int layout_set_lookup(const char *);
2573u_int layout_set_select(struct window *, u_int);
2574u_int layout_set_next(struct window *);
2575u_int layout_set_previous(struct window *);
2576
2577/* mode-tree.c */
2578typedef void (*mode_tree_build_cb)(void *, struct mode_tree_sort_criteria *,
2579 uint64_t *, const char *);
2580typedef void (*mode_tree_draw_cb)(void *, void *, struct screen_write_ctx *,
2581 u_int, u_int);
2582typedef int (*mode_tree_search_cb)(void *, void *, const char *);
2583typedef void (*mode_tree_menu_cb)(void *, struct client *, key_code);
2584typedef void (*mode_tree_each_cb)(void *, void *, struct client *, key_code);
2585u_int mode_tree_count_tagged(struct mode_tree_data *);
2586void *mode_tree_get_current(struct mode_tree_data *);
2587void mode_tree_expand_current(struct mode_tree_data *);
2588void mode_tree_set_current(struct mode_tree_data *, uint64_t);
2589void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb,
2590 struct client *, key_code, int);
2591void mode_tree_down(struct mode_tree_data *, int);
2592struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *,
2593 mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb,
2594 mode_tree_menu_cb, void *, const struct menu_item *, const char **,
2595 u_int, struct screen **);
2596void mode_tree_zoom(struct mode_tree_data *, struct args *);
2597void mode_tree_build(struct mode_tree_data *);
2598void mode_tree_free(struct mode_tree_data *);
2599void mode_tree_resize(struct mode_tree_data *, u_int, u_int);
2600struct mode_tree_item *mode_tree_add(struct mode_tree_data *,
2601 struct mode_tree_item *, void *, uint64_t, const char *,
2602 const char *, int);
2603void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *);
2604void mode_tree_draw(struct mode_tree_data *);
2605int mode_tree_key(struct mode_tree_data *, struct client *, key_code *,
2606 struct mouse_event *, u_int *, u_int *);
2607void mode_tree_run_command(struct client *, struct cmd_find_state *,
2608 const char *, const char *);
2609
2610/* window-buffer.c */
2611extern const struct window_mode window_buffer_mode;
2612
2613/* window-tree.c */
2614extern const struct window_mode window_tree_mode;
2615
2616/* window-clock.c */
2617extern const struct window_mode window_clock_mode;
2618extern const char window_clock_table[14][5][5];
2619
2620/* window-client.c */
2621extern const struct window_mode window_client_mode;
2622
2623/* window-copy.c */
2624extern const struct window_mode window_copy_mode;
2625extern const struct window_mode window_view_mode;
2626void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
2627void window_copy_vadd(struct window_pane *, const char *, va_list);
2628void window_copy_pageup(struct window_pane *, int);
2629void window_copy_start_drag(struct client *, struct mouse_event *);
2630
2631/* names.c */
2632void check_window_name(struct window *);
2633char *default_window_name(struct window *);
2634char *parse_window_name(const char *);
2635
2636/* control.c */
2637void control_start(struct client *);
2638void printflike(2, 3) control_write(struct client *, const char *, ...);
2639
2640/* control-notify.c */
2641void control_notify_input(struct client *, struct window_pane *,
2642 const u_char *, size_t);
2643void control_notify_pane_mode_changed(int);
2644void control_notify_window_layout_changed(struct window *);
2645void control_notify_window_pane_changed(struct window *);
2646void control_notify_window_unlinked(struct session *, struct window *);
2647void control_notify_window_linked(struct session *, struct window *);
2648void control_notify_window_renamed(struct window *);
2649void control_notify_client_session_changed(struct client *);
2650void control_notify_session_renamed(struct session *);
2651void control_notify_session_created(struct session *);
2652void control_notify_session_closed(struct session *);
2653void control_notify_session_window_changed(struct session *);
2654
2655/* session.c */
2656extern struct sessions sessions;
2657int session_cmp(struct session *, struct session *);
2658RB_PROTOTYPE(sessions, session, entry, session_cmp);
2659int session_alive(struct session *);
2660struct session *session_find(const char *);
2661struct session *session_find_by_id_str(const char *);
2662struct session *session_find_by_id(u_int);
2663struct session *session_create(const char *, const char *, const char *,
2664 struct environ *, struct options *, struct termios *);
2665void session_destroy(struct session *, int, const char *);
2666void session_add_ref(struct session *, const char *);
2667void session_remove_ref(struct session *, const char *);
2668int session_check_name(const char *);
2669void session_update_activity(struct session *, struct timeval *);
2670struct session *session_next_session(struct session *);
2671struct session *session_previous_session(struct session *);
2672struct winlink *session_new(struct session *, const char *, int, char **,
2673 const char *, const char *, int, char **);
2674struct winlink *session_attach(struct session *, struct window *, int,
2675 char **);
2676int session_detach(struct session *, struct winlink *);
2677int session_has(struct session *, struct window *);
2678int session_is_linked(struct session *, struct window *);
2679int session_next(struct session *, int);
2680int session_previous(struct session *, int);
2681int session_select(struct session *, int);
2682int session_last(struct session *);
2683int session_set_current(struct session *, struct winlink *);
2684struct session_group *session_group_contains(struct session *);
2685struct session_group *session_group_find(const char *);
2686struct session_group *session_group_new(const char *);
2687void session_group_add(struct session_group *, struct session *);
2688void session_group_synchronize_to(struct session *);
2689void session_group_synchronize_from(struct session *);
2690u_int session_group_count(struct session_group *);
2691u_int session_group_attached_count(struct session_group *);
2692void session_renumber_windows(struct session *);
2693
2694/* utf8.c */
2695void utf8_set(struct utf8_data *, u_char);
2696void utf8_copy(struct utf8_data *, const struct utf8_data *);
2697enum utf8_state utf8_open(struct utf8_data *, u_char);
2698enum utf8_state utf8_append(struct utf8_data *, u_char);
2699enum utf8_state utf8_combine(const struct utf8_data *, wchar_t *);
2700enum utf8_state utf8_split(wchar_t, struct utf8_data *);
2701int utf8_isvalid(const char *);
2702int utf8_strvis(char *, const char *, size_t, int);
2703int utf8_stravis(char **, const char *, int);
2704char *utf8_sanitize(const char *);
2705size_t utf8_strlen(const struct utf8_data *);
2706u_int utf8_strwidth(const struct utf8_data *, ssize_t);
2707struct utf8_data *utf8_fromcstr(const char *);
2708char *utf8_tocstr(struct utf8_data *);
2709u_int utf8_cstrwidth(const char *);
2710char *utf8_padcstr(const char *, u_int);
2711char *utf8_rpadcstr(const char *, u_int);
2712int utf8_cstrhas(const char *, const struct utf8_data *);
2713
2714/* osdep-*.c */
2715char *osdep_get_name(int, char *);
2716char *osdep_get_cwd(int);
2717struct event_base *osdep_event_init(void);
2718
2719/* log.c */
2720void log_add_level(void);
2721int log_get_level(void);
2722void log_open(const char *);
2723void log_toggle(const char *);
2724void log_close(void);
2725void printflike(1, 2) log_debug(const char *, ...);
2726__dead void printflike(1, 2) fatal(const char *, ...);
2727__dead void printflike(1, 2) fatalx(const char *, ...);
2728
2729/* menu.c */
2730struct menu *menu_create(const char *);
2731void menu_add_items(struct menu *, const struct menu_item *,
2732 struct cmdq_item *, struct client *,
2733 struct cmd_find_state *);
2734void menu_add_item(struct menu *, const struct menu_item *,
2735 struct cmdq_item *, struct client *,
2736 struct cmd_find_state *);
2737
2738void menu_free(struct menu *);
2739int menu_display(struct menu *, int, struct cmdq_item *, u_int,
2740 u_int, struct client *, struct cmd_find_state *,
2741 menu_choice_cb, void *);
2742
2743/* style.c */
2744int style_parse(struct style *,const struct grid_cell *,
2745 const char *);
2746const char *style_tostring(struct style *);
2747void style_apply(struct grid_cell *, struct options *,
2748 const char *);
2749int style_equal(struct style *, struct style *);
2750void style_set(struct style *, const struct grid_cell *);
2751void style_copy(struct style *, struct style *);
2752int style_is_default(struct style *);
2753
2754/* spawn.c */
2755struct winlink *spawn_window(struct spawn_context *, char **);
2756struct window_pane *spawn_pane(struct spawn_context *, char **);
2757
2758/* regsub.c */
2759char *regsub(const char *, const char *, const char *, int);
2760
2761#endif /* TMUX_H */
2762