Coverage Report

Created: 2026-10-17 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tmux/tmux.h
Line
Count
Source
1
/* $OpenBSD: tmux.h,v 1.1466 2026/10/16 16:51:19 nicm Exp $ */
2
3
/*
4
 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
5
 *
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.
9
 *
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.
17
 */
18
19
#ifndef TMUX_H
20
#define TMUX_H
21
22
#include <sys/types.h>
23
#include <sys/time.h>
24
#include <sys/uio.h>
25
26
#include <limits.h>
27
#include <stdarg.h>
28
#include <stddef.h>
29
#include <stdio.h>
30
#include <termios.h>
31
#include <wchar.h>
32
33
#ifdef HAVE_UTEMPTER
34
#include <utempter.h>
35
#endif
36
37
#include "compat.h"
38
#include "tmux-image.h"
39
#include "tmux-protocol.h"
40
#include "xmalloc.h"
41
42
extern char   **environ;
43
44
struct args;
45
struct args_command_state;
46
struct client;
47
struct cmd;
48
struct cmd_find_state;
49
struct cmdq_item;
50
struct cmdq_list;
51
struct cmdq_state;
52
struct cmds;
53
struct control_state;
54
struct environ;
55
struct event_payload;
56
struct event_payload_item;
57
struct events_sink;
58
struct format_job_tree;
59
struct format_tree;
60
struct hyperlinks_uri;
61
struct hyperlinks;
62
struct input_ctx;
63
struct input_request;
64
struct input_requests;
65
struct job;
66
struct json_node;
67
struct menu_data;
68
struct mode_tree_data;
69
struct mouse_event;
70
struct options;
71
struct options_array_item;
72
struct options_entry;
73
struct prompt;
74
struct window_pane_prompt;
75
struct redraw_damage;
76
struct redraw_scene;
77
struct redraw_span;
78
struct screen_write_citem;
79
struct screen_write_cline;
80
struct screen_write_ctx;
81
struct session;
82
83
struct tty_ctx;
84
struct tty_code;
85
struct tty_key;
86
struct tmuxpeer;
87
struct tmuxproc;
88
struct winlink;
89
90
/* Default configuration files and socket paths. */
91
#ifndef TMUX_CONF
92
#define TMUX_CONF "/etc/tmux.conf:~/.tmux.conf"
93
#endif
94
#ifndef TMUX_SOCK
95
0
#define TMUX_SOCK "$TMUX_TMPDIR:" _PATH_TMP
96
#endif
97
#ifndef TMUX_SOCK_PERM
98
0
#define TMUX_SOCK_PERM (7 /* o+rwx */)
99
#endif
100
#ifndef TMUX_TERM
101
#define TMUX_TERM "screen"
102
#endif
103
#ifndef TMUX_LOCK_CMD
104
#define TMUX_LOCK_CMD "lock -np"
105
#endif
106
#ifndef TMUX_MOUSE
107
#define TMUX_MOUSE 0
108
#endif
109
110
/* Minimum and maximum layout cell size, NOT including border lines. */
111
0
#define PANE_MINIMUM 1
112
0
#define PANE_MAXIMUM 10000
113
114
/* Minimum and maximum window size. */
115
0
#define WINDOW_MINIMUM PANE_MINIMUM
116
0
#define WINDOW_MAXIMUM 10000
117
118
/* Automatic name refresh interval, in microseconds. Must be < 1 second. */
119
0
#define NAME_INTERVAL 500000
120
121
/* Default pixel cell sizes. */
122
0
#define DEFAULT_XPIXEL 16
123
0
#define DEFAULT_YPIXEL 32
124
125
/* Attribute to make GCC check printf-like arguments. */
126
#define printflike(a, b) __attribute__ ((format (printf, a, b)))
127
128
/* Number of items in array. */
129
#ifndef nitems
130
34.4M
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
131
#endif
132
133
/* Alert option values. */
134
#define ALERT_NONE 0
135
0
#define ALERT_ANY 1
136
0
#define ALERT_CURRENT 2
137
0
#define ALERT_OTHER 3
138
139
/* Visual option values. */
140
0
#define VISUAL_OFF 0
141
#define VISUAL_ON 1
142
0
#define VISUAL_BOTH 2
143
144
/* Key modifier bits. */
145
24.4k
#define KEYC_META            0x00100000000000ULL
146
24.4k
#define KEYC_CTRL            0x00200000000000ULL
147
24.4k
#define KEYC_SHIFT           0x00400000000000ULL
148
149
/* Key flag bits. */
150
24.4k
#define KEYC_LITERAL       0x01000000000000ULL
151
0
#define KEYC_KEYPAD      0x02000000000000ULL
152
0
#define KEYC_CURSOR      0x04000000000000ULL
153
0
#define KEYC_IMPLIED_META    0x08000000000000ULL
154
0
#define KEYC_BUILD_MODIFIERS 0x10000000000000ULL
155
0
#define KEYC_VI        0x20000000000000ULL
156
0
#define KEYC_SENT      0x40000000000000ULL
157
158
/* Masks for key bits. */
159
33.4k
#define KEYC_MASK_TYPE       0x0000ff00000000ULL
160
0
#define KEYC_MASK_MODIFIERS  0x00ff0000000000ULL
161
0
#define KEYC_MASK_FLAGS      0xff000000000000ULL
162
24.2M
#define KEYC_MASK_KEY        0x0000ffffffffffULL
163
164
0
#define KEYC_NUSER           1000
165
50.2k
#define KEYC_SHIFT_TYPE(t)   ((unsigned long long)(t) << 32)
166
0
#define KEYC_IS_TYPE(k, t)   (((k) & KEYC_MASK_TYPE) == KEYC_SHIFT_TYPE(t))
167
enum key_code_type {
168
  KEYC_TYPE_UNICODE,
169
  KEYC_TYPE_USER,
170
  KEYC_TYPE_FUNCTION,
171
  KEYC_TYPE_MOUSEMOVE,
172
  KEYC_TYPE_MOUSEDOWN,
173
  KEYC_TYPE_MOUSEUP,
174
  KEYC_TYPE_MOUSEDRAG,
175
  KEYC_TYPE_MOUSEDRAGEND,
176
  KEYC_TYPE_WHEELDOWN,
177
  KEYC_TYPE_WHEELUP,
178
  KEYC_TYPE_SECONDCLICK,
179
  KEYC_TYPE_DOUBLECLICK,
180
  KEYC_TYPE_TRIPLECLICK,
181
  KEYC_TYPE_NOTYPE /* end */
182
};
183
184
enum key_code_mouse_location {
185
  KEYC_MOUSE_LOCATION_PANE,
186
  KEYC_MOUSE_LOCATION_STATUS,
187
  KEYC_MOUSE_LOCATION_STATUS_LEFT,
188
  KEYC_MOUSE_LOCATION_STATUS_RIGHT,
189
  KEYC_MOUSE_LOCATION_STATUS_DEFAULT,
190
  KEYC_MOUSE_LOCATION_STATUS_BORDER,
191
  KEYC_MOUSE_LOCATION_BORDER,
192
  KEYC_MOUSE_LOCATION_SCROLLBAR_UP,
193
  KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER,
194
  KEYC_MOUSE_LOCATION_SCROLLBAR_DOWN,
195
  KEYC_MOUSE_LOCATION_EMPTY,
196
  KEYC_MOUSE_LOCATION_CONTROL0, /* keep order */
197
  KEYC_MOUSE_LOCATION_CONTROL1,
198
  KEYC_MOUSE_LOCATION_CONTROL2,
199
  KEYC_MOUSE_LOCATION_CONTROL3,
200
  KEYC_MOUSE_LOCATION_CONTROL4,
201
  KEYC_MOUSE_LOCATION_CONTROL5,
202
  KEYC_MOUSE_LOCATION_CONTROL6,
203
  KEYC_MOUSE_LOCATION_CONTROL7,
204
  KEYC_MOUSE_LOCATION_CONTROL8,
205
  KEYC_MOUSE_LOCATION_CONTROL9,
206
  KEYC_MOUSE_LOCATION_NOWHERE /* end */
207
};
208
209
/* Is this a Unicode key? */
210
#define KEYC_IS_UNICODE(key) \
211
16.7k
  (((key) & KEYC_MASK_TYPE) == KEYC_SHIFT_TYPE(KEYC_TYPE_UNICODE) && \
212
16.7k
   ((key) & KEYC_MASK_KEY) > 0x7f)
213
214
/* Is this a user key? */
215
#define KEYC_IS_USER(key) \
216
16.7k
  (((key) & KEYC_MASK_TYPE) == KEYC_SHIFT_TYPE(KEYC_TYPE_USER))
217
218
/* Is this a function key? */
219
#define KEYC_IS_SPECIAL(key) \
220
0
  (((key) & KEYC_MASK_TYPE) == KEYC_SHIFT_TYPE(KEYC_TYPE_FUNCTION))
221
222
/* Is this a mouse key? */
223
#define KEYC_IS_MOUSE(key) \
224
0
  (((key) & KEYC_MASK_KEY) == KEYC_MOUSE || \
225
0
   (((key) & KEYC_MASK_TYPE) >= KEYC_SHIFT_TYPE(KEYC_TYPE_MOUSEMOVE) && \
226
0
    ((key) & KEYC_MASK_TYPE) <= KEYC_SHIFT_TYPE(KEYC_TYPE_TRIPLECLICK)))
227
228
/* Is this a paste key? */
229
#define KEYC_IS_PASTE(key) \
230
0
  (((key) & KEYC_MASK_TYPE) == KEYC_SHIFT_TYPE(KEYC_TYPE_FUNCTION) && \
231
0
   (((key) & KEYC_MASK_KEY) == KEYC_PASTE_START || \
232
0
   ((key) & KEYC_MASK_KEY) == KEYC_PASTE_END))
233
234
/* Multiple click timeout. */
235
0
#define KEYC_CLICK_TIMEOUT 300
236
237
/* Bit shift for mouse events. */
238
0
#define KEYC_MOUSE_LOCATION_SHIFT  0
239
0
#define KEYC_MOUSE_BUTTON_SHIFT 8
240
241
/* Mouse key codes. */
242
#define KEYC_MOUSE_KEYS(t)                                             \
243
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, PANE),             \
244
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, STATUS),           \
245
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, STATUS_LEFT),      \
246
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, STATUS_RIGHT),     \
247
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, STATUS_DEFAULT),   \
248
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, STATUS_BORDER),    \
249
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, BORDER),           \
250
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_UP),     \
251
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_SLIDER), \
252
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_DOWN),   \
253
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, EMPTY),            \
254
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL0),         \
255
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL1),         \
256
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL2),         \
257
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL3),         \
258
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL4),         \
259
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL5),         \
260
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL6),         \
261
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL7),         \
262
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL8),         \
263
  KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL9)
264
#define KEYC_MOUSE_KEY(p, t, l)                                                \
265
  p ## _ ## l = KEYC_MAKE_MOUSE_KEY(t, 0, KEYC_MOUSE_LOCATION_ ## l),    \
266
  p ## 1_ ## l = KEYC_MAKE_MOUSE_KEY(t, 1, KEYC_MOUSE_LOCATION_ ## l),   \
267
  p ## 2_ ## l = KEYC_MAKE_MOUSE_KEY(t, 2, KEYC_MOUSE_LOCATION_ ## l),   \
268
  p ## 3_ ## l = KEYC_MAKE_MOUSE_KEY(t, 3, KEYC_MOUSE_LOCATION_ ## l),   \
269
  p ## 6_ ## l = KEYC_MAKE_MOUSE_KEY(t, 6, KEYC_MOUSE_LOCATION_ ## l),   \
270
  p ## 7_ ## l = KEYC_MAKE_MOUSE_KEY(t, 7, KEYC_MOUSE_LOCATION_ ## l),   \
271
  p ## 8_ ## l = KEYC_MAKE_MOUSE_KEY(t, 8, KEYC_MOUSE_LOCATION_ ## l),   \
272
  p ## 9_ ## l = KEYC_MAKE_MOUSE_KEY(t, 9, KEYC_MOUSE_LOCATION_ ## l),   \
273
  p ## 10_ ## l = KEYC_MAKE_MOUSE_KEY(t, 10, KEYC_MOUSE_LOCATION_ ## l), \
274
  p ## 11_ ## l = KEYC_MAKE_MOUSE_KEY(t, 11, KEYC_MOUSE_LOCATION_ ## l)
275
#define KEYC_MAKE_MOUSE_KEY(t, b, l)                            \
276
0
  ((KEYC_SHIFT_TYPE(t)) |                                 \
277
0
   ((unsigned long long)(b) << KEYC_MOUSE_BUTTON_SHIFT) | \
278
0
         ((unsigned long long)(l) << KEYC_MOUSE_LOCATION_SHIFT))
279
#define KEYC_MOUSE_STRING(name, s)              \
280
  { #s "Pane", KEYC_ ## name ## _PANE },            \
281
  { #s "Status", KEYC_ ## name ## _STATUS },          \
282
  { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT },       \
283
  { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT },       \
284
  { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT },     \
285
  { #s "StatusBorder", KEYC_ ## name ## _STATUS_BORDER },       \
286
  { #s "ScrollbarUp", KEYC_ ## name ## _SCROLLBAR_UP },         \
287
  { #s "ScrollbarSlider", KEYC_ ## name ## _SCROLLBAR_SLIDER }, \
288
  { #s "ScrollbarDown", KEYC_ ## name ## _SCROLLBAR_DOWN },     \
289
  { #s "Empty", KEYC_ ## name ## _EMPTY },          \
290
  { #s "Border", KEYC_ ## name ## _BORDER },          \
291
  { #s "Control0", KEYC_ ## name ## _CONTROL0 },          \
292
  { #s "Control1", KEYC_ ## name ## _CONTROL1 },          \
293
  { #s "Control2", KEYC_ ## name ## _CONTROL2 },          \
294
  { #s "Control3", KEYC_ ## name ## _CONTROL3 },          \
295
  { #s "Control4", KEYC_ ## name ## _CONTROL4 },          \
296
  { #s "Control5", KEYC_ ## name ## _CONTROL5 },          \
297
  { #s "Control6", KEYC_ ## name ## _CONTROL6 },          \
298
  { #s "Control7", KEYC_ ## name ## _CONTROL7 },          \
299
  { #s "Control8", KEYC_ ## name ## _CONTROL8 },          \
300
  { #s "Control9", KEYC_ ## name ## _CONTROL9 }
301
302
/*
303
 * A single key. This can be ASCII or Unicode or one of the keys between
304
 * KEYC_BASE and KEYC_BASE_END.
305
 */
306
typedef unsigned long long key_code;
307
308
/* C0 control characters */
309
enum {
310
  C0_NUL,
311
  C0_SOH,
312
  C0_STX,
313
  C0_ETX,
314
  C0_EOT,
315
  C0_ENQ,
316
  C0_ASC,
317
  C0_BEL,
318
  C0_BS,
319
  C0_HT,
320
  C0_LF,
321
  C0_VT,
322
  C0_FF,
323
  C0_CR,
324
  C0_SO,
325
  C0_SI,
326
  C0_DLE,
327
  C0_DC1,
328
  C0_DC2,
329
  C0_DC3,
330
  C0_DC4,
331
  C0_NAK,
332
  C0_SYN,
333
  C0_ETB,
334
  C0_CAN,
335
  C0_EM,
336
  C0_SUB,
337
  C0_ESC,
338
  C0_FS,
339
  C0_GS,
340
  C0_RS,
341
  C0_US
342
};
343
344
/* Special key codes. */
345
enum {
346
  /* User key code range. */
347
  KEYC_USER = KEYC_SHIFT_TYPE(KEYC_TYPE_USER),
348
349
  /* Functional key code range. */
350
  KEYC_NONE = KEYC_SHIFT_TYPE(KEYC_TYPE_FUNCTION),
351
  KEYC_UNKNOWN,
352
353
  /* Focus events. */
354
  KEYC_FOCUS_IN,
355
  KEYC_FOCUS_OUT,
356
357
  /* "Any" key, used if not found in key table. */
358
  KEYC_ANY,
359
360
  /* Paste brackets. */
361
  KEYC_PASTE_START,
362
  KEYC_PASTE_END,
363
364
  /* Backspace key. */
365
  KEYC_BSPACE,
366
367
  /* Function keys. */
368
  KEYC_F1,
369
  KEYC_F2,
370
  KEYC_F3,
371
  KEYC_F4,
372
  KEYC_F5,
373
  KEYC_F6,
374
  KEYC_F7,
375
  KEYC_F8,
376
  KEYC_F9,
377
  KEYC_F10,
378
  KEYC_F11,
379
  KEYC_F12,
380
  KEYC_IC,
381
  KEYC_DC,
382
  KEYC_HOME,
383
  KEYC_END,
384
  KEYC_NPAGE,
385
  KEYC_PPAGE,
386
  KEYC_BTAB,
387
388
  /* Arrow keys. */
389
  KEYC_UP,
390
  KEYC_DOWN,
391
  KEYC_LEFT,
392
  KEYC_RIGHT,
393
394
  /* Numeric keypad. */
395
  KEYC_KP_SLASH,
396
  KEYC_KP_STAR,
397
  KEYC_KP_MINUS,
398
  KEYC_KP_SEVEN,
399
  KEYC_KP_EIGHT,
400
  KEYC_KP_NINE,
401
  KEYC_KP_PLUS,
402
  KEYC_KP_FOUR,
403
  KEYC_KP_FIVE,
404
  KEYC_KP_SIX,
405
  KEYC_KP_ONE,
406
  KEYC_KP_TWO,
407
  KEYC_KP_THREE,
408
  KEYC_KP_ENTER,
409
  KEYC_KP_ZERO,
410
  KEYC_KP_PERIOD,
411
412
  /* Theme reporting. */
413
  KEYC_REPORT_DARK_THEME,
414
  KEYC_REPORT_LIGHT_THEME,
415
416
  /* Terminal replies, handled in tty-keys.c and never fired. */
417
  KEYC_REPORT_CLIPBOARD,
418
  KEYC_REPORT_SYNC,
419
  KEYC_REPORT_KITTY_GRAPHICS,
420
  KEYC_REPORT_DA,
421
  KEYC_REPORT_DA2,
422
  KEYC_REPORT_XDA,
423
  KEYC_REPORT_COLOURS,
424
  KEYC_REPORT_PALETTE,
425
  KEYC_REPORT_WINSZ,
426
427
  /* Mouse state. */
428
  KEYC_MOUSE, /* unclassified mouse event */
429
  KEYC_DRAGGING, /* dragging in progress */
430
  KEYC_DOUBLECLICK, /* double click complete */
431
432
  /* Mouse key code ranges. Must be at the end. */
433
  KEYC_MOUSE_KEYS(MOUSEMOVE),
434
  KEYC_MOUSE_KEYS(WHEELDOWN),
435
  KEYC_MOUSE_KEYS(WHEELUP),
436
  KEYC_MOUSE_KEYS(MOUSEDOWN),
437
  KEYC_MOUSE_KEYS(MOUSEUP),
438
  KEYC_MOUSE_KEYS(MOUSEDRAG),
439
  KEYC_MOUSE_KEYS(MOUSEDRAGEND),
440
  KEYC_MOUSE_KEYS(SECONDCLICK),
441
  KEYC_MOUSE_KEYS(DOUBLECLICK),
442
  KEYC_MOUSE_KEYS(TRIPLECLICK),
443
};
444
445
/* Termcap codes. */
446
enum tty_code_code {
447
  TTYC_ACSC,
448
  TTYC_AM,
449
  TTYC_AX,
450
  TTYC_BCE,
451
  TTYC_BEL,
452
  TTYC_BIDI,
453
  TTYC_BLINK,
454
  TTYC_BOLD,
455
  TTYC_CIVIS,
456
  TTYC_CLEAR,
457
  TTYC_CLMG,
458
  TTYC_CMG,
459
  TTYC_CNORM,
460
  TTYC_COLORS,
461
  TTYC_CR,
462
  TTYC_CS,
463
  TTYC_CSR,
464
  TTYC_CUB,
465
  TTYC_CUB1,
466
  TTYC_CUD,
467
  TTYC_CUD1,
468
  TTYC_CUF,
469
  TTYC_CUF1,
470
  TTYC_CUP,
471
  TTYC_CUU,
472
  TTYC_CUU1,
473
  TTYC_CVVIS,
474
  TTYC_DCH,
475
  TTYC_DCH1,
476
  TTYC_DIM,
477
  TTYC_DL,
478
  TTYC_DL1,
479
  TTYC_DSBP,
480
  TTYC_DSEKS,
481
  TTYC_DSESC,
482
  TTYC_DSFCS,
483
  TTYC_DSMG,
484
  TTYC_E3,
485
  TTYC_ECH,
486
  TTYC_ED,
487
  TTYC_EL,
488
  TTYC_EL1,
489
  TTYC_ENACS,
490
  TTYC_ENBP,
491
  TTYC_ENEKS,
492
  TTYC_ENESC,
493
  TTYC_ENFCS,
494
  TTYC_ENMG,
495
  TTYC_FSL,
496
  TTYC_HLS,
497
  TTYC_HOME,
498
  TTYC_HPA,
499
  TTYC_ICH,
500
  TTYC_ICH1,
501
  TTYC_IL,
502
  TTYC_IL1,
503
  TTYC_IND,
504
  TTYC_INDN,
505
  TTYC_INVIS,
506
  TTYC_ISCRL,
507
  TTYC_KCBT,
508
  TTYC_KCUB1,
509
  TTYC_KCUD1,
510
  TTYC_KCUF1,
511
  TTYC_KCUU1,
512
  TTYC_KDC2,
513
  TTYC_KDC3,
514
  TTYC_KDC4,
515
  TTYC_KDC5,
516
  TTYC_KDC6,
517
  TTYC_KDC7,
518
  TTYC_KDCH1,
519
  TTYC_KDN2,
520
  TTYC_KDN3,
521
  TTYC_KDN4,
522
  TTYC_KDN5,
523
  TTYC_KDN6,
524
  TTYC_KDN7,
525
  TTYC_KEND,
526
  TTYC_KEND2,
527
  TTYC_KEND3,
528
  TTYC_KEND4,
529
  TTYC_KEND5,
530
  TTYC_KEND6,
531
  TTYC_KEND7,
532
  TTYC_KF1,
533
  TTYC_KF10,
534
  TTYC_KF11,
535
  TTYC_KF12,
536
  TTYC_KF13,
537
  TTYC_KF14,
538
  TTYC_KF15,
539
  TTYC_KF16,
540
  TTYC_KF17,
541
  TTYC_KF18,
542
  TTYC_KF19,
543
  TTYC_KF2,
544
  TTYC_KF20,
545
  TTYC_KF21,
546
  TTYC_KF22,
547
  TTYC_KF23,
548
  TTYC_KF24,
549
  TTYC_KF25,
550
  TTYC_KF26,
551
  TTYC_KF27,
552
  TTYC_KF28,
553
  TTYC_KF29,
554
  TTYC_KF3,
555
  TTYC_KF30,
556
  TTYC_KF31,
557
  TTYC_KF32,
558
  TTYC_KF33,
559
  TTYC_KF34,
560
  TTYC_KF35,
561
  TTYC_KF36,
562
  TTYC_KF37,
563
  TTYC_KF38,
564
  TTYC_KF39,
565
  TTYC_KF4,
566
  TTYC_KF40,
567
  TTYC_KF41,
568
  TTYC_KF42,
569
  TTYC_KF43,
570
  TTYC_KF44,
571
  TTYC_KF45,
572
  TTYC_KF46,
573
  TTYC_KF47,
574
  TTYC_KF48,
575
  TTYC_KF49,
576
  TTYC_KF5,
577
  TTYC_KF50,
578
  TTYC_KF51,
579
  TTYC_KF52,
580
  TTYC_KF53,
581
  TTYC_KF54,
582
  TTYC_KF55,
583
  TTYC_KF56,
584
  TTYC_KF57,
585
  TTYC_KF58,
586
  TTYC_KF59,
587
  TTYC_KF6,
588
  TTYC_KF60,
589
  TTYC_KF61,
590
  TTYC_KF62,
591
  TTYC_KF63,
592
  TTYC_KF7,
593
  TTYC_KF8,
594
  TTYC_KF9,
595
  TTYC_KHOM2,
596
  TTYC_KHOM3,
597
  TTYC_KHOM4,
598
  TTYC_KHOM5,
599
  TTYC_KHOM6,
600
  TTYC_KHOM7,
601
  TTYC_KHOME,
602
  TTYC_KIC2,
603
  TTYC_KIC3,
604
  TTYC_KIC4,
605
  TTYC_KIC5,
606
  TTYC_KIC6,
607
  TTYC_KIC7,
608
  TTYC_KICH1,
609
  TTYC_KIND,
610
  TTYC_KLFT2,
611
  TTYC_KLFT3,
612
  TTYC_KLFT4,
613
  TTYC_KLFT5,
614
  TTYC_KLFT6,
615
  TTYC_KLFT7,
616
  TTYC_KMOUS,
617
  TTYC_KNP,
618
  TTYC_KNXT2,
619
  TTYC_KNXT3,
620
  TTYC_KNXT4,
621
  TTYC_KNXT5,
622
  TTYC_KNXT6,
623
  TTYC_KNXT7,
624
  TTYC_KPP,
625
  TTYC_KPRV2,
626
  TTYC_KPRV3,
627
  TTYC_KPRV4,
628
  TTYC_KPRV5,
629
  TTYC_KPRV6,
630
  TTYC_KPRV7,
631
  TTYC_KRI,
632
  TTYC_KRIT2,
633
  TTYC_KRIT3,
634
  TTYC_KRIT4,
635
  TTYC_KRIT5,
636
  TTYC_KRIT6,
637
  TTYC_KRIT7,
638
  TTYC_KUP2,
639
  TTYC_KUP3,
640
  TTYC_KUP4,
641
  TTYC_KUP5,
642
  TTYC_KUP6,
643
  TTYC_KUP7,
644
  TTYC_MS,
645
  TTYC_NCV,
646
  TTYC_NOBR,
647
  TTYC_OL,
648
  TTYC_OP,
649
  TTYC_RECT,
650
  TTYC_REV,
651
  TTYC_RGB,
652
  TTYC_RI,
653
  TTYC_RIN,
654
  TTYC_RMACS,
655
  TTYC_RMCUP,
656
  TTYC_RMKX,
657
  TTYC_SE,
658
  TTYC_SETAB,
659
  TTYC_SETAF,
660
  TTYC_SETAL,
661
  TTYC_SETRGBB,
662
  TTYC_SETRGBF,
663
  TTYC_SETULC,
664
  TTYC_SETULC1,
665
  TTYC_SGR0,
666
  TTYC_SITM,
667
  TTYC_SMACS,
668
  TTYC_SMCUP,
669
  TTYC_SMKX,
670
  TTYC_SMOL,
671
  TTYC_SMSO,
672
  TTYC_SMUL,
673
  TTYC_SMULX,
674
  TTYC_SMXX,
675
  TTYC_SPB,
676
  TTYC_SXL,
677
  TTYC_SS,
678
  TTYC_SWD,
679
  TTYC_SYNC,
680
  TTYC_TC,
681
  TTYC_TSL,
682
  TTYC_U8,
683
  TTYC_VPA,
684
  TTYC_XT
685
};
686
687
/* Character classes. */
688
0
#define WHITESPACE "\t "
689
690
/* Mode keys. */
691
0
#define MODEKEY_EMACS 0
692
0
#define MODEKEY_VI 1
693
694
/* Modes. */
695
221
#define MODE_CURSOR 0x1
696
0
#define MODE_INSERT 0x2
697
221
#define MODE_KCURSOR 0x4
698
0
#define MODE_KKEYPAD 0x8
699
221
#define MODE_WRAP 0x10
700
221
#define MODE_MOUSE_STANDARD 0x20
701
221
#define MODE_MOUSE_BUTTON 0x40
702
221
#define MODE_CURSOR_BLINKING 0x80
703
221
#define MODE_MOUSE_UTF8 0x100
704
221
#define MODE_MOUSE_SGR 0x200
705
221
#define MODE_BRACKETPASTE 0x400
706
221
#define MODE_FOCUSON 0x800
707
221
#define MODE_MOUSE_ALL 0x1000
708
221
#define MODE_ORIGIN 0x2000
709
0
#define MODE_CRLF 0x4000
710
0
#define MODE_KEYS_EXTENDED 0x8000
711
0
#define MODE_CURSOR_VERY_VISIBLE 0x10000
712
0
#define MODE_CURSOR_BLINKING_SET 0x20000
713
0
#define MODE_KEYS_EXTENDED_2 0x40000
714
221
#define MODE_THEME_UPDATES 0x80000
715
221
#define MODE_SYNC 0x100000
716
717
0
#define ALL_MODES 0xffffff
718
0
#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
719
0
#define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
720
0
#define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
721
0
#define EXTENDED_KEY_MODES (MODE_KEYS_EXTENDED|MODE_KEYS_EXTENDED_2)
722
723
/* Mouse protocol constants. */
724
0
#define MOUSE_PARAM_MAX 0xff
725
0
#define MOUSE_PARAM_UTF8_MAX 0x7ff
726
0
#define MOUSE_PARAM_BTN_OFF 0x20
727
0
#define MOUSE_PARAM_POS_OFF 0x21
728
729
/* A single UTF-8 character. */
730
typedef u_int utf8_char;
731
732
/*
733
 * An expanded UTF-8 character. UTF8_SIZE must be big enough to hold combining
734
 * characters as well. It can't be more than 32 bytes without changes to how
735
 * characters are stored.
736
 */
737
0
#define UTF8_SIZE 32
738
struct utf8_data {
739
  u_char  data[UTF8_SIZE];
740
741
  u_char  have;
742
  u_char  size;
743
744
  u_char  width;  /* 0xff if invalid */
745
};
746
enum utf8_state {
747
  UTF8_MORE,
748
  UTF8_DONE,
749
  UTF8_ERROR
750
};
751
752
/* State for processing of Korean characters. */
753
enum hanguljamo_state {
754
  HANGULJAMO_STATE_NOT_HANGULJAMO,
755
  HANGULJAMO_STATE_CHOSEONG,
756
  HANGULJAMO_STATE_COMPOSABLE,
757
  HANGULJAMO_STATE_NOT_COMPOSABLE
758
};
759
760
/* Colour flags. */
761
46.0k
#define COLOUR_FLAG_256 0x01000000
762
73.7k
#define COLOUR_FLAG_RGB 0x02000000
763
20.3k
#define COLOUR_FLAG_THEME 0x04000000
764
765
/* Special colours. */
766
0
#define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
767
768
/* Theme colours. */
769
enum colour_theme {
770
  COLOUR_THEME_BLACK,
771
  COLOUR_THEME_WHITE,
772
  COLOUR_THEME_LIGHT_GREY,
773
  COLOUR_THEME_DARK_GREY,
774
  COLOUR_THEME_GREEN,
775
  COLOUR_THEME_YELLOW,
776
  COLOUR_THEME_RED,
777
  COLOUR_THEME_BLUE,
778
  COLOUR_THEME_CYAN,
779
  COLOUR_THEME_MAGENTA
780
};
781
0
#define COLOUR_THEME_COUNT 10
782
783
/* Replacement palette. */
784
struct colour_palette {
785
  int  fg;
786
  int  bg;
787
788
  int *palette;
789
  int *default_palette;
790
};
791
792
/* Grid attributes. Anything above 0xff is stored in an extended cell. */
793
118k
#define GRID_ATTR_BRIGHT 0x1
794
59.1k
#define GRID_ATTR_DIM 0x2
795
59.1k
#define GRID_ATTR_UNDERSCORE 0x4
796
59.1k
#define GRID_ATTR_BLINK 0x8
797
59.1k
#define GRID_ATTR_REVERSE 0x10
798
59.1k
#define GRID_ATTR_HIDDEN 0x20
799
59.1k
#define GRID_ATTR_ITALICS 0x40
800
59.1k
#define GRID_ATTR_CHARSET 0x80  /* alternative character set */
801
59.1k
#define GRID_ATTR_STRIKETHROUGH 0x100
802
59.1k
#define GRID_ATTR_UNDERSCORE_2 0x200
803
59.1k
#define GRID_ATTR_UNDERSCORE_3 0x400
804
59.1k
#define GRID_ATTR_UNDERSCORE_4 0x800
805
59.1k
#define GRID_ATTR_UNDERSCORE_5 0x1000
806
59.1k
#define GRID_ATTR_OVERLINE 0x2000
807
200
#define GRID_ATTR_NOATTR 0x4000
808
809
/* All underscore attributes. */
810
#define GRID_ATTR_ALL_UNDERSCORE \
811
0
  (GRID_ATTR_UNDERSCORE|  \
812
0
   GRID_ATTR_UNDERSCORE_2| \
813
0
   GRID_ATTR_UNDERSCORE_3| \
814
0
   GRID_ATTR_UNDERSCORE_4| \
815
0
   GRID_ATTR_UNDERSCORE_5)
816
817
/* Grid flags. */
818
0
#define GRID_FLAG_FG256 0x1
819
0
#define GRID_FLAG_BG256 0x2
820
0
#define GRID_FLAG_PADDING 0x4
821
0
#define GRID_FLAG_EXTENDED 0x8
822
0
#define GRID_FLAG_SELECTED 0x10
823
0
#define GRID_FLAG_NOPALETTE 0x20
824
0
#define GRID_FLAG_CLEARED 0x40
825
0
#define GRID_FLAG_TAB 0x80
826
827
/* Grid line flags. */
828
0
#define GRID_LINE_WRAPPED 0x1
829
0
#define GRID_LINE_EXTENDED 0x2
830
0
#define GRID_LINE_DEAD 0x4
831
0
#define GRID_LINE_START_PROMPT 0x8
832
0
#define GRID_LINE_SECOND_PROMPT 0x10
833
0
#define GRID_LINE_START_COMMAND 0x20
834
0
#define GRID_LINE_START_OUTPUT 0x40
835
0
#define GRID_LINE_END_OUTPUT 0x80
836
0
#define GRID_LINE_HYPERLINK 0x100
837
838
/* All OSC 133 flags. */
839
#define GRID_LINE_OSC133_FLAGS \
840
0
  (GRID_LINE_START_PROMPT| \
841
0
   GRID_LINE_SECOND_PROMPT| \
842
0
   GRID_LINE_START_COMMAND| \
843
0
   GRID_LINE_START_OUTPUT| \
844
0
   GRID_LINE_END_OUTPUT)
845
846
/* Grid string flags. */
847
0
#define GRID_STRING_WITH_SEQUENCES 0x1
848
0
#define GRID_STRING_ESCAPE_SEQUENCES 0x2
849
0
#define GRID_STRING_TRIM_SPACES 0x4
850
#define GRID_STRING_USED_ONLY 0x8
851
0
#define GRID_STRING_EMPTY_CELLS 0x10
852
853
/*
854
 * Cell border characters. Border cells are named for the directions they
855
 * connect to: U for up, D for down, L for left and R for right.
856
 */
857
#define CELL_INSIDE 0
858
0
#define CELL_UD 1
859
0
#define CELL_LR 2
860
0
#define CELL_RD 3
861
0
#define CELL_LD 4
862
0
#define CELL_RU 5
863
0
#define CELL_LU 6
864
0
#define CELL_LRD 7
865
0
#define CELL_LRU 8
866
0
#define CELL_URD 9
867
0
#define CELL_ULD 10
868
0
#define CELL_LRUD 11
869
0
#define CELL_NONE 12
870
#define CELL_SCROLLBAR 13
871
872
/* Cell borders. */
873
0
#define CELL_BORDERS " xqlkmjwvtun~"
874
0
#define SIMPLE_BORDERS " |-+++++++++."
875
0
#define PADDED_BORDERS "             "
876
877
/* Grid cell data. */
878
struct grid_cell {
879
  struct utf8_data  data;
880
  u_short     attr;
881
  u_char      flags;
882
  int     fg;
883
  int     bg;
884
  int     us;
885
  u_int     link;
886
};
887
888
/* Grid extended cell entry. */
889
struct grid_extd_entry {
890
  utf8_char   data;
891
  u_short     attr;
892
  u_char      flags;
893
  int     fg;
894
  int     bg;
895
  int     us;
896
  u_int     link;
897
} __packed;
898
899
/* Grid cell entry. */
900
struct grid_cell_entry {
901
  union {
902
    u_int   offset;
903
    struct {
904
      u_char  attr;
905
      u_char  fg;
906
      u_char  bg;
907
      u_char  data;
908
    } data;
909
  };
910
  u_char      flags;
911
} __packed;
912
913
/* OSC 133 data for a grid line. */
914
struct osc133_data {
915
  u_short      prompt_col;
916
  u_short      cmd_col;
917
  u_short      out_start_col;
918
  u_short      out_end_col;
919
  u_char       exit_status;
920
};
921
922
/* Grid line. */
923
struct grid_line {
924
  struct grid_cell_entry  *celldata;
925
  struct grid_extd_entry  *extddata;
926
927
  u_short      cellused;
928
  u_short      cellsize;
929
  u_int      extdsize;
930
931
  u_int      time;
932
  struct osc133_data   osc133_data;
933
  u_short      flags;
934
#ifdef ENABLE_IMAGES
935
  struct image_line *images;
936
#endif
937
};
938
939
/* Entire grid of cells. */
940
struct grid {
941
  int      flags;
942
0
#define GRID_HISTORY 0x1 /* scroll lines into history */
943
944
  u_int      sx;
945
  u_int      sy;
946
947
  u_int      hscrolled;
948
  u_int      hsize;
949
  u_int      hlimit;
950
951
  u_int      scroll_added;
952
  u_int      scroll_collected;
953
  u_int      scroll_generation;
954
955
  struct grid_line  *linedata;
956
#ifdef ENABLE_IMAGES
957
  struct image_store  *images;
958
#endif
959
};
960
961
/* Virtual cursor in a grid. */
962
struct grid_reader {
963
  struct grid *gd;
964
  u_int    cx;
965
  u_int    cy;
966
};
967
968
/* Style alignment. */
969
enum style_align {
970
  STYLE_ALIGN_DEFAULT,
971
  STYLE_ALIGN_LEFT,
972
  STYLE_ALIGN_CENTRE,
973
  STYLE_ALIGN_RIGHT,
974
  STYLE_ALIGN_ABSOLUTE_CENTRE
975
};
976
977
/* Style list. */
978
enum style_list {
979
  STYLE_LIST_OFF,
980
  STYLE_LIST_ON,
981
  STYLE_LIST_FOCUS,
982
  STYLE_LIST_LEFT_MARKER,
983
  STYLE_LIST_RIGHT_MARKER,
984
};
985
986
/* Style range. */
987
enum style_range_type {
988
  STYLE_RANGE_NONE,
989
  STYLE_RANGE_LEFT,
990
  STYLE_RANGE_RIGHT,
991
  STYLE_RANGE_PANE,
992
  STYLE_RANGE_WINDOW,
993
  STYLE_RANGE_SESSION,
994
  STYLE_RANGE_USER,
995
  STYLE_RANGE_CONTROL
996
};
997
struct style_range {
998
  enum style_range_type  type;
999
  u_int      argument;
1000
  char       string[16];
1001
1002
  u_int      start;
1003
  u_int      end; /* not included */
1004
  u_int      y; /* row for multi-row areas */
1005
1006
  TAILQ_ENTRY(style_range) entry;
1007
};
1008
TAILQ_HEAD(style_ranges, style_range);
1009
1010
/* Ranges connected with a status line. */
1011
struct style_line_entry {
1012
  char      *expanded;
1013
  struct style_ranges  ranges;
1014
};
1015
1016
/* Default style width and pad. */
1017
#define STYLE_WIDTH_DEFAULT -1
1018
#define STYLE_PAD_DEFAULT -1
1019
1020
/* Style default. */
1021
enum style_default_type {
1022
  STYLE_DEFAULT_BASE,
1023
  STYLE_DEFAULT_PUSH,
1024
  STYLE_DEFAULT_POP,
1025
  STYLE_DEFAULT_SET
1026
};
1027
1028
/* Style option. */
1029
struct style {
1030
  struct grid_cell  gc;
1031
  int     ignore;
1032
  int     dim;
1033
1034
  int     fill;
1035
  enum style_align  align;
1036
  enum style_list   list;
1037
1038
  enum style_range_type range_type;
1039
  u_int     range_argument;
1040
  char      range_string[16];
1041
1042
  int     width;
1043
  int     width_percentage;
1044
  int     pad;
1045
  int     nl;
1046
  u_int     link;
1047
1048
  enum style_default_type default_type;
1049
};
1050
1051
/* Cursor style. */
1052
enum screen_cursor_style {
1053
  SCREEN_CURSOR_DEFAULT,
1054
  SCREEN_CURSOR_BLOCK,
1055
  SCREEN_CURSOR_UNDERLINE,
1056
  SCREEN_CURSOR_BAR
1057
};
1058
1059
1060
/* Progress bar, OSC 9;4. */
1061
enum progress_bar_state {
1062
  PROGRESS_BAR_HIDDEN = 0,
1063
  PROGRESS_BAR_NORMAL = 1,
1064
  PROGRESS_BAR_ERROR = 2,
1065
  PROGRESS_BAR_INDETERMINATE = 3,
1066
  PROGRESS_BAR_PAUSED = 4
1067
};
1068
struct progress_bar {
1069
  enum progress_bar_state state;
1070
  int     progress;
1071
};
1072
1073
/* Virtual screen. */
1074
struct screen_sel;
1075
struct screen_titles;
1076
struct screen {
1077
  char        *title;
1078
  char        *path;
1079
  struct screen_titles    *titles;
1080
  u_int        ntitles;
1081
1082
  struct grid     *grid;    /* grid data */
1083
1084
  u_int        cx;    /* cursor x */
1085
  u_int        cy;    /* cursor y */
1086
1087
  enum screen_cursor_style   cstyle;  /* cursor style */
1088
  enum screen_cursor_style   default_cstyle;
1089
  int        ccolour; /* cursor colour */
1090
  int        default_ccolour;
1091
1092
  u_int        rupper;  /* scroll region top */
1093
  u_int        rlower;  /* scroll region bottom */
1094
1095
  int        mode;
1096
  int        default_mode;
1097
1098
  u_int        saved_cx;
1099
  u_int        saved_cy;
1100
  struct grid     *saved_grid;
1101
  struct grid_cell     saved_cell;
1102
  int        saved_flags;
1103
1104
  bitstr_t      *tabs;
1105
  struct screen_sel   *sel;
1106
1107
  struct screen_write_cline *write_list;
1108
1109
  struct hyperlinks   *hyperlinks;
1110
  struct progress_bar    progress_bar;
1111
};
1112
1113
/* Screen write context. */
1114
typedef void (*screen_write_init_ctx_cb)(struct screen_write_ctx *,
1115
    struct tty_ctx *);
1116
struct screen_write_ctx {
1117
  struct window_pane    *wp;
1118
  struct screen     *s;
1119
1120
  int        flags;
1121
0
#define SCREEN_WRITE_SYNC 0x1
1122
0
#define SCREEN_WRITE_OBSCURED 0x2
1123
0
#define SCREEN_WRITE_CHECKED_IF_OBSCURED 0x4
1124
0
#define SCREEN_WRITE_INPUT 0x8
1125
1126
  screen_write_init_ctx_cb   init_ctx_cb;
1127
  void        *arg;
1128
1129
  struct screen_write_citem *item;
1130
  u_int        scrolled;
1131
  u_int        bg;
1132
};
1133
1134
/* Box border lines option. */
1135
enum box_lines {
1136
  BOX_LINES_DEFAULT = -1,
1137
  BOX_LINES_SINGLE,
1138
  BOX_LINES_DOUBLE,
1139
  BOX_LINES_HEAVY,
1140
  BOX_LINES_SIMPLE,
1141
  BOX_LINES_ROUNDED,
1142
  BOX_LINES_PADDED,
1143
  BOX_LINES_NONE
1144
};
1145
1146
/* Pane border lines option. */
1147
enum pane_lines {
1148
  PANE_LINES_SINGLE,
1149
  PANE_LINES_DOUBLE,
1150
  PANE_LINES_HEAVY,
1151
  PANE_LINES_SIMPLE,
1152
  PANE_LINES_NUMBER,
1153
  PANE_LINES_SPACES,
1154
  PANE_LINES_NONE,
1155
  PANE_LINES_ROUNDED
1156
};
1157
1158
/* Pane border indicator option. */
1159
#define PANE_BORDER_OFF 0
1160
0
#define PANE_BORDER_COLOUR 1
1161
0
#define PANE_BORDER_ARROWS 2
1162
0
#define PANE_BORDER_BOTH 3
1163
1164
/* Mode returned by window_pane_mode function. */
1165
0
#define WINDOW_PANE_NO_MODE 0
1166
0
#define WINDOW_PANE_COPY_MODE 1
1167
0
#define WINDOW_PANE_VIEW_MODE 2
1168
1169
/* Screen size. */
1170
0
#define screen_size_x(s) ((s)->grid->sx)
1171
0
#define screen_size_y(s) ((s)->grid->sy)
1172
0
#define screen_hsize(s) ((s)->grid->hsize)
1173
0
#define screen_hlimit(s) ((s)->grid->hlimit)
1174
1175
/* Menu. */
1176
struct menu_item {
1177
  const char  *name;
1178
  key_code   key;
1179
  const char  *command;
1180
};
1181
struct menu {
1182
  const char    *title;
1183
  struct menu_item  *items;
1184
  u_int      count;
1185
  u_int      width;
1186
  u_int      item_width;
1187
};
1188
typedef void (*menu_choice_cb)(struct menu *, u_int, key_code, void *);
1189
1190
/*
1191
 * Window mode. Windows can be in several modes and this is used to call the
1192
 * right function to handle input and output.
1193
 */
1194
struct window_mode_entry;
1195
struct window_mode {
1196
  const char  *name;
1197
  const char  *default_format;
1198
1199
  int    flags;
1200
0
#define WINDOW_MODE_HIDE_PANE_STATUS 0x1
1201
0
#define WINDOW_MODE_NO_STACK 0x2
1202
#define WINDOW_MODE_FILL_WINDOW 0x4
1203
0
#define WINDOW_MODE_HIDE_SCROLLBARS 0x8
1204
1205
  struct screen *(*init)(struct window_mode_entry *,
1206
           struct cmdq_item *, struct cmd_find_state *,
1207
           struct args *);
1208
  void     (*free)(struct window_mode_entry *);
1209
  void     (*resize)(struct window_mode_entry *, u_int, u_int);
1210
  void     (*update)(struct window_mode_entry *);
1211
  void     (*style_changed)(struct window_mode_entry *);
1212
  void     (*key)(struct window_mode_entry *, struct client *,
1213
           struct session *, struct winlink *, key_code,
1214
           struct mouse_event *);
1215
1216
  const char  *(*key_table)(struct window_mode_entry *);
1217
  void     (*command)(struct window_mode_entry *, struct client *,
1218
           struct session *, struct winlink *, struct args *,
1219
           struct mouse_event *);
1220
  void     (*formats)(struct window_mode_entry *,
1221
           struct format_tree *);
1222
  struct screen *(*get_screen)(struct window_mode_entry *);
1223
};
1224
1225
/* Active window mode. */
1226
struct window_mode_entry {
1227
  struct window_pane    *wp;
1228
  struct window_pane    *swp;
1229
1230
  const struct window_mode  *mode;
1231
  void        *data;
1232
1233
  struct screen     *screen;
1234
  u_int        prefix;
1235
1236
  int        kill;
1237
1238
  TAILQ_ENTRY(window_mode_entry)   entry;
1239
};
1240
1241
/* Type of request to client. */
1242
enum input_request_type {
1243
  INPUT_REQUEST_PALETTE,
1244
  INPUT_REQUEST_CLIPBOARD,
1245
  INPUT_REQUEST_QUEUE
1246
};
1247
1248
/* Palette request reply data. */
1249
struct input_request_palette_data {
1250
  int idx;
1251
  int c;
1252
};
1253
1254
/* Clipboard request reply data. */
1255
struct input_request_clipboard_data {
1256
  char  *buf;
1257
  size_t   len;
1258
  char   clip;
1259
};
1260
1261
/* Request sent to client on behalf of pane. */
1262
TAILQ_HEAD(input_requests, input_request);
1263
1264
/* Offsets into pane buffer. */
1265
struct window_pane_offset {
1266
  size_t  used;
1267
};
1268
1269
/* Queued pane resize. */
1270
struct window_pane_resize {
1271
  u_int       sx;
1272
  u_int       sy;
1273
1274
  u_int       osx;
1275
  u_int       osy;
1276
1277
  TAILQ_ENTRY(window_pane_resize) entry;
1278
};
1279
TAILQ_HEAD(window_pane_resizes, window_pane_resize);
1280
1281
/*
1282
 * Client theme, this is worked out from the background colour if not reported
1283
 * by terminal.
1284
 */
1285
enum client_theme {
1286
  THEME_UNKNOWN,
1287
  THEME_LIGHT,
1288
  THEME_DARK
1289
};
1290
1291
/* Visible range array element. */
1292
struct visible_range {
1293
  u_int px; /* start */
1294
  u_int nx; /* length */
1295
};
1296
1297
/* Visible areas not obstructed. */
1298
struct visible_ranges {
1299
  struct visible_range  *ranges;  /* dynamically allocated array */
1300
  u_int      used;    /* number of entries in ranges */
1301
  u_int      size;    /* allocated capacity of ranges */
1302
};
1303
1304
/* Child window structure. */
1305
struct window_pane {
1306
  u_int    id;
1307
  int    references;
1308
  u_int    active_point;
1309
1310
  struct window *window;
1311
  struct options  *options;
1312
1313
  struct layout_cell *layout_cell;
1314
  struct layout_cell *saved_layout_cell;
1315
1316
  u_int    sx;
1317
  u_int    sy;
1318
1319
  int    xoff;
1320
  int    yoff;
1321
1322
  int    flags;
1323
0
#define PANE_REDRAW 0x1
1324
0
#define PANE_DROP 0x2
1325
0
#define PANE_FOCUSED 0x4
1326
0
#define PANE_VISITED 0x8
1327
0
#define PANE_ZOOMED 0x10
1328
0
#define PANE_NEWSTATUS 0x20
1329
0
#define PANE_INPUTOFF 0x40
1330
0
#define PANE_CHANGED 0x80
1331
0
#define PANE_EXITED 0x100
1332
0
#define PANE_STATUSREADY 0x200
1333
0
#define PANE_STATUSDRAWN 0x400
1334
0
#define PANE_EMPTY 0x800
1335
0
#define PANE_STYLECHANGED 0x1000
1336
0
#define PANE_THEMECHANGED 0x2000
1337
0
#define PANE_UNSEENCHANGES 0x4000
1338
0
#define PANE_REDRAWSCROLLBAR 0x8000
1339
0
#define PANE_DESTROYED 0x10000
1340
0
#define PANE_CMDRUNNING 0x20000
1341
0
#define PANE_ACTIVITY 0x40000
1342
0
#define PANE_CLOSEONCLICK 0x80000
1343
0
#define PANE_CAPTUREALLKEYS 0x100000
1344
0
#define PANE_FLOATOVERZOOM 0x200000
1345
0
#define PANE_CLOSEONCANCEL 0x400000
1346
#define PANE_UTMP 0x800000
1347
1348
  bitstr_t  *sync_dirty;
1349
  u_int    sync_dirty_size;
1350
  u_int    sync_scrolled;
1351
  u_int    sync_rupper;
1352
  u_int    sync_rlower;
1353
  u_int    sync_bg;
1354
1355
  u_int    sb_slider_y;
1356
  u_int    sb_slider_h;
1357
  int    sb_auto_visible;
1358
  int    sb_auto_hover;
1359
  struct event   sb_auto_timer;
1360
1361
  int    argc;
1362
  char         **argv;
1363
  char    *shell;
1364
  char    *cwd;
1365
1366
  pid_t    pid;
1367
  char     tty[TTY_NAME_MAX];
1368
  int    status;
1369
  struct timeval   dead_time;
1370
  struct cmdq_item *wait_item;
1371
  struct spawn_editor_state *editor;
1372
1373
  uint64_t   output_generation;
1374
  time_t     last_output_time;
1375
  time_t     last_prompt_time;
1376
  time_t     cmd_start_time;
1377
  time_t     cmd_end_time;
1378
  int    cmd_status;
1379
  char    *cmd_line;
1380
1381
  int    fd;
1382
  struct bufferevent *event;
1383
1384
  struct window_pane_offset offset;
1385
  size_t     base_offset;
1386
1387
  struct window_pane_resizes resize_queue;
1388
  struct event   resize_timer;
1389
  struct event   sync_timer;
1390
1391
  struct input_ctx *ictx;
1392
1393
  struct grid_cell cached_gc;
1394
  struct grid_cell cached_active_gc;
1395
  u_int    cached_dim;
1396
  u_int    cached_active_dim;
1397
  struct colour_palette palette;
1398
  enum client_theme last_theme;
1399
  struct style_line_entry border_status_line;
1400
1401
  int    pipe_fd;
1402
  pid_t    pipe_pid;
1403
  struct bufferevent *pipe_event;
1404
  struct window_pane_offset pipe_offset;
1405
1406
  struct screen *screen;
1407
  struct screen  base;
1408
1409
  struct screen  status_screen;
1410
  u_int    status_generation;
1411
1412
  TAILQ_HEAD(, window_mode_entry) modes;
1413
1414
  char    *searchstr;
1415
  int    searchregex;
1416
1417
  struct prompt *prompt;
1418
  struct window_pane_prompt *prompt_data;
1419
  u_int    prompt_cx;
1420
1421
  int    border_gc_set;
1422
  struct grid_cell border_gc;
1423
  int    active_border_gc_set;
1424
  struct grid_cell active_border_gc;
1425
1426
  int    control_bg;
1427
  int    control_fg;
1428
1429
  struct style   scrollbar_style;
1430
1431
  struct visible_ranges r;
1432
1433
  TAILQ_ENTRY(window_pane) entry;  /* link in list of all panes */
1434
  TAILQ_ENTRY(window_pane) sentry; /* link in list of last visited */
1435
        TAILQ_ENTRY(window_pane) zentry; /* z-index link in list of all panes */
1436
  RB_ENTRY(window_pane) tree_entry;
1437
};
1438
TAILQ_HEAD(window_panes, window_pane);
1439
TAILQ_HEAD(window_panes_zindex, window_pane);
1440
RB_HEAD(window_pane_tree, window_pane);
1441
TAILQ_HEAD(redraw_damages, redraw_damage);
1442
1443
/* Window structure. */
1444
struct window {
1445
  u_int      id;
1446
  void      *latest;
1447
1448
  char      *name;
1449
  struct event     name_event;
1450
  struct timeval     name_time;
1451
1452
  struct event     alerts_timer;
1453
  struct event     offset_timer;
1454
1455
  struct timeval     activity_time;
1456
  struct timeval     creation_time;
1457
1458
  struct window_pane  *active;
1459
  struct window_pane  *modal;
1460
  struct window_pane  *modal_last;
1461
  struct window_pane  *was_zoomed;
1462
  struct window_panes    last_panes;
1463
  struct window_panes      z_index;
1464
  struct window_panes  panes;
1465
1466
  int      lastlayout;
1467
  struct layout_cell  *layout_root;
1468
  struct layout_cell  *saved_layout_root;
1469
  char      *old_layout;
1470
1471
  u_int      sx;
1472
  u_int      sy;
1473
  u_int      manual_sx;
1474
  u_int      manual_sy;
1475
  u_int      xpixel;
1476
  u_int      ypixel;
1477
1478
  u_int      new_sx;
1479
  u_int      new_sy;
1480
  u_int      new_xpixel;
1481
  u_int      new_ypixel;
1482
1483
  uint64_t     redraw_scene_generation;
1484
1485
  struct redraw_damages  damage;
1486
  u_int      damage_count;
1487
  uint64_t     scroll_generation;
1488
  int      scroll_pending;
1489
1490
  struct menu_data  *menu;
1491
  u_int      menu_last_px;
1492
  u_int      menu_last_py;
1493
1494
  u_int      last_new_pane_x;
1495
  u_int      last_new_pane_y;
1496
1497
  int      sb;
1498
  int      sb_pos;
1499
1500
  struct grid_cell   inside_cell;
1501
  struct grid_cell   outside_cell;
1502
  int      flags;
1503
0
#define WINDOW_BELL 0x1
1504
0
#define WINDOW_ACTIVITY 0x2
1505
0
#define WINDOW_SILENCE 0x4
1506
0
#define WINDOW_ZOOMED 0x8
1507
0
#define WINDOW_WASZOOMED 0x10
1508
0
#define WINDOW_RESIZE 0x20
1509
0
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
1510
1511
  int      alerts_queued;
1512
  TAILQ_ENTRY(window)  alerts_entry;
1513
1514
  struct options    *options;
1515
1516
  u_int      references;
1517
  TAILQ_HEAD(, winlink)  winlinks;
1518
1519
  RB_ENTRY(window)   entry;
1520
};
1521
RB_HEAD(windows, window);
1522
1523
/* Entry on local window list. */
1524
struct winlink {
1525
  int    idx;
1526
  struct session  *session;
1527
  struct window *window;
1528
1529
  int    flags;
1530
0
#define WINLINK_BELL 0x1
1531
0
#define WINLINK_ACTIVITY 0x2
1532
0
#define WINLINK_SILENCE 0x4
1533
0
#define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE)
1534
0
#define WINLINK_VISITED 0x8
1535
1536
  RB_ENTRY(winlink) entry;
1537
  TAILQ_ENTRY(winlink) wentry;
1538
  TAILQ_ENTRY(winlink) sentry;
1539
};
1540
RB_HEAD(winlinks, winlink);
1541
TAILQ_HEAD(winlink_stack, winlink);
1542
1543
/* Window size option. */
1544
0
#define WINDOW_SIZE_LARGEST 0
1545
0
#define WINDOW_SIZE_SMALLEST 1
1546
0
#define WINDOW_SIZE_MANUAL 2
1547
0
#define WINDOW_SIZE_LATEST 3
1548
1549
/* Pane border status option. */
1550
0
#define PANE_STATUS_OFF 0
1551
0
#define PANE_STATUS_TOP 1
1552
0
#define PANE_STATUS_BOTTOM 2
1553
0
#define PANE_STATUS_TOP_FLOATING 3
1554
0
#define PANE_STATUS_BOTTOM_FLOATING 4
1555
1556
/* Pane scrollbars option. */
1557
#define PANE_SCROLLBARS_OFF 0
1558
0
#define PANE_SCROLLBARS_MODAL 1
1559
0
#define PANE_SCROLLBARS_ALWAYS 2
1560
0
#define PANE_SCROLLBARS_AUTOHIDE 3
1561
1562
/* Pane scrollbars position option. */
1563
0
#define PANE_SCROLLBARS_RIGHT 0
1564
0
#define PANE_SCROLLBARS_LEFT 1
1565
1566
/* Pane scrollbars width, padding and fill character. */
1567
0
#define PANE_SCROLLBARS_DEFAULT_PADDING 0
1568
0
#define PANE_SCROLLBARS_DEFAULT_WIDTH 1
1569
0
#define PANE_SCROLLBARS_CHARACTER ' '
1570
1571
/* True if screen in alternate screen. */
1572
0
#define SCREEN_IS_ALTERNATE(s) ((s)->saved_grid != NULL)
1573
1574
/* Layout direction. */
1575
enum layout_type {
1576
  LAYOUT_LEFTRIGHT,
1577
  LAYOUT_TOPBOTTOM,
1578
  LAYOUT_WINDOWPANE
1579
};
1580
1581
/* Layout cell sizes and position. */
1582
struct layout_geometry {
1583
  u_int sx;
1584
  u_int sy;
1585
  int xoff;
1586
  int yoff;
1587
};
1588
1589
/* Layout cells queue. */
1590
TAILQ_HEAD(layout_cells, layout_cell);
1591
1592
/* Layout cell. */
1593
struct layout_cell {
1594
  enum layout_type   type;
1595
1596
  int      flags;
1597
0
#define LAYOUT_CELL_FLOATING 0x1
1598
1599
  struct layout_cell  *parent;
1600
1601
  struct layout_geometry   g;
1602
  struct layout_geometry   fg; /* saved floating pane */
1603
1604
  struct window_pane  *wp;
1605
  struct layout_cells  cells;
1606
1607
  TAILQ_ENTRY(layout_cell) entry;
1608
};
1609
1610
/* Environment variable. */
1611
struct environ_entry {
1612
  char    *name;
1613
  char    *value;
1614
1615
  int    flags;
1616
0
#define ENVIRON_HIDDEN 0x1
1617
1618
  RB_ENTRY(environ_entry) entry;
1619
};
1620
1621
/* Client session. */
1622
struct session_group {
1623
  const char    *name;
1624
  TAILQ_HEAD(, session)  sessions;
1625
1626
  RB_ENTRY(session_group)  entry;
1627
};
1628
RB_HEAD(session_groups, session_group);
1629
1630
struct session {
1631
  u_int    id;
1632
1633
  char    *name;
1634
  const char  *cwd;
1635
1636
  struct timeval   creation_time;
1637
  struct timeval   last_attached_time;
1638
  struct timeval   activity_time;
1639
  struct timeval   last_activity_time;
1640
1641
  struct event   lock_timer;
1642
1643
  struct winlink  *curw;
1644
  struct winlink_stack lastw;
1645
  struct winlinks  windows;
1646
1647
  int    statusat;
1648
  u_int    statuslines;
1649
  int    sidestatusat; /* -1 off, 0 left, 1 right */
1650
  u_int    sidestatuswidth;
1651
1652
  struct options  *options;
1653
1654
0
#define SESSION_ALERTED 0x1
1655
  int    flags;
1656
1657
  u_int    attached;
1658
1659
  struct termios  *tio;
1660
1661
  struct environ  *environ;
1662
1663
  int    references;
1664
1665
  TAILQ_ENTRY(session) gentry;
1666
  RB_ENTRY(session)    entry;
1667
};
1668
RB_HEAD(sessions, session);
1669
1670
/* Mouse button masks. */
1671
0
#define MOUSE_MASK_BUTTONS 195
1672
0
#define MOUSE_MASK_SHIFT 4
1673
0
#define MOUSE_MASK_META 8
1674
0
#define MOUSE_MASK_CTRL 16
1675
0
#define MOUSE_MASK_DRAG 32
1676
#define MOUSE_MASK_MODIFIERS (MOUSE_MASK_SHIFT|MOUSE_MASK_META|MOUSE_MASK_CTRL)
1677
1678
/* Mouse wheel type. */
1679
0
#define MOUSE_WHEEL_UP 64
1680
0
#define MOUSE_WHEEL_DOWN 65
1681
1682
/* Mouse button type. */
1683
0
#define MOUSE_BUTTON_1 0
1684
0
#define MOUSE_BUTTON_2 1
1685
0
#define MOUSE_BUTTON_3 2
1686
0
#define MOUSE_BUTTON_6 66
1687
0
#define MOUSE_BUTTON_7 67
1688
0
#define MOUSE_BUTTON_8 128
1689
0
#define MOUSE_BUTTON_9 129
1690
0
#define MOUSE_BUTTON_10 130
1691
0
#define MOUSE_BUTTON_11 131
1692
1693
/* Mouse helpers. */
1694
0
#define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS)
1695
#define MOUSE_WHEEL(b) \
1696
0
  (((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_UP || \
1697
0
   ((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_DOWN)
1698
0
#define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG)
1699
0
#define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3)
1700
1701
/* Mouse input. */
1702
struct mouse_event {
1703
  int   valid;
1704
  int   ignore;
1705
1706
  key_code  key;
1707
1708
  int   statusat;
1709
  u_int   statuslines;
1710
  int   sideat;
1711
  u_int   sidewidth;
1712
1713
  u_int   x;
1714
  u_int   y;
1715
  u_int   b;
1716
1717
  u_int   lx;
1718
  u_int   ly;
1719
  u_int   lb;
1720
1721
  u_int   ox;
1722
  u_int   oy;
1723
1724
  int   s;
1725
  int   w;
1726
  int   wp;
1727
1728
  u_int   sgr_type;
1729
  u_int   sgr_b;
1730
};
1731
1732
/* Key event. */
1733
struct key_event {
1734
  struct client   *client;
1735
1736
  key_code     key;
1737
  struct mouse_event   m;
1738
1739
  char      *buf;
1740
  size_t       len;
1741
};
1742
1743
/* Terminal definition. */
1744
struct tty_term {
1745
  char    *name;
1746
  struct tty  *tty;
1747
  int    applied_features;
1748
1749
  char     acs[UCHAR_MAX + 1][2];
1750
1751
  struct tty_code *codes;
1752
1753
4.13k
#define TERM_256COLOURS 0x1
1754
0
#define TERM_NOAM 0x2
1755
0
#define TERM_DECSLRM 0x4
1756
0
#define TERM_DECFRA 0x8
1757
4.13k
#define TERM_RGBCOLOURS 0x10
1758
0
#define TERM_VT100LIKE 0x20
1759
0
#define TERM_SIXEL 0x40
1760
0
#define TERM_INVALIDMS 0x80
1761
0
#define TERM_NOREPLACE 0x100
1762
#define TERM_KITTYGRAPHICS 0x200
1763
  int    flags;
1764
1765
  LIST_ENTRY(tty_term) entry;
1766
};
1767
LIST_HEAD(tty_terms, tty_term);
1768
1769
/* Terminal style context. */
1770
struct tty_style_ctx {
1771
  const struct grid_cell  *defaults;
1772
  struct colour_palette *palette;
1773
  u_int      dim;
1774
  struct hyperlinks *hyperlinks;
1775
};
1776
1777
/* Client terminal. */
1778
struct tty {
1779
  struct client *client;
1780
  struct event   start_timer;
1781
  struct event   clipboard_timer;
1782
  time_t     last_requests;
1783
1784
  u_int    sx;
1785
  u_int    sy;
1786
        /* Cell size in pixels. */
1787
  u_int    xpixel;
1788
  u_int    ypixel;
1789
1790
  u_int    cx;
1791
  u_int    cy;
1792
  enum screen_cursor_style cstyle;
1793
  int    ccolour;
1794
1795
        /* Properties of the area being drawn on. */
1796
        /* When true, the drawing area is bigger than the terminal. */
1797
  int    oflag;
1798
  u_int    oox;
1799
  u_int    ooy;
1800
  u_int    osx;
1801
  u_int    osy;
1802
1803
  int    mode;
1804
  int              fg;
1805
  int              bg;
1806
1807
  u_int    rlower;
1808
  u_int    rupper;
1809
1810
  u_int    rleft;
1811
  u_int    rright;
1812
1813
  struct event   event_in;
1814
  struct evbuffer *in;
1815
  struct event   event_out;
1816
  struct evbuffer *out;
1817
  struct event   timer;
1818
  size_t     discarded;
1819
1820
  size_t     sync_offset;
1821
1822
  struct termios   tio;
1823
1824
  struct grid_cell cell;
1825
  struct grid_cell last_cell;
1826
1827
0
#define TTY_NOCURSOR 0x1
1828
0
#define TTY_FREEZE 0x2
1829
0
#define TTY_TIMER 0x4
1830
0
#define TTY_NOBLOCK 0x8
1831
0
#define TTY_STARTED 0x10
1832
0
#define TTY_OPENED 0x20
1833
0
#define TTY_OSC52QUERY 0x40
1834
0
#define TTY_BLOCK 0x80
1835
0
#define TTY_HAVEDA 0x100
1836
0
#define TTY_HAVEXDA 0x200
1837
0
#define TTY_SYNCING 0x400
1838
0
#define TTY_HAVEDA2 0x800
1839
0
#define TTY_WINSIZEQUERY 0x1000
1840
0
#define TTY_WAITFG 0x2000
1841
0
#define TTY_WAITBG 0x4000
1842
0
#define TTY_BRACKETPASTE 0x8000
1843
0
#define TTY_HAVESYNC 0x10000
1844
0
#define TTY_HAVEKITTYGRAPHICS 0x20000
1845
#define TTY_ALL_REQUEST_FLAGS \
1846
0
  (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA|TTY_HAVESYNC|TTY_HAVEKITTYGRAPHICS)
1847
  int    flags;
1848
1849
  struct tty_term *term;
1850
1851
  u_int    mouse_last_x;
1852
  u_int    mouse_last_y;
1853
  u_int    mouse_last_b;
1854
  int    mouse_drag_flag;
1855
  int    mouse_drag_status;
1856
  enum key_code_mouse_location mouse_drag_location;
1857
  u_int    mouse_drag_x;
1858
  u_int    mouse_drag_y;
1859
  int    mouse_scrolling_flag;
1860
  int    mouse_slider_mpos;
1861
  int              mouse_last_pane;
1862
  void    (*mouse_drag_update)(struct client *,
1863
          struct mouse_event *);
1864
  void    (*mouse_drag_release)(struct client *,
1865
          struct mouse_event *);
1866
1867
  struct event   key_timer;
1868
  struct tty_key  *key_tree;
1869
1870
  struct window *scroll_window;
1871
  uint64_t   scroll_generation;
1872
  int    scroll_failed;
1873
1874
#ifdef ENABLE_IMAGES
1875
  struct image_backend  *image_backend;
1876
  void      *image_data;
1877
#endif
1878
};
1879
1880
/* Terminal command context. */
1881
typedef void (*tty_ctx_redraw_cb)(const struct tty_ctx *, u_int, u_int);
1882
typedef int (*tty_ctx_set_client_cb)(struct tty_ctx *, struct client *);
1883
struct tty_ctx {
1884
  struct screen   *s;
1885
1886
  tty_ctx_redraw_cb  redraw_cb;
1887
  tty_ctx_set_client_cb  set_client_cb;
1888
  void      *arg;
1889
1890
  const struct grid_cell  *cell;
1891
  int                      flags;
1892
0
#define TTY_CTX_WRAPPED 0x1
1893
0
#define TTY_CTX_INVISIBLE_PANES 0x2
1894
0
#define TTY_CTX_WINDOW_BIGGER 0x4
1895
0
#define TTY_CTX_SYNC 0x8
1896
0
#define TTY_CTX_CELL_INVALIDATE 0x20
1897
0
#define TTY_CTX_PANE_OBSCURED 0x40
1898
1899
  union {
1900
    u_int      n;
1901
1902
    struct {
1903
      const char  *data;
1904
      size_t     size;
1905
    } data;
1906
1907
    struct {
1908
      const char  *clip;
1909
      const char  *data;
1910
      size_t     size;
1911
    } sel;
1912
1913
  };
1914
1915
  /*
1916
   * Cursor and region position before the screen was updated - this is
1917
   * where the command should be applied; the values in the screen have
1918
   * already been updated.
1919
   */
1920
  u_int      ocx;
1921
  u_int      ocy;
1922
1923
  u_int      orupper;
1924
  u_int      orlower;
1925
1926
  /* Target region (usually pane) offset and size. */
1927
  int      xoff;
1928
  int      yoff;
1929
  int      rxoff;
1930
  int      ryoff;
1931
  u_int      sx;
1932
  u_int      sy;
1933
1934
  /* The background colour used for clearing (erasing). */
1935
  u_int      bg;
1936
1937
  /* The default colours and palette. */
1938
  struct grid_cell   defaults;
1939
  struct tty_style_ctx   style_ctx;
1940
1941
  /* Containing region (usually window) offset and size. */
1942
  u_int      wox;
1943
  u_int      woy;
1944
  u_int      wsx;
1945
  u_int      wsy;
1946
};
1947
1948
/* Saved message entry. */
1949
struct message_entry {
1950
  char        *msg;
1951
  u_int        msg_num;
1952
  struct timeval       msg_time;
1953
1954
  TAILQ_ENTRY(message_entry)   entry;
1955
};
1956
TAILQ_HEAD(message_list, message_entry);
1957
1958
/* Argument type. */
1959
enum args_type {
1960
  ARGS_NONE,
1961
  ARGS_STRING,
1962
  ARGS_COMMANDS
1963
};
1964
1965
/* Argument value. */
1966
struct args_value {
1967
  enum args_type     type;
1968
  union {
1969
    char    *string;
1970
    struct cmd_list *cmdlist;
1971
  };
1972
  char      *cached;
1973
  TAILQ_ENTRY(args_value)  entry;
1974
};
1975
1976
/* Arguments set. */
1977
struct args_entry;
1978
RB_HEAD(args_tree, args_entry);
1979
1980
/* Arguments parsing type. */
1981
enum args_parse_type {
1982
  ARGS_PARSE_INVALID,
1983
  ARGS_PARSE_STRING,
1984
  ARGS_PARSE_COMMANDS_OR_STRING,
1985
  ARGS_PARSE_COMMANDS
1986
};
1987
1988
/* Arguments parsing state. */
1989
typedef enum args_parse_type (*args_parse_cb)(struct args *, u_int, char **);
1990
struct args_parse {
1991
  const char  *template;
1992
  int    lower;
1993
  int    upper;
1994
  args_parse_cb  cb;
1995
};
1996
1997
/* Command find structures. */
1998
enum cmd_find_type {
1999
  CMD_FIND_PANE,
2000
  CMD_FIND_WINDOW,
2001
  CMD_FIND_SESSION,
2002
};
2003
struct cmd_find_state {
2004
  int      flags;
2005
  struct cmd_find_state *current;
2006
2007
  struct session    *s;
2008
  struct winlink    *wl;
2009
  struct window   *w;
2010
  struct window_pane  *wp;
2011
  int      idx;
2012
};
2013
2014
/* Command find flags. */
2015
0
#define CMD_FIND_PREFER_UNATTACHED 0x1
2016
0
#define CMD_FIND_QUIET 0x2
2017
0
#define CMD_FIND_WINDOW_INDEX 0x4
2018
0
#define CMD_FIND_DEFAULT_MARKED 0x8
2019
0
#define CMD_FIND_EXACT_SESSION 0x10
2020
0
#define CMD_FIND_EXACT_WINDOW 0x20
2021
0
#define CMD_FIND_CANFAIL 0x40
2022
2023
/* List of commands. */
2024
struct cmd_list {
2025
  int    references;
2026
  u_int    group;
2027
  struct cmds *list;
2028
};
2029
2030
/* Command return values. */
2031
enum cmd_retval {
2032
  CMD_RETURN_ERROR = -1,
2033
  CMD_RETURN_NORMAL = 0,
2034
  CMD_RETURN_WAIT,
2035
  CMD_RETURN_STOP
2036
};
2037
2038
/* Command parse result. */
2039
enum cmd_parse_status {
2040
  CMD_PARSE_ERROR,
2041
  CMD_PARSE_SUCCESS
2042
};
2043
struct cmd_parse_result {
2044
  enum cmd_parse_status  status;
2045
  struct cmd_list   *cmdlist;
2046
  char      *error;
2047
};
2048
struct cmd_parse_input {
2049
  int      flags;
2050
0
#define CMD_PARSE_QUIET 0x1
2051
0
#define CMD_PARSE_PARSEONLY 0x2
2052
2
#define CMD_PARSE_NOALIAS 0x4
2053
0
#define CMD_PARSE_VERBOSE 0x8
2054
4
#define CMD_PARSE_ONEGROUP 0x10
2055
2056
  const char    *file;
2057
  u_int      line;
2058
2059
  struct cmdq_item  *item;
2060
  struct client   *c;
2061
  struct cmd_find_state  fs;
2062
};
2063
2064
/* Command queue flags. */
2065
0
#define CMDQ_STATE_REPEAT 0x1
2066
0
#define CMDQ_STATE_CONTROL 0x2
2067
0
#define CMDQ_STATE_NOHOOKS 0x4
2068
2069
/* Command queue callback. */
2070
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
2071
2072
/* Command definition flag. */
2073
struct cmd_entry_flag {
2074
  char       flag;
2075
  enum cmd_find_type   type;
2076
  int      flags;
2077
};
2078
2079
/* Command definition. */
2080
struct cmd_entry {
2081
  const char    *name;
2082
  const char    *description;
2083
  const char    *alias;
2084
2085
  struct args_parse  args;
2086
  const char    *usage;
2087
2088
  struct cmd_entry_flag  source;
2089
  struct cmd_entry_flag  target;
2090
2091
0
#define CMD_STARTSERVER 0x1
2092
0
#define CMD_READONLY 0x2
2093
0
#define CMD_AFTERHOOK 0x4
2094
0
#define CMD_CLIENT_CFLAG 0x8
2095
0
#define CMD_CLIENT_TFLAG 0x10
2096
0
#define CMD_CLIENT_CANFAIL 0x20
2097
  int    flags;
2098
2099
  enum cmd_retval  (*exec)(struct cmd *, struct cmdq_item *);
2100
};
2101
2102
/* Status line. */
2103
#define STATUS_LINES_LIMIT 5
2104
struct status_line {
2105
  struct event     timer;
2106
2107
  struct screen    screen;
2108
  struct screen   *active;
2109
  int      references;
2110
2111
  u_int      prompt_cx;
2112
  struct grid_cell   style;
2113
  struct style_line_entry  entries[STATUS_LINES_LIMIT];
2114
};
2115
2116
/* Side status line. */
2117
struct side_status_line {
2118
  struct screen    screen;
2119
2120
  struct grid_cell   style;
2121
  char      *expanded;
2122
  int      linex;
2123
  struct style_ranges  ranges;
2124
};
2125
2126
/* File in client. */
2127
typedef void (*client_file_cb) (struct client *, const char *, int, int,
2128
    struct evbuffer *, void *);
2129
struct client_file {
2130
  struct client     *c;
2131
  struct tmuxpeer     *peer;
2132
  struct client_files   *tree;
2133
  int        references;
2134
  int        stream;
2135
2136
  char        *path;
2137
  struct evbuffer     *buffer;
2138
  struct bufferevent    *event;
2139
2140
  int        fd;
2141
  int        error;
2142
  int        closed;
2143
2144
  client_file_cb       cb;
2145
  void        *data;
2146
2147
  RB_ENTRY(client_file)    entry;
2148
};
2149
RB_HEAD(client_files, client_file);
2150
2151
/* Maximum time to be pasting. */
2152
0
#define CLIENT_PASTE_TIME_LIMIT 5
2153
2154
/* Prompt type. */
2155
0
#define PROMPT_NTYPES 2
2156
enum prompt_type {
2157
  PROMPT_TYPE_COMMAND,
2158
  PROMPT_TYPE_SEARCH,
2159
  PROMPT_TYPE_INVALID = 0xff
2160
};
2161
2162
/* Prompt result. */
2163
enum prompt_result {
2164
  PROMPT_CONTINUE,
2165
  PROMPT_CLOSE
2166
};
2167
2168
/* Prompt key result. */
2169
enum prompt_key_result {
2170
  PROMPT_KEY_NOT_HANDLED,
2171
  PROMPT_KEY_HANDLED,
2172
  PROMPT_KEY_CLOSE,
2173
  PROMPT_KEY_MOVE
2174
};
2175
2176
/* Prompt callbacks. */
2177
typedef enum prompt_result (*prompt_input_cb)(void *, const char *,
2178
    enum prompt_key_result);
2179
typedef enum prompt_result (*status_prompt_input_cb)(struct client *, void *,
2180
    const char *, enum prompt_key_result);
2181
typedef enum prompt_result (*mode_tree_prompt_input_cb)(struct client *, void *,
2182
    const char *, enum prompt_key_result);
2183
typedef void (*prompt_free_cb)(void *);
2184
2185
/* Prompt flags. */
2186
0
#define PROMPT_SINGLE 0x1
2187
0
#define PROMPT_NUMERIC 0x2
2188
0
#define PROMPT_INCREMENTAL 0x4
2189
0
#define PROMPT_NOFORMAT 0x8
2190
0
#define PROMPT_KEY 0x10
2191
0
#define PROMPT_ACCEPT 0x20
2192
0
#define PROMPT_QUOTENEXT 0x40
2193
0
#define PROMPT_BSPACE_EXIT 0x80
2194
0
#define PROMPT_NOFREEZE 0x100
2195
0
#define PROMPT_COMMANDMODE 0x200
2196
0
#define PROMPT_ISPANE 0x400
2197
0
#define PROMPT_ISMODE 0x800
2198
0
#define PROMPT_EDITARROWS 0x1000
2199
2200
/* Prompt create data. */
2201
struct prompt_create_data {
2202
  struct cmd_find_state *fs;
2203
  const char    *prompt;
2204
  const char    *input;
2205
  enum prompt_type   type;
2206
  int      flags;
2207
2208
  struct grid_cell   style;
2209
  struct grid_cell   command_style;
2210
  const char    *style_str;
2211
  const char    *command_style_str;
2212
  enum screen_cursor_style cstyle;
2213
  enum screen_cursor_style command_cstyle;
2214
  int      ccolour;
2215
  int      command_ccolour;
2216
  int      cmode;
2217
  int      command_cmode;
2218
  const char    *message_format;
2219
  int      keys;
2220
  const char    *word_separators;
2221
2222
  prompt_input_cb    inputcb;
2223
  prompt_free_cb     freecb;
2224
  void      *data;
2225
};
2226
2227
/* Prompt draw data. */
2228
struct prompt_draw_data {
2229
  struct screen_write_ctx *ctx;
2230
  u_int     *cursor_x;
2231
2232
  u_int      area_x;
2233
  u_int      area_width;
2234
  u_int      prompt_line;
2235
};
2236
2237
/* Client connection. */
2238
struct client {
2239
  const char    *name;
2240
  struct tmuxpeer   *peer;
2241
  const char    *user;
2242
  struct cmdq_list  *queue;
2243
2244
  struct control_state  *control_state;
2245
  u_int      pause_age;
2246
2247
  pid_t      pid;
2248
  int      fd;
2249
  int      out_fd;
2250
  struct event     event;
2251
  int      retval;
2252
2253
  struct timeval     creation_time;
2254
  struct timeval     activity_time;
2255
  struct timeval     last_activity_time;
2256
2257
  struct environ    *environ;
2258
  struct format_job_tree  *jobs;
2259
2260
  char      *title;
2261
  char      *path;
2262
  const char    *cwd;
2263
  struct progress_bar  progress_bar;
2264
2265
  char      *term_name;
2266
  int      term_features;
2267
  int      term_nofeatures;
2268
  char      *term_type;
2269
  char           **term_caps;
2270
  u_int      term_ncaps;
2271
2272
  char      *ttyname;
2273
  struct tty     tty;
2274
2275
  size_t       written;
2276
  size_t       discarded;
2277
  size_t       redraw;
2278
2279
  struct redraw_scene *redraw_scene;
2280
2281
  struct event     repeat_timer;
2282
2283
  struct event     click_timer;
2284
  int      click_loc;
2285
  int      click_wp;
2286
2287
  struct event     exit_timer;
2288
  u_int      click_button;
2289
  struct mouse_event   click_event;
2290
2291
  struct status_line   status;
2292
  struct side_status_line  side_status;
2293
  struct event     cycle_timer;
2294
  enum client_theme  theme;
2295
2296
  struct input_requests  input_requests;
2297
2298
0
#define CLIENT_TERMINAL 0x1
2299
0
#define CLIENT_LOGIN 0x2
2300
0
#define CLIENT_EXIT 0x4
2301
0
#define CLIENT_REDRAWWINDOW 0x8
2302
0
#define CLIENT_REDRAWSTATUS 0x10
2303
0
#define CLIENT_REPEAT 0x20
2304
0
#define CLIENT_SUSPENDED 0x40
2305
0
#define CLIENT_ATTACHED 0x80
2306
0
#define CLIENT_EXITED 0x100
2307
0
#define CLIENT_DEAD 0x200
2308
0
#define CLIENT_REDRAWBORDERS 0x400
2309
0
#define CLIENT_READONLY 0x800
2310
0
#define CLIENT_NOSTARTSERVER 0x1000
2311
0
#define CLIENT_CONTROL 0x2000
2312
0
#define CLIENT_CONTROLCONTROL 0x4000
2313
0
#define CLIENT_FOCUSED 0x8000
2314
0
#define CLIENT_UTF8 0x10000
2315
0
#define CLIENT_IGNORESIZE 0x20000
2316
0
#define CLIENT_IDENTIFIED 0x40000
2317
0
#define CLIENT_STATUSFORCE 0x80000
2318
0
#define CLIENT_DOUBLECLICK 0x100000
2319
0
#define CLIENT_TRIPLECLICK 0x200000
2320
0
#define CLIENT_SIZECHANGED 0x400000
2321
0
#define CLIENT_STATUSOFF 0x800000
2322
0
#define CLIENT_REDRAWSTATUSALWAYS 0x1000000
2323
/* 0x2000000 unused */
2324
0
#define CLIENT_CONTROL_NOOUTPUT 0x4000000
2325
0
#define CLIENT_DEFAULTSOCKET 0x8000000
2326
0
#define CLIENT_STARTSERVER 0x10000000
2327
0
#define CLIENT_REDRAWMENU 0x20000000
2328
0
#define CLIENT_NOFORK 0x40000000
2329
0
#define CLIENT_REDRAWSCROLLBARS 0x80000000ULL
2330
0
#define CLIENT_CONTROL_PAUSEAFTER 0x100000000ULL
2331
0
#define CLIENT_CONTROL_WAITEXIT 0x200000000ULL
2332
0
#define CLIENT_WINDOWSIZECHANGED 0x400000000ULL
2333
0
#define CLIENT_CONTROL_NEWLAYOUTS 0x800000000ULL
2334
0
#define CLIENT_BRACKETPASTING 0x1000000000ULL
2335
0
#define CLIENT_ASSUMEPASTING 0x2000000000ULL
2336
0
#define CLIENT_WRITE_ACK 0x4000000000ULL
2337
0
#define CLIENT_NO_DETACH_ON_DESTROY 0x8000000000ULL
2338
0
#define CLIENT_CONTROL_DISCARD 0x10000000000ULL
2339
0
#define CLIENT_SIDESTATUSOFF 0x20000000000ULL
2340
#define CLIENT_ALLREDRAWFLAGS   \
2341
0
  (CLIENT_REDRAWWINDOW|   \
2342
0
   CLIENT_REDRAWSTATUS|   \
2343
0
   CLIENT_REDRAWSTATUSALWAYS| \
2344
0
   CLIENT_REDRAWBORDERS|   \
2345
0
   CLIENT_REDRAWMENU)
2346
#define CLIENT_UNATTACHEDFLAGS  \
2347
0
  (CLIENT_DEAD|   \
2348
0
   CLIENT_SUSPENDED| \
2349
0
   CLIENT_EXIT)
2350
#define CLIENT_NODETACHFLAGS  \
2351
0
  (CLIENT_DEAD|   \
2352
0
   CLIENT_EXIT)
2353
#define CLIENT_NOSIZEFLAGS  \
2354
0
  (CLIENT_DEAD|   \
2355
0
   CLIENT_SUSPENDED| \
2356
0
   CLIENT_EXIT)
2357
  uint64_t     flags;
2358
2359
  enum {
2360
    CLIENT_EXIT_RETURN,
2361
    CLIENT_EXIT_SHUTDOWN,
2362
    CLIENT_EXIT_DETACH
2363
  }      exit_type;
2364
  enum msgtype     exit_msgtype;
2365
  char      *exit_session;
2366
  char      *exit_message;
2367
2368
  struct key_table  *keytable;
2369
  key_code     last_key;
2370
  time_t       paste_time;
2371
2372
  int      message_ignore_keys;
2373
  int      message_ignore_styles;
2374
  char      *message_string;
2375
  struct event     message_timer;
2376
2377
  struct prompt   *prompt;
2378
2379
  struct session    *session;
2380
  struct session    *last_session;
2381
2382
  int      references;
2383
2384
  int      theme_colours[COLOUR_THEME_COUNT];
2385
2386
  void      *pan_window;
2387
  u_int      pan_ox;
2388
  u_int      pan_oy;
2389
2390
  struct client_files  files;
2391
  u_int      source_file_depth;
2392
2393
  u_int     *clipboard_panes;
2394
  u_int      clipboard_npanes;
2395
2396
  TAILQ_ENTRY(client)  entry;
2397
};
2398
TAILQ_HEAD(clients, client);
2399
2400
/* Monitor. */
2401
enum monitor_type {
2402
  MONITOR_SESSION,
2403
  MONITOR_PANE,
2404
  MONITOR_ALL_PANES,
2405
  MONITOR_WINDOW,
2406
  MONITOR_ALL_WINDOWS
2407
};
2408
0
#define MONITOR_NOTIFY_INITIAL 0x1
2409
0
#define MONITOR_NOTIFY_TRUE 0x2
2410
struct monitor_change {
2411
  const char    *name;
2412
  const char    *value;
2413
  const char    *last;
2414
2415
  struct client   *c;
2416
  struct session    *s;
2417
  struct winlink    *wl;
2418
  struct window_pane  *wp;
2419
};
2420
typedef void (*monitor_cb)(struct monitor_change *, void *);
2421
2422
/* Event payload type. */
2423
enum event_payload_type {
2424
  EVENT_PAYLOAD_STRING,
2425
  EVENT_PAYLOAD_TIME,
2426
  EVENT_PAYLOAD_INT,
2427
  EVENT_PAYLOAD_UINT,
2428
  EVENT_PAYLOAD_CLIENT,
2429
  EVENT_PAYLOAD_SESSION,
2430
  EVENT_PAYLOAD_WINDOW,
2431
  EVENT_PAYLOAD_PANE,
2432
  EVENT_PAYLOAD_POINTER
2433
};
2434
2435
/* Event payload callbacks. */
2436
typedef void (*event_payload_free_cb)(void *);
2437
typedef void (*event_payload_print_cb)(void *, struct evbuffer *);
2438
2439
/* Key binding and key table. */
2440
struct key_binding {
2441
  key_code     key;
2442
  struct cmd_list   *cmdlist;
2443
  const char    *note;
2444
  const char    *tablename;
2445
2446
  int      flags;
2447
0
#define KEY_BINDING_REPEAT 0x1
2448
2449
  RB_ENTRY(key_binding)  entry;
2450
};
2451
RB_HEAD(key_bindings, key_binding);
2452
2453
struct key_table {
2454
  const char    *name;
2455
  struct timeval     activity_time;
2456
  struct key_bindings  key_bindings;
2457
  struct key_bindings  default_key_bindings;
2458
2459
  u_int      references;
2460
2461
  RB_ENTRY(key_table)  entry;
2462
};
2463
RB_HEAD(key_tables, key_table);
2464
2465
/* Option data. */
2466
RB_HEAD(options_array, options_array_item);
2467
union options_value {
2468
  char      *string;
2469
  long long    number;
2470
  struct style     style;
2471
  struct options_array   array;
2472
  struct cmd_list   *cmdlist;
2473
};
2474
2475
/* Option table entries. */
2476
enum options_table_type {
2477
  OPTIONS_TABLE_STRING,
2478
  OPTIONS_TABLE_NUMBER,
2479
  OPTIONS_TABLE_KEY,
2480
  OPTIONS_TABLE_COLOUR,
2481
  OPTIONS_TABLE_FLAG,
2482
  OPTIONS_TABLE_CHOICE,
2483
  OPTIONS_TABLE_COMMAND
2484
};
2485
2486
0
#define OPTIONS_TABLE_NONE 0
2487
548
#define OPTIONS_TABLE_SERVER 0x1
2488
548
#define OPTIONS_TABLE_SESSION 0x2
2489
548
#define OPTIONS_TABLE_WINDOW 0x4
2490
0
#define OPTIONS_TABLE_PANE 0x8
2491
2492
7.69M
#define OPTIONS_TABLE_IS_ARRAY 0x1
2493
1.83M
#define OPTIONS_TABLE_IS_HOOK 0x2
2494
0
#define OPTIONS_TABLE_IS_STYLE 0x4
2495
0
#define OPTIONS_TABLE_IS_COLOUR 0x8
2496
2497
struct options_table_entry {
2498
  const char     *name;
2499
  const char     *alternative_name;
2500
  enum options_table_type   type;
2501
  int       scope;
2502
  int       flags;
2503
2504
  u_int       minimum;
2505
  u_int       maximum;
2506
  const char    **choices;
2507
2508
  const char     *default_str;
2509
  long long     default_num;
2510
  const char    **default_arr;
2511
2512
  const char     *separator;
2513
  const char     *pattern;
2514
2515
  const char     *text;
2516
  const char     *unit;
2517
};
2518
2519
struct options_name_map {
2520
  const char    *from;
2521
  const char    *to;
2522
};
2523
2524
/* Common command usages. */
2525
#define CMD_TARGET_PANE_USAGE "[-t target-pane]"
2526
#define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
2527
#define CMD_TARGET_SESSION_USAGE "[-t target-session]"
2528
#define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
2529
#define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]"
2530
#define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
2531
#define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
2532
#define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
2533
#define CMD_BUFFER_USAGE "[-b buffer-name]"
2534
2535
/* Spawn common context. */
2536
struct spawn_context {
2537
  struct cmdq_item   *item;
2538
2539
  struct session     *s;
2540
  struct winlink     *wl;
2541
  struct client    *tc;
2542
2543
  struct window_pane   *wp0;
2544
  struct layout_cell   *lc;
2545
2546
  const char     *name;
2547
  char      **argv;
2548
  int       argc;
2549
  struct environ     *environ;
2550
2551
  int       idx;
2552
  const char     *cwd;
2553
2554
  int       flags;
2555
0
#define SPAWN_KILL 0x1
2556
0
#define SPAWN_DETACHED 0x2
2557
0
#define SPAWN_RESPAWN 0x4
2558
0
#define SPAWN_BEFORE 0x8
2559
0
#define SPAWN_NONOTIFY 0x10
2560
0
#define SPAWN_FULLSIZE 0x20
2561
0
#define SPAWN_EMPTY 0x40
2562
0
#define SPAWN_ZOOM 0x80
2563
0
#define SPAWN_FLOATING 0x100
2564
0
#define SPAWN_HORIZONTAL 0x200
2565
0
#define SPAWN_SPLIT 0x400
2566
0
#define SPAWN_MODAL 0x800
2567
0
#define SPAWN_FLOATOVERZOOM 0x1000
2568
};
2569
2570
/* Paste buffer. */
2571
struct paste_buffer {
2572
  char    *data;
2573
  size_t     size;
2574
2575
  char    *name;
2576
  time_t     created;
2577
  int    automatic;
2578
  u_int    order;
2579
2580
  RB_ENTRY(paste_buffer) name_entry;
2581
  RB_ENTRY(paste_buffer) time_entry;
2582
};
2583
2584
/* Sort orders. */
2585
enum sort_order {
2586
  SORT_ACTIVITY,
2587
  SORT_CREATION,
2588
  SORT_INDEX,
2589
  SORT_MODIFIER,
2590
  SORT_NAME,
2591
  SORT_ORDER,
2592
  SORT_SIZE,
2593
  SORT_Z,
2594
  SORT_END,
2595
};
2596
2597
/* Sort criteria. */
2598
struct sort_criteria {
2599
  enum sort_order  order;
2600
  int    reversed;
2601
  enum sort_order *order_seq; /* available sort orders */
2602
};
2603
2604
/* tmux.c */
2605
extern struct options *global_options;
2606
extern struct options *global_s_options;
2607
extern struct options *global_w_options;
2608
extern struct environ *global_environ;
2609
extern struct timeval  start_time;
2610
extern const char *socket_path;
2611
extern const char *shell_command;
2612
extern int     ptm_fd;
2613
extern const char *shell_command;
2614
int    checkshell(const char *);
2615
void     setblocking(int, int);
2616
char    *shell_argv0(const char *, int);
2617
uint64_t   get_timer(void);
2618
char    *clean_name(const char *, int);
2619
int    check_name(const char *);
2620
const char  *sig2name(int);
2621
const char  *find_cwd(void);
2622
const char  *find_home(void);
2623
const char  *getversion(void);
2624
2625
/* proc.c */
2626
struct imsg;
2627
int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t);
2628
struct tmuxproc *proc_start(const char *);
2629
void  proc_loop(struct tmuxproc *, int (*)(void));
2630
void  proc_exit(struct tmuxproc *);
2631
void  proc_set_signals(struct tmuxproc *, void(*)(int));
2632
void  proc_clear_signals(struct tmuxproc *, int);
2633
struct tmuxpeer *proc_add_peer(struct tmuxproc *, int,
2634
      void (*)(struct imsg *, void *), void *);
2635
void  proc_remove_peer(struct tmuxpeer *);
2636
void  proc_kill_peer(struct tmuxpeer *);
2637
void  proc_flush_peer(struct tmuxpeer *);
2638
void  proc_toggle_log(struct tmuxproc *);
2639
pid_t proc_fork_and_daemon(int *);
2640
uid_t proc_get_peer_uid(struct tmuxpeer *);
2641
gid_t proc_get_peer_gid(struct tmuxpeer *);
2642
2643
/* cfg.c */
2644
extern int cfg_finished;
2645
extern struct client *cfg_client;
2646
extern char **cfg_files;
2647
extern u_int cfg_nfiles;
2648
extern int cfg_quiet;
2649
void  start_cfg(void);
2650
void  cfg_client_lost(struct client *);
2651
int load_cfg(const char *, struct client *, struct cmdq_item *,
2652
            struct cmd_find_state *, int, struct cmdq_item **);
2653
int load_cfg_from_buffer(const void *, size_t, const char *,
2654
        struct client *, struct cmdq_item *, struct cmd_find_state *,
2655
      int, struct cmdq_item **);
2656
void printflike(1, 2) cfg_add_cause(const char *, ...);
2657
void  cfg_print_causes(struct cmdq_item *);
2658
void  cfg_show_causes(struct session *);
2659
2660
/* paste.c */
2661
const char  *paste_buffer_name(struct paste_buffer *);
2662
u_int    paste_buffer_order(struct paste_buffer *);
2663
time_t     paste_buffer_created(struct paste_buffer *);
2664
const char  *paste_buffer_data(struct paste_buffer *, size_t *);
2665
struct paste_buffer *paste_walk(struct paste_buffer *);
2666
int    paste_is_empty(void);
2667
struct paste_buffer *paste_get_top(char **);
2668
struct paste_buffer *paste_get_name(const char *);
2669
void     paste_free(struct paste_buffer *);
2670
void     paste_add(const char *, char *, size_t);
2671
int    paste_rename(const char *, const char *, char **);
2672
int    paste_set(char *, size_t, const char *, char **);
2673
void     paste_replace(struct paste_buffer *, char *, size_t);
2674
char    *paste_make_sample(struct paste_buffer *);
2675
2676
/* sort.c */
2677
void        sort_next_order(struct sort_criteria *);
2678
enum sort_order     sort_order_from_string(const char *);
2679
const char     *sort_order_to_string(enum sort_order);
2680
int       sort_would_window_tree_swap(struct sort_criteria *,
2681
            struct winlink *, struct winlink *);
2682
struct paste_buffer **sort_get_buffers(u_int *, struct sort_criteria *);
2683
struct client   **sort_get_clients(u_int *, struct sort_criteria *);
2684
struct session    **sort_get_sessions(u_int *, struct sort_criteria *);
2685
struct window_pane  **sort_get_panes(u_int *, struct sort_criteria *);
2686
struct window_pane  **sort_get_panes_session(struct session *, u_int *,
2687
            struct sort_criteria *);
2688
struct window_pane  **sort_get_panes_window(struct window *, u_int *,
2689
            struct sort_criteria *);
2690
struct winlink    **sort_get_winlinks(u_int *, struct sort_criteria *);
2691
struct winlink    **sort_get_winlinks_session(struct session *, u_int *,
2692
            struct sort_criteria *);
2693
struct key_binding  **sort_get_key_bindings(u_int *,
2694
            struct sort_criteria *);
2695
struct key_binding  **sort_get_key_bindings_table(struct key_table *,
2696
            u_int *, struct sort_criteria *);
2697
2698
/* format.c */
2699
18.5k
#define FORMAT_STATUS 0x1
2700
0
#define FORMAT_FORCE 0x2
2701
26.6k
#define FORMAT_NOJOBS 0x4
2702
22.2M
#define FORMAT_VERBOSE 0x8
2703
#define FORMAT_LAST 0x10
2704
1.83M
#define FORMAT_NONE 0
2705
0
#define FORMAT_PANE 0x80000000U
2706
0
#define FORMAT_WINDOW 0x40000000U
2707
struct format_tree;
2708
struct format_modifier;
2709
typedef void *(*format_cb)(struct format_tree *);
2710
void     format_tidy_jobs(void);
2711
const char  *format_skip(const char *, const char *);
2712
int    format_true(const char *);
2713
struct format_tree *format_create(struct client *, struct cmdq_item *, int,
2714
         int);
2715
void     format_free(struct format_tree *);
2716
void     format_merge(struct format_tree *, struct format_tree *);
2717
struct window_pane *format_get_pane(struct format_tree *);
2718
void printflike(3, 4) format_add(struct format_tree *, const char *,
2719
         const char *, ...);
2720
void     format_add_tv(struct format_tree *, const char *,
2721
         struct timeval *);
2722
void     format_add_cb(struct format_tree *, const char *, format_cb);
2723
void     format_log_debug(struct format_tree *, const char *);
2724
void     format_each(struct format_tree *, void (*)(const char *,
2725
         const char *, void *), void *);
2726
char    *format_pretty_time(time_t, int);
2727
char    *format_expand_time(struct format_tree *, const char *);
2728
char    *format_expand(struct format_tree *, const char *);
2729
char    *format_single(struct cmdq_item *, const char *,
2730
         struct client *, struct session *, struct winlink *,
2731
         struct window_pane *);
2732
char    *format_single_from_state(struct cmdq_item *, const char *,
2733
        struct client *, struct cmd_find_state *);
2734
char    *format_single_from_target(struct cmdq_item *, const char *);
2735
struct format_tree *format_create_defaults(struct cmdq_item *, struct client *,
2736
         struct session *, struct winlink *, struct window_pane *);
2737
struct format_tree *format_create_from_state(struct cmdq_item *,
2738
         struct client *, struct cmd_find_state *);
2739
struct format_tree *format_create_from_target(struct cmdq_item *);
2740
void     format_defaults(struct format_tree *, struct client *,
2741
         struct session *, struct winlink *, struct window_pane *);
2742
void     format_defaults_window(struct format_tree *, struct window *);
2743
void     format_defaults_pane(struct format_tree *,
2744
         struct window_pane *);
2745
void     format_defaults_paste_buffer(struct format_tree *,
2746
         struct paste_buffer *);
2747
void     format_lost_client(struct client *);
2748
char    *format_grid_word(struct grid *, u_int, u_int);
2749
char    *format_grid_hyperlink(struct grid *, u_int, u_int,
2750
         struct screen *);
2751
char    *format_grid_line(struct grid *, u_int);
2752
2753
/* events-payload.c */
2754
struct event_payload *event_payload_create(void);
2755
void   event_payload_free(struct event_payload *);
2756
void printflike(2, 3) event_payload_log(struct event_payload *, const char *,
2757
       ...);
2758
char  *event_payload_item_print(struct event_payload_item *);
2759
void   event_payload_set_target(struct event_payload *,
2760
       struct cmd_find_state *);
2761
int  event_payload_get_target(struct event_payload *,
2762
       struct cmd_find_state *);
2763
void printflike(3, 4) event_payload_set_string(struct event_payload *,
2764
       const char *, const char *, ...);
2765
void   event_payload_set_time(struct event_payload *, const char *, time_t);
2766
void   event_payload_set_int(struct event_payload *, const char *, int);
2767
void   event_payload_set_uint(struct event_payload *, const char *, u_int);
2768
void   event_payload_set_client(struct event_payload *, const char *,
2769
       struct client *);
2770
void   event_payload_set_session(struct event_payload *, const char *,
2771
       struct session *);
2772
void   event_payload_set_window(struct event_payload *, const char *,
2773
       struct window *);
2774
void   event_payload_set_pane(struct event_payload *, const char *,
2775
       struct window_pane *);
2776
void   event_payload_set_pointer(struct event_payload *, const char *, void *,
2777
       event_payload_free_cb, event_payload_print_cb);
2778
const char *event_payload_get_string(struct event_payload *, const char *);
2779
char  *event_payload_print(struct event_payload *, const char *);
2780
void   event_payload_add_formats(struct event_payload *,
2781
       struct format_tree *, const char *);
2782
struct event_payload_item *event_payload_first(struct event_payload *);
2783
struct event_payload_item *event_payload_next(struct event_payload_item *);
2784
const char *event_payload_item_name(struct event_payload_item *);
2785
enum event_payload_type event_payload_item_type(struct event_payload_item *);
2786
time_t   event_payload_get_time(struct event_payload *, const char *);
2787
int  event_payload_get_int(struct event_payload *, const char *, int *);
2788
int  event_payload_get_uint(struct event_payload *, const char *, u_int *);
2789
struct client *event_payload_get_client(struct event_payload *, const char *);
2790
struct session *event_payload_get_session(struct event_payload *, const char *);
2791
struct window *event_payload_get_window(struct event_payload *, const char *);
2792
struct window_pane *event_payload_get_pane(struct event_payload *,
2793
       const char *);
2794
void  *event_payload_get_pointer(struct event_payload *, const char *);
2795
2796
/* events.c */
2797
typedef void (*events_cb)(const char *, struct event_payload *, void *);
2798
struct events_sink *events_add_sink(const char *, events_cb, void *);
2799
void   events_remove_sink(struct events_sink *);
2800
void   events_fire(const char *, struct event_payload *);
2801
void   events_fire_client(const char *, struct client *);
2802
void   events_fire_session(const char *, struct session *);
2803
void   events_fire_window(const char *, struct window *);
2804
void   events_fire_pane(const char *, struct window_pane *);
2805
void   events_fire_winlink(const char *, struct winlink *);
2806
2807
/* format-draw.c */
2808
0
#define FORMAT_DRAW_DEFAULT_COLOURS 0x1
2809
0
#define FORMAT_DRAW_NO_LIST 0x2
2810
void   format_draw(struct screen_write_ctx *, const struct grid_cell *,
2811
       u_int, const char *, struct style_ranges *, int);
2812
u_int  format_draw_lines(struct screen_write_ctx *,
2813
       const struct grid_cell *, u_int, u_int, u_int, const char *,
2814
       struct style_ranges *, int);
2815
u_int  format_width(const char *);
2816
char  *format_trim_left(const char *, u_int);
2817
char  *format_trim_right(const char *, u_int);
2818
2819
/* hooks.c */
2820
void   hooks_add_event(const char *);
2821
int  hooks_is_event(const char *);
2822
int  hooks_valid_event_name(const char *);
2823
void   hooks_build_events(void);
2824
void   hooks_run(struct cmdq_item *, const char *);
2825
void   hooks_monitor_add(struct cmdq_item *, struct options *,
2826
      const char *, enum monitor_type, int, const char *,
2827
      int, struct cmd_find_state *, struct session *);
2828
void   hooks_monitor_remove(struct options *, const char *);
2829
void   hooks_monitor_free(void *);
2830
char  *hooks_monitor_to_string(struct options_entry *);
2831
int  hooks_monitor_get(struct options_entry *, enum monitor_type *, int *,
2832
       const char **);
2833
u_int  hooks_monitor_get_fire_count(struct options_entry *);
2834
time_t   hooks_monitor_get_fire_time(struct options_entry *);
2835
2836
/* options.c */
2837
struct options  *options_create(struct options *);
2838
void     options_free(struct options *);
2839
struct options  *options_get_parent(struct options *);
2840
void     options_set_parent(struct options *, struct options *);
2841
struct options_entry *options_first(struct options *);
2842
struct options_entry *options_next(struct options_entry *);
2843
struct options_entry *options_empty(struct options *,
2844
         const struct options_table_entry *);
2845
struct options_entry *options_default(struct options *,
2846
         const struct options_table_entry *);
2847
char    *options_default_to_string(const struct options_table_entry *);
2848
const char  *options_name(struct options_entry *);
2849
struct options  *options_owner(struct options_entry *);
2850
void    *options_get_monitor_data(struct options_entry *);
2851
void     options_set_monitor_data(struct options_entry *, void *);
2852
void     options_hook_fired(struct options_entry *);
2853
u_int    options_get_fire_count(struct options_entry *);
2854
time_t     options_get_fire_time(struct options_entry *);
2855
const struct options_table_entry *options_table_entry(struct options_entry *);
2856
struct options_entry *options_get_only(struct options *, const char *);
2857
struct options_entry *options_get(struct options *, const char *);
2858
void     options_array_clear(struct options_entry *);
2859
union options_value *options_array_get(struct options_entry *, const char *);
2860
union options_value * printflike(2, 3) options_array_getv(
2861
         struct options_entry *, const char *, ...);
2862
int    options_array_set(struct options_entry *, const char *,
2863
         const char *, int, char **);
2864
int    options_array_assign(struct options_entry *, const char *,
2865
         char **);
2866
struct options_array_item *options_array_first(struct options_entry *);
2867
struct options_array_item *options_array_next(struct options_array_item *);
2868
const char  *options_array_item_key(struct options_array_item *);
2869
union options_value *options_array_item_value(struct options_array_item *);
2870
int    options_is_array(struct options_entry *);
2871
int    options_is_string(struct options_entry *);
2872
char    *options_to_string(struct options_entry *, const char *, int);
2873
char    *options_parse(const char *, char **);
2874
struct options_entry *options_parse_get(struct options *, const char *,
2875
         char **, int);
2876
const struct options_table_entry *options_search(const char *);
2877
char    *options_match(const char *, char **, int *);
2878
struct options_entry *options_match_get(struct options *, const char *,
2879
         char **, int, int *);
2880
const char  *options_get_string(struct options *, const char *);
2881
long long  options_get_number(struct options *, const char *);
2882
struct cmd_list *options_get_command(struct options *, const char *);
2883
struct options_entry * printflike(4, 5) options_set_string(struct options *,
2884
         const char *, int, const char *, ...);
2885
struct options_entry *options_set_number(struct options *, const char *,
2886
         long long);
2887
struct options_entry *options_set_command(struct options *, const char *,
2888
         struct cmd_list *);
2889
int    options_scope_from_name(struct args *, int,
2890
         const char *, struct cmd_find_state *, struct options **,
2891
         char **);
2892
int    options_scope_from_flags(struct args *, int,
2893
         struct cmd_find_state *, struct options **, char **);
2894
struct style  *options_string_to_style(struct options *, const char *,
2895
         struct format_tree *);
2896
int    options_from_string(struct options *,
2897
         const struct options_table_entry *, const char *,
2898
         const char *, int, char **);
2899
int    options_find_choice(const struct options_table_entry *,
2900
         const char *, char **);
2901
void     options_push_changes(const char *);
2902
int    options_remove_or_default(struct options_entry *, const char *,
2903
         char **);
2904
2905
/* options-table.c */
2906
extern const struct options_table_entry options_table[];
2907
extern const struct options_name_map  options_other_names[];
2908
2909
/* job.c */
2910
typedef void (*job_update_cb) (struct job *);
2911
typedef void (*job_complete_cb) (struct job *);
2912
typedef void (*job_free_cb) (void *);
2913
0
#define JOB_NOWAIT 0x1
2914
0
#define JOB_KEEPWRITE 0x2
2915
0
#define JOB_PTY 0x4
2916
0
#define JOB_DEFAULTSHELL 0x8
2917
0
#define JOB_SHOWSTDERR 0x10
2918
struct job  *job_run(const char *, int, char **, struct environ *,
2919
         struct session *, const char *, job_update_cb,
2920
         job_complete_cb, job_free_cb, void *, int, int, int);
2921
void     job_free(struct job *);
2922
int    job_transfer(struct job *, pid_t *, char *, size_t);
2923
void     job_resize(struct job *, u_int, u_int);
2924
void     job_check_died(pid_t, int);
2925
int    job_get_status(struct job *);
2926
void    *job_get_data(struct job *);
2927
struct bufferevent *job_get_event(struct job *);
2928
void     job_kill_all(void);
2929
int    job_still_running(void);
2930
void     job_print_summary(struct cmdq_item *, int);
2931
2932
/* environ.c */
2933
struct environ *environ_create(void);
2934
void  environ_free(struct environ *);
2935
struct environ_entry *environ_first(struct environ *);
2936
struct environ_entry *environ_next(struct environ_entry *);
2937
void  environ_copy(struct environ *, struct environ *);
2938
struct environ_entry *environ_find(struct environ *, const char *);
2939
void printflike(4, 5) environ_set(struct environ *, const char *, int,
2940
      const char *, ...);
2941
void  environ_clear(struct environ *, const char *);
2942
void  environ_put(struct environ *, const char *, int);
2943
void  environ_unset(struct environ *, const char *);
2944
void  environ_update(struct options *, struct environ *, struct environ *);
2945
void  environ_push(struct environ *);
2946
void printflike(2, 3) environ_log(struct environ *, const char *, ...);
2947
struct environ *environ_for_session(struct session *, int);
2948
2949
/* tty-draw.c */
2950
void  tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int,
2951
      u_int, u_int, const struct tty_style_ctx *);
2952
2953
/* tty.c */
2954
void  tty_create_log(void);
2955
int tty_window_bigger(struct tty *);
2956
int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *);
2957
void  tty_update_window_offset(struct window *);
2958
void  tty_update_client_offset(struct client *);
2959
void  tty_raw(struct tty *, const char *);
2960
void  tty_attributes(struct tty *, const struct grid_cell *,
2961
      const struct tty_style_ctx *);
2962
void  tty_reset(struct tty *);
2963
void  tty_region_off(struct tty *);
2964
void  tty_margin_off(struct tty *);
2965
void  tty_cursor(struct tty *, u_int, u_int);
2966
int tty_fake_bce(const struct tty *, const struct grid_cell *, u_int);
2967
void  tty_repeat_space(struct tty *, u_int);
2968
void  tty_clipboard_query(struct tty *);
2969
void  tty_putcode(struct tty *, enum tty_code_code);
2970
void  tty_putcode_i(struct tty *, enum tty_code_code, int);
2971
void  tty_putcode_ii(struct tty *, enum tty_code_code, int, int);
2972
void  tty_putcode_iii(struct tty *, enum tty_code_code, int, int, int);
2973
void  tty_putcode_s(struct tty *, enum tty_code_code, const char *);
2974
void  tty_putcode_ss(struct tty *, enum tty_code_code, const char *,
2975
      const char *);
2976
void  tty_puts(struct tty *, const char *);
2977
void  tty_putc(struct tty *, u_char);
2978
void  tty_putn(struct tty *, const void *, size_t, u_int);
2979
void  tty_cell(struct tty *, const struct grid_cell *,
2980
      const struct tty_style_ctx *);
2981
int tty_init(struct tty *, struct client *);
2982
void  tty_resize(struct tty *);
2983
int tty_set_size(struct tty *, u_int, u_int, u_int, u_int);
2984
void  tty_invalidate(struct tty *);
2985
void  tty_start_tty(struct tty *);
2986
void  tty_send_requests(struct tty *);
2987
void  tty_repeat_requests(struct tty *, int);
2988
void  tty_stop_tty(struct tty *);
2989
void  tty_set_title(struct tty *, const char *);
2990
void  tty_set_path(struct tty *, const char *);
2991
void  tty_set_progress_bar(struct tty *, struct progress_bar *);
2992
void  tty_default_attributes(struct tty *, u_int,
2993
      const struct tty_style_ctx *);
2994
void  tty_update_mode(struct tty *, int, struct screen *);
2995
const struct grid_cell *tty_check_codeset(struct tty *,
2996
      const struct grid_cell *);
2997
void  tty_sync_start(struct tty *);
2998
void  tty_sync_end(struct tty *);
2999
int tty_open(struct tty *, char **);
3000
void  tty_close(struct tty *);
3001
void  tty_free(struct tty *);
3002
void  tty_update_features(struct tty *);
3003
void  tty_set_selection(struct tty *, const char *, const char *, size_t);
3004
void  tty_write(void (*)(struct tty *, const struct tty_ctx *),
3005
      struct tty_ctx *);
3006
void  tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
3007
void  tty_cmd_cell(struct tty *, const struct tty_ctx *);
3008
void  tty_cmd_cells(struct tty *, const struct tty_ctx *);
3009
void  tty_cmd_redrawline(struct tty *, const struct tty_ctx *);
3010
void  tty_cmd_clearendofline(struct tty *, const struct tty_ctx *);
3011
void  tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *);
3012
void  tty_cmd_clearline(struct tty *, const struct tty_ctx *);
3013
void  tty_cmd_clearscreen(struct tty *, const struct tty_ctx *);
3014
void  tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *);
3015
void  tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *);
3016
void  tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *);
3017
void  tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *);
3018
void  tty_cmd_deleteline(struct tty *, const struct tty_ctx *);
3019
void  tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *);
3020
void  tty_cmd_insertline(struct tty *, const struct tty_ctx *);
3021
void  tty_cmd_linefeed(struct tty *, const struct tty_ctx *);
3022
void  tty_cmd_scrollup(struct tty *, const struct tty_ctx *);
3023
void  tty_cmd_scrolldown(struct tty *, const struct tty_ctx *);
3024
void  tty_cmd_reverseindex(struct tty *, const struct tty_ctx *);
3025
void  tty_cmd_setselection(struct tty *, const struct tty_ctx *);
3026
void  tty_cmd_rawstring(struct tty *, const struct tty_ctx *);
3027
void  tty_cmd_syncstart(struct tty *, const struct tty_ctx *);
3028
void  tty_default_colours(struct grid_cell *, struct window_pane *, u_int *);
3029
3030
/* tty-term.c */
3031
extern struct tty_terms tty_terms;
3032
u_int    tty_term_ncodes(void);
3033
void     tty_term_apply(struct tty_term *, const char *, int, int);
3034
void     tty_term_apply_overrides(struct tty_term *);
3035
struct tty_term *tty_term_create(struct tty *, char *, char **, u_int, char **);
3036
void     tty_term_free(struct tty_term *);
3037
int    tty_term_read_list(const char *, int, char ***, u_int *,
3038
         char **);
3039
void     tty_term_free_list(char **, u_int);
3040
int    tty_term_has(struct tty_term *, enum tty_code_code);
3041
int    tty_term_has_name(struct tty_term *, const char *);
3042
const char  *tty_term_string(struct tty_term *, enum tty_code_code);
3043
const char  *tty_term_string_i(struct tty_term *, enum tty_code_code, int);
3044
const char  *tty_term_string_ii(struct tty_term *, enum tty_code_code, int,
3045
         int);
3046
const char  *tty_term_string_iii(struct tty_term *, enum tty_code_code, int,
3047
         int, int);
3048
const char  *tty_term_string_s(struct tty_term *, enum tty_code_code,
3049
         const char *);
3050
const char  *tty_term_string_ss(struct tty_term *, enum tty_code_code,
3051
         const char *, const char *);
3052
int    tty_term_number(struct tty_term *, enum tty_code_code);
3053
int    tty_term_flag(struct tty_term *, enum tty_code_code);
3054
const char  *tty_term_describe(struct tty_term *, enum tty_code_code);
3055
3056
/* tty-features.c */
3057
void     tty_parse_client_features(struct client *, const char *,
3058
         const char *);
3059
void     tty_parse_features(const char *, const char *, int *, int *);
3060
const char  *tty_get_features(int);
3061
int    tty_feature_present(struct tty_term *, const char *);
3062
int    tty_apply_features(struct tty_term *);
3063
void     tty_default_features(struct client *, const char *, u_int);
3064
3065
/* tty-acs.c */
3066
int    tty_acs_needed(struct tty *);
3067
const char  *tty_acs_get(struct tty *, u_char);
3068
int    tty_acs_reverse_get(struct tty *, const char *, size_t);
3069
const struct utf8_data *tty_acs_double_borders(int);
3070
const struct utf8_data *tty_acs_heavy_borders(int);
3071
const struct utf8_data *tty_acs_rounded_borders(int);
3072
3073
/* tty-keys.c */
3074
void    tty_keys_build(struct tty *);
3075
void    tty_keys_free(struct tty *);
3076
int   tty_keys_next(struct tty *);
3077
int   tty_keys_colours(struct tty *, const char *, size_t, size_t *,
3078
         int *, int *);
3079
3080
/* arguments.c */
3081
void     args_set(struct args *, u_char, struct args_value *, int);
3082
struct args   *args_create(void);
3083
struct args *args_parse(const struct args_parse *, struct args_value *,
3084
         u_int, char **);
3085
struct args *args_copy(struct args *, int, char **);
3086
void     args_to_vector(struct args *, int *, char ***);
3087
struct args_value *args_from_vector(int, char **);
3088
void     args_free_value(struct args_value *);
3089
void     args_free_values(struct args_value *, u_int);
3090
void     args_free(struct args *);
3091
char    *args_print(struct args *);
3092
char    *args_escape(const char *);
3093
int    args_has(struct args *, u_char);
3094
const char  *args_get(struct args *, u_char);
3095
u_char     args_first(struct args *, struct args_entry **);
3096
u_char     args_next(struct args_entry **);
3097
u_int    args_count(struct args *);
3098
struct args_value *args_values(struct args *);
3099
struct args_value *args_value(struct args *, u_int);
3100
const char  *args_string(struct args *, u_int);
3101
struct cmd_list *args_make_commands_now(struct cmd *, struct cmdq_item *,
3102
         u_int, int);
3103
struct args_command_state *args_make_commands_prepare(struct cmd *,
3104
         struct cmdq_item *, u_int, const char *, int, int);
3105
struct cmd_list *args_make_commands(struct args_command_state *, int, char **,
3106
         char **);
3107
void     args_make_commands_free(struct args_command_state *);
3108
char    *args_make_commands_get_command(struct args_command_state *);
3109
struct args_value *args_first_value(struct args *, u_char);
3110
struct args_value *args_next_value(struct args_value *);
3111
long long  args_strtonum(struct args *, u_char, long long, long long,
3112
         char **);
3113
long long  args_strtonum_and_expand(struct args *, u_char, long long,
3114
         long long, struct cmdq_item *, char **);
3115
long long  args_percentage(struct args *, u_char, long long,
3116
         long long, long long, char **);
3117
long long  args_string_percentage(const char *, long long, long long,
3118
         long long, char **);
3119
long long  args_percentage_and_expand(struct args *, u_char, long long,
3120
         long long, long long, struct cmdq_item *, char **);
3121
long long  args_string_percentage_and_expand(const char *, long long,
3122
         long long, long long, struct cmdq_item *, char **);
3123
3124
/* cmd-find.c */
3125
int    cmd_find_target(struct cmd_find_state *, struct cmdq_item *,
3126
         const char *, enum cmd_find_type, int);
3127
struct client *cmd_find_best_client(struct session *);
3128
struct client *cmd_find_client(struct cmdq_item *, const char *, int);
3129
void     cmd_find_clear_state(struct cmd_find_state *, int);
3130
int    cmd_find_empty_state(struct cmd_find_state *);
3131
int    cmd_find_valid_state(struct cmd_find_state *);
3132
void     cmd_find_copy_state(struct cmd_find_state *,
3133
         struct cmd_find_state *);
3134
void     cmd_find_from_session(struct cmd_find_state *,
3135
         struct session *, int);
3136
void     cmd_find_from_winlink(struct cmd_find_state *,
3137
         struct winlink *, int);
3138
int    cmd_find_from_session_window(struct cmd_find_state *,
3139
         struct session *, struct window *, int);
3140
int    cmd_find_from_window(struct cmd_find_state *, struct window *,
3141
         int);
3142
void     cmd_find_from_winlink_pane(struct cmd_find_state *,
3143
         struct winlink *, struct window_pane *, int);
3144
int    cmd_find_from_pane(struct cmd_find_state *,
3145
         struct window_pane *, int);
3146
int    cmd_find_from_client(struct cmd_find_state *, struct client *,
3147
         int);
3148
int    cmd_find_from_mouse(struct cmd_find_state *,
3149
         struct mouse_event *, int);
3150
int    cmd_find_from_nothing(struct cmd_find_state *, int);
3151
3152
/* cmd.c */
3153
extern const struct cmd_entry *cmd_table[];
3154
const struct cmd_entry *cmd_find(const char *, char **);
3155
void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...);
3156
void     cmd_prepend_argv(int *, char ***, const char *);
3157
void     cmd_append_argv(int *, char ***, const char *);
3158
int    cmd_pack_argv(int, char **, char *, size_t);
3159
int    cmd_unpack_argv(char *, size_t, int, char ***);
3160
char         **cmd_copy_argv(int, char **);
3161
void     cmd_free_argv(int, char **);
3162
char    *cmd_stringify_argv(int, char **);
3163
char    *cmd_get_alias(const char *);
3164
const struct cmd_entry *cmd_get_entry(struct cmd *);
3165
struct args *cmd_get_args(struct cmd *);
3166
u_int    cmd_get_group(struct cmd *);
3167
void     cmd_get_source(struct cmd *, const char **, u_int *);
3168
int    cmd_get_parse_flags(struct cmd *);
3169
struct cmd  *cmd_parse(struct args_value *, u_int, const char *, u_int, int,
3170
         char **);
3171
struct cmd  *cmd_copy(struct cmd *, int, char **);
3172
void     cmd_free(struct cmd *);
3173
char    *cmd_print(struct cmd *);
3174
struct cmd_list *cmd_list_new(void);
3175
struct cmd_list *cmd_list_copy(const struct cmd_list *, int, char **);
3176
void     cmd_list_append(struct cmd_list *, struct cmd *);
3177
void     cmd_list_append_all(struct cmd_list *, struct cmd_list *);
3178
void     cmd_list_move(struct cmd_list *, struct cmd_list *);
3179
void     cmd_list_free(struct cmd_list *);
3180
7.65k
#define CMD_LIST_PRINT_ESCAPED 0x1
3181
7.65k
#define CMD_LIST_PRINT_NO_GROUPS 0x2
3182
char    *cmd_list_print(const struct cmd_list *, int);
3183
struct cmd  *cmd_list_first(struct cmd_list *);
3184
struct cmd  *cmd_list_next(struct cmd *);
3185
int    cmd_list_all_have(struct cmd_list *, int);
3186
int    cmd_list_any_have(struct cmd_list *, int);
3187
int    cmd_mouse_at(struct window_pane *, struct mouse_event *,
3188
         u_int *, u_int *, int);
3189
struct winlink  *cmd_mouse_window(struct mouse_event *, struct session **);
3190
struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **,
3191
         struct winlink **);
3192
char    *cmd_template_replace(const char *, const char *, int);
3193
3194
/* cmd-attach-session.c */
3195
enum cmd_retval  cmd_attach_session(struct cmdq_item *, const char *, int, int,
3196
         int, const char *, int, const char *);
3197
3198
/* cmd-parse.c */
3199
struct cmd_parse_result *cmd_parse_from_file(FILE *, struct cmd_parse_input *);
3200
struct cmd_parse_result *cmd_parse_from_string(const char *,
3201
         struct cmd_parse_input *);
3202
enum cmd_parse_status cmd_parse_and_insert(const char *,
3203
         struct cmd_parse_input *, struct cmdq_item *,
3204
         struct cmdq_state *, char **);
3205
enum cmd_parse_status cmd_parse_and_append(const char *,
3206
         struct cmd_parse_input *, struct client *,
3207
         struct cmdq_state *, char **);
3208
struct cmd_parse_result *cmd_parse_from_buffer(const void *, size_t,
3209
         struct cmd_parse_input *);
3210
struct cmd_parse_result *cmd_parse_from_arguments(struct args_value *, u_int,
3211
         struct cmd_parse_input *);
3212
3213
/* cmd-queue.c */
3214
struct cmdq_state *cmdq_new_state(struct cmd_find_state *, struct key_event *,
3215
         int);
3216
struct cmdq_state *cmdq_link_state(struct cmdq_state *);
3217
struct cmdq_state *cmdq_copy_state(struct cmdq_state *,
3218
         struct cmd_find_state *);
3219
void      cmdq_free_state(struct cmdq_state *);
3220
void printflike(3, 4) cmdq_add_format(struct cmdq_state *, const char *,
3221
         const char *, ...);
3222
void      cmdq_add_formats(struct cmdq_state *, struct format_tree *);
3223
void      cmdq_merge_formats(struct cmdq_item *, struct format_tree *);
3224
struct cmdq_list *cmdq_new(void);
3225
void cmdq_free(struct cmdq_list *);
3226
const char   *cmdq_get_name(struct cmdq_item *);
3227
struct cmd   *cmdq_get_cmd(struct cmdq_item *);
3228
struct client  *cmdq_get_client(struct cmdq_item *);
3229
struct client  *cmdq_get_target_client(struct cmdq_item *);
3230
struct cmdq_state *cmdq_get_state(struct cmdq_item *);
3231
struct cmd_find_state *cmdq_get_target(struct cmdq_item *);
3232
struct cmd_find_state *cmdq_get_source(struct cmdq_item *);
3233
struct key_event *cmdq_get_event(struct cmdq_item *);
3234
struct cmd_find_state *cmdq_get_current(struct cmdq_item *);
3235
int     cmdq_get_flags(struct cmdq_item *);
3236
struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmdq_state *);
3237
0
#define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data)
3238
struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *);
3239
struct cmdq_item *cmdq_get_error(const char *);
3240
struct cmdq_item *cmdq_insert_after(struct cmdq_item *, struct cmdq_item *);
3241
struct cmdq_item *cmdq_append(struct client *, struct cmdq_item *);
3242
void printflike(4, 5) cmdq_insert_hook(struct session *, struct cmdq_item *,
3243
         struct cmd_find_state *, const char *, ...);
3244
void     cmdq_continue(struct cmdq_item *);
3245
u_int    cmdq_next(struct client *);
3246
struct cmdq_item *cmdq_running(struct client *);
3247
void     cmdq_guard(struct cmdq_item *, const char *, int);
3248
void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...);
3249
void     cmdq_print_data(struct cmdq_item *, struct evbuffer *);
3250
void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...);
3251
3252
/* cmd-wait-for.c */
3253
void  cmd_wait_for_client_lost(struct client *);
3254
void  cmd_wait_for_flush(void);
3255
3256
/* client.c */
3257
int client_main(struct event_base *, int, char **, uint64_t, int);
3258
3259
/* key-bindings.c */
3260
struct key_table *key_bindings_get_table(const char *, int);
3261
struct key_table *key_bindings_first_table(void);
3262
struct key_table *key_bindings_next_table(struct key_table *);
3263
void   key_bindings_unref_table(struct key_table *);
3264
struct key_binding *key_bindings_get(struct key_table *, key_code);
3265
struct key_binding *key_bindings_get_default(struct key_table *, key_code);
3266
struct key_binding *key_bindings_first(struct key_table *);
3267
struct key_binding *key_bindings_next(struct key_table *, struct key_binding *);
3268
void   key_bindings_add(const char *, key_code, const char *, int,
3269
       struct cmd_list *);
3270
void   key_bindings_remove(const char *, key_code);
3271
void   key_bindings_reset(const char *, key_code);
3272
void   key_bindings_remove_table(const char *);
3273
void   key_bindings_reset_table(const char *);
3274
void   key_bindings_init(void);
3275
int  key_bindings_has_repeat(struct key_binding **, u_int);
3276
struct cmdq_item *key_bindings_dispatch(struct key_binding *,
3277
       struct cmdq_item *, struct client *, struct key_event *,
3278
       struct cmd_find_state *);
3279
3280
/* key-string.c */
3281
key_code   key_string_lookup_string(const char *);
3282
const char  *key_string_lookup_key(key_code, int);
3283
3284
/* alerts.c */
3285
void  alerts_reset_all(void);
3286
void  alerts_queue(struct window *, int);
3287
void  alerts_check_session(struct session *);
3288
3289
/* file.c */
3290
int  file_cmp(struct client_file *, struct client_file *);
3291
RB_PROTOTYPE(client_files, client_file, entry, file_cmp);
3292
struct client_file *file_create_with_peer(struct tmuxpeer *,
3293
      struct client_files *, int, client_file_cb, void *);
3294
struct client_file *file_create_with_client(struct client *, int,
3295
      client_file_cb, void *);
3296
void   file_free(struct client_file *);
3297
void   file_fire_done(struct client_file *);
3298
void   file_fire_read(struct client_file *);
3299
int  file_can_print(struct client *);
3300
void printflike(2, 3) file_print(struct client *, const char *, ...);
3301
void printflike(2, 0) file_vprint(struct client *, const char *, va_list);
3302
void   file_print_buffer(struct client *, void *, size_t);
3303
void printflike(2, 3) file_error(struct client *, const char *, ...);
3304
void   file_write(struct client *, const char *, int, const void *, size_t,
3305
       client_file_cb, void *);
3306
struct client_file *file_read(struct client *, const char *, client_file_cb,
3307
       void *);
3308
void   file_cancel(struct client_file *);
3309
void   file_push(struct client_file *);
3310
int  file_write_left(struct client_files *);
3311
void   file_write_open(struct client_files *, struct tmuxpeer *,
3312
       struct imsg *, int, int, client_file_cb, void *);
3313
void   file_write_data(struct client_files *, struct imsg *);
3314
void   file_write_close(struct client_files *, struct imsg *);
3315
void   file_read_open(struct client_files *, struct tmuxpeer *, struct imsg *,
3316
       int, int, client_file_cb, void *);
3317
int  file_write_ready(struct client_files *, struct imsg *);
3318
int  file_write_done(struct client_files *, struct imsg *);
3319
int  file_read_data(struct client_files *, struct imsg *);
3320
int  file_read_done(struct client_files *, struct imsg *);
3321
void   file_read_cancel(struct client_files *, struct imsg *);
3322
3323
/* server.c */
3324
extern struct tmuxproc *server_proc;
3325
extern struct clients clients;
3326
extern struct cmd_find_state marked_pane;
3327
extern struct message_list message_log;
3328
extern time_t current_time;
3329
void   server_set_marked(struct session *, struct winlink *,
3330
       struct window_pane *);
3331
void   server_clear_marked(void);
3332
int  server_is_marked(struct session *, struct winlink *,
3333
       struct window_pane *);
3334
int  server_check_marked(void);
3335
int  server_start(struct tmuxproc *, uint64_t, struct event_base *, int,
3336
       char *);
3337
void   server_update_socket(void);
3338
void   server_add_accept(int);
3339
void printflike(1, 2) server_add_message(const char *, ...);
3340
int  server_create_socket(uint64_t, char **);
3341
3342
/* server-client.c */
3343
u_int  server_client_how_many(void);
3344
void   server_client_ensure_ranges(struct visible_ranges *, u_int);
3345
int  server_client_ranges_is_empty(struct visible_ranges *);
3346
void   server_client_set_key_table(struct client *, const char *);
3347
const char *server_client_get_key_table(struct client *);
3348
int  server_client_check_nested(struct client *);
3349
int  server_client_handle_key(struct client *, struct key_event *);
3350
int  server_client_handle_key_after(struct client *, struct key_event *,
3351
       struct cmdq_item *, struct cmdq_item **);
3352
struct client *server_client_create(int);
3353
int  server_client_open(struct client *, char **);
3354
void   server_client_unref(struct client *);
3355
void   server_client_set_session(struct client *, struct session *);
3356
void   server_client_lost(struct client *);
3357
void   server_client_suspend(struct client *);
3358
void   server_client_detach(struct client *, enum msgtype);
3359
void   server_client_exec(struct client *, const char *);
3360
void   server_client_loop(void);
3361
const char *server_client_get_cwd(struct client *, struct session *);
3362
void   server_client_set_flags(struct client *, const char *);
3363
const char *server_client_get_flags(struct client *);
3364
void   server_client_remove_pane(struct window_pane *);
3365
void   server_client_print(struct client *, int, struct evbuffer *);
3366
3367
/* server-fn.c */
3368
void   server_redraw_client(struct client *);
3369
void   server_client_update_theme_colours(struct client *);
3370
void   server_status_client(struct client *);
3371
void   server_redraw_session(struct session *);
3372
void   server_redraw_session_group(struct session *);
3373
void   server_status_session(struct session *);
3374
void   server_status_session_group(struct session *);
3375
void   server_redraw_window(struct window *);
3376
void   server_redraw_window_menu(struct window *);
3377
void   server_redraw_window_borders(struct window *);
3378
void   server_status_window(struct window *);
3379
void   server_lock(void);
3380
void   server_lock_session(struct session *);
3381
void   server_lock_client(struct client *);
3382
void   server_kill_pane(struct window_pane *);
3383
void   server_kill_window(struct window *, int);
3384
void   server_renumber_session(struct session *);
3385
void   server_renumber_all(void);
3386
int  server_link_window(struct session *,
3387
       struct winlink *, struct session *, int, int, int, char **);
3388
void   server_unlink_window(struct session *, struct winlink *);
3389
void   server_destroy_pane(struct window_pane *, int);
3390
void   server_destroy_session(struct session *);
3391
void   server_check_unattached(void);
3392
void   server_unzoom_window(struct window *);
3393
3394
/* status.c */
3395
void   status_timer_start(struct client *);
3396
void   status_timer_start_all(void);
3397
void   status_update_cache(struct session *);
3398
u_int  status_prompt_line_at(struct client *);
3399
int  status_at_line(struct client *);
3400
u_int  status_line_size(struct client *);
3401
u_int  status_side_size(struct client *);
3402
int  status_side_at_column(struct client *);
3403
u_int  status_side_rows(struct client *);
3404
void   status_side_init(struct client *);
3405
void   status_side_free(struct client *);
3406
int  status_side_redraw(struct client *);
3407
struct style_range *status_side_get_range(struct client *, u_int, u_int);
3408
struct style_range *status_get_range(struct client *, u_int, u_int);
3409
void   status_init(struct client *);
3410
void   status_free(struct client *);
3411
int  status_redraw(struct client *);
3412
void printflike(6, 7) status_message_set(struct client *, int, int, int, int,
3413
       const char *, ...);
3414
void   status_message_clear(struct client *);
3415
int  status_message_redraw(struct client *);
3416
void   status_prompt_set(struct client *, struct cmd_find_state *,
3417
       const char *, const char *, status_prompt_input_cb, prompt_free_cb,
3418
       void *, int, enum prompt_type);
3419
void   status_prompt_clear(struct client *);
3420
int  status_prompt_redraw(struct client *);
3421
void   status_prompt_cursor(struct client *, u_int *, u_int *);
3422
enum prompt_key_result status_prompt_key(struct client *, key_code,
3423
       struct mouse_event *);
3424
void   status_prompt_update(struct client *, const char *, const char *);
3425
3426
/* prompt.c */
3427
void   prompt_set_options(struct prompt_create_data *, struct session *);
3428
struct prompt *prompt_create(const struct prompt_create_data *);
3429
void   prompt_free(struct prompt *);
3430
void   prompt_incremental_start(struct prompt *);
3431
void   prompt_draw(struct prompt *, struct prompt_draw_data *);
3432
enum prompt_key_result prompt_key(struct prompt *, key_code, int *);
3433
enum prompt_key_result prompt_mouse(struct prompt *, u_int, u_int, u_int,
3434
       int *);
3435
void   prompt_update(struct prompt *, const char *, const char *);
3436
int  prompt_closed(struct prompt *);
3437
enum prompt_type prompt_type(const char *);
3438
const char *prompt_type_string(enum prompt_type);
3439
3440
/* prompt-history.c */
3441
const char *prompt_up_history(u_int *, u_int);
3442
const char *prompt_down_history(u_int *, u_int);
3443
void   prompt_add_history(const char *, u_int);
3444
u_int  prompt_history_size(enum prompt_type);
3445
const char *prompt_history_get(enum prompt_type, u_int);
3446
void   prompt_history_clear(enum prompt_type);
3447
void   prompt_load_history(void);
3448
void   prompt_save_history(void);
3449
3450
/* resize.c */
3451
void   resize_window(struct window *, u_int, u_int, int, int);
3452
void   default_window_size(struct client *, struct session *, struct window *,
3453
       u_int *, u_int *, u_int *, u_int *, int);
3454
void   recalculate_size(struct window *, int);
3455
void   recalculate_sizes(void);
3456
void   recalculate_sizes_now(int);
3457
3458
/* input.c */
3459
#define INPUT_BUF_DEFAULT_SIZE 1048576
3460
struct input_ctx *input_init(struct window_pane *, struct bufferevent *,
3461
       struct colour_palette *);
3462
void   input_free(struct input_ctx *);
3463
void   input_reset(struct input_ctx *, int);
3464
struct evbuffer *input_pending(struct input_ctx *);
3465
void   input_parse_pane(struct window_pane *);
3466
void   input_parse_buffer(struct window_pane *, const u_char *, size_t);
3467
void   input_parse_screen(struct input_ctx *, struct screen *,
3468
       screen_write_init_ctx_cb, void *, const u_char *, size_t);
3469
void   input_reply(struct input_ctx *, int, const char *,
3470
       ...) printflike(3, 4);
3471
void   input_reply_clipboard(struct bufferevent *, const char *, size_t,
3472
       const char *, char);
3473
void   input_set_buffer_size(size_t);
3474
void   input_request_reply(struct client *, enum input_request_type, void *);
3475
void   input_cancel_requests(struct client *);
3476
3477
/* input-key.c */
3478
void   input_key_build(void);
3479
int  input_key_pane(struct window_pane *, key_code, struct mouse_event *);
3480
int  input_key(struct screen *, struct bufferevent *, key_code);
3481
int  input_key_get_mouse(struct screen *, struct mouse_event *, u_int,
3482
       u_int, const char **, size_t *);
3483
3484
/* colour.c */
3485
int  colour_find_rgb(u_char, u_char, u_char);
3486
int  colour_join_rgb(u_char, u_char, u_char);
3487
void   colour_split_rgb(int, u_char *, u_char *, u_char *);
3488
int  colour_force_rgb(int);
3489
int  colour_dim(int, u_int);
3490
const char *colour_tostring(int);
3491
const char *colour_toescape(struct client *, int, int);
3492
enum client_theme colour_totheme(int);
3493
int  colour_fromstring(const char *);
3494
const char *colour_theme_option(u_int, enum client_theme);
3495
int  colour_theme_terminal_colour(u_int);
3496
int  colour_256toRGB(int);
3497
int  colour_256to16(int);
3498
int  colour_byname(const char *);
3499
int  colour_parseX11(const char *);
3500
void   colour_palette_init(struct colour_palette *);
3501
void   colour_palette_clear(struct colour_palette *);
3502
void   colour_palette_free(struct colour_palette *);
3503
int  colour_palette_get(struct colour_palette *, int);
3504
int  colour_palette_set(struct colour_palette *, int, int);
3505
void   colour_palette_from_option(struct colour_palette *, struct options *);
3506
3507
/* attributes.c */
3508
const char *attributes_tostring(int);
3509
int  attributes_fromstring(const char *);
3510
3511
/* fuzzy.c */
3512
bitstr_t  *fuzzy_match(const char *, const char *, u_int, u_int *);
3513
3514
/* grid.c */
3515
extern const struct grid_cell grid_default_cell;
3516
void   grid_check_is_clear(struct grid *);
3517
void   grid_empty_line(struct grid *, u_int, u_int);
3518
void   grid_set_tab(struct grid_cell *, u_int);
3519
int  grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
3520
int  grid_cells_look_equal(const struct grid_cell *,
3521
       const struct grid_cell *);
3522
struct grid *grid_create(u_int, u_int, u_int);
3523
void   grid_destroy(struct grid *);
3524
void   grid_free_lines(struct grid *, u_int, u_int);
3525
int  grid_compare(struct grid *, struct grid *);
3526
const char *grid_line_flags_string(int);
3527
const char *grid_cell_flags_string(int);
3528
const char *grid_cell_attr_string(int);
3529
time_t   grid_line_time(const struct grid_line *);
3530
void   grid_collect_history(struct grid *, int);
3531
void   grid_remove_history(struct grid *, u_int );
3532
void   grid_scroll_history(struct grid *, u_int);
3533
void   grid_scroll_history_region(struct grid *, u_int, u_int, u_int);
3534
void   grid_clear_history(struct grid *);
3535
const struct grid_line *grid_peek_line(struct grid *, u_int);
3536
void   grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
3537
void   grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
3538
void   grid_set_padding(struct grid *, u_int, u_int, int);
3539
void   grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *,
3540
       const char *, size_t);
3541
struct grid_line *grid_get_line(struct grid *, u_int);
3542
void   grid_adjust_lines(struct grid *, u_int);
3543
void   grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
3544
void   grid_clear_lines(struct grid *, u_int, u_int, u_int);
3545
void   grid_move_lines(struct grid *, u_int, u_int, u_int, u_int);
3546
void   grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int);
3547
char  *grid_string_cells(struct grid *, u_int, u_int, u_int,
3548
       struct grid_cell **, int, struct screen *);
3549
void   grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
3550
       u_int);
3551
void   grid_reflow(struct grid *, u_int);
3552
void   grid_wrap_position(struct grid *, u_int, u_int, u_int *, u_int *);
3553
void   grid_unwrap_position(struct grid *, u_int *, u_int *, u_int, u_int);
3554
u_int  grid_line_length(struct grid *, u_int);
3555
u_int  grid_line_limit(struct grid *, u_int);
3556
int  grid_in_set(struct grid *, u_int, u_int, const char *);
3557
3558
/* grid-reader.c */
3559
void   grid_reader_start(struct grid_reader *, struct grid *, u_int, u_int);
3560
void   grid_reader_get_cursor(struct grid_reader *, u_int *, u_int *);
3561
u_int  grid_reader_line_length(struct grid_reader *);
3562
int  grid_reader_in_set(struct grid_reader *, const char *);
3563
int  grid_reader_output_range(struct grid_reader *, u_int *, u_int *,
3564
         u_int *, u_int *);
3565
void   grid_reader_cursor_right(struct grid_reader *, int, int, int);
3566
void   grid_reader_cursor_left(struct grid_reader *, int);
3567
void   grid_reader_cursor_down(struct grid_reader *);
3568
void   grid_reader_cursor_up(struct grid_reader *);
3569
void   grid_reader_cursor_start_of_line(struct grid_reader *, int);
3570
void   grid_reader_cursor_end_of_line(struct grid_reader *, int, int);
3571
void   grid_reader_cursor_next_word(struct grid_reader *, const char *);
3572
void   grid_reader_cursor_next_word_end(struct grid_reader *, const char *);
3573
void   grid_reader_cursor_previous_word(struct grid_reader *, const char *,
3574
       int, int);
3575
int  grid_reader_cursor_jump(struct grid_reader *,
3576
       const struct utf8_data *);
3577
int  grid_reader_cursor_jump_back(struct grid_reader *,
3578
       const struct utf8_data *);
3579
void   grid_reader_cursor_back_to_indentation(struct grid_reader *);
3580
3581
/* grid-view.c */
3582
void   grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
3583
void   grid_view_set_cell(struct grid *, u_int, u_int,
3584
       const struct grid_cell *);
3585
void   grid_view_set_padding(struct grid *, u_int, u_int, int);
3586
void   grid_view_set_cells(struct grid *, u_int, u_int,
3587
       const struct grid_cell *, const char *, size_t);
3588
void   grid_view_clear_history(struct grid *, u_int);
3589
void   grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
3590
void   grid_view_scroll_region_up(struct grid *, u_int, u_int, u_int);
3591
void   grid_view_scroll_region_down(struct grid *, u_int, u_int, u_int);
3592
void   grid_view_insert_lines(struct grid *, u_int, u_int, u_int);
3593
void   grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int,
3594
       u_int);
3595
void   grid_view_delete_lines(struct grid *, u_int, u_int, u_int);
3596
void   grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int,
3597
       u_int);
3598
void   grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int);
3599
void   grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int);
3600
char  *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
3601
3602
/* screen-write.c */
3603
void   screen_write_make_list(struct screen *);
3604
void   screen_write_free_list(struct screen *);
3605
void   screen_write_start_pane(struct screen_write_ctx *,
3606
       struct window_pane *, struct screen *);
3607
void   screen_write_start(struct screen_write_ctx *, struct screen *);
3608
void   screen_write_start_callback(struct screen_write_ctx *, struct screen *,
3609
       screen_write_init_ctx_cb, void *);
3610
void   screen_write_stop(struct screen_write_ctx *);
3611
void   screen_write_reset(struct screen_write_ctx *);
3612
size_t printflike(1, 2) screen_write_strlen(const char *, ...);
3613
int printflike(7, 8) screen_write_text(struct screen_write_ctx *, u_int, u_int,
3614
       u_int, int, const struct grid_cell *, const char *, ...);
3615
void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
3616
       const struct grid_cell *, const char *, ...);
3617
void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *,
3618
       ssize_t, const struct grid_cell *, const char *, ...);
3619
void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx *, ssize_t,
3620
       const struct grid_cell *, const char *, va_list);
3621
void   screen_write_putc(struct screen_write_ctx *, const struct grid_cell *,
3622
       u_char);
3623
void   screen_write_fast_copy(struct screen_write_ctx *, struct screen *,
3624
       u_int, u_int, u_int, u_int);
3625
void   screen_write_hline(struct screen_write_ctx *, u_int, int, int,
3626
       enum box_lines, const struct grid_cell *);
3627
void   screen_write_vline(struct screen_write_ctx *, u_int, int, int,
3628
       const struct grid_cell *);
3629
void   screen_write_menu(struct screen_write_ctx *, struct menu *, int,
3630
       enum box_lines, const struct grid_cell *, const struct grid_cell *,
3631
       const struct grid_cell *);
3632
void   screen_write_box(struct screen_write_ctx *, u_int, u_int,
3633
             enum box_lines, const struct grid_cell *, const char *);
3634
void   screen_write_preview(struct screen_write_ctx *, struct screen *, u_int,
3635
       u_int);
3636
void   screen_write_backspace(struct screen_write_ctx *);
3637
void   screen_write_mode_set(struct screen_write_ctx *, int);
3638
void   screen_write_mode_clear(struct screen_write_ctx *, int);
3639
void   screen_write_start_sync(struct window_pane *);
3640
void   screen_write_stop_sync(struct window_pane *);
3641
void   screen_write_end_sync(struct screen_write_ctx *);
3642
void   screen_write_sync_clear_dirty(struct window_pane *);
3643
void   screen_write_cursorup(struct screen_write_ctx *, u_int);
3644
void   screen_write_cursordown(struct screen_write_ctx *, u_int);
3645
void   screen_write_cursorright(struct screen_write_ctx *, u_int);
3646
void   screen_write_cursorleft(struct screen_write_ctx *, u_int);
3647
void   screen_write_alignmenttest(struct screen_write_ctx *);
3648
void   screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int);
3649
void   screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int);
3650
void   screen_write_clearcharacter(struct screen_write_ctx *, u_int, u_int);
3651
void   screen_write_insertline(struct screen_write_ctx *, u_int, u_int);
3652
void   screen_write_deleteline(struct screen_write_ctx *, u_int, u_int);
3653
void   screen_write_clearline(struct screen_write_ctx *, u_int);
3654
void   screen_write_clearendofline(struct screen_write_ctx *, u_int);
3655
void   screen_write_clearstartofline(struct screen_write_ctx *, u_int);
3656
void   screen_write_cursormove(struct screen_write_ctx *, int, int, int);
3657
void   screen_write_reverseindex(struct screen_write_ctx *, u_int);
3658
void   screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
3659
void   screen_write_linefeed(struct screen_write_ctx *, int, u_int);
3660
void   screen_write_scrollup(struct screen_write_ctx *, u_int, u_int);
3661
void   screen_write_scrolldown(struct screen_write_ctx *, u_int, u_int);
3662
void   screen_write_carriagereturn(struct screen_write_ctx *);
3663
void   screen_write_clearendofscreen(struct screen_write_ctx *, u_int);
3664
void   screen_write_clearstartofscreen(struct screen_write_ctx *, u_int);
3665
void   screen_write_clearscreen(struct screen_write_ctx *, u_int);
3666
void   screen_write_clearhistory(struct screen_write_ctx *);
3667
void   screen_write_fullredraw(struct screen_write_ctx *);
3668
void   screen_write_collect_end(struct screen_write_ctx *);
3669
void   screen_write_collect_add(struct screen_write_ctx *,
3670
       const struct grid_cell *);
3671
void   screen_write_cell(struct screen_write_ctx *, const struct grid_cell *);
3672
void   screen_write_setselection(struct screen_write_ctx *, const char *,
3673
       u_char *, u_int);
3674
void   screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int,
3675
       int);
3676
void   screen_write_alternateon(struct screen_write_ctx *,
3677
       struct grid_cell *, int);
3678
void   screen_write_alternateoff(struct screen_write_ctx *,
3679
       struct grid_cell *, int);
3680
3681
/* screen-redraw.c */
3682
void   redraw_screen(struct client *);
3683
void   redraw_pane(struct client *, struct window_pane *);
3684
void   redraw_pane_scrollbar(struct client *, struct window_pane *);
3685
void   redraw_free_scene(struct redraw_scene *);
3686
int  redraw_client_has_window(struct client *, struct window *);
3687
void   redraw_invalidate_scene(struct window *);
3688
void   redraw_invalidate_all_scenes(void);
3689
void   redraw_damage_window(struct window *, u_int, u_int, u_int, u_int);
3690
void   redraw_damage_scroll(struct window *, u_int, u_int, u_int, u_int);
3691
void   redraw_scroll_result(struct tty *, const struct tty_ctx *, int);
3692
void   redraw_free_damage(struct window *);
3693
void   redraw_client_damage(struct client *);
3694
int  redraw_get_status_border_cell_type(struct redraw_span **, u_int);
3695
3696
/* screen.c */
3697
void   screen_init(struct screen *, u_int, u_int, u_int);
3698
void   screen_reinit(struct screen *);
3699
void   screen_free(struct screen *);
3700
void   screen_reset_tabs(struct screen *);
3701
void   screen_reset_hyperlinks(struct screen *);
3702
void   screen_set_default_cursor(struct screen *, struct options *);
3703
void   screen_set_cursor_style(u_int, enum screen_cursor_style *, int *);
3704
void   screen_set_cursor_colour(struct screen *, int);
3705
int  screen_set_title(struct screen *, const char *, int);
3706
int  screen_set_path(struct screen *, const char *, int);
3707
void   screen_push_title(struct screen *);
3708
void   screen_pop_title(struct screen *);
3709
void   screen_set_progress_bar(struct screen *, enum progress_bar_state, int);
3710
void   screen_resize(struct screen *, u_int, u_int, int);
3711
void   screen_resize_cursor(struct screen *, u_int, u_int, int, int, int);
3712
void   screen_set_selection(struct screen *, u_int, u_int, u_int, u_int,
3713
       u_int, u_int, int, struct grid_cell *);
3714
void   screen_clear_selection(struct screen *);
3715
void   screen_hide_selection(struct screen *);
3716
int  screen_check_selection(struct screen *, u_int, u_int);
3717
int  screen_select_cell(struct screen *, struct grid_cell *,
3718
       const struct grid_cell *);
3719
int  screen_alternate_on(struct screen *, struct grid_cell *, int);
3720
int  screen_alternate_off(struct screen *, struct grid_cell *, int);
3721
const char *screen_mode_to_string(int);
3722
const char *screen_print(struct screen *, int);
3723
3724
/* window.c */
3725
extern struct windows windows;
3726
extern struct window_pane_tree all_window_panes;
3727
int    window_cmp(struct window *, struct window *);
3728
RB_PROTOTYPE(windows, window, entry, window_cmp);
3729
int    winlink_cmp(struct winlink *, struct winlink *);
3730
RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
3731
int    window_pane_cmp(struct window_pane *, struct window_pane *);
3732
RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp);
3733
struct winlink  *winlink_find_by_index(struct winlinks *, int);
3734
struct winlink  *winlink_find_by_window(struct winlinks *, struct window *);
3735
struct winlink  *winlink_find_by_window_id(struct winlinks *, u_int);
3736
u_int    winlink_count(struct winlinks *);
3737
struct winlink  *winlink_add(struct winlinks *, int);
3738
void     winlink_set_window(struct winlink *, struct window *);
3739
void     winlink_remove(struct winlinks *, struct winlink *);
3740
struct winlink  *winlink_next(struct winlink *);
3741
struct winlink  *winlink_previous(struct winlink *);
3742
struct winlink  *winlink_next_by_number(struct winlink *, struct session *,
3743
         int);
3744
struct winlink  *winlink_previous_by_number(struct winlink *, struct session *,
3745
         int);
3746
void     winlink_stack_push(struct winlink_stack *, struct winlink *);
3747
void     winlink_stack_remove(struct winlink_stack *, struct winlink *);
3748
struct window *window_find_by_id_str(const char *);
3749
struct window *window_find_by_id(u_int);
3750
void     window_update_activity(struct window *);
3751
struct window *window_create(u_int, u_int, u_int, u_int);
3752
void     window_pane_set_event(struct window_pane *);
3753
void     window_pane_utmp_add(struct window_pane *);
3754
void     window_pane_utmp_remove(struct window_pane *);
3755
void     window_pane_wait_finish(struct window_pane *);
3756
struct window_pane *window_get_active_at(struct window *, u_int, u_int);
3757
struct window_pane *window_find_string(struct window *, const char *);
3758
int    window_has_floating_panes(struct window *);
3759
int    window_has_pane(struct window *, struct window_pane *);
3760
int    window_pane_contains(struct window_pane *, u_int, u_int);
3761
int    window_pane_floating_overlaps(struct window_pane *,
3762
         struct window_pane *);
3763
int    window_set_active_pane(struct window *, struct window_pane *,
3764
         int);
3765
void     window_fire_pane_moved(struct window_pane *, struct window *,
3766
         int, struct window *, int);
3767
void     window_update_focus(struct window *);
3768
void     window_pane_update_focus(struct window_pane *);
3769
void     window_redraw_active_switch(struct window *,
3770
         struct window_pane *);
3771
struct window_pane *window_add_pane(struct window *, struct window_pane *,
3772
         u_int, int);
3773
void     window_resize(struct window *, u_int, u_int, int, int);
3774
void     window_pane_send_resize(struct window_pane *, u_int, u_int);
3775
int    window_zoom(struct window_pane *);
3776
int    window_unzoom(struct window *, int);
3777
int    window_active_pane_is_over_zoom(struct window *);
3778
struct window_pane *window_zoomed_pane(struct window *);
3779
int    window_push_zoom(struct window *, int, int);
3780
int    window_pop_zoom(struct window *);
3781
void     window_lost_pane(struct window *, struct window_pane *);
3782
void     window_remove_pane(struct window *, struct window_pane *);
3783
struct window_pane *window_pane_at_index(struct window *, u_int);
3784
struct window_pane *window_pane_next_by_number(struct window *,
3785
      struct window_pane *, u_int);
3786
struct window_pane *window_pane_previous_by_number(struct window *,
3787
      struct window_pane *, u_int);
3788
int    window_pane_index(struct window_pane *, u_int *);
3789
int    window_pane_zindex(struct window_pane *, u_int *);
3790
int    window_pane_last_index(struct window_pane *, u_int *);
3791
u_int    window_count_panes(struct window *, int);
3792
void     window_destroy_panes(struct window *);
3793
struct window_pane *window_pane_find_by_id_str(const char *);
3794
struct window_pane *window_pane_find_by_id(u_int);
3795
int    window_pane_destroy_ready(struct window_pane *);
3796
void     window_pane_resize(struct window_pane *, u_int, u_int);
3797
void     window_pane_clear_resizes(struct window_pane *,
3798
         struct window_pane_resize *);
3799
int    window_pane_set_mode(struct window_pane *,
3800
         struct window_pane *, const struct window_mode *,
3801
         struct cmdq_item *, struct cmd_find_state *, struct args *);
3802
void     window_pane_reset_mode(struct window_pane *);
3803
void     window_pane_reset_mode_all(struct window_pane *);
3804
int    window_pane_key(struct window_pane *, struct client *,
3805
         struct session *, struct winlink *, key_code,
3806
         struct mouse_event *);
3807
void     window_pane_paste(struct window_pane *, key_code, char *,
3808
         size_t);
3809
void     window_pane_set_prompt(struct window_pane *, struct client *,
3810
         struct cmd_find_state *, const char *, const char *,
3811
         status_prompt_input_cb, prompt_free_cb, void *, int,
3812
         enum prompt_type);
3813
void     window_pane_clear_prompt(struct window_pane *);
3814
int    window_pane_has_prompt(struct window_pane *);
3815
void     window_pane_update_prompt(struct window_pane *, const char *,
3816
         const char *);
3817
enum prompt_key_result window_pane_prompt_key(struct window_pane *,
3818
         struct client *, key_code, struct mouse_event *);
3819
int    window_pane_is_visible(struct window_pane *);
3820
int    window_pane_exited(struct window_pane *);
3821
u_int    window_pane_search(struct window_pane *, const char *, int,
3822
         int);
3823
const char  *window_printable_flags(struct winlink *, int);
3824
const char      *window_pane_printable_flags(struct window_pane *);
3825
struct window_pane *window_pane_find_up(struct window_pane *);
3826
struct window_pane *window_pane_find_down(struct window_pane *);
3827
struct window_pane *window_pane_find_left(struct window_pane *);
3828
struct window_pane *window_pane_find_right(struct window_pane *);
3829
void     window_pane_stack_push(struct window_panes *,
3830
         struct window_pane *);
3831
void     window_pane_stack_remove(struct window_panes *,
3832
         struct window_pane *);
3833
void     window_set_name(struct window *, const char *, int);
3834
void     window_add_ref(struct window *, const char *);
3835
void     window_remove_ref(struct window *, const char *);
3836
void     window_pane_add_ref(struct window_pane *, const char *);
3837
void     window_pane_remove_ref(struct window_pane *, const char *);
3838
void     winlink_clear_flags(struct winlink *);
3839
int    winlink_shuffle_up(struct session *, struct winlink *, int);
3840
int    window_pane_start_input(struct window_pane *,
3841
         struct cmdq_item *, char **);
3842
void    *window_pane_get_new_data(struct window_pane *,
3843
         struct window_pane_offset *, size_t *);
3844
void     window_pane_update_used_data(struct window_pane *,
3845
         struct window_pane_offset *, size_t);
3846
void     window_pane_default_cursor(struct window_pane *);
3847
int    window_pane_mode(struct window_pane *);
3848
int    window_pane_show_scrollbar(struct window_pane *);
3849
int    window_pane_scrollbar_reserve(struct window_pane *);
3850
int    window_pane_scrollbar_visible(struct window_pane *);
3851
int    window_pane_scrollbar_overlay(struct window_pane *);
3852
int    window_pane_scrollbar_overlay_visible(struct window_pane *);
3853
void     window_pane_scrollbar_show(struct window_pane *, int);
3854
void     window_pane_scrollbar_hide(struct window_pane *);
3855
void     window_pane_scrollbar_start_timer(struct window_pane *);
3856
void     window_pane_scrollbar_redraw(struct window_pane *);
3857
int    window_pane_get_bg(struct window_pane *);
3858
int    window_pane_get_fg(struct window_pane *);
3859
int    window_pane_get_fg_control_client(struct window_pane *);
3860
int    window_pane_get_bg_control_client(struct window_pane *);
3861
int    window_get_bg_client(struct window_pane *);
3862
enum client_theme window_pane_get_theme(struct window_pane *);
3863
void     window_pane_send_theme_update(struct window_pane *);
3864
enum pane_lines  window_pane_get_pane_lines(struct window_pane *);
3865
enum pane_lines  window_get_pane_lines(struct window *);
3866
int    window_get_pane_status(struct window *);
3867
int    window_pane_get_pane_status(struct window_pane *);
3868
struct style_range *window_pane_status_get_range(struct window_pane *, u_int,
3869
         u_int);
3870
int    window_pane_is_floating(struct window_pane *);
3871
int    window_pane_is_floating_with_hidden(struct window_pane *);
3872
void     window_redraw_floating_pane(struct window_pane *, int, int,
3873
         int, int);
3874
3875
/* window-border.c */
3876
void     window_set_fill_cells(struct window *);
3877
void     window_get_border_cell(struct window_pane *, enum pane_lines,
3878
         int, struct grid_cell *);
3879
void     window_get_fill_cell(struct window *, int, struct grid_cell *);
3880
void     window_pane_get_border_cell(struct window_pane *, int,
3881
         struct grid_cell *);
3882
void     window_pane_get_border_style(struct window_pane *,
3883
         struct client *, struct grid_cell *);
3884
int    window_make_pane_status(struct window_pane *, struct client *,
3885
         u_int, struct redraw_span *);
3886
3887
/* window-visible.c */
3888
int    window_position_is_visible(struct visible_ranges *, u_int);
3889
struct visible_ranges *window_visible_ranges(struct window_pane *, int, int,
3890
         u_int, struct visible_ranges *);
3891
3892
/* layout.c */
3893
u_int    layout_count_cells(struct layout_cell *, int);
3894
struct layout_cell *layout_create_cell(struct layout_cell *);
3895
void     layout_free_cell(struct layout_cell *, int);
3896
void     layout_print_cell(struct layout_cell *, const char *, u_int);
3897
void     layout_destroy_cell(struct window *, struct layout_cell *,
3898
         struct layout_cell **);
3899
void     layout_resize_layout(struct window *, struct layout_cell *,
3900
         enum layout_type, int, int);
3901
struct layout_cell *layout_search_by_border(struct layout_cell *, u_int, u_int);
3902
void     layout_set_size(struct layout_cell *, u_int, u_int, int, int);
3903
void     layout_make_leaf(struct layout_cell *, struct window_pane *);
3904
void     layout_make_node(struct layout_cell *, enum layout_type);
3905
int    layout_cell_is_tiled(struct layout_cell *);
3906
int    layout_cell_has_tiled_child(struct layout_cell *);
3907
int    layout_add_horizontal_border(struct layout_cell *,
3908
         struct layout_cell *, int);
3909
void     layout_fix_offsets(struct window *);
3910
void     layout_fix_panes(struct window *, struct window_pane *);
3911
void     layout_resize_adjust(struct window *, struct layout_cell *,
3912
         enum layout_type, int);
3913
void     layout_resize_set_size(struct window *, struct layout_cell *,
3914
         enum layout_type, u_int);
3915
struct layout_cell *layout_cell_get_neighbour(struct layout_cell *);
3916
void     layout_init(struct window *, struct window_pane *);
3917
void     layout_free(struct window *, int);
3918
void     layout_resize(struct window *, u_int, u_int);
3919
void     layout_resize_pane(struct window_pane *, enum layout_type,
3920
         int, int);
3921
void     layout_resize_pane_to(struct window_pane *, enum layout_type,
3922
         u_int);
3923
int    layout_resize_floating_pane(struct window_pane *,
3924
         enum layout_type, int, int, char **);
3925
int    layout_resize_floating_pane_to(struct window_pane *,
3926
         enum layout_type, u_int, char **);
3927
void     layout_assign_pane(struct layout_cell *, struct window_pane *,
3928
         int);
3929
int    layout_split_check_space(struct window_pane *,
3930
         struct layout_cell *, enum layout_type);
3931
void     layout_split_sizes(struct layout_cell *, int, int,
3932
         enum layout_type, u_int *, u_int *, u_int *);
3933
struct layout_cell *layout_replace_with_node(struct window *,
3934
         struct layout_cell *, enum layout_type);
3935
struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type,
3936
         int, int);
3937
struct layout_cell *layout_floating_pane(struct window *, struct window_pane *,
3938
         struct layout_geometry *);
3939
void     layout_close_pane(struct window_pane *);
3940
int    layout_spread_cell(struct window *, struct layout_cell *);
3941
void     layout_spread_out(struct window_pane *);
3942
struct layout_cell *layout_get_tiled_cell(struct cmdq_item *, struct args *,
3943
         struct window *, struct window_pane *, int, char **);
3944
struct layout_cell *layout_get_floating_cell(struct cmdq_item *, struct args *,
3945
         enum pane_lines, struct window *, struct window_pane *,
3946
         int, char **);
3947
int    layout_floating_args_parse(struct cmdq_item *, struct args *,
3948
         enum pane_lines, struct window *, struct layout_geometry *,
3949
         char **);
3950
int    layout_split_floating_cell(struct layout_cell *,
3951
         struct window *, struct layout_geometry *, enum pane_lines,
3952
         int, char **);
3953
int    layout_remove_tile(struct window *, struct layout_cell *);
3954
int    layout_insert_tile(struct window *, struct layout_cell *);
3955
3956
/* layout-custom.c */
3957
0
#define LAYOUT_CUSTOM_OLD_FORMAT 0x1
3958
char    *layout_dump(struct window *, struct layout_cell *, int);
3959
int    layout_parse(struct window *, const char *, char **);
3960
3961
/* layout-set.c */
3962
int    layout_set_lookup(const char *);
3963
u_int    layout_set_select(struct window *, u_int);
3964
u_int    layout_set_next(struct window *);
3965
u_int    layout_set_previous(struct window *);
3966
3967
/* mode-tree.c */
3968
typedef void (*mode_tree_build_cb)(void *, struct sort_criteria *,
3969
           uint64_t *, const char *);
3970
typedef void (*mode_tree_draw_cb)(void *, void *, struct screen_write_ctx *,
3971
       u_int, u_int);
3972
typedef int (*mode_tree_search_cb)(void *, void *, const char *, int);
3973
typedef void (*mode_tree_menu_cb)(void *, struct client *, key_code);
3974
typedef u_int (*mode_tree_height_cb)(void *, u_int);
3975
typedef key_code (*mode_tree_key_cb)(void *, void *, u_int);
3976
typedef int (*mode_tree_swap_cb)(void *, void *, struct sort_criteria *);
3977
typedef void (*mode_tree_sort_cb)(struct sort_criteria *);
3978
typedef void (*mode_tree_each_cb)(void *, void *, struct client *, key_code);
3979
typedef const char** (*mode_tree_help_cb)(u_int *, const char**);
3980
u_int  mode_tree_count_tagged(struct mode_tree_data *);
3981
void  *mode_tree_get_current(struct mode_tree_data *);
3982
const char *mode_tree_get_current_name(struct mode_tree_data *);
3983
void   mode_tree_select_top(struct mode_tree_data *);
3984
void   mode_tree_expand_current(struct mode_tree_data *);
3985
void   mode_tree_collapse_current(struct mode_tree_data *);
3986
void   mode_tree_expand(struct mode_tree_data *, uint64_t);
3987
int  mode_tree_set_current(struct mode_tree_data *, uint64_t);
3988
void   mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb,
3989
       struct client *, key_code, int);
3990
void   mode_tree_up(struct mode_tree_data *, int);
3991
int  mode_tree_down(struct mode_tree_data *, int);
3992
struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *,
3993
       mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb,
3994
       mode_tree_menu_cb, mode_tree_height_cb, mode_tree_key_cb,
3995
             mode_tree_swap_cb, mode_tree_sort_cb, mode_tree_help_cb, void *,
3996
       const struct menu_item *, struct screen **);
3997
void   mode_tree_zoom(struct mode_tree_data *, struct args *);
3998
void   mode_tree_build(struct mode_tree_data *);
3999
void   mode_tree_free(struct mode_tree_data *);
4000
void   mode_tree_resize(struct mode_tree_data *, u_int, u_int);
4001
struct mode_tree_item *mode_tree_add(struct mode_tree_data *,
4002
       struct mode_tree_item *, void *, uint64_t, const char *,
4003
       const char *, int);
4004
void   mode_tree_view_name(struct mode_tree_data *, const char *);
4005
void   mode_tree_draw_as_parent(struct mode_tree_item *);
4006
void   mode_tree_no_tag(struct mode_tree_item *);
4007
void   mode_tree_align(struct mode_tree_item *, int);
4008
void   mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *);
4009
void   mode_tree_draw(struct mode_tree_data *);
4010
int  mode_tree_key(struct mode_tree_data *, struct client *, key_code *,
4011
       struct mouse_event *, u_int *, u_int *);
4012
void   mode_tree_set_prompt(struct mode_tree_data *, struct client *,
4013
       const char *, const char *, enum prompt_type, int,
4014
       mode_tree_prompt_input_cb, prompt_free_cb, void *);
4015
void   mode_tree_clear_prompt(struct mode_tree_data *);
4016
int  mode_tree_has_prompt(struct mode_tree_data *);
4017
void   mode_tree_run_command(struct client *, struct cmd_find_state *,
4018
       const char *, const char *);
4019
4020
/* window-buffer.c */
4021
extern const struct window_mode window_buffer_mode;
4022
4023
/* window-tree.c */
4024
extern const struct window_mode window_tree_mode;
4025
4026
/* window-switch.c */
4027
extern const struct window_mode window_switch_mode;
4028
void  window_switch_set_input(struct window_mode_entry *, struct evbuffer *);
4029
4030
/* window-clock.c */
4031
extern const struct window_mode window_clock_mode;
4032
extern const char window_clock_table[14][5][5];
4033
4034
/* window-panes.c */
4035
extern const struct window_mode window_panes_mode;
4036
4037
/* window-client.c */
4038
extern const struct window_mode window_client_mode;
4039
4040
/* window-copy.c */
4041
extern const struct window_mode window_copy_mode;
4042
extern const struct window_mode window_view_mode;
4043
void printflike(3, 4) window_copy_add(struct window_pane *, int, const char *,
4044
         ...);
4045
void printflike(3, 0) window_copy_vadd(struct window_pane *, int, const char *,
4046
         va_list);
4047
void     window_copy_scroll(struct window_pane *, int, u_int, u_int, int);
4048
void     window_copy_pageup(struct window_pane *, int);
4049
void     window_copy_pagedown(struct window_pane *, int, int);
4050
void     window_copy_start_drag(struct client *, struct mouse_event *);
4051
char    *window_copy_get_word(struct window_pane *, u_int, u_int);
4052
char    *window_copy_get_line(struct window_pane *, u_int);
4053
int    window_copy_get_current_offset(struct window_pane *, u_int *,
4054
         u_int *);
4055
char    *window_copy_get_hyperlink(struct window_pane *, u_int, u_int);
4056
void     window_copy_set_line_numbers(struct window_pane *, int);
4057
4058
/* window-customize.c */
4059
extern const struct window_mode window_customize_mode;
4060
4061
/* names.c */
4062
void   check_window_name(struct window *);
4063
char  *default_window_name(struct window *);
4064
char  *parse_window_name(const char *);
4065
4066
/* monitor.c */
4067
struct monitor_set *monitor_create_client(struct client *, monitor_cb, void *);
4068
struct monitor_set *monitor_create_session(struct session *, monitor_cb, void *);
4069
void  monitor_destroy(struct monitor_set *);
4070
int monitor_parse(const char *, char **, enum monitor_type *, int *,
4071
      char **);
4072
void  monitor_add(struct monitor_set *, const char *, enum monitor_type, int,
4073
      const char *, int);
4074
void  monitor_remove(struct monitor_set *, const char *);
4075
u_int monitor_get_fire_count(struct monitor_set *, const char *);
4076
time_t  monitor_get_fire_time(struct monitor_set *, const char *);
4077
4078
/* control.c */
4079
void  control_discard(struct client *);
4080
void  control_discard_all(struct client *);
4081
void  control_start(struct client *);
4082
void  control_ready(struct client *);
4083
void  control_stop(struct client *);
4084
void  control_wait_exit(int);
4085
void  control_set_pane_on(struct client *, struct window_pane *);
4086
void  control_set_pane_off(struct client *, struct window_pane *);
4087
void  control_continue_pane(struct client *, struct window_pane *);
4088
void  control_pause_pane(struct client *, struct window_pane *);
4089
void  control_reset_pane(struct client *, struct window_pane *);
4090
void  control_set_window_size(struct client *, u_int, u_int, u_int);
4091
int control_get_window_size(struct client *, u_int, u_int *, u_int *);
4092
void  control_clear_window_size(struct client *, u_int);
4093
struct window_pane_offset *control_pane_offset(struct client *,
4094
     struct window_pane *, int *);
4095
void  control_reset_offsets(struct client *);
4096
void printflike(2, 3) control_write(struct client *, const char *, ...);
4097
void printflike(2, 3) control_notify_write(struct client *, const char *, ...);
4098
void  control_write_guard(struct client *, const char *, long, u_int, int);
4099
void  control_write_output(struct client *, struct window_pane *);
4100
int control_all_done(struct client *);
4101
void  control_add_sub(struct client *, const char *, enum monitor_type, int,
4102
      const char *);
4103
void  control_remove_sub(struct client *, const char *);
4104
4105
/* control-notify.c */
4106
void  control_build_events(void);
4107
4108
/* session.c */
4109
extern struct sessions sessions;
4110
extern struct session_groups session_groups;
4111
extern u_int next_session_id;
4112
int session_cmp(struct session *, struct session *);
4113
RB_PROTOTYPE(sessions, session, entry, session_cmp);
4114
int session_group_cmp(struct session_group *, struct session_group *s2);
4115
RB_PROTOTYPE(session_groups, session_group, entry, session_group_cmp);
4116
int    session_alive(struct session *);
4117
struct session  *session_find(const char *);
4118
struct session  *session_find_by_id_str(const char *);
4119
struct session  *session_find_by_id(u_int);
4120
struct session  *session_create(const char *, const char *, const char *,
4121
         struct environ *, struct options *, struct termios *);
4122
void     session_destroy(struct session *, int,  const char *);
4123
void     session_add_ref(struct session *, const char *);
4124
void     session_remove_ref(struct session *, const char *);
4125
void     session_update_activity(struct session *, struct timeval *);
4126
struct session  *session_next_session(struct session *, struct sort_criteria *);
4127
struct session  *session_previous_session(struct session *,
4128
         struct sort_criteria *);
4129
struct winlink  *session_attach(struct session *, struct window *, int,
4130
         char **);
4131
int    session_detach(struct session *, struct winlink *);
4132
int    session_has(struct session *, struct window *);
4133
int    session_is_linked(struct session *, struct window *);
4134
int    session_next(struct session *, int);
4135
int    session_previous(struct session *, int);
4136
int    session_select(struct session *, int);
4137
int    session_last(struct session *);
4138
int    session_set_current(struct session *, struct winlink *);
4139
struct session_group *session_group_contains(struct session *);
4140
struct session_group *session_group_find(const char *);
4141
struct session_group *session_group_new(const char *);
4142
void     session_group_add(struct session_group *, struct session *);
4143
void     session_group_synchronize_to(struct session *);
4144
void     session_group_synchronize_from(struct session *);
4145
u_int    session_group_count(struct session_group *);
4146
u_int    session_group_attached_count(struct session_group *);
4147
void     session_renumber_windows(struct session *);
4148
void     session_theme_changed(struct session *);
4149
void     session_update_history(struct session *);
4150
4151
/* utf8.c */
4152
enum utf8_state  utf8_towc (const struct utf8_data *, wchar_t *);
4153
enum utf8_state  utf8_fromwc(wchar_t wc, struct utf8_data *);
4154
int    utf8_has_whitespace(const struct utf8_data *);
4155
void     utf8_update_width_cache(void);
4156
utf8_char  utf8_build_one(u_char);
4157
enum utf8_state  utf8_from_data(const struct utf8_data *, utf8_char *);
4158
void     utf8_to_data(utf8_char, struct utf8_data *);
4159
void     utf8_set(struct utf8_data *, u_char);
4160
void     utf8_copy(struct utf8_data *, const struct utf8_data *);
4161
enum utf8_state  utf8_open(struct utf8_data *, u_char);
4162
enum utf8_state  utf8_append(struct utf8_data *, u_char);
4163
int    utf8_isvalid(const char *);
4164
size_t     utf8_strvis(char *, const char *, size_t, int);
4165
size_t     utf8_stravis(char **, const char *, int);
4166
size_t     utf8_stravisx(char **, const char *, size_t, int);
4167
char    *utf8_sanitize(const char *);
4168
size_t     utf8_strlen(const struct utf8_data *);
4169
u_int    utf8_strwidth(const struct utf8_data *, ssize_t);
4170
struct utf8_data *utf8_fromcstr(const char *);
4171
char    *utf8_tocstr(struct utf8_data *);
4172
u_int    utf8_cstrwidth(const char *);
4173
char    *utf8_padcstr(const char *, u_int);
4174
char    *utf8_rpadcstr(const char *, u_int);
4175
int    utf8_cstrhas(const char *, const struct utf8_data *);
4176
4177
/* osdep-*.c */
4178
char    *osdep_get_name(int, char *);
4179
char    *osdep_get_cwd(int);
4180
struct event_base *osdep_event_init(void);
4181
4182
/* utf8-combined.c */
4183
int    utf8_has_zwj(const struct utf8_data *);
4184
int    utf8_is_zwj(const struct utf8_data *);
4185
int    utf8_is_vs(const struct utf8_data *);
4186
int    utf8_is_hangul_filler(const struct utf8_data *);
4187
int    utf8_should_combine(const struct utf8_data *,
4188
        const struct utf8_data *);
4189
enum hanguljamo_state hanguljamo_check_state(const struct utf8_data *,
4190
        const struct utf8_data *);
4191
4192
/* log.c */
4193
void  log_add_level(void);
4194
int log_get_level(void);
4195
void  log_open(const char *);
4196
void  log_toggle(const char *);
4197
void  log_close(void);
4198
void printflike(1, 2) log_debug(const char *, ...);
4199
__dead void printflike(1, 2) fatal(const char *, ...);
4200
__dead void printflike(1, 2) fatalx(const char *, ...);
4201
4202
/* menu.c */
4203
0
#define MENU_NOMOUSE 0x1
4204
0
#define MENU_TAB 0x2
4205
0
#define MENU_STAYOPEN 0x4
4206
struct menu *menu_create(const char *);
4207
void     menu_add_items(struct menu *, const struct menu_item *,
4208
        struct cmdq_item *, struct client *,
4209
        struct cmd_find_state *);
4210
void     menu_add_item(struct menu *, const struct menu_item *,
4211
        struct cmdq_item *, struct client *,
4212
        struct cmd_find_state *);
4213
void     menu_free(struct menu *);
4214
void     menu_get_size(struct menu *, enum box_lines, u_int *, u_int *);
4215
int    menu_display(struct menu *, int, int, struct cmdq_item *,
4216
        u_int, u_int, struct client *, enum box_lines, const char *,
4217
        const char *, const char *, struct cmd_find_state *,
4218
        menu_choice_cb, void *);
4219
void     menu_close(struct window *);
4220
void     menu_destroy(struct window *);
4221
void     menu_update(struct menu_data *);
4222
struct screen *menu_screen(struct menu_data *);
4223
u_int    menu_width(struct menu_data *);
4224
u_int    menu_height(struct menu_data *);
4225
u_int    menu_x(struct menu_data *);
4226
u_int    menu_y(struct menu_data *);
4227
void     menu_get_cursor(struct menu_data *, u_int *, u_int *);
4228
void     menu_resize(struct menu_data *, struct window *);
4229
int    menu_key(struct client *, struct menu_data *, struct key_event *);
4230
4231
/* style.c */
4232
int    style_parse(struct style *,const struct grid_cell *,
4233
         const char *);
4234
int    style_parse_colour(struct style *,
4235
         const struct grid_cell *, const char *);
4236
const char  *style_tostring(struct style *);
4237
const char  *style_link(struct style *);
4238
struct style  *style_add(struct grid_cell *, struct options *,
4239
         const char *, struct format_tree *);
4240
void     style_apply(struct grid_cell *, struct options *,
4241
         const char *, struct format_tree *);
4242
void     style_set(struct style *, const struct grid_cell *);
4243
void     style_copy(struct style *, struct style *);
4244
void     style_set_scrollbar_style_from_option(struct style *,
4245
         struct options *);
4246
void     style_ranges_init(struct style_ranges *);
4247
void     style_ranges_free(struct style_ranges *);
4248
struct style_range *style_ranges_get_range(struct style_ranges *, u_int);
4249
struct style_range *style_ranges_get_range_at(struct style_ranges *, u_int,
4250
         u_int);
4251
4252
/* spawn.c */
4253
struct winlink  *spawn_window(struct spawn_context *, char **);
4254
struct window_pane *spawn_pane(struct spawn_context *, char **);
4255
typedef void (*spawn_finish_edit_cb)(char *, size_t, void *);
4256
struct spawn_editor_state *spawn_editor(struct client *, const char *, size_t,
4257
         const char *, spawn_finish_edit_cb, void *);
4258
void     spawn_cancel_editor(struct spawn_editor_state *);
4259
pid_t    spawn_get_editor_pid(struct spawn_editor_state *);
4260
void     spawn_editor_finish(struct window_pane *);
4261
4262
/* regsub.c */
4263
char    *regsub(const char *, const char *, const char *, int);
4264
4265
/* server-acl.c */
4266
0
#define SERVER_ACL_READONLY 0x1
4267
0
#define SERVER_ACL_IS_GROUP 0x2
4268
void       server_acl_init(void);
4269
int      server_acl_find(id_t, int);
4270
void       server_acl_display(struct cmdq_item *);
4271
void       server_acl_allow(id_t, int);
4272
void       server_acl_deny(id_t, int);
4273
void       server_acl_allow_write(id_t, int);
4274
void       server_acl_deny_write(id_t, int);
4275
int      server_acl_join(struct client *);
4276
4277
/* hyperlink.c */
4278
u_int      hyperlinks_put(struct hyperlinks *, const char *,
4279
           const char *);
4280
int      hyperlinks_get(struct hyperlinks *, u_int,
4281
           const char **, const char **, const char **);
4282
struct hyperlinks *hyperlinks_init(void);
4283
struct hyperlinks *hyperlinks_copy(struct hyperlinks *);
4284
void       hyperlinks_reset(struct hyperlinks *);
4285
void       hyperlinks_free(struct hyperlinks *);
4286
4287
/* json.c */
4288
struct json_node  *json_parse(const char *, char **);
4289
void       json_destroy_node(struct json_node *);
4290
char      *json_to_string(struct json_node *);
4291
struct json_node  *json_find(struct json_node *, const char *);
4292
struct json_node  *json_array_first(struct json_node *);
4293
struct json_node  *json_array_next(struct json_node *);
4294
int      json_get_string(struct json_node *, const char **);
4295
int      json_get_number(struct json_node *, int64_t *);
4296
int      json_get_boolean(struct json_node *, int *);
4297
int      json_get_object(struct json_node *,
4298
           struct json_node **);
4299
int      json_get_array(struct json_node *,
4300
           struct json_node **);
4301
int      json_find_string(struct json_node *, const char *,
4302
           const char **, char **);
4303
int      json_find_number(struct json_node *, const char *,
4304
           int64_t *, char **);
4305
int      json_find_boolean(struct json_node *, const char *,
4306
           int *, char **);
4307
int      json_find_object(struct json_node *, const char *,
4308
           struct json_node **, char **);
4309
int      json_find_array(struct json_node *, const char *,
4310
           struct json_node **, char **);
4311
4312
#endif /* TMUX_H */