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