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