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