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