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