Annotation of src/usr.bin/tmux/tmux.h, Revision 1.18
1.18 ! nicm 1: /* $OpenBSD: tmux.h,v 1.17 2009/07/08 05:26:45 nicm Exp $ */
1.1 nicm 2:
3: /*
4: * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
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: #define PROTOCOL_VERSION -13
23:
24: #include <sys/param.h>
25: #include <sys/time.h>
26: #include <sys/queue.h>
27: #include <sys/tree.h>
28:
1.6 nicm 29: #include <bitstring.h>
1.1 nicm 30: #include <getopt.h>
31: #include <limits.h>
32: #include <poll.h>
33: #include <signal.h>
34: #include <stdarg.h>
35: #include <stdint.h>
36: #include <stdio.h>
37: #include <termios.h>
38:
39: #include "array.h"
40:
41: extern const char *__progname;
42:
43: /* Default configuration file. */
44: #define DEFAULT_CFG ".tmux.conf"
45:
46: /* Default prompt history length. */
47: #define PROMPT_HISTORY 100
48:
49: /* Minimum pane size. */
50: #define PANE_MINIMUM 4 /* includes separator line */
51:
52: /* Automatic name refresh interval, in milliseconds. */
53: #define NAME_INTERVAL 500
54:
55: /* Escape timer period, in milliseconds. */
56: #define ESCAPE_PERIOD 250
57:
58: /* Maximum poll timeout (when attached). */
59: #define POLL_TIMEOUT 50
60:
61: /* Fatal errors. */
62: #define fatal(msg) log_fatal("%s: %s", __func__, msg);
63: #define fatalx(msg) log_fatalx("%s: %s", __func__, msg);
64:
65: /* Definition to shut gcc up about unused arguments. */
66: #define unused __attribute__ ((unused))
67:
68: /* Attribute to make gcc check printf-like arguments. */
69: #define printflike1 __attribute__ ((format (printf, 1, 2)))
70: #define printflike2 __attribute__ ((format (printf, 2, 3)))
71: #define printflike3 __attribute__ ((format (printf, 3, 4)))
72: #define printflike4 __attribute__ ((format (printf, 4, 5)))
1.4 nicm 73: #define printflike5 __attribute__ ((format (printf, 5, 6)))
1.1 nicm 74:
75: /* Number of items in array. */
1.14 nicm 76: #ifndef nitems
1.1 nicm 77: #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
1.14 nicm 78: #endif
1.1 nicm 79:
80: /* Buffer macros. */
81: #define BUFFER_USED(b) ((b)->size)
82: #define BUFFER_FREE(b) ((b)->space - (b)->off - (b)->size)
83: #define BUFFER_IN(b) ((b)->base + (b)->off + (b)->size)
84: #define BUFFER_OUT(b) ((b)->base + (b)->off)
85:
86: /* Buffer structure. */
87: struct buffer {
88: u_char *base; /* buffer start */
89: size_t space; /* total size of buffer */
90:
91: size_t size; /* size of data in buffer */
92: size_t off; /* offset of data in buffer */
93: };
94:
95: /* Bell option values. */
96: #define BELL_NONE 0
97: #define BELL_ANY 1
98: #define BELL_CURRENT 2
99:
100: /* Key codes. ncurses defines KEY_*. Grrr. */
101: #define KEYC_NONE 0x00ffff
102: #define KEYC_OFFSET 0x010000
103: #define KEYC_ESCAPE 0x020000
104: #define KEYC_CONTROL 0x080000
105: #define KEYC_SHIFT 0x100000
106:
107: #define KEYC_ADDESC(k) ((k) | KEYC_ESCAPE)
108: #define KEYC_REMOVEESC(k) ((k) & ~KEYC_ESCAPE)
109: #define KEYC_ISESC(k) ((k) != KEYC_NONE && ((k) & KEYC_ESCAPE))
110:
111: #define KEYC_ADDCTL(k) ((k) | KEYC_CONTROL)
112: #define KEYC_REMOVECTL(k) ((k) & ~KEYC_CONTROL)
113: #define KEYC_ISCTL(k) ((k) != KEYC_NONE && ((k) & KEYC_CONTROL))
114:
115: #define KEYC_ADDSFT(k) ((k) | KEYC_SHIFT)
116: #define KEYC_REMOVESFT(k) ((k) & ~KEYC_SHIFT)
117: #define KEYC_ISSFT(k) ((k) != KEYC_NONE && ((k) & KEYC_SHIFT))
118:
119: /* Mouse key. */
120: #define KEYC_MOUSE (KEYC_OFFSET + 0x00)
121:
122: /* Function keys. */
123: #define KEYC_F1 (KEYC_OFFSET + 0x01)
124: #define KEYC_F2 (KEYC_OFFSET + 0x02)
125: #define KEYC_F3 (KEYC_OFFSET + 0x03)
126: #define KEYC_F4 (KEYC_OFFSET + 0x04)
127: #define KEYC_F5 (KEYC_OFFSET + 0x05)
128: #define KEYC_F6 (KEYC_OFFSET + 0x06)
129: #define KEYC_F7 (KEYC_OFFSET + 0x07)
130: #define KEYC_F8 (KEYC_OFFSET + 0x08)
131: #define KEYC_F9 (KEYC_OFFSET + 0x09)
132: #define KEYC_F10 (KEYC_OFFSET + 0x10)
133: #define KEYC_F11 (KEYC_OFFSET + 0x11)
134: #define KEYC_F12 (KEYC_OFFSET + 0x12)
135: #define KEYC_F13 (KEYC_OFFSET + 0x13)
136: #define KEYC_F14 (KEYC_OFFSET + 0x14)
137: #define KEYC_F15 (KEYC_OFFSET + 0x15)
138: #define KEYC_F16 (KEYC_OFFSET + 0x16)
139: #define KEYC_F17 (KEYC_OFFSET + 0x17)
140: #define KEYC_F18 (KEYC_OFFSET + 0x18)
141: #define KEYC_F19 (KEYC_OFFSET + 0x19)
142: #define KEYC_F20 (KEYC_OFFSET + 0x1a)
143: #define KEYC_IC (KEYC_OFFSET + 0x1b)
144: #define KEYC_DC (KEYC_OFFSET + 0x1c)
145: #define KEYC_HOME (KEYC_OFFSET + 0x1d)
146: #define KEYC_END (KEYC_OFFSET + 0x1e)
147: #define KEYC_NPAGE (KEYC_OFFSET + 0x1f)
148: #define KEYC_PPAGE (KEYC_OFFSET + 0x20)
149: #define KEYC_BTAB (KEYC_OFFSET + 0x21)
150:
151: /* Arrow keys. */
152: #define KEYC_UP (KEYC_OFFSET + 0x50)
153: #define KEYC_DOWN (KEYC_OFFSET + 0x51)
154: #define KEYC_LEFT (KEYC_OFFSET + 0x52)
155: #define KEYC_RIGHT (KEYC_OFFSET + 0x53)
156:
157: /* Numeric keypad. Numbered from top-left, KPY_X. */
158: #define KEYC_KP0_1 (KEYC_OFFSET + 0x100)
159: #define KEYC_KP0_2 (KEYC_OFFSET + 0x101)
160: #define KEYC_KP0_3 (KEYC_OFFSET + 0x102)
161: #define KEYC_KP1_0 (KEYC_OFFSET + 0x103)
162: #define KEYC_KP1_1 (KEYC_OFFSET + 0x104)
163: #define KEYC_KP1_2 (KEYC_OFFSET + 0x105)
164: #define KEYC_KP1_3 (KEYC_OFFSET + 0x106)
165: #define KEYC_KP2_0 (KEYC_OFFSET + 0x107)
166: #define KEYC_KP2_1 (KEYC_OFFSET + 0x108)
167: #define KEYC_KP2_2 (KEYC_OFFSET + 0x109)
168: #define KEYC_KP3_0 (KEYC_OFFSET + 0x10a)
169: #define KEYC_KP3_1 (KEYC_OFFSET + 0x10b)
170: #define KEYC_KP3_2 (KEYC_OFFSET + 0x10c)
171: #define KEYC_KP3_3 (KEYC_OFFSET + 0x10d)
172: #define KEYC_KP4_0 (KEYC_OFFSET + 0x10e)
173: #define KEYC_KP4_2 (KEYC_OFFSET + 0x10f)
174:
175: /* Termcap codes. */
176: enum tty_code_code {
177: TTYC_AX = 0,
178: TTYC_ACSC, /* acs_chars, ac */
179: TTYC_BEL, /* bell, bl */
180: TTYC_BLINK, /* enter_blink_mode, mb */
181: TTYC_BOLD, /* enter_bold_mode, md */
182: TTYC_CIVIS, /* cursor_invisible, vi */
183: TTYC_CLEAR, /* clear_screen, cl */
184: TTYC_CNORM, /* cursor_normal, ve */
185: TTYC_COLORS, /* max_colors, Co */
186: TTYC_CSR, /* change_scroll_region, cs */
187: TTYC_CUD, /* parm_down_cursor, DO */
188: TTYC_CUD1, /* cursor_down, do */
189: TTYC_CUP, /* cursor_address, cm */
190: TTYC_DCH, /* parm_dch, DC */
191: TTYC_DCH1, /* delete_character, dc */
192: TTYC_DIM, /* enter_dim_mode, mh */
193: TTYC_DL, /* parm_delete_line, DL */
194: TTYC_DL1, /* delete_line, dl */
195: TTYC_EL, /* clr_eol, ce */
196: TTYC_EL1, /* clr_bol, cb */
197: TTYC_ENACS, /* ena_acs, eA */
198: TTYC_ICH, /* parm_ich, IC */
199: TTYC_ICH1, /* insert_character, ic */
200: TTYC_IL, /* parm_insert_line, IL */
201: TTYC_IL1, /* insert_line, il */
202: TTYC_INVIS, /* enter_secure_mode, mk */
203: TTYC_IS1, /* init_1string, i1 */
204: TTYC_IS2, /* init_2string, i2 */
205: TTYC_IS3, /* init_3string, i3 */
206: TTYC_KCBT, /* key_btab, kB */
207: TTYC_KCUB1, /* key_left, kl */
208: TTYC_KCUD1, /* key_down, kd */
209: TTYC_KCUF1, /* key_right, kr */
210: TTYC_KCUU1, /* key_up, ku */
211: TTYC_KDCH1, /* key_dc, kD */
212: TTYC_KEND, /* key_end, ke */
213: TTYC_KF1, /* key_f1, k1 */
214: TTYC_KF10, /* key_f10, k; */
215: TTYC_KF11, /* key_f11, F1 */
216: TTYC_KF12, /* key_f12, F2 */
217: TTYC_KF13, /* key_f13, F3 */
218: TTYC_KF14, /* key_f14, F4 */
219: TTYC_KF15, /* key_f15, F5 */
220: TTYC_KF16, /* key_f16, F6 */
221: TTYC_KF17, /* key_f17, F7 */
222: TTYC_KF18, /* key_f18, F8 */
223: TTYC_KF19, /* key_f19, F9 */
224: TTYC_KF20, /* key_f20, F10 */
225: TTYC_KF2, /* key_f2, k2 */
226: TTYC_KF3, /* key_f3, k3 */
227: TTYC_KF4, /* key_f4, k4 */
228: TTYC_KF5, /* key_f5, k5 */
229: TTYC_KF6, /* key_f6, k6 */
230: TTYC_KF7, /* key_f7, k7 */
231: TTYC_KF8, /* key_f8, k8 */
232: TTYC_KF9, /* key_f9, k9 */
233: TTYC_KHOME, /* key_home, kh */
234: TTYC_KICH1, /* key_ic, kI */
235: TTYC_KMOUS, /* key_mouse, Km */
236: TTYC_KNP, /* key_npage, kN */
237: TTYC_KPP, /* key_ppage, kP */
238: TTYC_OP, /* orig_pair, op */
239: TTYC_REV, /* enter_reverse_mode, mr */
240: TTYC_RI, /* scroll_reverse, sr */
241: TTYC_RMACS, /* exit_alt_charset_mode */
242: TTYC_RMCUP, /* exit_ca_mode, te */
243: TTYC_RMIR, /* exit_insert_mode, ei */
244: TTYC_RMKX, /* keypad_local, ke */
245: TTYC_SETAB, /* set_a_background, AB */
246: TTYC_SETAF, /* set_a_foreground, AF */
247: TTYC_SGR0, /* exit_attribute_mode, me */
248: TTYC_SMACS, /* enter_alt_charset_mode, as */
249: TTYC_SMCUP, /* enter_ca_mode, ti */
250: TTYC_SMIR, /* enter_insert_mode, im */
251: TTYC_SMKX, /* keypad_xmit, ks */
252: TTYC_SMSO, /* enter_standout_mode, so */
253: TTYC_SMUL, /* enter_underline_mode, us */
254: TTYC_XENL, /* eat_newline_glitch, xn */
255: };
256: #define NTTYCODE (TTYC_XENL + 1)
257:
258: /* Termcap types. */
259: enum tty_code_type {
260: TTYCODE_NONE = 0,
261: TTYCODE_STRING,
262: TTYCODE_NUMBER,
263: TTYCODE_FLAG,
264: };
265:
266: /* Termcap code. */
267: struct tty_code {
268: enum tty_code_type type;
269: union {
270: char *string;
271: int number;
272: int flag;
273: } value;
274: };
275:
276: /* Entry in terminal code table. */
277: struct tty_term_code_entry {
278: enum tty_code_code code;
279: enum tty_code_type type;
280: const char *name;
281: };
282:
283: /* Output commands. */
284: enum tty_cmd {
1.5 nicm 285: TTY_ALIGNMENTTEST,
1.1 nicm 286: TTY_CELL,
287: TTY_CLEARENDOFLINE,
288: TTY_CLEARENDOFSCREEN,
289: TTY_CLEARLINE,
290: TTY_CLEARSCREEN,
291: TTY_CLEARSTARTOFLINE,
292: TTY_CLEARSTARTOFSCREEN,
293: TTY_DELETECHARACTER,
294: TTY_DELETELINE,
295: TTY_INSERTCHARACTER,
296: TTY_INSERTLINE,
297: TTY_LINEFEED,
298: TTY_RAW,
299: TTY_REVERSEINDEX,
300: };
301:
302: /* Message codes. */
303: enum hdrtype {
304: MSG_COMMAND,
305: MSG_DETACH,
306: MSG_ERROR,
307: MSG_EXIT,
308: MSG_EXITED,
309: MSG_EXITING,
310: MSG_IDENTIFY,
311: MSG_PRINT,
312: MSG_READY,
313: MSG_RESIZE,
314: MSG_SHUTDOWN,
315: MSG_SUSPEND,
316: MSG_UNLOCK,
317: MSG_WAKEUP,
318: };
319:
320: /* Message header structure. */
321: struct hdr {
322: enum hdrtype type;
323: size_t size;
324: };
325:
326: struct msg_command_data {
327: pid_t pid; /* pid from $TMUX or -1 */
328: u_int idx; /* index from $TMUX */
329:
330: size_t namelen;
331: };
332:
333: struct msg_identify_data {
334: char tty[TTY_NAME_MAX];
335: int version;
336:
337: char cwd[MAXPATHLEN];
338:
339: #define IDENTIFY_UTF8 0x1
340: #define IDENTIFY_256COLOURS 0x2
341: #define IDENTIFY_88COLOURS 0x4
342: #define IDENTIFY_HASDEFAULTS 0x8
343: int flags;
344:
345: u_int sx;
346: u_int sy;
347:
348: size_t termlen;
349: };
350:
351: struct msg_resize_data {
352: u_int sx;
353: u_int sy;
354: };
355:
356: /* Editing keys. */
357: enum mode_key_cmd {
358: MODEKEYCMD_BACKSPACE = 0x1000,
359: MODEKEYCMD_CHOOSE,
360: MODEKEYCMD_CLEARSELECTION,
361: MODEKEYCMD_COMPLETE,
362: MODEKEYCMD_COPYSELECTION,
363: MODEKEYCMD_DELETE,
364: MODEKEYCMD_DOWN,
365: MODEKEYCMD_ENDOFLINE,
366: MODEKEYCMD_LEFT,
367: MODEKEYCMD_NEXTPAGE,
368: MODEKEYCMD_NEXTWORD,
369: MODEKEYCMD_NONE,
370: MODEKEYCMD_OTHERKEY,
371: MODEKEYCMD_PASTE,
372: MODEKEYCMD_PREVIOUSPAGE,
373: MODEKEYCMD_PREVIOUSWORD,
374: MODEKEYCMD_QUIT,
375: MODEKEYCMD_RIGHT,
376: MODEKEYCMD_STARTOFLINE,
377: MODEKEYCMD_STARTSELECTION,
378: MODEKEYCMD_UP,
379: };
380:
381: struct mode_key_data {
382: int type;
383:
384: int flags;
385: #define MODEKEY_EDITMODE 0x1
386: #define MODEKEY_CANEDIT 0x2
387: #define MODEKEY_CHOOSEMODE 0x4
388: };
389:
390: #define MODEKEY_EMACS 0
391: #define MODEKEY_VI 1
392:
393: /* Modes. */
394: #define MODE_CURSOR 0x1
395: #define MODE_INSERT 0x2
396: #define MODE_KCURSOR 0x4
397: #define MODE_KKEYPAD 0x8
398: #define MODE_MOUSE 0x10
399:
400: /* Grid output. */
401: #if defined(DEBUG) && \
402: ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
403: (defined(__GNUC__) && __GNUC__ >= 3))
404: #define GRID_DEBUG(gd, fmt, ...) log_debug3("%s: (sx=%u, sy=%u, hsize=%u) " \
405: fmt, __func__, (gd)->sx, (gd)->sy, (gd)->hsize, ## __VA_ARGS__)
406: #else
407: #define GRID_DEBUG(...)
408: #endif
409:
410: /* Grid attributes. */
411: #define GRID_ATTR_BRIGHT 0x1
412: #define GRID_ATTR_DIM 0x2
413: #define GRID_ATTR_UNDERSCORE 0x4
414: #define GRID_ATTR_BLINK 0x8
415: #define GRID_ATTR_REVERSE 0x10
416: #define GRID_ATTR_HIDDEN 0x20
417: #define GRID_ATTR_ITALICS 0x40
418: #define GRID_ATTR_CHARSET 0x80 /* alternative character set */
419:
420: /* Grid flags. */
421: #define GRID_FLAG_FG256 0x1
422: #define GRID_FLAG_BG256 0x2
423: #define GRID_FLAG_PADDING 0x4
424: #define GRID_FLAG_UTF8 0x8
425:
426: /* Grid cell data. */
427: struct grid_cell {
428: u_char attr;
429: u_char flags;
430: u_char fg;
431: u_char bg;
432: u_char data;
433: } __packed;
434:
435: /* Grid cell UTF-8 data. Used instead of data in grid_cell for UTF-8 cells. */
436: #define UTF8_SIZE 8
437: struct grid_utf8 {
438: u_char width;
439: u_char data[UTF8_SIZE];
440: } __packed;
441:
442: /* Entire grid of cells. */
443: struct grid {
444: u_int sx;
445: u_int sy;
446:
447: u_int hsize;
448: u_int hlimit;
449:
450: u_int *size;
451: struct grid_cell **data;
452:
453: u_int *usize;
454: struct grid_utf8 **udata;
455: };
456:
457: /* Option data structures. */
458: struct options_entry {
459: char *name;
460:
461: enum {
462: OPTIONS_STRING,
463: OPTIONS_NUMBER,
464: OPTIONS_KEY,
465: } type;
466: union {
467: char *string;
468: long long number;
469: int key;
470: } value;
471:
472: SPLAY_ENTRY(options_entry) entry;
473: };
474:
475: struct options {
476: SPLAY_HEAD(options_tree, options_entry) tree;
477: struct options *parent;
478: };
479:
480: /* Screen selection. */
481: struct screen_sel {
482: int flag;
483:
484: u_int sx;
485: u_int sy;
486:
487: u_int ex;
488: u_int ey;
489:
490: struct grid_cell cell;
491: };
492:
493: /* Virtual screen. */
494: struct screen {
495: char *title;
496:
497: struct grid *grid; /* grid data */
498:
499: u_int cx; /* cursor x */
500: u_int cy; /* cursor y */
501:
502: u_int old_cx;
503: u_int old_cy;
504:
505: u_int rupper; /* scroll region top */
506: u_int rlower; /* scroll region bottom */
507:
508: u_int old_rupper;
509: u_int old_rlower;
510:
511: int mode;
512:
1.6 nicm 513: bitstr_t *tabs;
514:
1.1 nicm 515: struct screen_sel sel;
516: };
517:
518: /* Screen write context. */
519: struct screen_write_ctx {
520: struct window_pane *wp;
521: struct screen *s;
522: };
523:
524: /* Screen size. */
525: #define screen_size_x(s) ((s)->grid->sx)
526: #define screen_size_y(s) ((s)->grid->sy)
527: #define screen_hsize(s) ((s)->grid->hsize)
528: #define screen_hlimit(s) ((s)->grid->hlimit)
529:
530: /* Input parser sequence argument. */
531: struct input_arg {
532: u_char data[64];
533: size_t used;
534: };
535:
536: /* Input parser context. */
537: struct input_ctx {
538: struct window_pane *wp;
539: struct screen_write_ctx ctx;
540:
541: u_char *buf;
542: size_t len;
543: size_t off;
544:
545: struct grid_cell cell;
546:
547:
548: struct grid_cell saved_cell;
549: u_int saved_cx;
550: u_int saved_cy;
551:
552: #define MAXSTRINGLEN 1024
553: u_char *string_buf;
554: size_t string_len;
555: int string_type;
556: #define STRING_SYSTEM 0
557: #define STRING_APPLICATION 1
558: #define STRING_NAME 2
559:
560: u_char utf8_buf[4];
561: u_int utf8_len;
562: u_int utf8_off;
563:
564: u_char intermediate;
565: void *(*state)(u_char, struct input_ctx *);
566:
567: u_char private;
568: ARRAY_DECL(, struct input_arg) args;
569: };
570:
571: /*
572: * Window mode. Windows can be in several modes and this is used to call the
573: * right function to handle input and output.
574: */
575: struct client;
576: struct window;
577: struct window_mode {
578: struct screen *(*init)(struct window_pane *);
579: void (*free)(struct window_pane *);
580: void (*resize)(struct window_pane *, u_int, u_int);
581: void (*key)(struct window_pane *, struct client *, int);
582: void (*mouse)(struct window_pane *,
583: struct client *, u_char, u_char, u_char);
584: void (*timer)(struct window_pane *);
585: };
586:
587: /* Child window structure. */
588: struct window_pane {
589: struct window *window;
590:
591: u_int sx;
592: u_int sy;
593:
594: u_int xoff;
595: u_int yoff;
596:
597: int flags;
598: #define PANE_HIDDEN 0x1
1.2 nicm 599: #define PANE_REDRAW 0x2
1.1 nicm 600:
601: char *cmd;
602: char *cwd;
603:
604: pid_t pid;
605: int fd;
606: char tty[TTY_NAME_MAX];
607: struct buffer *in;
608: struct buffer *out;
609:
610: struct input_ctx ictx;
611:
612: struct screen *screen;
613: struct screen base;
614:
615: const struct window_mode *mode;
616: void *modedata;
617:
618: TAILQ_ENTRY(window_pane) entry;
619: };
620: TAILQ_HEAD(window_panes, window_pane);
621:
622: /* Window structure. */
623: struct window {
624: char *name;
625: struct timeval name_timer;
626:
627: struct window_pane *active;
628: struct window_panes panes;
629: u_int layout;
630:
631: u_int sx;
632: u_int sy;
633:
634: int flags;
635: #define WINDOW_BELL 0x1
636: #define WINDOW_HIDDEN 0x2
637: #define WINDOW_ACTIVITY 0x4
638: #define WINDOW_CONTENT 0x6
639: #define WINDOW_REDRAW 0x8
640:
641: struct options options;
642:
643: u_int references;
644: };
645: ARRAY_DECL(windows, struct window *);
646:
647: /* Entry on local window list. */
648: struct winlink {
649: int idx;
650: struct window *window;
651:
652: RB_ENTRY(winlink) entry;
653: SLIST_ENTRY(winlink) sentry;
654: };
655: RB_HEAD(winlinks, winlink);
656: SLIST_HEAD(winlink_stack, winlink);
657:
658: /* Paste buffer. */
659: struct paste_buffer {
660: char *data;
661: struct timeval tv;
662: };
663: ARRAY_DECL(paste_stack, struct paste_buffer *);
664:
665: /* Client session. */
666: struct session_alert {
667: struct winlink *wl;
668: int type;
669:
670: SLIST_ENTRY(session_alert) entry;
671: };
672:
673: struct session {
674: char *name;
675: struct timeval tv;
676:
677: u_int sx;
678: u_int sy;
679:
680: struct winlink *curw;
681: struct winlink_stack lastw;
682: struct winlinks windows;
683:
684: struct options options;
685:
686: struct paste_stack buffers;
687:
688: SLIST_HEAD(, session_alert) alerts;
689:
690: #define SESSION_UNATTACHED 0x1 /* not attached to any clients */
691: int flags;
692: };
693: ARRAY_DECL(sessions, struct session *);
694:
695: /* TTY information. */
696: struct tty_key {
697: int key;
698: char *string;
699:
700: int flags;
701: #define TTYKEY_CTRL 0x1
702: #define TTYKEY_RAW 0x2
703:
704: RB_ENTRY(tty_key) entry;
705: };
706:
707: struct tty_term {
708: char *name;
709: u_int references;
710:
711: struct tty_code codes[NTTYCODE];
712:
713: #define TERM_HASDEFAULTS 0x1
714: #define TERM_256COLOURS 0x2
715: #define TERM_88COLOURS 0x4
716: #define TERM_EARLYWRAP 0x8
717: int flags;
718:
719: SLIST_ENTRY(tty_term) entry;
720: };
721: SLIST_HEAD(tty_terms, tty_term);
722:
723: struct tty {
724: char *path;
725:
726: u_int sx;
727: u_int sy;
728:
729: u_int cx;
730: u_int cy;
731:
732: int mode;
733:
734: u_int rlower;
735: u_int rupper;
736:
737: char *termname;
738: struct tty_term *term;
739:
740: int fd;
741: struct buffer *in;
742: struct buffer *out;
743:
744: int log_fd;
745:
746: struct termios tio;
747:
748: struct grid_cell cell;
749:
750: u_char acs[UCHAR_MAX + 1];
751:
752: #define TTY_NOCURSOR 0x1
753: #define TTY_FREEZE 0x2
754: #define TTY_ESCAPE 0x4
755: #define TTY_UTF8 0x8
756: int flags;
757:
758: int term_flags;
759:
760: struct timeval key_timer;
761:
762: size_t ksize; /* maximum key size */
763: RB_HEAD(tty_keys, tty_key) ktree;
764: };
765:
766: /* Client connection. */
767: struct client {
768: int fd;
769: struct buffer *in;
770: struct buffer *out;
771:
772: char *title;
773: char *cwd;
774:
775: struct tty tty;
776: struct timeval status_timer;
777: struct timeval repeat_timer;
778:
779: struct screen status;
780:
781: #define CLIENT_TERMINAL 0x1
782: #define CLIENT_PREFIX 0x2
783: #define CLIENT_MOUSE 0x4
784: #define CLIENT_REDRAW 0x8
785: #define CLIENT_STATUS 0x10
786: #define CLIENT_REPEAT 0x20 /* allow command to repeat within repeat time */
787: #define CLIENT_SUSPENDED 0x40
788: int flags;
789:
790: char *message_string;
791: struct timeval message_timer;
792:
793: char *prompt_string;
794: char *prompt_buffer;
795: size_t prompt_index;
796: int (*prompt_callback)(void *, const char *);
797: void *prompt_data;
798:
799: #define PROMPT_HIDDEN 0x1
800: #define PROMPT_SINGLE 0x2
801: int prompt_flags;
802:
803: u_int prompt_hindex;
804: ARRAY_DECL(, char *) prompt_hdata;
805:
806: struct mode_key_data prompt_mdata;
807:
808: struct session *session;
809: };
810: ARRAY_DECL(clients, struct client *);
811:
812: /* Client context. */
813: struct client_ctx {
814: int srv_fd;
815: struct buffer *srv_in;
816: struct buffer *srv_out;
817:
818: #define CCTX_DETACH 0x1
819: #define CCTX_EXIT 0x2
820: #define CCTX_SHUTDOWN 0x4
821: int flags;
822: };
823:
824: /* Key/command line command. */
825: struct cmd_ctx {
826: struct client *cmdclient;
827:
828: struct client *curclient;
829: struct session *cursession;
830: struct msg_command_data *msgdata;
831:
832: void (*print)(struct cmd_ctx *, const char *, ...);
833: void (*info)(struct cmd_ctx *, const char *, ...);
834: void (*error)(struct cmd_ctx *, const char *, ...);
835: };
836:
837: struct cmd {
838: const struct cmd_entry *entry;
839: void *data;
840:
841: TAILQ_ENTRY(cmd) qentry;
842: };
843: TAILQ_HEAD(cmd_list, cmd);
844:
845: struct cmd_entry {
846: const char *name;
847: const char *alias;
848: const char *usage;
849:
850: #define CMD_STARTSERVER 0x1
851: #define CMD_CANTNEST 0x2
852: #define CMD_ARG1 0x4
853: #define CMD_ARG01 0x8
854: #define CMD_AFLAG 0x10
855: #define CMD_DFLAG 0x20
856: #define CMD_GFLAG 0x40
857: #define CMD_KFLAG 0x80
858: #define CMD_UFLAG 0x100
859: #define CMD_BIGDFLAG 0x200
860: #define CMD_BIGUFLAG 0x400
861:
862: int flags;
863:
864: void (*init)(struct cmd *, int);
865: int (*parse)(struct cmd *, int, char **, char **);
866: int (*exec)(struct cmd *, struct cmd_ctx *);
867: void (*send)(struct cmd *, struct buffer *);
868: void (*recv)(struct cmd *, struct buffer *);
869: void (*free)(struct cmd *);
870: size_t (*print)(struct cmd *, char *, size_t);
871: };
872:
873: /* Generic command data. */
874: struct cmd_target_data {
875: int flags;
876: char *target;
877: char *arg;
878: };
879:
880: struct cmd_srcdst_data {
881: int flags;
882: char *src;
883: char *dst;
884: char *arg;
885: };
886:
887: struct cmd_buffer_data {
888: int flags;
889: char *target;
890: int buffer;
891: char *arg;
892: };
893:
894: struct cmd_option_data {
895: int flags;
896: char *target;
897: char *option;
898: char *value;
899: };
900:
901: struct cmd_pane_data {
902: int flags;
903: char *target;
904: char *arg;
905: int pane;
906: };
907:
908: /* Key binding. */
909: struct key_binding {
910: int key;
911: struct cmd_list *cmdlist;
912: int can_repeat;
913:
914: SPLAY_ENTRY(key_binding) entry;
915: };
916: SPLAY_HEAD(key_bindings, key_binding);
917:
918: /* Set/display option data. */
919: struct set_option_entry {
920: const char *name;
921: enum {
922: SET_OPTION_STRING,
923: SET_OPTION_NUMBER,
924: SET_OPTION_KEY,
925: SET_OPTION_COLOUR,
926: SET_OPTION_ATTRIBUTES,
927: SET_OPTION_FLAG,
928: SET_OPTION_CHOICE
929: } type;
930:
931: u_int minimum;
932: u_int maximum;
933:
934: const char **choices;
935: };
936: extern const struct set_option_entry set_option_table[];
937: extern const struct set_option_entry set_window_option_table[];
1.4 nicm 938: #define NSETOPTION 25
1.1 nicm 939: #define NSETWINDOWOPTION 19
940:
941: /* tmux.c */
942: extern volatile sig_atomic_t sigwinch;
943: extern volatile sig_atomic_t sigterm;
944: extern volatile sig_atomic_t sigcont;
945: extern volatile sig_atomic_t sigchld;
946: extern volatile sig_atomic_t sigusr1;
947: extern volatile sig_atomic_t sigusr2;
1.16 nicm 948: extern struct options global_s_options;
949: extern struct options global_w_options;
1.1 nicm 950: extern char *cfg_file;
951: extern int server_locked;
952: extern char *server_password;
953: extern time_t server_activity;
954: extern int debug_level;
955: extern int be_quiet;
956: extern time_t start_time;
957: extern char *socket_path;
958: void logfile(const char *);
959: void siginit(void);
960: void sigreset(void);
961: void sighandler(int);
962:
963: /* cfg.c */
964: int load_cfg(const char *, char **x);
965:
966: /* mode-key.c */
967: void mode_key_init(struct mode_key_data *, int, int);
968: void mode_key_free(struct mode_key_data *);
969: enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
970:
971: /* options.c */
972: int options_cmp(struct options_entry *, struct options_entry *);
973: SPLAY_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
974: void options_init(struct options *, struct options *);
975: void options_free(struct options *);
976: struct options_entry *options_find1(struct options *, const char *);
977: struct options_entry *options_find(struct options *, const char *);
978: int options_remove(struct options *, const char *);
979: void printflike3 options_set_string(
980: struct options *, const char *, const char *, ...);
981: char *options_get_string(struct options *, const char *);
982: void options_set_number(struct options *, const char *, long long);
983: long long options_get_number(struct options *, const char *);
984:
985: /* tty.c */
986: u_char tty_get_acs(struct tty *, u_char);
987: void tty_emulate_repeat(struct tty *,
988: enum tty_code_code, enum tty_code_code, u_int);
989: void tty_reset(struct tty *);
990: void tty_region(struct tty *, u_int, u_int, u_int);
991: void tty_cursor(struct tty *, u_int, u_int, u_int, u_int);
992: void tty_cell(struct tty *,
993: const struct grid_cell *, const struct grid_utf8 *);
994: void tty_putcode(struct tty *, enum tty_code_code);
995: void tty_putcode1(struct tty *, enum tty_code_code, int);
996: void tty_putcode2(struct tty *, enum tty_code_code, int, int);
997: void tty_puts(struct tty *, const char *);
998: void tty_putc(struct tty *, u_char);
1.8 nicm 999: void tty_pututf8(struct tty *, const struct grid_utf8 *);
1.1 nicm 1000: void tty_init(struct tty *, char *, char *);
1001: void tty_start_tty(struct tty *);
1002: void tty_stop_tty(struct tty *);
1003: void tty_detect_utf8(struct tty *);
1004: void tty_set_title(struct tty *, const char *);
1005: void tty_update_mode(struct tty *, int);
1006: void tty_draw_line(
1007: struct tty *, struct screen *, u_int, u_int, u_int);
1008: void tty_redraw_region(struct tty *, struct window_pane *);
1009: int tty_open(struct tty *, char **);
1010: void tty_close(struct tty *, int);
1011: void tty_free(struct tty *, int);
1012: void tty_vwrite(
1013: struct tty *, struct window_pane *, enum tty_cmd, va_list);
1014:
1015: /* tty-term.c */
1016: extern struct tty_terms tty_terms;
1017: extern struct tty_term_code_entry tty_term_codes[NTTYCODE];
1018: struct tty_term *tty_term_find(char *, int, char **);
1019: void tty_term_free(struct tty_term *);
1020: int tty_term_has(struct tty_term *, enum tty_code_code);
1021: const char *tty_term_string(struct tty_term *, enum tty_code_code);
1022: const char *tty_term_string1(struct tty_term *, enum tty_code_code, int);
1023: const char *tty_term_string2(
1024: struct tty_term *, enum tty_code_code, int, int);
1025: int tty_term_number(struct tty_term *, enum tty_code_code);
1026: int tty_term_flag(struct tty_term *, enum tty_code_code);
1027:
1028: /* tty-keys.c */
1029: int tty_keys_cmp(struct tty_key *, struct tty_key *);
1030: RB_PROTOTYPE(tty_keys, tty_key, entry, tty_keys_cmp);
1031: void tty_keys_init(struct tty *);
1032: void tty_keys_free(struct tty *);
1033: int tty_keys_next(struct tty *, int *, u_char *);
1034:
1035: /* tty-write.c */
1036: void tty_write_cmd(struct window_pane *, enum tty_cmd, ...);
1037:
1038: /* options-cmd.c */
1039: void set_option_string(struct cmd_ctx *,
1040: struct options *, const struct set_option_entry *, char *);
1041: void set_option_number(struct cmd_ctx *,
1042: struct options *, const struct set_option_entry *, char *);
1043: void set_option_key(struct cmd_ctx *,
1044: struct options *, const struct set_option_entry *, char *);
1045: void set_option_colour(struct cmd_ctx *,
1046: struct options *, const struct set_option_entry *, char *);
1047: void set_option_attributes(struct cmd_ctx *,
1048: struct options *, const struct set_option_entry *, char *);
1049: void set_option_flag(struct cmd_ctx *,
1050: struct options *, const struct set_option_entry *, char *);
1051: void set_option_choice(struct cmd_ctx *,
1052: struct options *, const struct set_option_entry *, char *);
1053:
1054: /* paste.c */
1055: void paste_init_stack(struct paste_stack *);
1056: void paste_free_stack(struct paste_stack *);
1057: struct paste_buffer *paste_walk_stack(struct paste_stack *, uint *);
1058: struct paste_buffer *paste_get_top(struct paste_stack *);
1059: struct paste_buffer *paste_get_index(struct paste_stack *, u_int);
1060: int paste_free_top(struct paste_stack *);
1061: int paste_free_index(struct paste_stack *, u_int);
1062: void paste_add(struct paste_stack *, char *, u_int);
1063: int paste_replace(struct paste_stack *, u_int, char *);
1064:
1065: /* clock.c */
1066: void clock_draw(struct screen_write_ctx *, u_int, int);
1067:
1068: /* arg.c */
1069: struct client *arg_parse_client(const char *);
1070: struct session *arg_parse_session(const char *);
1071: int arg_parse_window(const char *, struct session **, int *);
1072:
1073: /* cmd.c */
1074: struct cmd *cmd_parse(int, char **, char **);
1075: int cmd_exec(struct cmd *, struct cmd_ctx *);
1076: void cmd_send(struct cmd *, struct buffer *);
1077: struct cmd *cmd_recv(struct buffer *);
1078: void cmd_free(struct cmd *);
1079: size_t cmd_print(struct cmd *, char *, size_t);
1080: void cmd_send_string(struct buffer *, const char *);
1081: char *cmd_recv_string(struct buffer *);
1082: struct session *cmd_current_session(struct cmd_ctx *);
1083: struct client *cmd_find_client(struct cmd_ctx *, const char *);
1084: struct session *cmd_find_session(struct cmd_ctx *, const char *);
1085: struct winlink *cmd_find_window(
1086: struct cmd_ctx *, const char *, struct session **);
1087: extern const struct cmd_entry *cmd_table[];
1088: extern const struct cmd_entry cmd_attach_session_entry;
1089: extern const struct cmd_entry cmd_bind_key_entry;
1090: extern const struct cmd_entry cmd_break_pane_entry;
1091: extern const struct cmd_entry cmd_choose_session_entry;
1092: extern const struct cmd_entry cmd_choose_window_entry;
1093: extern const struct cmd_entry cmd_clear_history_entry;
1094: extern const struct cmd_entry cmd_clock_mode_entry;
1095: extern const struct cmd_entry cmd_command_prompt_entry;
1096: extern const struct cmd_entry cmd_confirm_before_entry;
1097: extern const struct cmd_entry cmd_copy_buffer_entry;
1098: extern const struct cmd_entry cmd_copy_mode_entry;
1099: extern const struct cmd_entry cmd_delete_buffer_entry;
1100: extern const struct cmd_entry cmd_detach_client_entry;
1101: extern const struct cmd_entry cmd_down_pane_entry;
1102: extern const struct cmd_entry cmd_find_window_entry;
1103: extern const struct cmd_entry cmd_has_session_entry;
1104: extern const struct cmd_entry cmd_kill_pane_entry;
1105: extern const struct cmd_entry cmd_kill_server_entry;
1106: extern const struct cmd_entry cmd_kill_session_entry;
1107: extern const struct cmd_entry cmd_kill_window_entry;
1108: extern const struct cmd_entry cmd_last_window_entry;
1109: extern const struct cmd_entry cmd_link_window_entry;
1110: extern const struct cmd_entry cmd_list_buffers_entry;
1111: extern const struct cmd_entry cmd_list_clients_entry;
1112: extern const struct cmd_entry cmd_list_commands_entry;
1113: extern const struct cmd_entry cmd_list_keys_entry;
1114: extern const struct cmd_entry cmd_list_sessions_entry;
1115: extern const struct cmd_entry cmd_list_windows_entry;
1116: extern const struct cmd_entry cmd_load_buffer_entry;
1117: extern const struct cmd_entry cmd_lock_server_entry;
1118: extern const struct cmd_entry cmd_move_window_entry;
1119: extern const struct cmd_entry cmd_new_session_entry;
1120: extern const struct cmd_entry cmd_new_window_entry;
1121: extern const struct cmd_entry cmd_next_layout_entry;
1122: extern const struct cmd_entry cmd_next_window_entry;
1123: extern const struct cmd_entry cmd_paste_buffer_entry;
1124: extern const struct cmd_entry cmd_previous_layout_entry;
1125: extern const struct cmd_entry cmd_previous_window_entry;
1126: extern const struct cmd_entry cmd_refresh_client_entry;
1127: extern const struct cmd_entry cmd_rename_session_entry;
1128: extern const struct cmd_entry cmd_rename_window_entry;
1129: extern const struct cmd_entry cmd_resize_pane_entry;
1130: extern const struct cmd_entry cmd_respawn_window_entry;
1131: extern const struct cmd_entry cmd_rotate_window_entry;
1132: extern const struct cmd_entry cmd_save_buffer_entry;
1133: extern const struct cmd_entry cmd_scroll_mode_entry;
1134: extern const struct cmd_entry cmd_select_layout_entry;
1135: extern const struct cmd_entry cmd_select_pane_entry;
1136: extern const struct cmd_entry cmd_select_prompt_entry;
1137: extern const struct cmd_entry cmd_select_window_entry;
1138: extern const struct cmd_entry cmd_send_keys_entry;
1139: extern const struct cmd_entry cmd_send_prefix_entry;
1140: extern const struct cmd_entry cmd_server_info_entry;
1141: extern const struct cmd_entry cmd_set_buffer_entry;
1142: extern const struct cmd_entry cmd_set_option_entry;
1143: extern const struct cmd_entry cmd_set_password_entry;
1144: extern const struct cmd_entry cmd_set_window_option_entry;
1145: extern const struct cmd_entry cmd_show_buffer_entry;
1146: extern const struct cmd_entry cmd_show_options_entry;
1147: extern const struct cmd_entry cmd_show_window_options_entry;
1148: extern const struct cmd_entry cmd_source_file_entry;
1149: extern const struct cmd_entry cmd_split_window_entry;
1150: extern const struct cmd_entry cmd_start_server_entry;
1151: extern const struct cmd_entry cmd_suspend_client_entry;
1152: extern const struct cmd_entry cmd_swap_pane_entry;
1153: extern const struct cmd_entry cmd_swap_window_entry;
1154: extern const struct cmd_entry cmd_switch_client_entry;
1155: extern const struct cmd_entry cmd_unbind_key_entry;
1156: extern const struct cmd_entry cmd_unlink_window_entry;
1157: extern const struct cmd_entry cmd_up_pane_entry;
1158:
1159: /* cmd-list.c */
1160: struct cmd_list *cmd_list_parse(int, char **, char **);
1161: int cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
1162: void cmd_list_send(struct cmd_list *, struct buffer *);
1163: struct cmd_list *cmd_list_recv(struct buffer *);
1164: void cmd_list_free(struct cmd_list *);
1165: size_t cmd_list_print(struct cmd_list *, char *, size_t);
1166:
1167: /* cmd-string.c */
1168: int cmd_string_parse(const char *, struct cmd_list **, char **);
1169:
1170: /* cmd-generic.c */
1171: size_t cmd_prarg(char *, size_t, const char *, char *);
1172: #define CMD_TARGET_WINDOW_USAGE "[-t target-window]"
1173: #define CMD_TARGET_SESSION_USAGE "[-t target-session]"
1174: #define CMD_TARGET_CLIENT_USAGE "[-t target-client]"
1175: void cmd_target_init(struct cmd *, int);
1176: int cmd_target_parse(struct cmd *, int, char **, char **);
1177: void cmd_target_send(struct cmd *, struct buffer *);
1178: void cmd_target_recv(struct cmd *, struct buffer *);
1179: void cmd_target_free(struct cmd *);
1180: size_t cmd_target_print(struct cmd *, char *, size_t);
1181: #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]"
1182: #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]"
1183: #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]"
1184: void cmd_srcdst_init(struct cmd *, int);
1185: int cmd_srcdst_parse(struct cmd *, int, char **, char **);
1186: void cmd_srcdst_send(struct cmd *, struct buffer *);
1187: void cmd_srcdst_recv(struct cmd *, struct buffer *);
1188: void cmd_srcdst_free(struct cmd *);
1189: size_t cmd_srcdst_print(struct cmd *, char *, size_t);
1190: #define CMD_BUFFER_WINDOW_USAGE "[-b buffer-index] [-t target-window]"
1191: #define CMD_BUFFER_SESSION_USAGE "[-b buffer-index] [-t target-session]"
1192: #define CMD_BUFFER_CLIENT_USAGE "[-b buffer-index] [-t target-client]"
1193: void cmd_buffer_init(struct cmd *, int);
1194: int cmd_buffer_parse(struct cmd *, int, char **, char **);
1195: void cmd_buffer_send(struct cmd *, struct buffer *);
1196: void cmd_buffer_recv(struct cmd *, struct buffer *);
1197: void cmd_buffer_free(struct cmd *);
1198: size_t cmd_buffer_print(struct cmd *, char *, size_t);
1199: #define CMD_OPTION_WINDOW_USAGE "[-gu] [-t target-window] option [value]"
1200: #define CMD_OPTION_SESSION_USAGE "[-gu] [-t target-session] option [value]"
1201: #define CMD_OPTION_CLIENT_USAGE "[-gu] [-t target-client] option [value]"
1202: void cmd_option_init(struct cmd *, int);
1203: int cmd_option_parse(struct cmd *, int, char **, char **);
1204: void cmd_option_send(struct cmd *, struct buffer *);
1205: void cmd_option_recv(struct cmd *, struct buffer *);
1206: void cmd_option_free(struct cmd *);
1207: size_t cmd_option_print(struct cmd *, char *, size_t);
1208: #define CMD_PANE_WINDOW_USAGE "[-t target-window] [-p pane-index]"
1209: #define CMD_PANE_SESSION_USAGE "[-t target-session] [-p pane-index]"
1210: #define CMD_PANE_CLIENT_USAGE "[-t target-client] [-p pane-index]"
1211: void cmd_pane_init(struct cmd *, int);
1212: int cmd_pane_parse(struct cmd *, int, char **, char **);
1213: void cmd_pane_send(struct cmd *, struct buffer *);
1214: void cmd_pane_recv(struct cmd *, struct buffer *);
1215: void cmd_pane_free(struct cmd *);
1216: size_t cmd_pane_print(struct cmd *, char *, size_t);
1217:
1218: /* client.c */
1219: int client_init(char *, struct client_ctx *, int, int);
1220: int client_main(struct client_ctx *);
1221:
1222: /* client-msg.c */
1223: int client_msg_dispatch(struct client_ctx *, char **);
1224:
1225: /* client-fn.c */
1226: void client_write_server(struct client_ctx *, enum hdrtype, void *, size_t);
1227: void client_write_server2(
1228: struct client_ctx *, enum hdrtype, void *, size_t, void *, size_t);
1229: void client_fill_session(struct msg_command_data *);
1230:
1231: /* key-bindings.c */
1232: extern struct key_bindings key_bindings;
1233: int key_bindings_cmp(struct key_binding *, struct key_binding *);
1234: SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
1235: struct key_binding *key_bindings_lookup(int);
1236: void key_bindings_add(int, int, struct cmd_list *);
1237: void key_bindings_remove(int);
1238: void key_bindings_init(void);
1239: void key_bindings_free(void);
1240: void key_bindings_dispatch(struct key_binding *, struct client *);
1241: void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
1242: void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
1243: void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
1244:
1245: /* key-string.c */
1246: int key_string_lookup_string(const char *);
1247: const char *key_string_lookup_key(int);
1248:
1249: /* server.c */
1250: extern struct clients clients;
1251: struct client *server_create_client(int);
1252: int server_client_index(struct client *);
1253: int server_start(char *);
1254:
1255: /* server-msg.c */
1256: int server_msg_dispatch(struct client *);
1257:
1258: /* server-fn.c */
1259: const char **server_fill_environ(struct session *);
1260: void server_write_client(
1261: struct client *, enum hdrtype, const void *, size_t);
1262: void server_write_session(
1263: struct session *, enum hdrtype, const void *, size_t);
1264: void server_redraw_client(struct client *);
1265: void server_status_client(struct client *);
1266: void server_redraw_session(struct session *);
1267: void server_status_session(struct session *);
1268: void server_redraw_window(struct window *);
1269: void server_status_window(struct window *);
1270: void server_lock(void);
1271: int server_unlock(const char *);
1272:
1273: /* status.c */
1274: int status_redraw(struct client *);
1275: void status_message_set(struct client *, const char *);
1276: void status_message_clear(struct client *);
1277: int status_message_redraw(struct client *);
1278: void status_prompt_set(struct client *,
1279: const char *, int (*)(void *, const char *), void *, int);
1280: void status_prompt_clear(struct client *);
1281: int status_prompt_redraw(struct client *);
1282: void status_prompt_key(struct client *, int);
1283:
1284: /* resize.c */
1285: void recalculate_sizes(void);
1286:
1287: /* input.c */
1288: void input_init(struct window_pane *);
1289: void input_free(struct window_pane *);
1290: void input_parse(struct window_pane *);
1291:
1292: /* input-key.c */
1293: void input_key(struct window_pane *, int);
1294: void input_mouse(struct window_pane *, u_char, u_char, u_char);
1295:
1296: /* colour.c */
1297: const char *colour_tostring(u_char);
1298: int colour_fromstring(const char *);
1299: u_char colour_256to16(u_char);
1300: u_char colour_256to88(u_char);
1301:
1302: /* attributes.c */
1303: const char *attributes_tostring(u_char);
1304: int attributes_fromstring(const char *);
1305:
1306: /* grid.c */
1307: extern const struct grid_cell grid_default_cell;
1308: struct grid *grid_create(u_int, u_int, u_int);
1309: void grid_destroy(struct grid *);
1310: int grid_compare(struct grid *, struct grid *);
1311: void grid_reduce_line(struct grid *, u_int, u_int);
1312: void grid_expand_line(struct grid *, u_int, u_int);
1313: void grid_expand_line_utf8(struct grid *, u_int, u_int);
1314: void grid_scroll_line(struct grid *);
1315: const struct grid_cell *grid_peek_cell(struct grid *, u_int, u_int);
1316: struct grid_cell *grid_get_cell(struct grid *, u_int, u_int);
1317: void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
1318: const struct grid_utf8 *grid_peek_utf8(struct grid *, u_int, u_int);
1319: struct grid_utf8 *grid_get_utf8(struct grid *, u_int, u_int);
1320: void grid_set_utf8(struct grid *, u_int, u_int, const struct grid_utf8 *);
1321: void grid_clear(struct grid *, u_int, u_int, u_int, u_int);
1322: void grid_clear_lines(struct grid *, u_int, u_int);
1323: void grid_move_lines(struct grid *, u_int, u_int, u_int);
1324: void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
1.9 nicm 1325: char *grid_string_cells(struct grid *, u_int, u_int, u_int);
1.1 nicm 1326:
1327: /* grid-view.c */
1328: const struct grid_cell *grid_view_peek_cell(struct grid *, u_int, u_int);
1329: struct grid_cell *grid_view_get_cell(struct grid *, u_int, u_int);
1330: void grid_view_set_cell(
1331: struct grid *, u_int, u_int, const struct grid_cell *);
1332: const struct grid_utf8 *grid_view_peek_utf8(struct grid *, u_int, u_int);
1333: struct grid_utf8 *grid_view_get_utf8(struct grid *, u_int, u_int);
1334: void grid_view_set_utf8(
1335: struct grid *, u_int, u_int, const struct grid_utf8 *);
1336: void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);
1337: void grid_view_scroll_region_up(struct grid *, u_int, u_int);
1338: void grid_view_scroll_region_down(struct grid *, u_int, u_int);
1339: void grid_view_insert_lines(struct grid *, u_int, u_int);
1.18 ! nicm 1340: void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int);
1.1 nicm 1341: void grid_view_delete_lines(struct grid *, u_int, u_int);
1.18 ! nicm 1342: void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int);
1.1 nicm 1343: void grid_view_insert_cells(struct grid *, u_int, u_int, u_int);
1344: void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
1.9 nicm 1345: char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
1.1 nicm 1346:
1347: /* screen-write.c */
1348: void screen_write_start(
1349: struct screen_write_ctx *, struct window_pane *, struct screen *);
1350: void screen_write_stop(struct screen_write_ctx *);
1.4 nicm 1351: size_t printflike2 screen_write_strlen(int, const char *, ...);
1.3 nicm 1352: void printflike3 screen_write_puts(struct screen_write_ctx *,
1353: struct grid_cell *, const char *, ...);
1.4 nicm 1354: void printflike5 screen_write_nputs(struct screen_write_ctx *,
1355: ssize_t, struct grid_cell *, int, const char *, ...);
1.3 nicm 1356: void screen_write_vnputs(struct screen_write_ctx *,
1.4 nicm 1357: ssize_t, struct grid_cell *, int, const char *, va_list);
1.1 nicm 1358: void screen_write_putc(
1359: struct screen_write_ctx *, struct grid_cell *, u_char);
1360: void screen_write_copy(struct screen_write_ctx *,
1361: struct screen *, u_int, u_int, u_int, u_int);
1362: void screen_write_cursorup(struct screen_write_ctx *, u_int);
1363: void screen_write_cursordown(struct screen_write_ctx *, u_int);
1364: void screen_write_cursorright(struct screen_write_ctx *, u_int);
1365: void screen_write_cursorleft(struct screen_write_ctx *, u_int);
1.5 nicm 1366: void screen_write_alignmenttest(struct screen_write_ctx *);
1.1 nicm 1367: void screen_write_insertcharacter(struct screen_write_ctx *, u_int);
1368: void screen_write_deletecharacter(struct screen_write_ctx *, u_int);
1369: void screen_write_insertline(struct screen_write_ctx *, u_int);
1370: void screen_write_deleteline(struct screen_write_ctx *, u_int);
1371: void screen_write_clearline(struct screen_write_ctx *);
1372: void screen_write_clearendofline(struct screen_write_ctx *);
1373: void screen_write_clearstartofline(struct screen_write_ctx *);
1374: void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
1375: void screen_write_cursormode(struct screen_write_ctx *, int);
1376: void screen_write_reverseindex(struct screen_write_ctx *);
1377: void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
1378: void screen_write_insertmode(struct screen_write_ctx *, int);
1379: void screen_write_mousemode(struct screen_write_ctx *, int);
1380: void screen_write_linefeed(struct screen_write_ctx *);
1381: void screen_write_carriagereturn(struct screen_write_ctx *);
1382: void screen_write_kcursormode(struct screen_write_ctx *, int);
1383: void screen_write_kkeypadmode(struct screen_write_ctx *, int);
1384: void screen_write_clearendofscreen(struct screen_write_ctx *);
1385: void screen_write_clearstartofscreen(struct screen_write_ctx *);
1386: void screen_write_clearscreen(struct screen_write_ctx *);
1387: void screen_write_cell(
1388: struct screen_write_ctx *, const struct grid_cell *, u_char *);
1389:
1390: /* screen-redraw.c */
1391: void screen_redraw_screen(struct client *);
1392: void screen_redraw_pane(struct client *, struct window_pane *);
1393: void screen_redraw_status(struct client *);
1394:
1395: /* screen.c */
1396: void screen_init(struct screen *, u_int, u_int, u_int);
1397: void screen_reinit(struct screen *);
1398: void screen_free(struct screen *);
1.6 nicm 1399: void screen_reset_tabs(struct screen *);
1.1 nicm 1400: void screen_set_title(struct screen *, const char *);
1401: void screen_resize(struct screen *, u_int, u_int);
1402: void screen_set_selection(
1403: struct screen *, u_int, u_int, u_int, u_int, struct grid_cell *);
1404: void screen_clear_selection(struct screen *);
1405: int screen_check_selection(struct screen *, u_int, u_int);
1406:
1407: /* window.c */
1408: extern struct windows windows;
1.17 nicm 1409: const char *window_default_command(void);
1.1 nicm 1410: int window_cmp(struct window *, struct window *);
1411: int winlink_cmp(struct winlink *, struct winlink *);
1412: RB_PROTOTYPE(windows, window, entry, window_cmp);
1413: RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp);
1414: struct winlink *winlink_find_by_index(struct winlinks *, int);
1415: struct winlink *winlink_find_by_window(struct winlinks *, struct window *);
1416: int winlink_next_index(struct winlinks *);
1417: u_int winlink_count(struct winlinks *);
1418: struct winlink *winlink_add(struct winlinks *, struct window *, int);
1419: void winlink_remove(struct winlinks *, struct winlink *);
1420: struct winlink *winlink_next(struct winlinks *, struct winlink *);
1421: struct winlink *winlink_previous(struct winlinks *, struct winlink *);
1422: void winlink_stack_push(struct winlink_stack *, struct winlink *);
1423: void winlink_stack_remove(struct winlink_stack *, struct winlink *);
1424: int window_index(struct window *, u_int *);
1425: struct window *window_create1(u_int, u_int);
1426: struct window *window_create(const char *, const char *,
1427: const char *, const char **, u_int, u_int, u_int, char **);
1428: void window_destroy(struct window *);
1429: int window_resize(struct window *, u_int, u_int);
1430: void window_set_active_pane(struct window *, struct window_pane *);
1431: struct window_pane *window_add_pane(struct window *, int,
1432: const char *, const char *, const char **, u_int, char **);
1433: void window_remove_pane(struct window *, struct window_pane *);
1434: struct window_pane *window_pane_at_index(struct window *, u_int);
1435: u_int window_count_panes(struct window *);
1436: void window_destroy_panes(struct window *);
1437: struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
1438: void window_pane_destroy(struct window_pane *);
1439: int window_pane_spawn(struct window_pane *,
1440: const char *, const char *, const char **, char **);
1441: int window_pane_resize(struct window_pane *, u_int, u_int);
1442: int window_pane_set_mode(
1443: struct window_pane *, const struct window_mode *);
1444: void window_pane_reset_mode(struct window_pane *);
1445: void window_pane_parse(struct window_pane *);
1446: void window_pane_key(struct window_pane *, struct client *, int);
1447: void window_pane_mouse(struct window_pane *,
1448: struct client *, u_char, u_char, u_char);
1.10 nicm 1449: char *window_pane_search(
1450: struct window_pane *, const char *, u_int *);
1.1 nicm 1451:
1452: /* layout.c */
1453: const char * layout_name(struct window *);
1454: int layout_lookup(const char *);
1455: void layout_refresh(struct window *, int);
1456: int layout_resize(struct window_pane *, int);
1457: int layout_select(struct window *, u_int);
1458: void layout_next(struct window *);
1459: void layout_previous(struct window *);
1460:
1461: /* layout-manual.c */
1462: void layout_manual_v_refresh(struct window *, int);
1463: void layout_manual_v_resize(struct window_pane *, int);
1464:
1465: /* window-clock.c */
1466: extern const struct window_mode window_clock_mode;
1467:
1468: /* window-copy.c */
1469: extern const struct window_mode window_copy_mode;
1470: void window_copy_pageup(struct window_pane *);
1471:
1472: /* window-scroll.c */
1473: extern const struct window_mode window_scroll_mode;
1474: void window_scroll_pageup(struct window_pane *);
1475:
1476: /* window-more.c */
1477: extern const struct window_mode window_more_mode;
1478: void window_more_vadd(struct window_pane *, const char *, va_list);
1479:
1480: /* window-choose.c */
1481: extern const struct window_mode window_choose_mode;
1482: void window_choose_vadd(
1483: struct window_pane *, int, const char *, va_list);
1484: void printflike3 window_choose_add(
1485: struct window_pane *, int, const char *, ...);
1486: void window_choose_ready(struct window_pane *,
1487: u_int, void (*)(void *, int), void *);
1488:
1489: /* names.c */
1490: void set_window_names(void);
1491: char *default_window_name(struct window *);
1492:
1493: /* session.c */
1494: extern struct sessions sessions;
1495: void session_alert_add(struct session *, struct window *, int);
1496: void session_alert_cancel(struct session *, struct winlink *);
1497: int session_alert_has(struct session *, struct winlink *, int);
1498: int session_alert_has_window(struct session *, struct window *, int);
1499: struct session *session_find(const char *);
1500: struct session *session_create(const char *, const char *,
1501: const char *, u_int, u_int, char **);
1502: void session_destroy(struct session *);
1503: int session_index(struct session *, u_int *);
1504: struct winlink *session_new(struct session *,
1505: const char *, const char *, const char *, int, char **);
1506: struct winlink *session_attach(
1507: struct session *, struct window *, int, char **);
1508: int session_detach(struct session *, struct winlink *);
1509: int session_has(struct session *, struct window *);
1510: int session_next(struct session *, int);
1511: int session_previous(struct session *, int);
1512: int session_select(struct session *, int);
1513: int session_last(struct session *);
1514:
1515: /* utf8.c */
1516: void utf8_build(void);
1.7 nicm 1517: int utf8_width(const u_char *);
1.1 nicm 1518:
1519: /* procname.c */
1520: char *get_proc_name(int, char *);
1521:
1522: /* buffer.c */
1523: struct buffer *buffer_create(size_t);
1524: void buffer_destroy(struct buffer *);
1525: void buffer_ensure(struct buffer *, size_t);
1526: void buffer_add(struct buffer *, size_t);
1527: void buffer_remove(struct buffer *, size_t);
1528: void buffer_write(struct buffer *, const void *, size_t);
1529: void buffer_read(struct buffer *, void *, size_t);
1530: void buffer_write8(struct buffer *, uint8_t);
1531: uint8_t buffer_read8(struct buffer *);
1532:
1533: /* buffer-poll.c */
1534: int buffer_poll(struct pollfd *, struct buffer *, struct buffer *);
1535:
1536: /* log.c */
1537: void log_open_tty(int);
1538: void log_open_file(int, const char *);
1539: void log_close(void);
1540: void printflike1 log_warn(const char *, ...);
1541: void printflike1 log_warnx(const char *, ...);
1542: void printflike1 log_info(const char *, ...);
1543: void printflike1 log_debug(const char *, ...);
1544: void printflike1 log_debug2(const char *, ...);
1545: void printflike1 log_debug3(const char *, ...);
1546: __dead void log_fatal(const char *, ...);
1547: __dead void log_fatalx(const char *, ...);
1548:
1549: /* xmalloc.c */
1550: char *xstrdup(const char *);
1551: void *xcalloc(size_t, size_t);
1552: void *xmalloc(size_t);
1553: void *xrealloc(void *, size_t, size_t);
1554: void xfree(void *);
1555: int printflike2 xasprintf(char **, const char *, ...);
1556: int xvasprintf(char **, const char *, va_list);
1557: int printflike3 xsnprintf(char *, size_t, const char *, ...);
1558: int xvsnprintf(char *, size_t, const char *, va_list);
1559:
1560: #endif /* TMUX_H */