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