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