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