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