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