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