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