Mention that load- and save-buffer can use stdin, from Ramon Fischer.
[tmux.git] / tmux.h
bloba60f89e99f68e5bbf8d1999dc7bab4b8e5256152
1 /* $OpenBSD$ */
3 /*
4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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 #include <sys/time.h>
23 #include <sys/queue.h>
24 #include <sys/tree.h>
26 #include <bitstring.h>
27 #include <event.h>
28 #include <limits.h>
29 #include <stdarg.h>
30 #include <stdint.h>
31 #include <stdio.h>
32 #include <termios.h>
33 #include <wchar.h>
35 #include "tmux-protocol.h"
36 #include "xmalloc.h"
38 extern char **environ;
40 struct args;
41 struct args_command_state;
42 struct client;
43 struct cmd;
44 struct cmd_find_state;
45 struct cmdq_item;
46 struct cmdq_list;
47 struct cmdq_state;
48 struct cmds;
49 struct control_state;
50 struct environ;
51 struct format_job_tree;
52 struct format_tree;
53 struct hyperlinks_uri;
54 struct hyperlinks;
55 struct input_ctx;
56 struct job;
57 struct menu_data;
58 struct mode_tree_data;
59 struct mouse_event;
60 struct options;
61 struct options_array_item;
62 struct options_entry;
63 struct screen_write_citem;
64 struct screen_write_cline;
65 struct screen_write_ctx;
66 struct session;
67 struct tty_ctx;
68 struct tty_code;
69 struct tty_key;
70 struct tmuxpeer;
71 struct tmuxproc;
72 struct winlink;
74 /* Default configuration files and socket paths. */
75 #ifndef TMUX_CONF
76 #define TMUX_CONF "/etc/tmux.conf:~/.tmux.conf"
77 #endif
78 #ifndef TMUX_SOCK
79 #define TMUX_SOCK "$TMUX_TMPDIR:" _PATH_TMP
80 #endif
81 #ifndef TMUX_TERM
82 #define TMUX_TERM "screen"
83 #endif
85 /* Minimum layout cell size, NOT including border lines. */
86 #define PANE_MINIMUM 1
88 /* Minimum and maximum window size. */
89 #define WINDOW_MINIMUM PANE_MINIMUM
90 #define WINDOW_MAXIMUM 10000
92 /* Automatic name refresh interval, in microseconds. Must be < 1 second. */
93 #define NAME_INTERVAL 500000
95 /* Default pixel cell sizes. */
96 #define DEFAULT_XPIXEL 16
97 #define DEFAULT_YPIXEL 32
99 /* Attribute to make GCC check printf-like arguments. */
100 #define printflike(a, b) __attribute__ ((format (printf, a, b)))
102 /* Number of items in array. */
103 #ifndef nitems
104 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
105 #endif
107 /* Alert option values. */
108 #define ALERT_NONE 0
109 #define ALERT_ANY 1
110 #define ALERT_CURRENT 2
111 #define ALERT_OTHER 3
113 /* Visual option values. */
114 #define VISUAL_OFF 0
115 #define VISUAL_ON 1
116 #define VISUAL_BOTH 2
118 /* No key or unknown key. */
119 #define KEYC_NONE 0x000ff000000000ULL
120 #define KEYC_UNKNOWN 0x000fe000000000ULL
123 * Base for special (that is, not Unicode) keys. An enum must be at most a
124 * signed int, so these are based in the highest Unicode PUA.
126 #define KEYC_BASE 0x0000000010e000ULL
127 #define KEYC_USER 0x0000000010f000ULL
129 /* Key modifier bits. */
130 #define KEYC_META 0x00100000000000ULL
131 #define KEYC_CTRL 0x00200000000000ULL
132 #define KEYC_SHIFT 0x00400000000000ULL
134 /* Key flag bits. */
135 #define KEYC_LITERAL 0x01000000000000ULL
136 #define KEYC_KEYPAD 0x02000000000000ULL
137 #define KEYC_CURSOR 0x04000000000000ULL
138 #define KEYC_IMPLIED_META 0x08000000000000ULL
139 #define KEYC_BUILD_MODIFIERS 0x10000000000000ULL
140 #define KEYC_VI 0x20000000000000ULL
141 #define KEYC_SENT 0x40000000000000ULL
143 /* Masks for key bits. */
144 #define KEYC_MASK_MODIFIERS 0x00f00000000000ULL
145 #define KEYC_MASK_FLAGS 0xff000000000000ULL
146 #define KEYC_MASK_KEY 0x000fffffffffffULL
148 /* Available user keys. */
149 #define KEYC_NUSER 1000
151 /* Is this a mouse key? */
152 #define KEYC_IS_MOUSE(key) \
153 (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \
154 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE)
156 /* Is this a Unicode key? */
157 #define KEYC_IS_UNICODE(key) \
158 (((key) & KEYC_MASK_KEY) > 0x7f && \
159 (((key) & KEYC_MASK_KEY) < KEYC_BASE || \
160 ((key) & KEYC_MASK_KEY) >= KEYC_BASE_END) && \
161 (((key) & KEYC_MASK_KEY) < KEYC_USER || \
162 ((key) & KEYC_MASK_KEY) >= KEYC_USER + KEYC_NUSER))
164 /* Multiple click timeout. */
165 #define KEYC_CLICK_TIMEOUT 300
167 /* Mouse key codes. */
168 #define KEYC_MOUSE_KEY(name) \
169 KEYC_ ## name ## _PANE, \
170 KEYC_ ## name ## _STATUS, \
171 KEYC_ ## name ## _STATUS_LEFT, \
172 KEYC_ ## name ## _STATUS_RIGHT, \
173 KEYC_ ## name ## _STATUS_DEFAULT, \
174 KEYC_ ## name ## _BORDER
175 #define KEYC_MOUSE_STRING(name, s) \
176 { #s "Pane", KEYC_ ## name ## _PANE }, \
177 { #s "Status", KEYC_ ## name ## _STATUS }, \
178 { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \
179 { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \
180 { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \
181 { #s "Border", KEYC_ ## name ## _BORDER }
184 * A single key. This can be ASCII or Unicode or one of the keys between
185 * KEYC_BASE and KEYC_BASE_END.
187 typedef unsigned long long key_code;
189 /* C0 control characters */
190 enum {
191 C0_NUL,
192 C0_SOH,
193 C0_STX,
194 C0_ETX,
195 C0_EOT,
196 C0_ENQ,
197 C0_ASC,
198 C0_BEL,
199 C0_BS,
200 C0_HT,
201 C0_LF,
202 C0_VT,
203 C0_FF,
204 C0_CR,
205 C0_SO,
206 C0_SI,
207 C0_DLE,
208 C0_DC1,
209 C0_DC2,
210 C0_DC3,
211 C0_DC4,
212 C0_NAK,
213 C0_SYN,
214 C0_ETB,
215 C0_CAN,
216 C0_EM,
217 C0_SUB,
218 C0_ESC,
219 C0_FS,
220 C0_GS,
221 C0_RS,
222 C0_US
225 /* Special key codes. */
226 enum {
227 /* Focus events. */
228 KEYC_FOCUS_IN = KEYC_BASE,
229 KEYC_FOCUS_OUT,
231 /* "Any" key, used if not found in key table. */
232 KEYC_ANY,
234 /* Paste brackets. */
235 KEYC_PASTE_START,
236 KEYC_PASTE_END,
238 /* Mouse keys. */
239 KEYC_MOUSE, /* unclassified mouse event */
240 KEYC_DRAGGING, /* dragging in progress */
241 KEYC_DOUBLECLICK, /* double click complete */
242 KEYC_MOUSE_KEY(MOUSEMOVE),
243 KEYC_MOUSE_KEY(MOUSEDOWN1),
244 KEYC_MOUSE_KEY(MOUSEDOWN2),
245 KEYC_MOUSE_KEY(MOUSEDOWN3),
246 KEYC_MOUSE_KEY(MOUSEDOWN6),
247 KEYC_MOUSE_KEY(MOUSEDOWN7),
248 KEYC_MOUSE_KEY(MOUSEDOWN8),
249 KEYC_MOUSE_KEY(MOUSEDOWN9),
250 KEYC_MOUSE_KEY(MOUSEDOWN10),
251 KEYC_MOUSE_KEY(MOUSEDOWN11),
252 KEYC_MOUSE_KEY(MOUSEUP1),
253 KEYC_MOUSE_KEY(MOUSEUP2),
254 KEYC_MOUSE_KEY(MOUSEUP3),
255 KEYC_MOUSE_KEY(MOUSEUP6),
256 KEYC_MOUSE_KEY(MOUSEUP7),
257 KEYC_MOUSE_KEY(MOUSEUP8),
258 KEYC_MOUSE_KEY(MOUSEUP9),
259 KEYC_MOUSE_KEY(MOUSEUP10),
260 KEYC_MOUSE_KEY(MOUSEUP11),
261 KEYC_MOUSE_KEY(MOUSEDRAG1),
262 KEYC_MOUSE_KEY(MOUSEDRAG2),
263 KEYC_MOUSE_KEY(MOUSEDRAG3),
264 KEYC_MOUSE_KEY(MOUSEDRAG6),
265 KEYC_MOUSE_KEY(MOUSEDRAG7),
266 KEYC_MOUSE_KEY(MOUSEDRAG8),
267 KEYC_MOUSE_KEY(MOUSEDRAG9),
268 KEYC_MOUSE_KEY(MOUSEDRAG10),
269 KEYC_MOUSE_KEY(MOUSEDRAG11),
270 KEYC_MOUSE_KEY(MOUSEDRAGEND1),
271 KEYC_MOUSE_KEY(MOUSEDRAGEND2),
272 KEYC_MOUSE_KEY(MOUSEDRAGEND3),
273 KEYC_MOUSE_KEY(MOUSEDRAGEND6),
274 KEYC_MOUSE_KEY(MOUSEDRAGEND7),
275 KEYC_MOUSE_KEY(MOUSEDRAGEND8),
276 KEYC_MOUSE_KEY(MOUSEDRAGEND9),
277 KEYC_MOUSE_KEY(MOUSEDRAGEND10),
278 KEYC_MOUSE_KEY(MOUSEDRAGEND11),
279 KEYC_MOUSE_KEY(WHEELUP),
280 KEYC_MOUSE_KEY(WHEELDOWN),
281 KEYC_MOUSE_KEY(SECONDCLICK1),
282 KEYC_MOUSE_KEY(SECONDCLICK2),
283 KEYC_MOUSE_KEY(SECONDCLICK3),
284 KEYC_MOUSE_KEY(SECONDCLICK6),
285 KEYC_MOUSE_KEY(SECONDCLICK7),
286 KEYC_MOUSE_KEY(SECONDCLICK8),
287 KEYC_MOUSE_KEY(SECONDCLICK9),
288 KEYC_MOUSE_KEY(SECONDCLICK10),
289 KEYC_MOUSE_KEY(SECONDCLICK11),
290 KEYC_MOUSE_KEY(DOUBLECLICK1),
291 KEYC_MOUSE_KEY(DOUBLECLICK2),
292 KEYC_MOUSE_KEY(DOUBLECLICK3),
293 KEYC_MOUSE_KEY(DOUBLECLICK6),
294 KEYC_MOUSE_KEY(DOUBLECLICK7),
295 KEYC_MOUSE_KEY(DOUBLECLICK8),
296 KEYC_MOUSE_KEY(DOUBLECLICK9),
297 KEYC_MOUSE_KEY(DOUBLECLICK10),
298 KEYC_MOUSE_KEY(DOUBLECLICK11),
299 KEYC_MOUSE_KEY(TRIPLECLICK1),
300 KEYC_MOUSE_KEY(TRIPLECLICK2),
301 KEYC_MOUSE_KEY(TRIPLECLICK3),
302 KEYC_MOUSE_KEY(TRIPLECLICK6),
303 KEYC_MOUSE_KEY(TRIPLECLICK7),
304 KEYC_MOUSE_KEY(TRIPLECLICK8),
305 KEYC_MOUSE_KEY(TRIPLECLICK9),
306 KEYC_MOUSE_KEY(TRIPLECLICK10),
307 KEYC_MOUSE_KEY(TRIPLECLICK11),
309 /* Backspace key. */
310 KEYC_BSPACE,
312 /* Function keys. */
313 KEYC_F1,
314 KEYC_F2,
315 KEYC_F3,
316 KEYC_F4,
317 KEYC_F5,
318 KEYC_F6,
319 KEYC_F7,
320 KEYC_F8,
321 KEYC_F9,
322 KEYC_F10,
323 KEYC_F11,
324 KEYC_F12,
325 KEYC_IC,
326 KEYC_DC,
327 KEYC_HOME,
328 KEYC_END,
329 KEYC_NPAGE,
330 KEYC_PPAGE,
331 KEYC_BTAB,
333 /* Arrow keys. */
334 KEYC_UP,
335 KEYC_DOWN,
336 KEYC_LEFT,
337 KEYC_RIGHT,
339 /* Numeric keypad. */
340 KEYC_KP_SLASH,
341 KEYC_KP_STAR,
342 KEYC_KP_MINUS,
343 KEYC_KP_SEVEN,
344 KEYC_KP_EIGHT,
345 KEYC_KP_NINE,
346 KEYC_KP_PLUS,
347 KEYC_KP_FOUR,
348 KEYC_KP_FIVE,
349 KEYC_KP_SIX,
350 KEYC_KP_ONE,
351 KEYC_KP_TWO,
352 KEYC_KP_THREE,
353 KEYC_KP_ENTER,
354 KEYC_KP_ZERO,
355 KEYC_KP_PERIOD,
357 /* End of special keys. */
358 KEYC_BASE_END
361 /* Termcap codes. */
362 enum tty_code_code {
363 TTYC_ACSC,
364 TTYC_AM,
365 TTYC_AX,
366 TTYC_BCE,
367 TTYC_BEL,
368 TTYC_BIDI,
369 TTYC_BLINK,
370 TTYC_BOLD,
371 TTYC_CIVIS,
372 TTYC_CLEAR,
373 TTYC_CLMG,
374 TTYC_CMG,
375 TTYC_CNORM,
376 TTYC_COLORS,
377 TTYC_CR,
378 TTYC_CS,
379 TTYC_CSR,
380 TTYC_CUB,
381 TTYC_CUB1,
382 TTYC_CUD,
383 TTYC_CUD1,
384 TTYC_CUF,
385 TTYC_CUF1,
386 TTYC_CUP,
387 TTYC_CUU,
388 TTYC_CUU1,
389 TTYC_CVVIS,
390 TTYC_DCH,
391 TTYC_DCH1,
392 TTYC_DIM,
393 TTYC_DL,
394 TTYC_DL1,
395 TTYC_DSBP,
396 TTYC_DSEKS,
397 TTYC_DSFCS,
398 TTYC_DSMG,
399 TTYC_E3,
400 TTYC_ECH,
401 TTYC_ED,
402 TTYC_EL,
403 TTYC_EL1,
404 TTYC_ENACS,
405 TTYC_ENBP,
406 TTYC_ENEKS,
407 TTYC_ENFCS,
408 TTYC_ENMG,
409 TTYC_FSL,
410 TTYC_HLS,
411 TTYC_HOME,
412 TTYC_HPA,
413 TTYC_ICH,
414 TTYC_ICH1,
415 TTYC_IL,
416 TTYC_IL1,
417 TTYC_INDN,
418 TTYC_INVIS,
419 TTYC_KCBT,
420 TTYC_KCUB1,
421 TTYC_KCUD1,
422 TTYC_KCUF1,
423 TTYC_KCUU1,
424 TTYC_KDC2,
425 TTYC_KDC3,
426 TTYC_KDC4,
427 TTYC_KDC5,
428 TTYC_KDC6,
429 TTYC_KDC7,
430 TTYC_KDCH1,
431 TTYC_KDN2,
432 TTYC_KDN3,
433 TTYC_KDN4,
434 TTYC_KDN5,
435 TTYC_KDN6,
436 TTYC_KDN7,
437 TTYC_KEND,
438 TTYC_KEND2,
439 TTYC_KEND3,
440 TTYC_KEND4,
441 TTYC_KEND5,
442 TTYC_KEND6,
443 TTYC_KEND7,
444 TTYC_KF1,
445 TTYC_KF10,
446 TTYC_KF11,
447 TTYC_KF12,
448 TTYC_KF13,
449 TTYC_KF14,
450 TTYC_KF15,
451 TTYC_KF16,
452 TTYC_KF17,
453 TTYC_KF18,
454 TTYC_KF19,
455 TTYC_KF2,
456 TTYC_KF20,
457 TTYC_KF21,
458 TTYC_KF22,
459 TTYC_KF23,
460 TTYC_KF24,
461 TTYC_KF25,
462 TTYC_KF26,
463 TTYC_KF27,
464 TTYC_KF28,
465 TTYC_KF29,
466 TTYC_KF3,
467 TTYC_KF30,
468 TTYC_KF31,
469 TTYC_KF32,
470 TTYC_KF33,
471 TTYC_KF34,
472 TTYC_KF35,
473 TTYC_KF36,
474 TTYC_KF37,
475 TTYC_KF38,
476 TTYC_KF39,
477 TTYC_KF4,
478 TTYC_KF40,
479 TTYC_KF41,
480 TTYC_KF42,
481 TTYC_KF43,
482 TTYC_KF44,
483 TTYC_KF45,
484 TTYC_KF46,
485 TTYC_KF47,
486 TTYC_KF48,
487 TTYC_KF49,
488 TTYC_KF5,
489 TTYC_KF50,
490 TTYC_KF51,
491 TTYC_KF52,
492 TTYC_KF53,
493 TTYC_KF54,
494 TTYC_KF55,
495 TTYC_KF56,
496 TTYC_KF57,
497 TTYC_KF58,
498 TTYC_KF59,
499 TTYC_KF6,
500 TTYC_KF60,
501 TTYC_KF61,
502 TTYC_KF62,
503 TTYC_KF63,
504 TTYC_KF7,
505 TTYC_KF8,
506 TTYC_KF9,
507 TTYC_KHOM2,
508 TTYC_KHOM3,
509 TTYC_KHOM4,
510 TTYC_KHOM5,
511 TTYC_KHOM6,
512 TTYC_KHOM7,
513 TTYC_KHOME,
514 TTYC_KIC2,
515 TTYC_KIC3,
516 TTYC_KIC4,
517 TTYC_KIC5,
518 TTYC_KIC6,
519 TTYC_KIC7,
520 TTYC_KICH1,
521 TTYC_KIND,
522 TTYC_KLFT2,
523 TTYC_KLFT3,
524 TTYC_KLFT4,
525 TTYC_KLFT5,
526 TTYC_KLFT6,
527 TTYC_KLFT7,
528 TTYC_KMOUS,
529 TTYC_KNP,
530 TTYC_KNXT2,
531 TTYC_KNXT3,
532 TTYC_KNXT4,
533 TTYC_KNXT5,
534 TTYC_KNXT6,
535 TTYC_KNXT7,
536 TTYC_KPP,
537 TTYC_KPRV2,
538 TTYC_KPRV3,
539 TTYC_KPRV4,
540 TTYC_KPRV5,
541 TTYC_KPRV6,
542 TTYC_KPRV7,
543 TTYC_KRI,
544 TTYC_KRIT2,
545 TTYC_KRIT3,
546 TTYC_KRIT4,
547 TTYC_KRIT5,
548 TTYC_KRIT6,
549 TTYC_KRIT7,
550 TTYC_KUP2,
551 TTYC_KUP3,
552 TTYC_KUP4,
553 TTYC_KUP5,
554 TTYC_KUP6,
555 TTYC_KUP7,
556 TTYC_MS,
557 TTYC_NOBR,
558 TTYC_OL,
559 TTYC_OP,
560 TTYC_RECT,
561 TTYC_REV,
562 TTYC_RGB,
563 TTYC_RI,
564 TTYC_RIN,
565 TTYC_RMACS,
566 TTYC_RMCUP,
567 TTYC_RMKX,
568 TTYC_SE,
569 TTYC_SETAB,
570 TTYC_SETAF,
571 TTYC_SETAL,
572 TTYC_SETRGBB,
573 TTYC_SETRGBF,
574 TTYC_SETULC,
575 TTYC_SETULC1,
576 TTYC_SGR0,
577 TTYC_SITM,
578 TTYC_SMACS,
579 TTYC_SMCUP,
580 TTYC_SMKX,
581 TTYC_SMOL,
582 TTYC_SMSO,
583 TTYC_SMUL,
584 TTYC_SMULX,
585 TTYC_SMXX,
586 TTYC_SXL,
587 TTYC_SS,
588 TTYC_SWD,
589 TTYC_SYNC,
590 TTYC_TC,
591 TTYC_TSL,
592 TTYC_U8,
593 TTYC_VPA,
594 TTYC_XT
597 /* Character classes. */
598 #define WHITESPACE " "
600 /* Mode keys. */
601 #define MODEKEY_EMACS 0
602 #define MODEKEY_VI 1
604 /* Modes. */
605 #define MODE_CURSOR 0x1
606 #define MODE_INSERT 0x2
607 #define MODE_KCURSOR 0x4
608 #define MODE_KKEYPAD 0x8
609 #define MODE_WRAP 0x10
610 #define MODE_MOUSE_STANDARD 0x20
611 #define MODE_MOUSE_BUTTON 0x40
612 #define MODE_CURSOR_BLINKING 0x80
613 #define MODE_MOUSE_UTF8 0x100
614 #define MODE_MOUSE_SGR 0x200
615 #define MODE_BRACKETPASTE 0x400
616 #define MODE_FOCUSON 0x800
617 #define MODE_MOUSE_ALL 0x1000
618 #define MODE_ORIGIN 0x2000
619 #define MODE_CRLF 0x4000
620 #define MODE_KEYS_EXTENDED 0x8000
621 #define MODE_CURSOR_VERY_VISIBLE 0x10000
622 #define MODE_CURSOR_BLINKING_SET 0x20000
623 #define MODE_KEYS_EXTENDED_2 0x40000
625 #define ALL_MODES 0xffffff
626 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
627 #define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
628 #define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
629 #define EXTENDED_KEY_MODES (MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2)
631 /* Mouse protocol constants. */
632 #define MOUSE_PARAM_MAX 0xff
633 #define MOUSE_PARAM_UTF8_MAX 0x7ff
634 #define MOUSE_PARAM_BTN_OFF 0x20
635 #define MOUSE_PARAM_POS_OFF 0x21
637 /* A single UTF-8 character. */
638 typedef u_int utf8_char;
641 * An expanded UTF-8 character. UTF8_SIZE must be big enough to hold combining
642 * characters as well. It can't be more than 32 bytes without changes to how
643 * characters are stored.
645 #define UTF8_SIZE 21
646 struct utf8_data {
647 u_char data[UTF8_SIZE];
649 u_char have;
650 u_char size;
652 u_char width; /* 0xff if invalid */
654 enum utf8_state {
655 UTF8_MORE,
656 UTF8_DONE,
657 UTF8_ERROR
660 /* Colour flags. */
661 #define COLOUR_FLAG_256 0x01000000
662 #define COLOUR_FLAG_RGB 0x02000000
664 /* Special colours. */
665 #define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
667 /* Replacement palette. */
668 struct colour_palette {
669 int fg;
670 int bg;
672 int *palette;
673 int *default_palette;
676 /* Grid attributes. Anything above 0xff is stored in an extended cell. */
677 #define GRID_ATTR_BRIGHT 0x1
678 #define GRID_ATTR_DIM 0x2
679 #define GRID_ATTR_UNDERSCORE 0x4
680 #define GRID_ATTR_BLINK 0x8
681 #define GRID_ATTR_REVERSE 0x10
682 #define GRID_ATTR_HIDDEN 0x20
683 #define GRID_ATTR_ITALICS 0x40
684 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
685 #define GRID_ATTR_STRIKETHROUGH 0x100
686 #define GRID_ATTR_UNDERSCORE_2 0x200
687 #define GRID_ATTR_UNDERSCORE_3 0x400
688 #define GRID_ATTR_UNDERSCORE_4 0x800
689 #define GRID_ATTR_UNDERSCORE_5 0x1000
690 #define GRID_ATTR_OVERLINE 0x2000
692 /* All underscore attributes. */
693 #define GRID_ATTR_ALL_UNDERSCORE \
694 (GRID_ATTR_UNDERSCORE| \
695 GRID_ATTR_UNDERSCORE_2| \
696 GRID_ATTR_UNDERSCORE_3| \
697 GRID_ATTR_UNDERSCORE_4| \
698 GRID_ATTR_UNDERSCORE_5)
700 /* Grid flags. */
701 #define GRID_FLAG_FG256 0x1
702 #define GRID_FLAG_BG256 0x2
703 #define GRID_FLAG_PADDING 0x4
704 #define GRID_FLAG_EXTENDED 0x8
705 #define GRID_FLAG_SELECTED 0x10
706 #define GRID_FLAG_NOPALETTE 0x20
707 #define GRID_FLAG_CLEARED 0x40
709 /* Grid line flags. */
710 #define GRID_LINE_WRAPPED 0x1
711 #define GRID_LINE_EXTENDED 0x2
712 #define GRID_LINE_DEAD 0x4
713 #define GRID_LINE_START_PROMPT 0x8
714 #define GRID_LINE_START_OUTPUT 0x10
716 /* Grid string flags. */
717 #define GRID_STRING_WITH_SEQUENCES 0x1
718 #define GRID_STRING_ESCAPE_SEQUENCES 0x2
719 #define GRID_STRING_TRIM_SPACES 0x4
720 #define GRID_STRING_USED_ONLY 0x8
721 #define GRID_STRING_EMPTY_CELLS 0x10
723 /* Cell positions. */
724 #define CELL_INSIDE 0
725 #define CELL_TOPBOTTOM 1
726 #define CELL_LEFTRIGHT 2
727 #define CELL_TOPLEFT 3
728 #define CELL_TOPRIGHT 4
729 #define CELL_BOTTOMLEFT 5
730 #define CELL_BOTTOMRIGHT 6
731 #define CELL_TOPJOIN 7
732 #define CELL_BOTTOMJOIN 8
733 #define CELL_LEFTJOIN 9
734 #define CELL_RIGHTJOIN 10
735 #define CELL_JOIN 11
736 #define CELL_OUTSIDE 12
738 /* Cell borders. */
739 #define CELL_BORDERS " xqlkmjwvtun~"
740 #define SIMPLE_BORDERS " |-+++++++++."
741 #define PADDED_BORDERS " "
743 /* Grid cell data. */
744 struct grid_cell {
745 struct utf8_data data;
746 u_short attr;
747 u_char flags;
748 int fg;
749 int bg;
750 int us;
751 u_int link;
754 /* Grid extended cell entry. */
755 struct grid_extd_entry {
756 utf8_char data;
757 u_short attr;
758 u_char flags;
759 int fg;
760 int bg;
761 int us;
762 u_int link;
763 } __packed;
765 /* Grid cell entry. */
766 struct grid_cell_entry {
767 union {
768 u_int offset;
769 struct {
770 u_char attr;
771 u_char fg;
772 u_char bg;
773 u_char data;
774 } data;
776 u_char flags;
777 } __packed;
779 /* Grid line. */
780 struct grid_line {
781 struct grid_cell_entry *celldata;
782 u_int cellused;
783 u_int cellsize;
785 struct grid_extd_entry *extddata;
786 u_int extdsize;
788 int flags;
789 time_t time;
792 /* Entire grid of cells. */
793 struct grid {
794 int flags;
795 #define GRID_HISTORY 0x1 /* scroll lines into history */
797 u_int sx;
798 u_int sy;
800 u_int hscrolled;
801 u_int hsize;
802 u_int hlimit;
804 struct grid_line *linedata;
807 /* Virtual cursor in a grid. */
808 struct grid_reader {
809 struct grid *gd;
810 u_int cx;
811 u_int cy;
814 /* Style alignment. */
815 enum style_align {
816 STYLE_ALIGN_DEFAULT,
817 STYLE_ALIGN_LEFT,
818 STYLE_ALIGN_CENTRE,
819 STYLE_ALIGN_RIGHT,
820 STYLE_ALIGN_ABSOLUTE_CENTRE
823 /* Style list. */
824 enum style_list {
825 STYLE_LIST_OFF,
826 STYLE_LIST_ON,
827 STYLE_LIST_FOCUS,
828 STYLE_LIST_LEFT_MARKER,
829 STYLE_LIST_RIGHT_MARKER,
832 /* Style range. */
833 enum style_range_type {
834 STYLE_RANGE_NONE,
835 STYLE_RANGE_LEFT,
836 STYLE_RANGE_RIGHT,
837 STYLE_RANGE_PANE,
838 STYLE_RANGE_WINDOW,
839 STYLE_RANGE_SESSION,
840 STYLE_RANGE_USER
842 struct style_range {
843 enum style_range_type type;
844 u_int argument;
845 char string[16];
847 u_int start;
848 u_int end; /* not included */
850 TAILQ_ENTRY(style_range) entry;
852 TAILQ_HEAD(style_ranges, style_range);
854 /* Style default. */
855 enum style_default_type {
856 STYLE_DEFAULT_BASE,
857 STYLE_DEFAULT_PUSH,
858 STYLE_DEFAULT_POP
861 /* Style option. */
862 struct style {
863 struct grid_cell gc;
864 int ignore;
866 int fill;
867 enum style_align align;
868 enum style_list list;
870 enum style_range_type range_type;
871 u_int range_argument;
872 char range_string[16];
874 enum style_default_type default_type;
877 /* Cursor style. */
878 enum screen_cursor_style {
879 SCREEN_CURSOR_DEFAULT,
880 SCREEN_CURSOR_BLOCK,
881 SCREEN_CURSOR_UNDERLINE,
882 SCREEN_CURSOR_BAR
885 /* Virtual screen. */
886 struct screen_sel;
887 struct screen_titles;
888 struct screen {
889 char *title;
890 char *path;
891 struct screen_titles *titles;
893 struct grid *grid; /* grid data */
895 u_int cx; /* cursor x */
896 u_int cy; /* cursor y */
898 enum screen_cursor_style cstyle; /* cursor style */
899 enum screen_cursor_style default_cstyle;
900 int ccolour; /* cursor colour */
901 int default_ccolour;
903 u_int rupper; /* scroll region top */
904 u_int rlower; /* scroll region bottom */
906 int mode;
907 int default_mode;
909 u_int saved_cx;
910 u_int saved_cy;
911 struct grid *saved_grid;
912 struct grid_cell saved_cell;
913 int saved_flags;
915 bitstr_t *tabs;
916 struct screen_sel *sel;
918 struct screen_write_cline *write_list;
920 struct hyperlinks *hyperlinks;
923 /* Screen write context. */
924 typedef void (*screen_write_init_ctx_cb)(struct screen_write_ctx *,
925 struct tty_ctx *);
926 struct screen_write_ctx {
927 struct window_pane *wp;
928 struct screen *s;
930 int flags;
931 #define SCREEN_WRITE_SYNC 0x1
933 screen_write_init_ctx_cb init_ctx_cb;
934 void *arg;
936 struct screen_write_citem *item;
937 u_int scrolled;
938 u_int bg;
941 /* Box border lines option. */
942 enum box_lines {
943 BOX_LINES_DEFAULT = -1,
944 BOX_LINES_SINGLE,
945 BOX_LINES_DOUBLE,
946 BOX_LINES_HEAVY,
947 BOX_LINES_SIMPLE,
948 BOX_LINES_ROUNDED,
949 BOX_LINES_PADDED,
950 BOX_LINES_NONE
953 /* Pane border lines option. */
954 enum pane_lines {
955 PANE_LINES_SINGLE,
956 PANE_LINES_DOUBLE,
957 PANE_LINES_HEAVY,
958 PANE_LINES_SIMPLE,
959 PANE_LINES_NUMBER
962 /* Pane border indicator option. */
963 #define PANE_BORDER_OFF 0
964 #define PANE_BORDER_COLOUR 1
965 #define PANE_BORDER_ARROWS 2
966 #define PANE_BORDER_BOTH 3
968 /* Screen redraw context. */
969 struct screen_redraw_ctx {
970 struct client *c;
972 u_int statuslines;
973 int statustop;
975 int pane_status;
976 enum pane_lines pane_lines;
978 struct grid_cell no_pane_gc;
979 int no_pane_gc_set;
981 u_int sx;
982 u_int sy;
983 u_int ox;
984 u_int oy;
987 /* Screen size. */
988 #define screen_size_x(s) ((s)->grid->sx)
989 #define screen_size_y(s) ((s)->grid->sy)
990 #define screen_hsize(s) ((s)->grid->hsize)
991 #define screen_hlimit(s) ((s)->grid->hlimit)
993 /* Menu. */
994 struct menu_item {
995 const char *name;
996 key_code key;
997 const char *command;
999 struct menu {
1000 const char *title;
1001 struct menu_item *items;
1002 u_int count;
1003 u_int width;
1005 typedef void (*menu_choice_cb)(struct menu *, u_int, key_code, void *);
1008 * Window mode. Windows can be in several modes and this is used to call the
1009 * right function to handle input and output.
1011 struct window_mode_entry;
1012 struct window_mode {
1013 const char *name;
1014 const char *default_format;
1016 struct screen *(*init)(struct window_mode_entry *,
1017 struct cmd_find_state *, struct args *);
1018 void (*free)(struct window_mode_entry *);
1019 void (*resize)(struct window_mode_entry *, u_int, u_int);
1020 void (*update)(struct window_mode_entry *);
1021 void (*key)(struct window_mode_entry *, struct client *,
1022 struct session *, struct winlink *, key_code,
1023 struct mouse_event *);
1025 const char *(*key_table)(struct window_mode_entry *);
1026 void (*command)(struct window_mode_entry *, struct client *,
1027 struct session *, struct winlink *, struct args *,
1028 struct mouse_event *);
1029 void (*formats)(struct window_mode_entry *,
1030 struct format_tree *);
1033 /* Active window mode. */
1034 struct window_mode_entry {
1035 struct window_pane *wp;
1036 struct window_pane *swp;
1038 const struct window_mode *mode;
1039 void *data;
1041 struct screen *screen;
1042 u_int prefix;
1044 TAILQ_ENTRY(window_mode_entry) entry;
1047 /* Offsets into pane buffer. */
1048 struct window_pane_offset {
1049 size_t used;
1052 /* Queued pane resize. */
1053 struct window_pane_resize {
1054 u_int sx;
1055 u_int sy;
1057 u_int osx;
1058 u_int osy;
1060 TAILQ_ENTRY(window_pane_resize) entry;
1062 TAILQ_HEAD(window_pane_resizes, window_pane_resize);
1064 /* Child window structure. */
1065 struct window_pane {
1066 u_int id;
1067 u_int active_point;
1069 struct window *window;
1070 struct options *options;
1072 struct layout_cell *layout_cell;
1073 struct layout_cell *saved_layout_cell;
1075 u_int sx;
1076 u_int sy;
1078 u_int xoff;
1079 u_int yoff;
1081 int flags;
1082 #define PANE_REDRAW 0x1
1083 #define PANE_DROP 0x2
1084 #define PANE_FOCUSED 0x4
1085 #define PANE_VISITED 0x8
1086 /* 0x10 unused */
1087 /* 0x20 unused */
1088 #define PANE_INPUTOFF 0x40
1089 #define PANE_CHANGED 0x80
1090 #define PANE_EXITED 0x100
1091 #define PANE_STATUSREADY 0x200
1092 #define PANE_STATUSDRAWN 0x400
1093 #define PANE_EMPTY 0x800
1094 #define PANE_STYLECHANGED 0x1000
1095 #define PANE_UNSEENCHANGES 0x2000
1097 int argc;
1098 char **argv;
1099 char *shell;
1100 char *cwd;
1102 pid_t pid;
1103 char tty[TTY_NAME_MAX];
1104 int status;
1105 struct timeval dead_time;
1107 int fd;
1108 struct bufferevent *event;
1110 struct window_pane_offset offset;
1111 size_t base_offset;
1113 struct window_pane_resizes resize_queue;
1114 struct event resize_timer;
1116 struct input_ctx *ictx;
1118 struct grid_cell cached_gc;
1119 struct grid_cell cached_active_gc;
1120 struct colour_palette palette;
1122 int pipe_fd;
1123 struct bufferevent *pipe_event;
1124 struct window_pane_offset pipe_offset;
1126 struct screen *screen;
1127 struct screen base;
1129 struct screen status_screen;
1130 size_t status_size;
1132 TAILQ_HEAD(, window_mode_entry) modes;
1134 char *searchstr;
1135 int searchregex;
1137 int border_gc_set;
1138 struct grid_cell border_gc;
1140 int control_bg;
1141 int control_fg;
1143 TAILQ_ENTRY(window_pane) entry; /* link in list of all panes */
1144 TAILQ_ENTRY(window_pane) sentry; /* link in list of last visited */
1145 RB_ENTRY(window_pane) tree_entry;
1147 TAILQ_HEAD(window_panes, window_pane);
1148 RB_HEAD(window_pane_tree, window_pane);
1150 /* Window structure. */
1151 struct window {
1152 u_int id;
1153 void *latest;
1155 char *name;
1156 struct event name_event;
1157 struct timeval name_time;
1159 struct event alerts_timer;
1160 struct event offset_timer;
1162 struct timeval activity_time;
1164 struct window_pane *active;
1165 struct window_panes last_panes;
1166 struct window_panes panes;
1168 int lastlayout;
1169 struct layout_cell *layout_root;
1170 struct layout_cell *saved_layout_root;
1171 char *old_layout;
1173 u_int sx;
1174 u_int sy;
1175 u_int manual_sx;
1176 u_int manual_sy;
1177 u_int xpixel;
1178 u_int ypixel;
1180 u_int new_sx;
1181 u_int new_sy;
1182 u_int new_xpixel;
1183 u_int new_ypixel;
1185 struct utf8_data *fill_character;
1186 int flags;
1187 #define WINDOW_BELL 0x1
1188 #define WINDOW_ACTIVITY 0x2
1189 #define WINDOW_SILENCE 0x4
1190 #define WINDOW_ZOOMED 0x8
1191 #define WINDOW_WASZOOMED 0x10
1192 #define WINDOW_RESIZE 0x20
1193 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
1195 int alerts_queued;
1196 TAILQ_ENTRY(window) alerts_entry;
1198 struct options *options;
1200 u_int references;
1201 TAILQ_HEAD(, winlink) winlinks;
1203 RB_ENTRY(window) entry;
1205 RB_HEAD(windows, window);
1207 /* Entry on local window list. */
1208 struct winlink {
1209 int idx;
1210 struct session *session;
1211 struct window *window;
1213 int flags;
1214 #define WINLINK_BELL 0x1
1215 #define WINLINK_ACTIVITY 0x2
1216 #define WINLINK_SILENCE 0x4
1217 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
1218 #define WINLINK_VISITED 0x8
1220 RB_ENTRY(winlink) entry;
1221 TAILQ_ENTRY(winlink) wentry;
1222 TAILQ_ENTRY(winlink) sentry;
1224 RB_HEAD(winlinks, winlink);
1225 TAILQ_HEAD(winlink_stack, winlink);
1227 /* Window size option. */
1228 #define WINDOW_SIZE_LARGEST 0
1229 #define WINDOW_SIZE_SMALLEST 1
1230 #define WINDOW_SIZE_MANUAL 2
1231 #define WINDOW_SIZE_LATEST 3
1233 /* Pane border status option. */
1234 #define PANE_STATUS_OFF 0
1235 #define PANE_STATUS_TOP 1
1236 #define PANE_STATUS_BOTTOM 2
1238 /* Layout direction. */
1239 enum layout_type {
1240 LAYOUT_LEFTRIGHT,
1241 LAYOUT_TOPBOTTOM,
1242 LAYOUT_WINDOWPANE
1245 /* Layout cells queue. */
1246 TAILQ_HEAD(layout_cells, layout_cell);
1248 /* Layout cell. */
1249 struct layout_cell {
1250 enum layout_type type;
1252 struct layout_cell *parent;
1254 u_int sx;
1255 u_int sy;
1257 u_int xoff;
1258 u_int yoff;
1260 struct window_pane *wp;
1261 struct layout_cells cells;
1263 TAILQ_ENTRY(layout_cell) entry;
1266 /* Environment variable. */
1267 struct environ_entry {
1268 char *name;
1269 char *value;
1271 int flags;
1272 #define ENVIRON_HIDDEN 0x1
1274 RB_ENTRY(environ_entry) entry;
1277 /* Client session. */
1278 struct session_group {
1279 const char *name;
1280 TAILQ_HEAD(, session) sessions;
1282 RB_ENTRY(session_group) entry;
1284 RB_HEAD(session_groups, session_group);
1286 struct session {
1287 u_int id;
1289 char *name;
1290 const char *cwd;
1292 struct timeval creation_time;
1293 struct timeval last_attached_time;
1294 struct timeval activity_time;
1295 struct timeval last_activity_time;
1297 struct event lock_timer;
1299 struct winlink *curw;
1300 struct winlink_stack lastw;
1301 struct winlinks windows;
1303 int statusat;
1304 u_int statuslines;
1306 struct options *options;
1308 #define SESSION_PASTING 0x1
1309 #define SESSION_ALERTED 0x2
1310 int flags;
1312 u_int attached;
1314 struct termios *tio;
1316 struct environ *environ;
1318 int references;
1320 TAILQ_ENTRY(session) gentry;
1321 RB_ENTRY(session) entry;
1323 RB_HEAD(sessions, session);
1325 /* Mouse button masks. */
1326 #define MOUSE_MASK_BUTTONS 195
1327 #define MOUSE_MASK_SHIFT 4
1328 #define MOUSE_MASK_META 8
1329 #define MOUSE_MASK_CTRL 16
1330 #define MOUSE_MASK_DRAG 32
1331 #define MOUSE_MASK_MODIFIERS (MOUSE_MASK_SHIFT|MOUSE_MASK_META|MOUSE_MASK_CTRL)
1333 /* Mouse wheel type. */
1334 #define MOUSE_WHEEL_UP 64
1335 #define MOUSE_WHEEL_DOWN 65
1337 /* Mouse button type. */
1338 #define MOUSE_BUTTON_1 0
1339 #define MOUSE_BUTTON_2 1
1340 #define MOUSE_BUTTON_3 2
1341 #define MOUSE_BUTTON_6 66
1342 #define MOUSE_BUTTON_7 67
1343 #define MOUSE_BUTTON_8 128
1344 #define MOUSE_BUTTON_9 129
1345 #define MOUSE_BUTTON_10 130
1346 #define MOUSE_BUTTON_11 131
1348 /* Mouse helpers. */
1349 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
1350 #define MOUSE_WHEEL(b) \
1351 (((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_UP || \
1352 ((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_DOWN)
1353 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
1354 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
1356 /* Mouse input. */
1357 struct mouse_event {
1358 int valid;
1359 int ignore;
1361 key_code key;
1363 int statusat;
1364 u_int statuslines;
1366 u_int x;
1367 u_int y;
1368 u_int b;
1370 u_int lx;
1371 u_int ly;
1372 u_int lb;
1374 u_int ox;
1375 u_int oy;
1377 int s;
1378 int w;
1379 int wp;
1381 u_int sgr_type;
1382 u_int sgr_b;
1385 /* Key event. */
1386 struct key_event {
1387 key_code key;
1388 struct mouse_event m;
1391 /* Terminal definition. */
1392 struct tty_term {
1393 char *name;
1394 struct tty *tty;
1395 int features;
1397 char acs[UCHAR_MAX + 1][2];
1399 struct tty_code *codes;
1401 #define TERM_256COLOURS 0x1
1402 #define TERM_NOAM 0x2
1403 #define TERM_DECSLRM 0x4
1404 #define TERM_DECFRA 0x8
1405 #define TERM_RGBCOLOURS 0x10
1406 #define TERM_VT100LIKE 0x20
1407 #define TERM_SIXEL 0x40
1408 int flags;
1410 LIST_ENTRY(tty_term) entry;
1412 LIST_HEAD(tty_terms, tty_term);
1414 /* Client terminal. */
1415 struct tty {
1416 struct client *client;
1417 struct event start_timer;
1418 struct event clipboard_timer;
1419 time_t last_requests;
1421 u_int sx;
1422 u_int sy;
1423 u_int xpixel;
1424 u_int ypixel;
1426 u_int cx;
1427 u_int cy;
1428 enum screen_cursor_style cstyle;
1429 int ccolour;
1431 int oflag;
1432 u_int oox;
1433 u_int ooy;
1434 u_int osx;
1435 u_int osy;
1437 int mode;
1438 int fg;
1439 int bg;
1441 u_int rlower;
1442 u_int rupper;
1444 u_int rleft;
1445 u_int rright;
1447 struct event event_in;
1448 struct evbuffer *in;
1449 struct event event_out;
1450 struct evbuffer *out;
1451 struct event timer;
1452 size_t discarded;
1454 struct termios tio;
1456 struct grid_cell cell;
1457 struct grid_cell last_cell;
1459 #define TTY_NOCURSOR 0x1
1460 #define TTY_FREEZE 0x2
1461 #define TTY_TIMER 0x4
1462 #define TTY_NOBLOCK 0x8
1463 #define TTY_STARTED 0x10
1464 #define TTY_OPENED 0x20
1465 #define TTY_OSC52QUERY 0x40
1466 #define TTY_BLOCK 0x80
1467 #define TTY_HAVEDA 0x100 /* Primary DA. */
1468 #define TTY_HAVEXDA 0x200
1469 #define TTY_SYNCING 0x400
1470 #define TTY_HAVEDA2 0x800 /* Secondary DA. */
1471 #define TTY_ALL_REQUEST_FLAGS \
1472 (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)
1473 int flags;
1475 struct tty_term *term;
1477 u_int mouse_last_x;
1478 u_int mouse_last_y;
1479 u_int mouse_last_b;
1480 int mouse_drag_flag;
1481 void (*mouse_drag_update)(struct client *,
1482 struct mouse_event *);
1483 void (*mouse_drag_release)(struct client *,
1484 struct mouse_event *);
1486 struct event key_timer;
1487 struct tty_key *key_tree;
1490 /* Terminal command context. */
1491 typedef void (*tty_ctx_redraw_cb)(const struct tty_ctx *);
1492 typedef int (*tty_ctx_set_client_cb)(struct tty_ctx *, struct client *);
1493 struct tty_ctx {
1494 struct screen *s;
1496 tty_ctx_redraw_cb redraw_cb;
1497 tty_ctx_set_client_cb set_client_cb;
1498 void *arg;
1500 const struct grid_cell *cell;
1501 int wrapped;
1503 u_int num;
1504 void *ptr;
1505 void *ptr2;
1508 * Whether this command should be sent even when the pane is not
1509 * visible (used for a passthrough sequence when allow-passthrough is
1510 * "all").
1512 int allow_invisible_panes;
1515 * Cursor and region position before the screen was updated - this is
1516 * where the command should be applied; the values in the screen have
1517 * already been updated.
1519 u_int ocx;
1520 u_int ocy;
1522 u_int orupper;
1523 u_int orlower;
1525 /* Target region (usually pane) offset and size. */
1526 u_int xoff;
1527 u_int yoff;
1528 u_int rxoff;
1529 u_int ryoff;
1530 u_int sx;
1531 u_int sy;
1533 /* The background colour used for clearing (erasing). */
1534 u_int bg;
1536 /* The default colours and palette. */
1537 struct grid_cell defaults;
1538 struct colour_palette *palette;
1540 /* Containing region (usually window) offset and size. */
1541 int bigger;
1542 u_int wox;
1543 u_int woy;
1544 u_int wsx;
1545 u_int wsy;
1548 /* Saved message entry. */
1549 struct message_entry {
1550 char *msg;
1551 u_int msg_num;
1552 struct timeval msg_time;
1554 TAILQ_ENTRY(message_entry) entry;
1556 TAILQ_HEAD(message_list, message_entry);
1558 /* Argument type. */
1559 enum args_type {
1560 ARGS_NONE,
1561 ARGS_STRING,
1562 ARGS_COMMANDS
1565 /* Argument value. */
1566 struct args_value {
1567 enum args_type type;
1568 union {
1569 char *string;
1570 struct cmd_list *cmdlist;
1572 char *cached;
1573 TAILQ_ENTRY(args_value) entry;
1576 /* Arguments set. */
1577 struct args_entry;
1578 RB_HEAD(args_tree, args_entry);
1580 /* Arguments parsing type. */
1581 enum args_parse_type {
1582 ARGS_PARSE_INVALID,
1583 ARGS_PARSE_STRING,
1584 ARGS_PARSE_COMMANDS_OR_STRING,
1585 ARGS_PARSE_COMMANDS
1588 /* Arguments parsing state. */
1589 typedef enum args_parse_type (*args_parse_cb)(struct args *, u_int, char **);
1590 struct args_parse {
1591 const char *template;
1592 int lower;
1593 int upper;
1594 args_parse_cb cb;
1597 /* Command find structures. */
1598 enum cmd_find_type {
1599 CMD_FIND_PANE,
1600 CMD_FIND_WINDOW,
1601 CMD_FIND_SESSION,
1603 struct cmd_find_state {
1604 int flags;
1605 struct cmd_find_state *current;
1607 struct session *s;
1608 struct winlink *wl;
1609 struct window *w;
1610 struct window_pane *wp;
1611 int idx;
1614 /* Command find flags. */
1615 #define CMD_FIND_PREFER_UNATTACHED 0x1
1616 #define CMD_FIND_QUIET 0x2
1617 #define CMD_FIND_WINDOW_INDEX 0x4
1618 #define CMD_FIND_DEFAULT_MARKED 0x8
1619 #define CMD_FIND_EXACT_SESSION 0x10
1620 #define CMD_FIND_EXACT_WINDOW 0x20
1621 #define CMD_FIND_CANFAIL 0x40
1623 /* List of commands. */
1624 struct cmd_list {
1625 int references;
1626 u_int group;
1627 struct cmds *list;
1630 /* Command return values. */
1631 enum cmd_retval {
1632 CMD_RETURN_ERROR = -1,
1633 CMD_RETURN_NORMAL = 0,
1634 CMD_RETURN_WAIT,
1635 CMD_RETURN_STOP
1638 /* Command parse result. */
1639 enum cmd_parse_status {
1640 CMD_PARSE_ERROR,
1641 CMD_PARSE_SUCCESS
1643 struct cmd_parse_result {
1644 enum cmd_parse_status status;
1645 struct cmd_list *cmdlist;
1646 char *error;
1648 struct cmd_parse_input {
1649 int flags;
1650 #define CMD_PARSE_QUIET 0x1
1651 #define CMD_PARSE_PARSEONLY 0x2
1652 #define CMD_PARSE_NOALIAS 0x4
1653 #define CMD_PARSE_VERBOSE 0x8
1654 #define CMD_PARSE_ONEGROUP 0x10
1656 const char *file;
1657 u_int line;
1659 struct cmdq_item *item;
1660 struct client *c;
1661 struct cmd_find_state fs;
1664 /* Command queue flags. */
1665 #define CMDQ_STATE_REPEAT 0x1
1666 #define CMDQ_STATE_CONTROL 0x2
1667 #define CMDQ_STATE_NOHOOKS 0x4
1669 /* Command queue callback. */
1670 typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
1672 /* Command definition flag. */
1673 struct cmd_entry_flag {
1674 char flag;
1675 enum cmd_find_type type;
1676 int flags;
1679 /* Command definition. */
1680 struct cmd_entry {
1681 const char *name;
1682 const char *alias;
1684 struct args_parse args;
1685 const char *usage;
1687 struct cmd_entry_flag source;
1688 struct cmd_entry_flag target;
1690 #define CMD_STARTSERVER 0x1
1691 #define CMD_READONLY 0x2
1692 #define CMD_AFTERHOOK 0x4
1693 #define CMD_CLIENT_CFLAG 0x8
1694 #define CMD_CLIENT_TFLAG 0x10
1695 #define CMD_CLIENT_CANFAIL 0x20
1696 int flags;
1698 enum cmd_retval (*exec)(struct cmd *, struct cmdq_item *);
1701 /* Status line. */
1702 #define STATUS_LINES_LIMIT 5
1703 struct status_line_entry {
1704 char *expanded;
1705 struct style_ranges ranges;
1707 struct status_line {
1708 struct event timer;
1710 struct screen screen;
1711 struct screen *active;
1712 int references;
1714 struct grid_cell style;
1715 struct status_line_entry entries[STATUS_LINES_LIMIT];
1718 /* Prompt type. */
1719 #define PROMPT_NTYPES 4
1720 enum prompt_type {
1721 PROMPT_TYPE_COMMAND,
1722 PROMPT_TYPE_SEARCH,
1723 PROMPT_TYPE_TARGET,
1724 PROMPT_TYPE_WINDOW_TARGET,
1725 PROMPT_TYPE_INVALID = 0xff
1728 /* File in client. */
1729 typedef void (*client_file_cb) (struct client *, const char *, int, int,
1730 struct evbuffer *, void *);
1731 struct client_file {
1732 struct client *c;
1733 struct tmuxpeer *peer;
1734 struct client_files *tree;
1735 int references;
1736 int stream;
1738 char *path;
1739 struct evbuffer *buffer;
1740 struct bufferevent *event;
1742 int fd;
1743 int error;
1744 int closed;
1746 client_file_cb cb;
1747 void *data;
1749 RB_ENTRY(client_file) entry;
1751 RB_HEAD(client_files, client_file);
1753 /* Client window. */
1754 struct client_window {
1755 u_int window;
1756 struct window_pane *pane;
1758 u_int sx;
1759 u_int sy;
1761 RB_ENTRY(client_window) entry;
1763 RB_HEAD(client_windows, client_window);
1765 /* Visible areas not obstructed by overlays. */
1766 #define OVERLAY_MAX_RANGES 3
1767 struct overlay_ranges {
1768 u_int px[OVERLAY_MAX_RANGES];
1769 u_int nx[OVERLAY_MAX_RANGES];
1772 /* Client connection. */
1773 typedef int (*prompt_input_cb)(struct client *, void *, const char *, int);
1774 typedef void (*prompt_free_cb)(void *);
1775 typedef void (*overlay_check_cb)(struct client*, void *, u_int, u_int, u_int,
1776 struct overlay_ranges *);
1777 typedef struct screen *(*overlay_mode_cb)(struct client *, void *, u_int *,
1778 u_int *);
1779 typedef void (*overlay_draw_cb)(struct client *, void *,
1780 struct screen_redraw_ctx *);
1781 typedef int (*overlay_key_cb)(struct client *, void *, struct key_event *);
1782 typedef void (*overlay_free_cb)(struct client *, void *);
1783 typedef void (*overlay_resize_cb)(struct client *, void *);
1784 struct client {
1785 const char *name;
1786 struct tmuxpeer *peer;
1787 struct cmdq_list *queue;
1789 struct client_windows windows;
1791 struct control_state *control_state;
1792 u_int pause_age;
1794 pid_t pid;
1795 int fd;
1796 int out_fd;
1797 struct event event;
1798 int retval;
1800 struct timeval creation_time;
1801 struct timeval activity_time;
1803 struct environ *environ;
1804 struct format_job_tree *jobs;
1806 char *title;
1807 char *path;
1808 const char *cwd;
1810 char *term_name;
1811 int term_features;
1812 char *term_type;
1813 char **term_caps;
1814 u_int term_ncaps;
1816 char *ttyname;
1817 struct tty tty;
1819 size_t written;
1820 size_t discarded;
1821 size_t redraw;
1823 struct event repeat_timer;
1825 struct event click_timer;
1826 u_int click_button;
1827 struct mouse_event click_event;
1829 struct status_line status;
1831 #define CLIENT_TERMINAL 0x1
1832 #define CLIENT_LOGIN 0x2
1833 #define CLIENT_EXIT 0x4
1834 #define CLIENT_REDRAWWINDOW 0x8
1835 #define CLIENT_REDRAWSTATUS 0x10
1836 #define CLIENT_REPEAT 0x20
1837 #define CLIENT_SUSPENDED 0x40
1838 #define CLIENT_ATTACHED 0x80
1839 #define CLIENT_EXITED 0x100
1840 #define CLIENT_DEAD 0x200
1841 #define CLIENT_REDRAWBORDERS 0x400
1842 #define CLIENT_READONLY 0x800
1843 #define CLIENT_NOSTARTSERVER 0x1000
1844 #define CLIENT_CONTROL 0x2000
1845 #define CLIENT_CONTROLCONTROL 0x4000
1846 #define CLIENT_FOCUSED 0x8000
1847 #define CLIENT_UTF8 0x10000
1848 #define CLIENT_IGNORESIZE 0x20000
1849 #define CLIENT_IDENTIFIED 0x40000
1850 #define CLIENT_STATUSFORCE 0x80000
1851 #define CLIENT_DOUBLECLICK 0x100000
1852 #define CLIENT_TRIPLECLICK 0x200000
1853 #define CLIENT_SIZECHANGED 0x400000
1854 #define CLIENT_STATUSOFF 0x800000
1855 #define CLIENT_REDRAWSTATUSALWAYS 0x1000000
1856 #define CLIENT_REDRAWOVERLAY 0x2000000
1857 #define CLIENT_CONTROL_NOOUTPUT 0x4000000
1858 #define CLIENT_DEFAULTSOCKET 0x8000000
1859 #define CLIENT_STARTSERVER 0x10000000
1860 #define CLIENT_REDRAWPANES 0x20000000
1861 #define CLIENT_NOFORK 0x40000000
1862 #define CLIENT_ACTIVEPANE 0x80000000ULL
1863 #define CLIENT_CONTROL_PAUSEAFTER 0x100000000ULL
1864 #define CLIENT_CONTROL_WAITEXIT 0x200000000ULL
1865 #define CLIENT_WINDOWSIZECHANGED 0x400000000ULL
1866 #define CLIENT_CLIPBOARDBUFFER 0x800000000ULL
1867 #define CLIENT_BRACKETPASTING 0x1000000000ULL
1868 #define CLIENT_ALLREDRAWFLAGS \
1869 (CLIENT_REDRAWWINDOW| \
1870 CLIENT_REDRAWSTATUS| \
1871 CLIENT_REDRAWSTATUSALWAYS| \
1872 CLIENT_REDRAWBORDERS| \
1873 CLIENT_REDRAWOVERLAY| \
1874 CLIENT_REDRAWPANES)
1875 #define CLIENT_UNATTACHEDFLAGS \
1876 (CLIENT_DEAD| \
1877 CLIENT_SUSPENDED| \
1878 CLIENT_EXIT)
1879 #define CLIENT_NODETACHFLAGS \
1880 (CLIENT_DEAD| \
1881 CLIENT_EXIT)
1882 #define CLIENT_NOSIZEFLAGS \
1883 (CLIENT_DEAD| \
1884 CLIENT_SUSPENDED| \
1885 CLIENT_EXIT)
1886 uint64_t flags;
1888 enum {
1889 CLIENT_EXIT_RETURN,
1890 CLIENT_EXIT_SHUTDOWN,
1891 CLIENT_EXIT_DETACH
1892 } exit_type;
1893 enum msgtype exit_msgtype;
1894 char *exit_session;
1895 char *exit_message;
1897 struct key_table *keytable;
1899 uint64_t redraw_panes;
1901 int message_ignore_keys;
1902 int message_ignore_styles;
1903 char *message_string;
1904 struct event message_timer;
1906 char *prompt_string;
1907 struct utf8_data *prompt_buffer;
1908 char *prompt_last;
1909 size_t prompt_index;
1910 prompt_input_cb prompt_inputcb;
1911 prompt_free_cb prompt_freecb;
1912 void *prompt_data;
1913 u_int prompt_hindex[PROMPT_NTYPES];
1914 enum {
1915 PROMPT_ENTRY,
1916 PROMPT_COMMAND
1917 } prompt_mode;
1918 struct utf8_data *prompt_saved;
1919 #define PROMPT_SINGLE 0x1
1920 #define PROMPT_NUMERIC 0x2
1921 #define PROMPT_INCREMENTAL 0x4
1922 #define PROMPT_NOFORMAT 0x8
1923 #define PROMPT_KEY 0x10
1924 int prompt_flags;
1925 enum prompt_type prompt_type;
1926 int prompt_cursor;
1928 struct session *session;
1929 struct session *last_session;
1931 int references;
1933 void *pan_window;
1934 u_int pan_ox;
1935 u_int pan_oy;
1937 overlay_check_cb overlay_check;
1938 overlay_mode_cb overlay_mode;
1939 overlay_draw_cb overlay_draw;
1940 overlay_key_cb overlay_key;
1941 overlay_free_cb overlay_free;
1942 overlay_resize_cb overlay_resize;
1943 void *overlay_data;
1944 struct event overlay_timer;
1946 struct client_files files;
1948 u_int *clipboard_panes;
1949 u_int clipboard_npanes;
1951 TAILQ_ENTRY(client) entry;
1953 TAILQ_HEAD(clients, client);
1955 /* Control mode subscription type. */
1956 enum control_sub_type {
1957 CONTROL_SUB_SESSION,
1958 CONTROL_SUB_PANE,
1959 CONTROL_SUB_ALL_PANES,
1960 CONTROL_SUB_WINDOW,
1961 CONTROL_SUB_ALL_WINDOWS
1964 /* Key binding and key table. */
1965 struct key_binding {
1966 key_code key;
1967 struct cmd_list *cmdlist;
1968 const char *note;
1970 int flags;
1971 #define KEY_BINDING_REPEAT 0x1
1973 RB_ENTRY(key_binding) entry;
1975 RB_HEAD(key_bindings, key_binding);
1977 struct key_table {
1978 const char *name;
1979 struct key_bindings key_bindings;
1980 struct key_bindings default_key_bindings;
1982 u_int references;
1984 RB_ENTRY(key_table) entry;
1986 RB_HEAD(key_tables, key_table);
1988 /* Option data. */
1989 RB_HEAD(options_array, options_array_item);
1990 union options_value {
1991 char *string;
1992 long long number;
1993 struct style style;
1994 struct options_array array;
1995 struct cmd_list *cmdlist;
1998 /* Option table entries. */
1999 enum options_table_type {
2000 OPTIONS_TABLE_STRING,
2001 OPTIONS_TABLE_NUMBER,
2002 OPTIONS_TABLE_KEY,
2003 OPTIONS_TABLE_COLOUR,
2004 OPTIONS_TABLE_FLAG,
2005 OPTIONS_TABLE_CHOICE,
2006 OPTIONS_TABLE_COMMAND
2009 #define OPTIONS_TABLE_NONE 0
2010 #define OPTIONS_TABLE_SERVER 0x1
2011 #define OPTIONS_TABLE_SESSION 0x2
2012 #define OPTIONS_TABLE_WINDOW 0x4
2013 #define OPTIONS_TABLE_PANE 0x8
2015 #define OPTIONS_TABLE_IS_ARRAY 0x1
2016 #define OPTIONS_TABLE_IS_HOOK 0x2
2017 #define OPTIONS_TABLE_IS_STYLE 0x4
2019 struct options_table_entry {
2020 const char *name;
2021 const char *alternative_name;
2022 enum options_table_type type;
2023 int scope;
2024 int flags;
2026 u_int minimum;
2027 u_int maximum;
2028 const char **choices;
2030 const char *default_str;
2031 long long default_num;
2032 const char **default_arr;
2034 const char *separator;
2035 const char *pattern;
2037 const char *text;
2038 const char *unit;
2041 struct options_name_map {
2042 const char *from;
2043 const char *to;
2046 /* Common command usages. */
2047 #define CMD_TARGET_PANE_USAGE "[-t target-pane]"
2048 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
2049 #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
2050 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
2051 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
2052 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
2053 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
2054 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
2055 #define CMD_BUFFER_USAGE "[-b buffer-name]"
2057 /* Spawn common context. */
2058 struct spawn_context {
2059 struct cmdq_item *item;
2061 struct session *s;
2062 struct winlink *wl;
2063 struct client *tc;
2065 struct window_pane *wp0;
2066 struct layout_cell *lc;
2068 const char *name;
2069 char **argv;
2070 int argc;
2071 struct environ *environ;
2073 int idx;
2074 const char *cwd;
2076 int flags;
2077 #define SPAWN_KILL 0x1
2078 #define SPAWN_DETACHED 0x2
2079 #define SPAWN_RESPAWN 0x4
2080 #define SPAWN_BEFORE 0x8
2081 #define SPAWN_NONOTIFY 0x10
2082 #define SPAWN_FULLSIZE 0x20
2083 #define SPAWN_EMPTY 0x40
2084 #define SPAWN_ZOOM 0x80
2087 /* Mode tree sort order. */
2088 struct mode_tree_sort_criteria {
2089 u_int field;
2090 int reversed;
2093 /* tmux.c */
2094 extern struct options *global_options;
2095 extern struct options *global_s_options;
2096 extern struct options *global_w_options;
2097 extern struct environ *global_environ;
2098 extern struct timeval start_time;
2099 extern const char *socket_path;
2100 extern const char *shell_command;
2101 extern int ptm_fd;
2102 extern const char *shell_command;
2103 int checkshell(const char *);
2104 void setblocking(int, int);
2105 char *shell_argv0(const char *, int);
2106 uint64_t get_timer(void);
2107 const char *sig2name(int);
2108 const char *find_cwd(void);
2109 const char *find_home(void);
2110 const char *getversion(void);
2112 /* proc.c */
2113 struct imsg;
2114 int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t);
2115 struct tmuxproc *proc_start(const char *);
2116 void proc_loop(struct tmuxproc *, int (*)(void));
2117 void proc_exit(struct tmuxproc *);
2118 void proc_set_signals(struct tmuxproc *, void(*)(int));
2119 void proc_clear_signals(struct tmuxproc *, int);
2120 struct tmuxpeer *proc_add_peer(struct tmuxproc *, int,
2121 void (*)(struct imsg *, void *), void *);
2122 void proc_remove_peer(struct tmuxpeer *);
2123 void proc_kill_peer(struct tmuxpeer *);
2124 void proc_flush_peer(struct tmuxpeer *);
2125 void proc_toggle_log(struct tmuxproc *);
2126 pid_t proc_fork_and_daemon(int *);
2127 uid_t proc_get_peer_uid(struct tmuxpeer *);
2129 /* cfg.c */
2130 extern int cfg_finished;
2131 extern struct client *cfg_client;
2132 extern char **cfg_files;
2133 extern u_int cfg_nfiles;
2134 extern int cfg_quiet;
2135 void start_cfg(void);
2136 int load_cfg(const char *, struct client *, struct cmdq_item *,
2137 struct cmd_find_state *, int, struct cmdq_item **);
2138 int load_cfg_from_buffer(const void *, size_t, const char *,
2139 struct client *, struct cmdq_item *, struct cmd_find_state *,
2140 int, struct cmdq_item **);
2141 void printflike(1, 2) cfg_add_cause(const char *, ...);
2142 void cfg_print_causes(struct cmdq_item *);
2143 void cfg_show_causes(struct session *);
2145 /* paste.c */
2146 struct paste_buffer;
2147 const char *paste_buffer_name(struct paste_buffer *);
2148 u_int paste_buffer_order(struct paste_buffer *);
2149 time_t paste_buffer_created(struct paste_buffer *);
2150 const char *paste_buffer_data(struct paste_buffer *, size_t *);
2151 struct paste_buffer *paste_walk(struct paste_buffer *);
2152 int paste_is_empty(void);
2153 struct paste_buffer *paste_get_top(const char **);
2154 struct paste_buffer *paste_get_name(const char *);
2155 void paste_free(struct paste_buffer *);
2156 void paste_add(const char *, char *, size_t);
2157 int paste_rename(const char *, const char *, char **);
2158 int paste_set(char *, size_t, const char *, char **);
2159 void paste_replace(struct paste_buffer *, char *, size_t);
2160 char *paste_make_sample(struct paste_buffer *);
2162 /* format.c */
2163 #define FORMAT_STATUS 0x1
2164 #define FORMAT_FORCE 0x2
2165 #define FORMAT_NOJOBS 0x4
2166 #define FORMAT_VERBOSE 0x8
2167 #define FORMAT_NONE 0
2168 #define FORMAT_PANE 0x80000000U
2169 #define FORMAT_WINDOW 0x40000000U
2170 struct format_tree;
2171 struct format_modifier;
2172 typedef void *(*format_cb)(struct format_tree *);
2173 void format_tidy_jobs(void);
2174 const char *format_skip(const char *, const char *);
2175 int format_true(const char *);
2176 struct format_tree *format_create(struct client *, struct cmdq_item *, int,
2177 int);
2178 void format_free(struct format_tree *);
2179 void format_merge(struct format_tree *, struct format_tree *);
2180 struct window_pane *format_get_pane(struct format_tree *);
2181 void printflike(3, 4) format_add(struct format_tree *, const char *,
2182 const char *, ...);
2183 void format_add_tv(struct format_tree *, const char *,
2184 struct timeval *);
2185 void format_add_cb(struct format_tree *, const char *, format_cb);
2186 void format_log_debug(struct format_tree *, const char *);
2187 void format_each(struct format_tree *, void (*)(const char *,
2188 const char *, void *), void *);
2189 char *format_pretty_time(time_t, int);
2190 char *format_expand_time(struct format_tree *, const char *);
2191 char *format_expand(struct format_tree *, const char *);
2192 char *format_single(struct cmdq_item *, const char *,
2193 struct client *, struct session *, struct winlink *,
2194 struct window_pane *);
2195 char *format_single_from_state(struct cmdq_item *, const char *,
2196 struct client *, struct cmd_find_state *);
2197 char *format_single_from_target(struct cmdq_item *, const char *);
2198 struct format_tree *format_create_defaults(struct cmdq_item *, struct client *,
2199 struct session *, struct winlink *, struct window_pane *);
2200 struct format_tree *format_create_from_state(struct cmdq_item *,
2201 struct client *, struct cmd_find_state *);
2202 struct format_tree *format_create_from_target(struct cmdq_item *);
2203 void format_defaults(struct format_tree *, struct client *,
2204 struct session *, struct winlink *, struct window_pane *);
2205 void format_defaults_window(struct format_tree *, struct window *);
2206 void format_defaults_pane(struct format_tree *,
2207 struct window_pane *);
2208 void format_defaults_paste_buffer(struct format_tree *,
2209 struct paste_buffer *);
2210 void format_lost_client(struct client *);
2211 char *format_grid_word(struct grid *, u_int, u_int);
2212 char *format_grid_hyperlink(struct grid *, u_int, u_int,
2213 struct screen *);
2214 char *format_grid_line(struct grid *, u_int);
2216 /* format-draw.c */
2217 void format_draw(struct screen_write_ctx *,
2218 const struct grid_cell *, u_int, const char *,
2219 struct style_ranges *, int);
2220 u_int format_width(const char *);
2221 char *format_trim_left(const char *, u_int);
2222 char *format_trim_right(const char *, u_int);
2224 /* notify.c */
2225 void notify_hook(struct cmdq_item *, const char *);
2226 void notify_client(const char *, struct client *);
2227 void notify_session(const char *, struct session *);
2228 void notify_winlink(const char *, struct winlink *);
2229 void notify_session_window(const char *, struct session *, struct window *);
2230 void notify_window(const char *, struct window *);
2231 void notify_pane(const char *, struct window_pane *);
2232 void notify_paste_buffer(const char *, int);
2234 /* options.c */
2235 struct options *options_create(struct options *);
2236 void options_free(struct options *);
2237 struct options *options_get_parent(struct options *);
2238 void options_set_parent(struct options *, struct options *);
2239 struct options_entry *options_first(struct options *);
2240 struct options_entry *options_next(struct options_entry *);
2241 struct options_entry *options_empty(struct options *,
2242 const struct options_table_entry *);
2243 struct options_entry *options_default(struct options *,
2244 const struct options_table_entry *);
2245 char *options_default_to_string(const struct options_table_entry *);
2246 const char *options_name(struct options_entry *);
2247 struct options *options_owner(struct options_entry *);
2248 const struct options_table_entry *options_table_entry(struct options_entry *);
2249 struct options_entry *options_get_only(struct options *, const char *);
2250 struct options_entry *options_get(struct options *, const char *);
2251 void options_array_clear(struct options_entry *);
2252 union options_value *options_array_get(struct options_entry *, u_int);
2253 int options_array_set(struct options_entry *, u_int, const char *,
2254 int, char **);
2255 int options_array_assign(struct options_entry *, const char *,
2256 char **);
2257 struct options_array_item *options_array_first(struct options_entry *);
2258 struct options_array_item *options_array_next(struct options_array_item *);
2259 u_int options_array_item_index(struct options_array_item *);
2260 union options_value *options_array_item_value(struct options_array_item *);
2261 int options_is_array(struct options_entry *);
2262 int options_is_string(struct options_entry *);
2263 char *options_to_string(struct options_entry *, int, int);
2264 char *options_parse(const char *, int *);
2265 struct options_entry *options_parse_get(struct options *, const char *, int *,
2266 int);
2267 char *options_match(const char *, int *, int *);
2268 struct options_entry *options_match_get(struct options *, const char *, int *,
2269 int, int *);
2270 const char *options_get_string(struct options *, const char *);
2271 long long options_get_number(struct options *, const char *);
2272 struct options_entry * printflike(4, 5) options_set_string(struct options *,
2273 const char *, int, const char *, ...);
2274 struct options_entry *options_set_number(struct options *, const char *,
2275 long long);
2276 int options_scope_from_name(struct args *, int,
2277 const char *, struct cmd_find_state *, struct options **,
2278 char **);
2279 int options_scope_from_flags(struct args *, int,
2280 struct cmd_find_state *, struct options **, char **);
2281 struct style *options_string_to_style(struct options *, const char *,
2282 struct format_tree *);
2283 int options_from_string(struct options *,
2284 const struct options_table_entry *, const char *,
2285 const char *, int, char **);
2286 int options_find_choice(const struct options_table_entry *,
2287 const char *, char **);
2288 void options_push_changes(const char *);
2289 int options_remove_or_default(struct options_entry *, int,
2290 char **);
2292 /* options-table.c */
2293 extern const struct options_table_entry options_table[];
2294 extern const struct options_name_map options_other_names[];
2296 /* job.c */
2297 typedef void (*job_update_cb) (struct job *);
2298 typedef void (*job_complete_cb) (struct job *);
2299 typedef void (*job_free_cb) (void *);
2300 #define JOB_NOWAIT 0x1
2301 #define JOB_KEEPWRITE 0x2
2302 #define JOB_PTY 0x4
2303 struct job *job_run(const char *, int, char **, struct environ *,
2304 struct session *, const char *, job_update_cb,
2305 job_complete_cb, job_free_cb, void *, int, int, int);
2306 void job_free(struct job *);
2307 int job_transfer(struct job *, pid_t *, char *, size_t);
2308 void job_resize(struct job *, u_int, u_int);
2309 void job_check_died(pid_t, int);
2310 int job_get_status(struct job *);
2311 void *job_get_data(struct job *);
2312 struct bufferevent *job_get_event(struct job *);
2313 void job_kill_all(void);
2314 int job_still_running(void);
2315 void job_print_summary(struct cmdq_item *, int);
2317 /* environ.c */
2318 struct environ *environ_create(void);
2319 void environ_free(struct environ *);
2320 struct environ_entry *environ_first(struct environ *);
2321 struct environ_entry *environ_next(struct environ_entry *);
2322 void environ_copy(struct environ *, struct environ *);
2323 struct environ_entry *environ_find(struct environ *, const char *);
2324 void printflike(4, 5) environ_set(struct environ *, const char *, int,
2325 const char *, ...);
2326 void environ_clear(struct environ *, const char *);
2327 void environ_put(struct environ *, const char *, int);
2328 void environ_unset(struct environ *, const char *);
2329 void environ_update(struct options *, struct environ *, struct environ *);
2330 void environ_push(struct environ *);
2331 void printflike(2, 3) environ_log(struct environ *, const char *, ...);
2332 struct environ *environ_for_session(struct session *, int);
2334 /* tty.c */
2335 void tty_create_log(void);
2336 int tty_window_bigger(struct tty *);
2337 int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *);
2338 void tty_update_window_offset(struct window *);
2339 void tty_update_client_offset(struct client *);
2340 void tty_raw(struct tty *, const char *);
2341 void tty_attributes(struct tty *, const struct grid_cell *,
2342 const struct grid_cell *, struct colour_palette *,
2343 struct hyperlinks *);
2344 void tty_reset(struct tty *);
2345 void tty_region_off(struct tty *);
2346 void tty_margin_off(struct tty *);
2347 void tty_cursor(struct tty *, u_int, u_int);
2348 void tty_clipboard_query(struct tty *);
2349 void tty_putcode(struct tty *, enum tty_code_code);
2350 void tty_putcode_i(struct tty *, enum tty_code_code, int);
2351 void tty_putcode_ii(struct tty *, enum tty_code_code, int, int);
2352 void tty_putcode_iii(struct tty *, enum tty_code_code, int, int, int);
2353 void tty_putcode_s(struct tty *, enum tty_code_code, const char *);
2354 void tty_putcode_ss(struct tty *, enum tty_code_code, const char *,
2355 const char *);
2356 void tty_puts(struct tty *, const char *);
2357 void tty_putc(struct tty *, u_char);
2358 void tty_putn(struct tty *, const void *, size_t, u_int);
2359 void tty_cell(struct tty *, const struct grid_cell *,
2360 const struct grid_cell *, struct colour_palette *,
2361 struct hyperlinks *);
2362 int tty_init(struct tty *, struct client *);
2363 void tty_resize(struct tty *);
2364 void tty_set_size(struct tty *, u_int, u_int, u_int, u_int);
2365 void tty_start_tty(struct tty *);
2366 void tty_send_requests(struct tty *);
2367 void tty_repeat_requests(struct tty *);
2368 void tty_stop_tty(struct tty *);
2369 void tty_set_title(struct tty *, const char *);
2370 void tty_set_path(struct tty *, const char *);
2371 void tty_update_mode(struct tty *, int, struct screen *);
2372 void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int,
2373 u_int, u_int, const struct grid_cell *, struct colour_palette *);
2374 void tty_sync_start(struct tty *);
2375 void tty_sync_end(struct tty *);
2376 int tty_open(struct tty *, char **);
2377 void tty_close(struct tty *);
2378 void tty_free(struct tty *);
2379 void tty_update_features(struct tty *);
2380 void tty_set_selection(struct tty *, const char *, const char *, size_t);
2381 void tty_write(void (*)(struct tty *, const struct tty_ctx *),
2382 struct tty_ctx *);
2383 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
2384 void tty_cmd_cell(struct tty *, const struct tty_ctx *);
2385 void tty_cmd_cells(struct tty *, const struct tty_ctx *);
2386 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
2387 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
2388 void tty_cmd_clearline(struct tty *, const struct tty_ctx *);
2389 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
2390 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
2391 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
2392 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
2393 void tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *);
2394 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
2395 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
2396 void tty_cmd_insertline(struct tty *, const struct tty_ctx *);
2397 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
2398 void tty_cmd_scrollup(struct tty *, const struct tty_ctx *);
2399 void tty_cmd_scrolldown(struct tty *, const struct tty_ctx *);
2400 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
2401 void tty_cmd_setselection(struct tty *, const struct tty_ctx *);
2402 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
2403 void tty_cmd_syncstart(struct tty *, const struct tty_ctx *);
2404 void tty_default_colours(struct grid_cell *, struct window_pane *);
2406 /* tty-term.c */
2407 extern struct tty_terms tty_terms;
2408 u_int tty_term_ncodes(void);
2409 void tty_term_apply(struct tty_term *, const char *, int);
2410 void tty_term_apply_overrides(struct tty_term *);
2411 struct tty_term *tty_term_create(struct tty *, char *, char **, u_int, int *,
2412 char **);
2413 void tty_term_free(struct tty_term *);
2414 int tty_term_read_list(const char *, int, char ***, u_int *,
2415 char **);
2416 void tty_term_free_list(char **, u_int);
2417 int tty_term_has(struct tty_term *, enum tty_code_code);
2418 const char *tty_term_string(struct tty_term *, enum tty_code_code);
2419 const char *tty_term_string_i(struct tty_term *, enum tty_code_code, int);
2420 const char *tty_term_string_ii(struct tty_term *, enum tty_code_code, int,
2421 int);
2422 const char *tty_term_string_iii(struct tty_term *, enum tty_code_code, int,
2423 int, int);
2424 const char *tty_term_string_s(struct tty_term *, enum tty_code_code,
2425 const char *);
2426 const char *tty_term_string_ss(struct tty_term *, enum tty_code_code,
2427 const char *, const char *);
2428 int tty_term_number(struct tty_term *, enum tty_code_code);
2429 int tty_term_flag(struct tty_term *, enum tty_code_code);
2430 const char *tty_term_describe(struct tty_term *, enum tty_code_code);
2432 /* tty-features.c */
2433 void tty_add_features(int *, const char *, const char *);
2434 const char *tty_get_features(int);
2435 int tty_apply_features(struct tty_term *, int);
2436 void tty_default_features(int *, const char *, u_int);
2438 /* tty-acs.c */
2439 int tty_acs_needed(struct tty *);
2440 const char *tty_acs_get(struct tty *, u_char);
2441 int tty_acs_reverse_get(struct tty *, const char *, size_t);
2442 const struct utf8_data *tty_acs_double_borders(int);
2443 const struct utf8_data *tty_acs_heavy_borders(int);
2444 const struct utf8_data *tty_acs_rounded_borders(int);
2446 /* tty-keys.c */
2447 void tty_keys_build(struct tty *);
2448 void tty_keys_free(struct tty *);
2449 int tty_keys_next(struct tty *);
2450 int tty_keys_colours(struct tty *, const char *, size_t, size_t *,
2451 int *, int *);
2453 /* arguments.c */
2454 void args_set(struct args *, u_char, struct args_value *, int);
2455 struct args *args_create(void);
2456 struct args *args_parse(const struct args_parse *, struct args_value *,
2457 u_int, char **);
2458 struct args *args_copy(struct args *, int, char **);
2459 void args_to_vector(struct args *, int *, char ***);
2460 struct args_value *args_from_vector(int, char **);
2461 void args_free_value(struct args_value *);
2462 void args_free_values(struct args_value *, u_int);
2463 void args_free(struct args *);
2464 char *args_print(struct args *);
2465 char *args_escape(const char *);
2466 int args_has(struct args *, u_char);
2467 const char *args_get(struct args *, u_char);
2468 u_char args_first(struct args *, struct args_entry **);
2469 u_char args_next(struct args_entry **);
2470 u_int args_count(struct args *);
2471 struct args_value *args_values(struct args *);
2472 struct args_value *args_value(struct args *, u_int);
2473 const char *args_string(struct args *, u_int);
2474 struct cmd_list *args_make_commands_now(struct cmd *, struct cmdq_item *,
2475 u_int, int);
2476 struct args_command_state *args_make_commands_prepare(struct cmd *,
2477 struct cmdq_item *, u_int, const char *, int, int);
2478 struct cmd_list *args_make_commands(struct args_command_state *, int, char **,
2479 char **);
2480 void args_make_commands_free(struct args_command_state *);
2481 char *args_make_commands_get_command(struct args_command_state *);
2482 struct args_value *args_first_value(struct args *, u_char);
2483 struct args_value *args_next_value(struct args_value *);
2484 long long args_strtonum(struct args *, u_char, long long, long long,
2485 char **);
2486 long long args_strtonum_and_expand(struct args *, u_char, long long,
2487 long long, struct cmdq_item *, char **);
2488 long long args_percentage(struct args *, u_char, long long,
2489 long long, long long, char **);
2490 long long args_string_percentage(const char *, long long, long long,
2491 long long, char **);
2492 long long args_percentage_and_expand(struct args *, u_char, long long,
2493 long long, long long, struct cmdq_item *, char **);
2494 long long args_string_percentage_and_expand(const char *, long long,
2495 long long, long long, struct cmdq_item *, char **);
2497 /* cmd-find.c */
2498 int cmd_find_target(struct cmd_find_state *, struct cmdq_item *,
2499 const char *, enum cmd_find_type, int);
2500 struct client *cmd_find_best_client(struct session *);
2501 struct client *cmd_find_client(struct cmdq_item *, const char *, int);
2502 void cmd_find_clear_state(struct cmd_find_state *, int);
2503 int cmd_find_empty_state(struct cmd_find_state *);
2504 int cmd_find_valid_state(struct cmd_find_state *);
2505 void cmd_find_copy_state(struct cmd_find_state *,
2506 struct cmd_find_state *);
2507 void cmd_find_from_session(struct cmd_find_state *,
2508 struct session *, int);
2509 void cmd_find_from_winlink(struct cmd_find_state *,
2510 struct winlink *, int);
2511 int cmd_find_from_session_window(struct cmd_find_state *,
2512 struct session *, struct window *, int);
2513 int cmd_find_from_window(struct cmd_find_state *, struct window *,
2514 int);
2515 void cmd_find_from_winlink_pane(struct cmd_find_state *,
2516 struct winlink *, struct window_pane *, int);
2517 int cmd_find_from_pane(struct cmd_find_state *,
2518 struct window_pane *, int);
2519 int cmd_find_from_client(struct cmd_find_state *, struct client *,
2520 int);
2521 int cmd_find_from_mouse(struct cmd_find_state *,
2522 struct mouse_event *, int);
2523 int cmd_find_from_nothing(struct cmd_find_state *, int);
2525 /* cmd.c */
2526 extern const struct cmd_entry *cmd_table[];
2527 void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
2528 void cmd_prepend_argv(int *, char ***, const char *);
2529 void cmd_append_argv(int *, char ***, const char *);
2530 int cmd_pack_argv(int, char **, char *, size_t);
2531 int cmd_unpack_argv(char *, size_t, int, char ***);
2532 char **cmd_copy_argv(int, char **);
2533 void cmd_free_argv(int, char **);
2534 char *cmd_stringify_argv(int, char **);
2535 char *cmd_get_alias(const char *);
2536 const struct cmd_entry *cmd_get_entry(struct cmd *);
2537 struct args *cmd_get_args(struct cmd *);
2538 u_int cmd_get_group(struct cmd *);
2539 void cmd_get_source(struct cmd *, const char **, u_int *);
2540 struct cmd *cmd_parse(struct args_value *, u_int, const char *, u_int,
2541 char **);
2542 struct cmd *cmd_copy(struct cmd *, int, char **);
2543 void cmd_free(struct cmd *);
2544 char *cmd_print(struct cmd *);
2545 struct cmd_list *cmd_list_new(void);
2546 struct cmd_list *cmd_list_copy(struct cmd_list *, int, char **);
2547 void cmd_list_append(struct cmd_list *, struct cmd *);
2548 void cmd_list_append_all(struct cmd_list *, struct cmd_list *);
2549 void cmd_list_move(struct cmd_list *, struct cmd_list *);
2550 void cmd_list_free(struct cmd_list *);
2551 char *cmd_list_print(struct cmd_list *, int);
2552 struct cmd *cmd_list_first(struct cmd_list *);
2553 struct cmd *cmd_list_next(struct cmd *);
2554 int cmd_list_all_have(struct cmd_list *, int);
2555 int cmd_list_any_have(struct cmd_list *, int);
2556 int cmd_mouse_at(struct window_pane *, struct mouse_event *,
2557 u_int *, u_int *, int);
2558 struct winlink *cmd_mouse_window(struct mouse_event *, struct session **);
2559 struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **,
2560 struct winlink **);
2561 char *cmd_template_replace(const char *, const char *, int);
2563 /* cmd-attach-session.c */
2564 enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int,
2565 int, const char *, int, const char *);
2567 /* cmd-parse.c */
2568 struct cmd_parse_result *cmd_parse_from_file(FILE *, struct cmd_parse_input *);
2569 struct cmd_parse_result *cmd_parse_from_string(const char *,
2570 struct cmd_parse_input *);
2571 enum cmd_parse_status cmd_parse_and_insert(const char *,
2572 struct cmd_parse_input *, struct cmdq_item *,
2573 struct cmdq_state *, char **);
2574 enum cmd_parse_status cmd_parse_and_append(const char *,
2575 struct cmd_parse_input *, struct client *,
2576 struct cmdq_state *, char **);
2577 struct cmd_parse_result *cmd_parse_from_buffer(const void *, size_t,
2578 struct cmd_parse_input *);
2579 struct cmd_parse_result *cmd_parse_from_arguments(struct args_value *, u_int,
2580 struct cmd_parse_input *);
2582 /* cmd-queue.c */
2583 struct cmdq_state *cmdq_new_state(struct cmd_find_state *, struct key_event *,
2584 int);
2585 struct cmdq_state *cmdq_link_state(struct cmdq_state *);
2586 struct cmdq_state *cmdq_copy_state(struct cmdq_state *,
2587 struct cmd_find_state *);
2588 void cmdq_free_state(struct cmdq_state *);
2589 void printflike(3, 4) cmdq_add_format(struct cmdq_state *, const char *,
2590 const char *, ...);
2591 void cmdq_add_formats(struct cmdq_state *, struct format_tree *);
2592 void cmdq_merge_formats(struct cmdq_item *, struct format_tree *);
2593 struct cmdq_list *cmdq_new(void);
2594 void cmdq_free(struct cmdq_list *);
2595 const char *cmdq_get_name(struct cmdq_item *);
2596 struct client *cmdq_get_client(struct cmdq_item *);
2597 struct client *cmdq_get_target_client(struct cmdq_item *);
2598 struct cmdq_state *cmdq_get_state(struct cmdq_item *);
2599 struct cmd_find_state *cmdq_get_target(struct cmdq_item *);
2600 struct cmd_find_state *cmdq_get_source(struct cmdq_item *);
2601 struct key_event *cmdq_get_event(struct cmdq_item *);
2602 struct cmd_find_state *cmdq_get_current(struct cmdq_item *);
2603 int cmdq_get_flags(struct cmdq_item *);
2604 struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmdq_state *);
2605 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
2606 struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *);
2607 struct cmdq_item *cmdq_get_error(const char *);
2608 struct cmdq_item *cmdq_insert_after(struct cmdq_item *, struct cmdq_item *);
2609 struct cmdq_item *cmdq_append(struct client *, struct cmdq_item *);
2610 void printflike(4, 5) cmdq_insert_hook(struct session *, struct cmdq_item *,
2611 struct cmd_find_state *, const char *, ...);
2612 void cmdq_continue(struct cmdq_item *);
2613 u_int cmdq_next(struct client *);
2614 struct cmdq_item *cmdq_running(struct client *);
2615 void cmdq_guard(struct cmdq_item *, const char *, int);
2616 void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
2617 void cmdq_print_data(struct cmdq_item *, int, struct evbuffer *);
2618 void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
2620 /* cmd-wait-for.c */
2621 void cmd_wait_for_flush(void);
2623 /* client.c */
2624 int client_main(struct event_base *, int, char **, uint64_t, int);
2626 /* key-bindings.c */
2627 struct key_table *key_bindings_get_table(const char *, int);
2628 struct key_table *key_bindings_first_table(void);
2629 struct key_table *key_bindings_next_table(struct key_table *);
2630 void key_bindings_unref_table(struct key_table *);
2631 struct key_binding *key_bindings_get(struct key_table *, key_code);
2632 struct key_binding *key_bindings_get_default(struct key_table *, key_code);
2633 struct key_binding *key_bindings_first(struct key_table *);
2634 struct key_binding *key_bindings_next(struct key_table *, struct key_binding *);
2635 void key_bindings_add(const char *, key_code, const char *, int,
2636 struct cmd_list *);
2637 void key_bindings_remove(const char *, key_code);
2638 void key_bindings_reset(const char *, key_code);
2639 void key_bindings_remove_table(const char *);
2640 void key_bindings_reset_table(const char *);
2641 void key_bindings_init(void);
2642 struct cmdq_item *key_bindings_dispatch(struct key_binding *,
2643 struct cmdq_item *, struct client *, struct key_event *,
2644 struct cmd_find_state *);
2646 /* key-string.c */
2647 key_code key_string_lookup_string(const char *);
2648 const char *key_string_lookup_key(key_code, int);
2650 /* alerts.c */
2651 void alerts_reset_all(void);
2652 void alerts_queue(struct window *, int);
2653 void alerts_check_session(struct session *);
2655 /* file.c */
2656 int file_cmp(struct client_file *, struct client_file *);
2657 RB_PROTOTYPE(client_files, client_file, entry, file_cmp);
2658 struct client_file *file_create_with_peer(struct tmuxpeer *,
2659 struct client_files *, int, client_file_cb, void *);
2660 struct client_file *file_create_with_client(struct client *, int,
2661 client_file_cb, void *);
2662 void file_free(struct client_file *);
2663 void file_fire_done(struct client_file *);
2664 void file_fire_read(struct client_file *);
2665 int file_can_print(struct client *);
2666 void printflike(2, 3) file_print(struct client *, const char *, ...);
2667 void printflike(2, 0) file_vprint(struct client *, const char *, va_list);
2668 void file_print_buffer(struct client *, void *, size_t);
2669 void printflike(2, 3) file_error(struct client *, const char *, ...);
2670 void file_write(struct client *, const char *, int, const void *, size_t,
2671 client_file_cb, void *);
2672 struct client_file *file_read(struct client *, const char *, client_file_cb,
2673 void *);
2674 void file_cancel(struct client_file *);
2675 void file_push(struct client_file *);
2676 int file_write_left(struct client_files *);
2677 void file_write_open(struct client_files *, struct tmuxpeer *,
2678 struct imsg *, int, int, client_file_cb, void *);
2679 void file_write_data(struct client_files *, struct imsg *);
2680 void file_write_close(struct client_files *, struct imsg *);
2681 void file_read_open(struct client_files *, struct tmuxpeer *, struct imsg *,
2682 int, int, client_file_cb, void *);
2683 void file_write_ready(struct client_files *, struct imsg *);
2684 void file_read_data(struct client_files *, struct imsg *);
2685 void file_read_done(struct client_files *, struct imsg *);
2686 void file_read_cancel(struct client_files *, struct imsg *);
2688 /* server.c */
2689 extern struct tmuxproc *server_proc;
2690 extern struct clients clients;
2691 extern struct cmd_find_state marked_pane;
2692 extern struct message_list message_log;
2693 extern time_t current_time;
2694 void server_set_marked(struct session *, struct winlink *,
2695 struct window_pane *);
2696 void server_clear_marked(void);
2697 int server_is_marked(struct session *, struct winlink *,
2698 struct window_pane *);
2699 int server_check_marked(void);
2700 int server_start(struct tmuxproc *, int, struct event_base *, int, char *);
2701 void server_update_socket(void);
2702 void server_add_accept(int);
2703 void printflike(1, 2) server_add_message(const char *, ...);
2705 /* server-client.c */
2706 RB_PROTOTYPE(client_windows, client_window, entry, server_client_window_cmp);
2707 u_int server_client_how_many(void);
2708 void server_client_set_overlay(struct client *, u_int, overlay_check_cb,
2709 overlay_mode_cb, overlay_draw_cb, overlay_key_cb,
2710 overlay_free_cb, overlay_resize_cb, void *);
2711 void server_client_clear_overlay(struct client *);
2712 void server_client_overlay_range(u_int, u_int, u_int, u_int, u_int, u_int,
2713 u_int, struct overlay_ranges *);
2714 void server_client_set_key_table(struct client *, const char *);
2715 const char *server_client_get_key_table(struct client *);
2716 int server_client_check_nested(struct client *);
2717 int server_client_handle_key(struct client *, struct key_event *);
2718 struct client *server_client_create(int);
2719 int server_client_open(struct client *, char **);
2720 void server_client_unref(struct client *);
2721 void server_client_set_session(struct client *, struct session *);
2722 void server_client_lost(struct client *);
2723 void server_client_suspend(struct client *);
2724 void server_client_detach(struct client *, enum msgtype);
2725 void server_client_exec(struct client *, const char *);
2726 void server_client_loop(void);
2727 const char *server_client_get_cwd(struct client *, struct session *);
2728 void server_client_set_flags(struct client *, const char *);
2729 const char *server_client_get_flags(struct client *);
2730 struct client_window *server_client_get_client_window(struct client *, u_int);
2731 struct client_window *server_client_add_client_window(struct client *, u_int);
2732 struct window_pane *server_client_get_pane(struct client *);
2733 void server_client_set_pane(struct client *, struct window_pane *);
2734 void server_client_remove_pane(struct window_pane *);
2735 void server_client_print(struct client *, int, struct evbuffer *);
2737 /* server-fn.c */
2738 void server_redraw_client(struct client *);
2739 void server_status_client(struct client *);
2740 void server_redraw_session(struct session *);
2741 void server_redraw_session_group(struct session *);
2742 void server_status_session(struct session *);
2743 void server_status_session_group(struct session *);
2744 void server_redraw_window(struct window *);
2745 void server_redraw_window_borders(struct window *);
2746 void server_status_window(struct window *);
2747 void server_lock(void);
2748 void server_lock_session(struct session *);
2749 void server_lock_client(struct client *);
2750 void server_kill_pane(struct window_pane *);
2751 void server_kill_window(struct window *, int);
2752 void server_renumber_session(struct session *);
2753 void server_renumber_all(void);
2754 int server_link_window(struct session *,
2755 struct winlink *, struct session *, int, int, int, char **);
2756 void server_unlink_window(struct session *, struct winlink *);
2757 void server_destroy_pane(struct window_pane *, int);
2758 void server_destroy_session(struct session *);
2759 void server_check_unattached(void);
2760 void server_unzoom_window(struct window *);
2762 /* status.c */
2763 extern char **status_prompt_hlist[];
2764 extern u_int status_prompt_hsize[];
2765 void status_timer_start(struct client *);
2766 void status_timer_start_all(void);
2767 void status_update_cache(struct session *);
2768 int status_at_line(struct client *);
2769 u_int status_line_size(struct client *);
2770 struct style_range *status_get_range(struct client *, u_int, u_int);
2771 void status_init(struct client *);
2772 void status_free(struct client *);
2773 int status_redraw(struct client *);
2774 void printflike(5, 6) status_message_set(struct client *, int, int, int,
2775 const char *, ...);
2776 void status_message_clear(struct client *);
2777 int status_message_redraw(struct client *);
2778 void status_prompt_set(struct client *, struct cmd_find_state *,
2779 const char *, const char *, prompt_input_cb, prompt_free_cb,
2780 void *, int, enum prompt_type);
2781 void status_prompt_clear(struct client *);
2782 int status_prompt_redraw(struct client *);
2783 int status_prompt_key(struct client *, key_code);
2784 void status_prompt_update(struct client *, const char *, const char *);
2785 void status_prompt_load_history(void);
2786 void status_prompt_save_history(void);
2787 const char *status_prompt_type_string(u_int);
2788 enum prompt_type status_prompt_type(const char *type);
2790 /* resize.c */
2791 void resize_window(struct window *, u_int, u_int, int, int);
2792 void default_window_size(struct client *, struct session *, struct window *,
2793 u_int *, u_int *, u_int *, u_int *, int);
2794 void recalculate_size(struct window *, int);
2795 void recalculate_sizes(void);
2796 void recalculate_sizes_now(int);
2798 /* input.c */
2799 struct input_ctx *input_init(struct window_pane *, struct bufferevent *,
2800 struct colour_palette *);
2801 void input_free(struct input_ctx *);
2802 void input_reset(struct input_ctx *, int);
2803 struct evbuffer *input_pending(struct input_ctx *);
2804 void input_parse_pane(struct window_pane *);
2805 void input_parse_buffer(struct window_pane *, u_char *, size_t);
2806 void input_parse_screen(struct input_ctx *, struct screen *,
2807 screen_write_init_ctx_cb, void *, u_char *, size_t);
2808 void input_reply_clipboard(struct bufferevent *, const char *, size_t,
2809 const char *);
2811 /* input-key.c */
2812 void input_key_build(void);
2813 int input_key_pane(struct window_pane *, key_code, struct mouse_event *);
2814 int input_key(struct screen *, struct bufferevent *, key_code);
2815 int input_key_get_mouse(struct screen *, struct mouse_event *, u_int,
2816 u_int, const char **, size_t *);
2818 /* colour.c */
2819 int colour_find_rgb(u_char, u_char, u_char);
2820 int colour_join_rgb(u_char, u_char, u_char);
2821 void colour_split_rgb(int, u_char *, u_char *, u_char *);
2822 int colour_force_rgb(int);
2823 const char *colour_tostring(int);
2824 int colour_fromstring(const char *s);
2825 int colour_256toRGB(int);
2826 int colour_256to16(int);
2827 int colour_byname(const char *);
2828 int colour_parseX11(const char *);
2829 void colour_palette_init(struct colour_palette *);
2830 void colour_palette_clear(struct colour_palette *);
2831 void colour_palette_free(struct colour_palette *);
2832 int colour_palette_get(struct colour_palette *, int);
2833 int colour_palette_set(struct colour_palette *, int, int);
2834 void colour_palette_from_option(struct colour_palette *, struct options *);
2836 /* attributes.c */
2837 const char *attributes_tostring(int);
2838 int attributes_fromstring(const char *);
2840 /* grid.c */
2841 extern const struct grid_cell grid_default_cell;
2842 void grid_empty_line(struct grid *, u_int, u_int);
2843 int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
2844 int grid_cells_look_equal(const struct grid_cell *,
2845 const struct grid_cell *);
2846 struct grid *grid_create(u_int, u_int, u_int);
2847 void grid_destroy(struct grid *);
2848 int grid_compare(struct grid *, struct grid *);
2849 void grid_collect_history(struct grid *);
2850 void grid_remove_history(struct grid *, u_int );
2851 void grid_scroll_history(struct grid *, u_int);
2852 void grid_scroll_history_region(struct grid *, u_int, u_int, u_int);
2853 void grid_clear_history(struct grid *);
2854 const struct grid_line *grid_peek_line(struct grid *, u_int);
2855 void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
2856 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
2857 void grid_set_padding(struct grid *, u_int, u_int);
2858 void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *,
2859 const char *, size_t);
2860 struct grid_line *grid_get_line(struct grid *, u_int);
2861 void grid_adjust_lines(struct grid *, u_int);
2862 void grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
2863 void grid_clear_lines(struct grid *, u_int, u_int, u_int);
2864 void grid_move_lines(struct grid *, u_int, u_int, u_int, u_int);
2865 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int);
2866 char *grid_string_cells(struct grid *, u_int, u_int, u_int,
2867 struct grid_cell **, int, struct screen *);
2868 void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
2869 u_int);
2870 void grid_reflow(struct grid *, u_int);
2871 void grid_wrap_position(struct grid *, u_int, u_int, u_int *, u_int *);
2872 void grid_unwrap_position(struct grid *, u_int *, u_int *, u_int, u_int);
2873 u_int grid_line_length(struct grid *, u_int);
2875 /* grid-reader.c */
2876 void grid_reader_start(struct grid_reader *, struct grid *, u_int, u_int);
2877 void grid_reader_get_cursor(struct grid_reader *, u_int *, u_int *);
2878 u_int grid_reader_line_length(struct grid_reader *);
2879 int grid_reader_in_set(struct grid_reader *, const char *);
2880 void grid_reader_cursor_right(struct grid_reader *, int, int);
2881 void grid_reader_cursor_left(struct grid_reader *, int);
2882 void grid_reader_cursor_down(struct grid_reader *);
2883 void grid_reader_cursor_up(struct grid_reader *);
2884 void grid_reader_cursor_start_of_line(struct grid_reader *, int);
2885 void grid_reader_cursor_end_of_line(struct grid_reader *, int, int);
2886 void grid_reader_cursor_next_word(struct grid_reader *, const char *);
2887 void grid_reader_cursor_next_word_end(struct grid_reader *, const char *);
2888 void grid_reader_cursor_previous_word(struct grid_reader *, const char *,
2889 int, int);
2890 int grid_reader_cursor_jump(struct grid_reader *,
2891 const struct utf8_data *);
2892 int grid_reader_cursor_jump_back(struct grid_reader *,
2893 const struct utf8_data *);
2894 void grid_reader_cursor_back_to_indentation(struct grid_reader *);
2896 /* grid-view.c */
2897 void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
2898 void grid_view_set_cell(struct grid *, u_int, u_int,
2899 const struct grid_cell *);
2900 void grid_view_set_padding(struct grid *, u_int, u_int);
2901 void grid_view_set_cells(struct grid *, u_int, u_int,
2902 const struct grid_cell *, const char *, size_t);
2903 void grid_view_clear_history(struct grid *, u_int);
2904 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
2905 void grid_view_scroll_region_up(struct grid *, u_int, u_int, u_int);
2906 void grid_view_scroll_region_down(struct grid *, u_int, u_int, u_int);
2907 void grid_view_insert_lines(struct grid *, u_int, u_int, u_int);
2908 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int,
2909 u_int);
2910 void grid_view_delete_lines(struct grid *, u_int, u_int, u_int);
2911 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int,
2912 u_int);
2913 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int);
2914 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int);
2915 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
2917 /* screen-write.c */
2918 void screen_write_make_list(struct screen *);
2919 void screen_write_free_list(struct screen *);
2920 void screen_write_start_pane(struct screen_write_ctx *,
2921 struct window_pane *, struct screen *);
2922 void screen_write_start(struct screen_write_ctx *, struct screen *);
2923 void screen_write_start_callback(struct screen_write_ctx *, struct screen *,
2924 screen_write_init_ctx_cb, void *);
2925 void screen_write_stop(struct screen_write_ctx *);
2926 void screen_write_reset(struct screen_write_ctx *);
2927 size_t printflike(1, 2) screen_write_strlen(const char *, ...);
2928 int printflike(7, 8) screen_write_text(struct screen_write_ctx *, u_int, u_int,
2929 u_int, int, const struct grid_cell *, const char *, ...);
2930 void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
2931 const struct grid_cell *, const char *, ...);
2932 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *,
2933 ssize_t, const struct grid_cell *, const char *, ...);
2934 void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx *, ssize_t,
2935 const struct grid_cell *, const char *, va_list);
2936 void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *,
2937 u_char);
2938 void screen_write_fast_copy(struct screen_write_ctx *, struct screen *,
2939 u_int, u_int, u_int, u_int);
2940 void screen_write_hline(struct screen_write_ctx *, u_int, int, int,
2941 enum box_lines, const struct grid_cell *);
2942 void screen_write_vline(struct screen_write_ctx *, u_int, int, int);
2943 void screen_write_menu(struct screen_write_ctx *, struct menu *, int,
2944 enum box_lines, const struct grid_cell *, const struct grid_cell *,
2945 const struct grid_cell *);
2946 void screen_write_box(struct screen_write_ctx *, u_int, u_int,
2947 enum box_lines, const struct grid_cell *, const char *);
2948 void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int,
2949 u_int);
2950 void screen_write_backspace(struct screen_write_ctx *);
2951 void screen_write_mode_set(struct screen_write_ctx *, int);
2952 void screen_write_mode_clear(struct screen_write_ctx *, int);
2953 void screen_write_cursorup(struct screen_write_ctx *, u_int);
2954 void screen_write_cursordown(struct screen_write_ctx *, u_int);
2955 void screen_write_cursorright(struct screen_write_ctx *, u_int);
2956 void screen_write_cursorleft(struct screen_write_ctx *, u_int);
2957 void screen_write_alignmenttest(struct screen_write_ctx *);
2958 void screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int);
2959 void screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int);
2960 void screen_write_clearcharacter(struct screen_write_ctx *, u_int, u_int);
2961 void screen_write_insertline(struct screen_write_ctx *, u_int, u_int);
2962 void screen_write_deleteline(struct screen_write_ctx *, u_int, u_int);
2963 void screen_write_clearline(struct screen_write_ctx *, u_int);
2964 void screen_write_clearendofline(struct screen_write_ctx *, u_int);
2965 void screen_write_clearstartofline(struct screen_write_ctx *, u_int);
2966 void screen_write_cursormove(struct screen_write_ctx *, int, int, int);
2967 void screen_write_reverseindex(struct screen_write_ctx *, u_int);
2968 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
2969 void screen_write_linefeed(struct screen_write_ctx *, int, u_int);
2970 void screen_write_scrollup(struct screen_write_ctx *, u_int, u_int);
2971 void screen_write_scrolldown(struct screen_write_ctx *, u_int, u_int);
2972 void screen_write_carriagereturn(struct screen_write_ctx *);
2973 void screen_write_clearendofscreen(struct screen_write_ctx *, u_int);
2974 void screen_write_clearstartofscreen(struct screen_write_ctx *, u_int);
2975 void screen_write_clearscreen(struct screen_write_ctx *, u_int);
2976 void screen_write_clearhistory(struct screen_write_ctx *);
2977 void screen_write_fullredraw(struct screen_write_ctx *);
2978 void screen_write_collect_end(struct screen_write_ctx *);
2979 void screen_write_collect_add(struct screen_write_ctx *,
2980 const struct grid_cell *);
2981 void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *);
2982 void screen_write_setselection(struct screen_write_ctx *, const char *,
2983 u_char *, u_int);
2984 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int,
2985 int);
2986 void screen_write_alternateon(struct screen_write_ctx *,
2987 struct grid_cell *, int);
2988 void screen_write_alternateoff(struct screen_write_ctx *,
2989 struct grid_cell *, int);
2991 /* screen-redraw.c */
2992 void screen_redraw_screen(struct client *);
2993 void screen_redraw_pane(struct client *, struct window_pane *);
2995 /* screen.c */
2996 void screen_init(struct screen *, u_int, u_int, u_int);
2997 void screen_reinit(struct screen *);
2998 void screen_free(struct screen *);
2999 void screen_reset_tabs(struct screen *);
3000 void screen_reset_hyperlinks(struct screen *);
3001 void screen_set_cursor_style(u_int, enum screen_cursor_style *, int *);
3002 void screen_set_cursor_colour(struct screen *, int);
3003 int screen_set_title(struct screen *, const char *);
3004 void screen_set_path(struct screen *, const char *);
3005 void screen_push_title(struct screen *);
3006 void screen_pop_title(struct screen *);
3007 void screen_resize(struct screen *, u_int, u_int, int);
3008 void screen_resize_cursor(struct screen *, u_int, u_int, int, int, int);
3009 void screen_set_selection(struct screen *, u_int, u_int, u_int, u_int,
3010 u_int, int, struct grid_cell *);
3011 void screen_clear_selection(struct screen *);
3012 void screen_hide_selection(struct screen *);
3013 int screen_check_selection(struct screen *, u_int, u_int);
3014 void screen_select_cell(struct screen *, struct grid_cell *,
3015 const struct grid_cell *);
3016 void screen_alternate_on(struct screen *, struct grid_cell *, int);
3017 void screen_alternate_off(struct screen *, struct grid_cell *, int);
3018 const char *screen_mode_to_string(int);
3020 /* window.c */
3021 extern struct windows windows;
3022 extern struct window_pane_tree all_window_panes;
3023 int window_cmp(struct window *, struct window *);
3024 RB_PROTOTYPE(windows, window, entry, window_cmp);
3025 int winlink_cmp(struct winlink *, struct winlink *);
3026 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
3027 int window_pane_cmp(struct window_pane *, struct window_pane *);
3028 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
3029 struct winlink *winlink_find_by_index(struct winlinks *, int);
3030 struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
3031 struct winlink *winlink_find_by_window_id(struct winlinks *, u_int);
3032 u_int winlink_count(struct winlinks *);
3033 struct winlink *winlink_add(struct winlinks *, int);
3034 void winlink_set_window(struct winlink *, struct window *);
3035 void winlink_remove(struct winlinks *, struct winlink *);
3036 struct winlink *winlink_next(struct winlink *);
3037 struct winlink *winlink_previous(struct winlink *);
3038 struct winlink *winlink_next_by_number(struct winlink *, struct session *,
3039 int);
3040 struct winlink *winlink_previous_by_number(struct winlink *, struct session *,
3041 int);
3042 void winlink_stack_push(struct winlink_stack *, struct winlink *);
3043 void winlink_stack_remove(struct winlink_stack *, struct winlink *);
3044 struct window *window_find_by_id_str(const char *);
3045 struct window *window_find_by_id(u_int);
3046 void window_update_activity(struct window *);
3047 struct window *window_create(u_int, u_int, u_int, u_int);
3048 void window_pane_set_event(struct window_pane *);
3049 struct window_pane *window_get_active_at(struct window *, u_int, u_int);
3050 struct window_pane *window_find_string(struct window *, const char *);
3051 int window_has_pane(struct window *, struct window_pane *);
3052 int window_set_active_pane(struct window *, struct window_pane *,
3053 int);
3054 void window_update_focus(struct window *);
3055 void window_pane_update_focus(struct window_pane *);
3056 void window_redraw_active_switch(struct window *,
3057 struct window_pane *);
3058 struct window_pane *window_add_pane(struct window *, struct window_pane *,
3059 u_int, int);
3060 void window_resize(struct window *, u_int, u_int, int, int);
3061 void window_pane_send_resize(struct window_pane *, u_int, u_int);
3062 int window_zoom(struct window_pane *);
3063 int window_unzoom(struct window *, int);
3064 int window_push_zoom(struct window *, int, int);
3065 int window_pop_zoom(struct window *);
3066 void window_lost_pane(struct window *, struct window_pane *);
3067 void window_remove_pane(struct window *, struct window_pane *);
3068 struct window_pane *window_pane_at_index(struct window *, u_int);
3069 struct window_pane *window_pane_next_by_number(struct window *,
3070 struct window_pane *, u_int);
3071 struct window_pane *window_pane_previous_by_number(struct window *,
3072 struct window_pane *, u_int);
3073 int window_pane_index(struct window_pane *, u_int *);
3074 u_int window_count_panes(struct window *);
3075 void window_destroy_panes(struct window *);
3076 struct window_pane *window_pane_find_by_id_str(const char *);
3077 struct window_pane *window_pane_find_by_id(u_int);
3078 int window_pane_destroy_ready(struct window_pane *);
3079 void window_pane_resize(struct window_pane *, u_int, u_int);
3080 int window_pane_set_mode(struct window_pane *,
3081 struct window_pane *, const struct window_mode *,
3082 struct cmd_find_state *, struct args *);
3083 void window_pane_reset_mode(struct window_pane *);
3084 void window_pane_reset_mode_all(struct window_pane *);
3085 int window_pane_key(struct window_pane *, struct client *,
3086 struct session *, struct winlink *, key_code,
3087 struct mouse_event *);
3088 int window_pane_visible(struct window_pane *);
3089 int window_pane_exited(struct window_pane *);
3090 u_int window_pane_search(struct window_pane *, const char *, int,
3091 int);
3092 const char *window_printable_flags(struct winlink *, int);
3093 struct window_pane *window_pane_find_up(struct window_pane *);
3094 struct window_pane *window_pane_find_down(struct window_pane *);
3095 struct window_pane *window_pane_find_left(struct window_pane *);
3096 struct window_pane *window_pane_find_right(struct window_pane *);
3097 void window_pane_stack_push(struct window_panes *,
3098 struct window_pane *);
3099 void window_pane_stack_remove(struct window_panes *,
3100 struct window_pane *);
3101 void window_set_name(struct window *, const char *);
3102 void window_add_ref(struct window *, const char *);
3103 void window_remove_ref(struct window *, const char *);
3104 void winlink_clear_flags(struct winlink *);
3105 int winlink_shuffle_up(struct session *, struct winlink *, int);
3106 int window_pane_start_input(struct window_pane *,
3107 struct cmdq_item *, char **);
3108 void *window_pane_get_new_data(struct window_pane *,
3109 struct window_pane_offset *, size_t *);
3110 void window_pane_update_used_data(struct window_pane *,
3111 struct window_pane_offset *, size_t);
3112 void window_set_fill_character(struct window *);
3113 void window_pane_default_cursor(struct window_pane *);
3115 /* layout.c */
3116 u_int layout_count_cells(struct layout_cell *);
3117 struct layout_cell *layout_create_cell(struct layout_cell *);
3118 void layout_free_cell(struct layout_cell *);
3119 void layout_print_cell(struct layout_cell *, const char *, u_int);
3120 void layout_destroy_cell(struct window *, struct layout_cell *,
3121 struct layout_cell **);
3122 void layout_resize_layout(struct window *, struct layout_cell *,
3123 enum layout_type, int, int);
3124 struct layout_cell *layout_search_by_border(struct layout_cell *, u_int, u_int);
3125 void layout_set_size(struct layout_cell *, u_int, u_int, u_int,
3126 u_int);
3127 void layout_make_leaf(struct layout_cell *, struct window_pane *);
3128 void layout_make_node(struct layout_cell *, enum layout_type);
3129 void layout_fix_offsets(struct window *);
3130 void layout_fix_panes(struct window *, struct window_pane *);
3131 void layout_resize_adjust(struct window *, struct layout_cell *,
3132 enum layout_type, int);
3133 void layout_init(struct window *, struct window_pane *);
3134 void layout_free(struct window *);
3135 void layout_resize(struct window *, u_int, u_int);
3136 void layout_resize_pane(struct window_pane *, enum layout_type,
3137 int, int);
3138 void layout_resize_pane_to(struct window_pane *, enum layout_type,
3139 u_int);
3140 void layout_assign_pane(struct layout_cell *, struct window_pane *,
3141 int);
3142 struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type,
3143 int, int);
3144 void layout_close_pane(struct window_pane *);
3145 int layout_spread_cell(struct window *, struct layout_cell *);
3146 void layout_spread_out(struct window_pane *);
3148 /* layout-custom.c */
3149 char *layout_dump(struct layout_cell *);
3150 int layout_parse(struct window *, const char *, char **);
3152 /* layout-set.c */
3153 int layout_set_lookup(const char *);
3154 u_int layout_set_select(struct window *, u_int);
3155 u_int layout_set_next(struct window *);
3156 u_int layout_set_previous(struct window *);
3158 /* mode-tree.c */
3159 typedef void (*mode_tree_build_cb)(void *, struct mode_tree_sort_criteria *,
3160 uint64_t *, const char *);
3161 typedef void (*mode_tree_draw_cb)(void *, void *, struct screen_write_ctx *,
3162 u_int, u_int);
3163 typedef int (*mode_tree_search_cb)(void *, void *, const char *);
3164 typedef void (*mode_tree_menu_cb)(void *, struct client *, key_code);
3165 typedef u_int (*mode_tree_height_cb)(void *, u_int);
3166 typedef key_code (*mode_tree_key_cb)(void *, void *, u_int);
3167 typedef void (*mode_tree_each_cb)(void *, void *, struct client *, key_code);
3168 u_int mode_tree_count_tagged(struct mode_tree_data *);
3169 void *mode_tree_get_current(struct mode_tree_data *);
3170 const char *mode_tree_get_current_name(struct mode_tree_data *);
3171 void mode_tree_expand_current(struct mode_tree_data *);
3172 void mode_tree_collapse_current(struct mode_tree_data *);
3173 void mode_tree_expand(struct mode_tree_data *, uint64_t);
3174 int mode_tree_set_current(struct mode_tree_data *, uint64_t);
3175 void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb,
3176 struct client *, key_code, int);
3177 void mode_tree_up(struct mode_tree_data *, int);
3178 int mode_tree_down(struct mode_tree_data *, int);
3179 struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *,
3180 mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb,
3181 mode_tree_menu_cb, mode_tree_height_cb, mode_tree_key_cb, void *,
3182 const struct menu_item *, const char **, u_int, struct screen **);
3183 void mode_tree_zoom(struct mode_tree_data *, struct args *);
3184 void mode_tree_build(struct mode_tree_data *);
3185 void mode_tree_free(struct mode_tree_data *);
3186 void mode_tree_resize(struct mode_tree_data *, u_int, u_int);
3187 struct mode_tree_item *mode_tree_add(struct mode_tree_data *,
3188 struct mode_tree_item *, void *, uint64_t, const char *,
3189 const char *, int);
3190 void mode_tree_draw_as_parent(struct mode_tree_item *);
3191 void mode_tree_no_tag(struct mode_tree_item *);
3192 void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *);
3193 void mode_tree_draw(struct mode_tree_data *);
3194 int mode_tree_key(struct mode_tree_data *, struct client *, key_code *,
3195 struct mouse_event *, u_int *, u_int *);
3196 void mode_tree_run_command(struct client *, struct cmd_find_state *,
3197 const char *, const char *);
3199 /* window-buffer.c */
3200 extern const struct window_mode window_buffer_mode;
3202 /* window-tree.c */
3203 extern const struct window_mode window_tree_mode;
3205 /* window-clock.c */
3206 extern const struct window_mode window_clock_mode;
3207 extern const char window_clock_table[14][5][5];
3209 /* window-client.c */
3210 extern const struct window_mode window_client_mode;
3212 /* window-copy.c */
3213 extern const struct window_mode window_copy_mode;
3214 extern const struct window_mode window_view_mode;
3215 void printflike(3, 4) window_copy_add(struct window_pane *, int, const char *,
3216 ...);
3217 void printflike(3, 0) window_copy_vadd(struct window_pane *, int, const char *,
3218 va_list);
3219 void window_copy_pageup(struct window_pane *, int);
3220 void window_copy_start_drag(struct client *, struct mouse_event *);
3221 char *window_copy_get_word(struct window_pane *, u_int, u_int);
3222 char *window_copy_get_line(struct window_pane *, u_int);
3224 /* window-option.c */
3225 extern const struct window_mode window_customize_mode;
3227 /* names.c */
3228 void check_window_name(struct window *);
3229 char *default_window_name(struct window *);
3230 char *parse_window_name(const char *);
3232 /* control.c */
3233 void control_discard(struct client *);
3234 void control_start(struct client *);
3235 void control_ready(struct client *);
3236 void control_stop(struct client *);
3237 void control_set_pane_on(struct client *, struct window_pane *);
3238 void control_set_pane_off(struct client *, struct window_pane *);
3239 void control_continue_pane(struct client *, struct window_pane *);
3240 void control_pause_pane(struct client *, struct window_pane *);
3241 struct window_pane_offset *control_pane_offset(struct client *,
3242 struct window_pane *, int *);
3243 void control_reset_offsets(struct client *);
3244 void printflike(2, 3) control_write(struct client *, const char *, ...);
3245 void control_write_output(struct client *, struct window_pane *);
3246 int control_all_done(struct client *);
3247 void control_add_sub(struct client *, const char *, enum control_sub_type,
3248 int, const char *);
3249 void control_remove_sub(struct client *, const char *);
3251 /* control-notify.c */
3252 void control_notify_pane_mode_changed(int);
3253 void control_notify_window_layout_changed(struct window *);
3254 void control_notify_window_pane_changed(struct window *);
3255 void control_notify_window_unlinked(struct session *, struct window *);
3256 void control_notify_window_linked(struct session *, struct window *);
3257 void control_notify_window_renamed(struct window *);
3258 void control_notify_client_session_changed(struct client *);
3259 void control_notify_client_detached(struct client *);
3260 void control_notify_session_renamed(struct session *);
3261 void control_notify_session_created(struct session *);
3262 void control_notify_session_closed(struct session *);
3263 void control_notify_session_window_changed(struct session *);
3264 void control_notify_paste_buffer_changed(const char *);
3265 void control_notify_paste_buffer_deleted(const char *);
3267 /* session.c */
3268 extern struct sessions sessions;
3269 extern u_int next_session_id;
3270 int session_cmp(struct session *, struct session *);
3271 RB_PROTOTYPE(sessions, session, entry, session_cmp);
3272 int session_alive(struct session *);
3273 struct session *session_find(const char *);
3274 struct session *session_find_by_id_str(const char *);
3275 struct session *session_find_by_id(u_int);
3276 struct session *session_create(const char *, const char *, const char *,
3277 struct environ *, struct options *, struct termios *);
3278 void session_destroy(struct session *, int, const char *);
3279 void session_add_ref(struct session *, const char *);
3280 void session_remove_ref(struct session *, const char *);
3281 char *session_check_name(const char *);
3282 void session_update_activity(struct session *, struct timeval *);
3283 struct session *session_next_session(struct session *);
3284 struct session *session_previous_session(struct session *);
3285 struct winlink *session_attach(struct session *, struct window *, int,
3286 char **);
3287 int session_detach(struct session *, struct winlink *);
3288 int session_has(struct session *, struct window *);
3289 int session_is_linked(struct session *, struct window *);
3290 int session_next(struct session *, int);
3291 int session_previous(struct session *, int);
3292 int session_select(struct session *, int);
3293 int session_last(struct session *);
3294 int session_set_current(struct session *, struct winlink *);
3295 struct session_group *session_group_contains(struct session *);
3296 struct session_group *session_group_find(const char *);
3297 struct session_group *session_group_new(const char *);
3298 void session_group_add(struct session_group *, struct session *);
3299 void session_group_synchronize_to(struct session *);
3300 void session_group_synchronize_from(struct session *);
3301 u_int session_group_count(struct session_group *);
3302 u_int session_group_attached_count(struct session_group *);
3303 void session_renumber_windows(struct session *);
3305 /* utf8.c */
3306 enum utf8_state utf8_towc (const struct utf8_data *, wchar_t *);
3307 enum utf8_state utf8_fromwc(wchar_t wc, struct utf8_data *);
3308 int utf8_in_table(wchar_t, const wchar_t *, u_int);
3309 utf8_char utf8_build_one(u_char);
3310 enum utf8_state utf8_from_data(const struct utf8_data *, utf8_char *);
3311 void utf8_to_data(utf8_char, struct utf8_data *);
3312 void utf8_set(struct utf8_data *, u_char);
3313 void utf8_copy(struct utf8_data *, const struct utf8_data *);
3314 enum utf8_state utf8_open(struct utf8_data *, u_char);
3315 enum utf8_state utf8_append(struct utf8_data *, u_char);
3316 int utf8_isvalid(const char *);
3317 int utf8_strvis(char *, const char *, size_t, int);
3318 int utf8_stravis(char **, const char *, int);
3319 int utf8_stravisx(char **, const char *, size_t, int);
3320 char *utf8_sanitize(const char *);
3321 size_t utf8_strlen(const struct utf8_data *);
3322 u_int utf8_strwidth(const struct utf8_data *, ssize_t);
3323 struct utf8_data *utf8_fromcstr(const char *);
3324 char *utf8_tocstr(struct utf8_data *);
3325 u_int utf8_cstrwidth(const char *);
3326 char *utf8_padcstr(const char *, u_int);
3327 char *utf8_rpadcstr(const char *, u_int);
3328 int utf8_cstrhas(const char *, const struct utf8_data *);
3330 /* utf8-combined.c */
3331 int utf8_has_zwj(const struct utf8_data *);
3332 int utf8_is_zwj(const struct utf8_data *);
3333 int utf8_is_vs(const struct utf8_data *);
3334 int utf8_is_modifier(const struct utf8_data *);
3336 /* procname.c */
3337 char *get_proc_name(int, char *);
3338 char *get_proc_cwd(int);
3340 /* log.c */
3341 void log_add_level(void);
3342 int log_get_level(void);
3343 void log_open(const char *);
3344 void log_toggle(const char *);
3345 void log_close(void);
3346 void printflike(1, 2) log_debug(const char *, ...);
3347 __dead void printflike(1, 2) fatal(const char *, ...);
3348 __dead void printflike(1, 2) fatalx(const char *, ...);
3350 /* menu.c */
3351 #define MENU_NOMOUSE 0x1
3352 #define MENU_TAB 0x2
3353 #define MENU_STAYOPEN 0x4
3354 struct menu *menu_create(const char *);
3355 void menu_add_items(struct menu *, const struct menu_item *,
3356 struct cmdq_item *, struct client *,
3357 struct cmd_find_state *);
3358 void menu_add_item(struct menu *, const struct menu_item *,
3359 struct cmdq_item *, struct client *,
3360 struct cmd_find_state *);
3361 void menu_free(struct menu *);
3362 struct menu_data *menu_prepare(struct menu *, int, int, struct cmdq_item *,
3363 u_int, u_int, struct client *, enum box_lines, const char *,
3364 const char *, const char *, struct cmd_find_state *,
3365 menu_choice_cb, void *);
3366 int menu_display(struct menu *, int, int, struct cmdq_item *,
3367 u_int, u_int, struct client *, enum box_lines, const char *,
3368 const char *, const char *, struct cmd_find_state *,
3369 menu_choice_cb, void *);
3370 struct screen *menu_mode_cb(struct client *, void *, u_int *, u_int *);
3371 void menu_check_cb(struct client *, void *, u_int, u_int, u_int,
3372 struct overlay_ranges *);
3373 void menu_draw_cb(struct client *, void *,
3374 struct screen_redraw_ctx *);
3375 void menu_free_cb(struct client *, void *);
3376 int menu_key_cb(struct client *, void *, struct key_event *);
3378 /* popup.c */
3379 #define POPUP_CLOSEEXIT 0x1
3380 #define POPUP_CLOSEEXITZERO 0x2
3381 #define POPUP_INTERNAL 0x4
3382 typedef void (*popup_close_cb)(int, void *);
3383 typedef void (*popup_finish_edit_cb)(char *, size_t, void *);
3384 int popup_display(int, enum box_lines, struct cmdq_item *, u_int,
3385 u_int, u_int, u_int, struct environ *, const char *, int,
3386 char **, const char *, const char *, struct client *,
3387 struct session *, const char *, const char *,
3388 popup_close_cb, void *);
3389 int popup_editor(struct client *, const char *, size_t,
3390 popup_finish_edit_cb, void *);
3392 /* style.c */
3393 int style_parse(struct style *,const struct grid_cell *,
3394 const char *);
3395 const char *style_tostring(struct style *);
3396 void style_add(struct grid_cell *, struct options *,
3397 const char *, struct format_tree *);
3398 void style_apply(struct grid_cell *, struct options *,
3399 const char *, struct format_tree *);
3400 void style_set(struct style *, const struct grid_cell *);
3401 void style_copy(struct style *, struct style *);
3403 /* spawn.c */
3404 struct winlink *spawn_window(struct spawn_context *, char **);
3405 struct window_pane *spawn_pane(struct spawn_context *, char **);
3407 /* regsub.c */
3408 char *regsub(const char *, const char *, const char *, int);
3410 /* server-acl.c */
3411 void server_acl_init(void);
3412 struct server_acl_user *server_acl_user_find(uid_t);
3413 void server_acl_display(struct cmdq_item *);
3414 void server_acl_user_allow(uid_t);
3415 void server_acl_user_deny(uid_t);
3416 void server_acl_user_allow_write(uid_t);
3417 void server_acl_user_deny_write(uid_t);
3418 int server_acl_join(struct client *);
3419 uid_t server_acl_get_uid(struct server_acl_user *);
3421 /* hyperlink.c */
3422 u_int hyperlinks_put(struct hyperlinks *, const char *,
3423 const char *);
3424 int hyperlinks_get(struct hyperlinks *, u_int,
3425 const char **, const char **, const char **);
3426 struct hyperlinks *hyperlinks_init(void);
3427 void hyperlinks_reset(struct hyperlinks *);
3428 void hyperlinks_free(struct hyperlinks *);
3430 #endif /* TMUX_H */