1 /* $OpenBSD$ */ 2 3 /* 4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> 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 #include <sys/time.h> 23 #include <sys/uio.h> 24 25 #include <event.h> 26 #include <limits.h> 27 #include <stdarg.h> 28 #include <stdio.h> 29 #include <termios.h> 30 #include <wchar.h> 31 32 #ifdef HAVE_UTEMPTER 33 #include <utempter.h> 34 #endif 35 36 #include "compat.h" 37 #include "xmalloc.h" 38 39 extern char **environ; 40 41 struct args; 42 struct client; 43 struct cmd_find_state; 44 struct cmdq_item; 45 struct cmdq_list; 46 struct environ; 47 struct format_job_tree; 48 struct input_ctx; 49 struct mode_tree_data; 50 struct mouse_event; 51 struct options; 52 struct options_entry; 53 struct session; 54 struct tmuxpeer; 55 struct tmuxproc; 56 57 /* Client-server protocol version. */ 58 #define PROTOCOL_VERSION 8 59 60 /* Default global configuration file. */ 61 #ifndef TMUX_CONF 62 #define TMUX_CONF "/etc/tmux.conf" 63 #endif 64 65 /* 66 * Minimum layout cell size, NOT including separator line. The scroll region 67 * cannot be one line in height so this must be at least two. 68 */ 69 #define PANE_MINIMUM 2 70 71 /* Automatic name refresh interval, in microseconds. Must be < 1 second. */ 72 #define NAME_INTERVAL 500000 73 74 /* Maximum size of data to hold from a pane. */ 75 #define READ_SIZE 4096 76 77 /* Attribute to make GCC check printf-like arguments. */ 78 #define printflike(a, b) __attribute__ ((format (printf, a, b))) 79 80 /* Number of items in array. */ 81 #ifndef nitems 82 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 83 #endif 84 85 /* Alert option values. */ 86 #define ALERT_NONE 0 87 #define ALERT_ANY 1 88 #define ALERT_CURRENT 2 89 #define ALERT_OTHER 3 90 91 /* Visual option values. */ 92 #define VISUAL_OFF 0 93 #define VISUAL_ON 1 94 #define VISUAL_BOTH 2 95 96 /* Special key codes. */ 97 #define KEYC_NONE 0xffff00000000ULL 98 #define KEYC_UNKNOWN 0xfffe00000000ULL 99 #define KEYC_BASE 0x000010000000ULL 100 #define KEYC_USER 0x000020000000ULL 101 102 /* Available user keys. */ 103 #define KEYC_NUSER 1000 104 105 /* Key modifier bits. */ 106 #define KEYC_ESCAPE 0x200000000000ULL 107 #define KEYC_CTRL 0x400000000000ULL 108 #define KEYC_SHIFT 0x800000000000ULL 109 #define KEYC_XTERM 0x1000000000000ULL 110 111 /* Mask to obtain key w/o modifiers. */ 112 #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT|KEYC_XTERM) 113 #define KEYC_MASK_KEY (~KEYC_MASK_MOD) 114 115 /* Is this a mouse key? */ 116 #define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \ 117 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE) 118 119 /* Multiple click timeout. */ 120 #define KEYC_CLICK_TIMEOUT 300 121 122 /* Mouse key codes. */ 123 #define KEYC_MOUSE_KEY(name) \ 124 KEYC_ ## name ## _PANE, \ 125 KEYC_ ## name ## _STATUS, \ 126 KEYC_ ## name ## _BORDER 127 #define KEYC_MOUSE_STRING(name, s) \ 128 { #s "Pane", KEYC_ ## name ## _PANE }, \ 129 { #s "Status", KEYC_ ## name ## _STATUS }, \ 130 { #s "Border", KEYC_ ## name ## _BORDER } 131 132 /* 133 * A single key. This can be ASCII or Unicode or one of the keys starting at 134 * KEYC_BASE. 135 */ 136 typedef unsigned long long key_code; 137 138 /* Special key codes. */ 139 enum { 140 /* Focus events. */ 141 KEYC_FOCUS_IN = KEYC_BASE, 142 KEYC_FOCUS_OUT, 143 144 /* "Any" key, used if not found in key table. */ 145 KEYC_ANY, 146 147 /* Paste brackets. */ 148 KEYC_PASTE_START, 149 KEYC_PASTE_END, 150 151 /* Mouse keys. */ 152 KEYC_MOUSE, /* unclassified mouse event */ 153 KEYC_DRAGGING, /* dragging in progress */ 154 KEYC_MOUSE_KEY(MOUSEMOVE), 155 KEYC_MOUSE_KEY(MOUSEDOWN1), 156 KEYC_MOUSE_KEY(MOUSEDOWN2), 157 KEYC_MOUSE_KEY(MOUSEDOWN3), 158 KEYC_MOUSE_KEY(MOUSEUP1), 159 KEYC_MOUSE_KEY(MOUSEUP2), 160 KEYC_MOUSE_KEY(MOUSEUP3), 161 KEYC_MOUSE_KEY(MOUSEDRAG1), 162 KEYC_MOUSE_KEY(MOUSEDRAG2), 163 KEYC_MOUSE_KEY(MOUSEDRAG3), 164 KEYC_MOUSE_KEY(MOUSEDRAGEND1), 165 KEYC_MOUSE_KEY(MOUSEDRAGEND2), 166 KEYC_MOUSE_KEY(MOUSEDRAGEND3), 167 KEYC_MOUSE_KEY(WHEELUP), 168 KEYC_MOUSE_KEY(WHEELDOWN), 169 KEYC_MOUSE_KEY(DOUBLECLICK1), 170 KEYC_MOUSE_KEY(DOUBLECLICK2), 171 KEYC_MOUSE_KEY(DOUBLECLICK3), 172 KEYC_MOUSE_KEY(TRIPLECLICK1), 173 KEYC_MOUSE_KEY(TRIPLECLICK2), 174 KEYC_MOUSE_KEY(TRIPLECLICK3), 175 176 /* Backspace key. */ 177 KEYC_BSPACE, 178 179 /* Function keys. */ 180 KEYC_F1, 181 KEYC_F2, 182 KEYC_F3, 183 KEYC_F4, 184 KEYC_F5, 185 KEYC_F6, 186 KEYC_F7, 187 KEYC_F8, 188 KEYC_F9, 189 KEYC_F10, 190 KEYC_F11, 191 KEYC_F12, 192 KEYC_IC, 193 KEYC_DC, 194 KEYC_HOME, 195 KEYC_END, 196 KEYC_NPAGE, 197 KEYC_PPAGE, 198 KEYC_BTAB, 199 200 /* Arrow keys. */ 201 KEYC_UP, 202 KEYC_DOWN, 203 KEYC_LEFT, 204 KEYC_RIGHT, 205 206 /* Numeric keypad. */ 207 KEYC_KP_SLASH, 208 KEYC_KP_STAR, 209 KEYC_KP_MINUS, 210 KEYC_KP_SEVEN, 211 KEYC_KP_EIGHT, 212 KEYC_KP_NINE, 213 KEYC_KP_PLUS, 214 KEYC_KP_FOUR, 215 KEYC_KP_FIVE, 216 KEYC_KP_SIX, 217 KEYC_KP_ONE, 218 KEYC_KP_TWO, 219 KEYC_KP_THREE, 220 KEYC_KP_ENTER, 221 KEYC_KP_ZERO, 222 KEYC_KP_PERIOD, 223 }; 224 225 /* Termcap codes. */ 226 enum tty_code_code { 227 TTYC_AX = 0, 228 TTYC_ACSC, 229 TTYC_BCE, 230 TTYC_BEL, 231 TTYC_BLINK, 232 TTYC_BOLD, 233 TTYC_CIVIS, 234 TTYC_CLEAR, 235 TTYC_CNORM, 236 TTYC_COLORS, 237 TTYC_CR, 238 TTYC_CS, 239 TTYC_CSR, 240 TTYC_CUB, 241 TTYC_CUB1, 242 TTYC_CUD, 243 TTYC_CUD1, 244 TTYC_CUF, 245 TTYC_CUF1, 246 TTYC_CUP, 247 TTYC_CUU, 248 TTYC_CUU1, 249 TTYC_CVVIS, 250 TTYC_DCH, 251 TTYC_DCH1, 252 TTYC_DIM, 253 TTYC_DL, 254 TTYC_DL1, 255 TTYC_E3, 256 TTYC_ECH, 257 TTYC_ED, 258 TTYC_EL, 259 TTYC_EL1, 260 TTYC_ENACS, 261 TTYC_FSL, 262 TTYC_HOME, 263 TTYC_HPA, 264 TTYC_ICH, 265 TTYC_ICH1, 266 TTYC_IL, 267 TTYC_IL1, 268 TTYC_INDN, 269 TTYC_INVIS, 270 TTYC_KCBT, 271 TTYC_KCUB1, 272 TTYC_KCUD1, 273 TTYC_KCUF1, 274 TTYC_KCUU1, 275 TTYC_KDC2, 276 TTYC_KDC3, 277 TTYC_KDC4, 278 TTYC_KDC5, 279 TTYC_KDC6, 280 TTYC_KDC7, 281 TTYC_KDCH1, 282 TTYC_KDN2, 283 TTYC_KDN3, 284 TTYC_KDN4, 285 TTYC_KDN5, 286 TTYC_KDN6, 287 TTYC_KDN7, 288 TTYC_KEND, 289 TTYC_KEND2, 290 TTYC_KEND3, 291 TTYC_KEND4, 292 TTYC_KEND5, 293 TTYC_KEND6, 294 TTYC_KEND7, 295 TTYC_KF1, 296 TTYC_KF10, 297 TTYC_KF11, 298 TTYC_KF12, 299 TTYC_KF13, 300 TTYC_KF14, 301 TTYC_KF15, 302 TTYC_KF16, 303 TTYC_KF17, 304 TTYC_KF18, 305 TTYC_KF19, 306 TTYC_KF2, 307 TTYC_KF20, 308 TTYC_KF21, 309 TTYC_KF22, 310 TTYC_KF23, 311 TTYC_KF24, 312 TTYC_KF25, 313 TTYC_KF26, 314 TTYC_KF27, 315 TTYC_KF28, 316 TTYC_KF29, 317 TTYC_KF3, 318 TTYC_KF30, 319 TTYC_KF31, 320 TTYC_KF32, 321 TTYC_KF33, 322 TTYC_KF34, 323 TTYC_KF35, 324 TTYC_KF36, 325 TTYC_KF37, 326 TTYC_KF38, 327 TTYC_KF39, 328 TTYC_KF4, 329 TTYC_KF40, 330 TTYC_KF41, 331 TTYC_KF42, 332 TTYC_KF43, 333 TTYC_KF44, 334 TTYC_KF45, 335 TTYC_KF46, 336 TTYC_KF47, 337 TTYC_KF48, 338 TTYC_KF49, 339 TTYC_KF5, 340 TTYC_KF50, 341 TTYC_KF51, 342 TTYC_KF52, 343 TTYC_KF53, 344 TTYC_KF54, 345 TTYC_KF55, 346 TTYC_KF56, 347 TTYC_KF57, 348 TTYC_KF58, 349 TTYC_KF59, 350 TTYC_KF6, 351 TTYC_KF60, 352 TTYC_KF61, 353 TTYC_KF62, 354 TTYC_KF63, 355 TTYC_KF7, 356 TTYC_KF8, 357 TTYC_KF9, 358 TTYC_KHOM2, 359 TTYC_KHOM3, 360 TTYC_KHOM4, 361 TTYC_KHOM5, 362 TTYC_KHOM6, 363 TTYC_KHOM7, 364 TTYC_KHOME, 365 TTYC_KIC2, 366 TTYC_KIC3, 367 TTYC_KIC4, 368 TTYC_KIC5, 369 TTYC_KIC6, 370 TTYC_KIC7, 371 TTYC_KICH1, 372 TTYC_KIND, 373 TTYC_KLFT2, 374 TTYC_KLFT3, 375 TTYC_KLFT4, 376 TTYC_KLFT5, 377 TTYC_KLFT6, 378 TTYC_KLFT7, 379 TTYC_KMOUS, 380 TTYC_KNP, 381 TTYC_KNXT2, 382 TTYC_KNXT3, 383 TTYC_KNXT4, 384 TTYC_KNXT5, 385 TTYC_KNXT6, 386 TTYC_KNXT7, 387 TTYC_KPP, 388 TTYC_KPRV2, 389 TTYC_KPRV3, 390 TTYC_KPRV4, 391 TTYC_KPRV5, 392 TTYC_KPRV6, 393 TTYC_KPRV7, 394 TTYC_KRI, 395 TTYC_KRIT2, 396 TTYC_KRIT3, 397 TTYC_KRIT4, 398 TTYC_KRIT5, 399 TTYC_KRIT6, 400 TTYC_KRIT7, 401 TTYC_KUP2, 402 TTYC_KUP3, 403 TTYC_KUP4, 404 TTYC_KUP5, 405 TTYC_KUP6, 406 TTYC_KUP7, 407 TTYC_MS, 408 TTYC_OP, 409 TTYC_REV, 410 TTYC_RGB, 411 TTYC_RI, 412 TTYC_RMACS, 413 TTYC_RMCUP, 414 TTYC_RMKX, 415 TTYC_SE, 416 TTYC_SETAB, 417 TTYC_SETAF, 418 TTYC_SETRGBB, 419 TTYC_SETRGBF, 420 TTYC_SGR0, 421 TTYC_SITM, 422 TTYC_SMACS, 423 TTYC_SMCUP, 424 TTYC_SMKX, 425 TTYC_SMSO, 426 TTYC_SMUL, 427 TTYC_SMXX, 428 TTYC_SS, 429 TTYC_TC, 430 TTYC_TSL, 431 TTYC_U8, 432 TTYC_VPA, 433 TTYC_XENL, 434 TTYC_XT, 435 }; 436 437 /* Message codes. */ 438 enum msgtype { 439 MSG_VERSION = 12, 440 441 MSG_IDENTIFY_FLAGS = 100, 442 MSG_IDENTIFY_TERM, 443 MSG_IDENTIFY_TTYNAME, 444 MSG_IDENTIFY_OLDCWD, /* unused */ 445 MSG_IDENTIFY_STDIN, 446 MSG_IDENTIFY_ENVIRON, 447 MSG_IDENTIFY_DONE, 448 MSG_IDENTIFY_CLIENTPID, 449 MSG_IDENTIFY_CWD, 450 451 MSG_COMMAND = 200, 452 MSG_DETACH, 453 MSG_DETACHKILL, 454 MSG_EXIT, 455 MSG_EXITED, 456 MSG_EXITING, 457 MSG_LOCK, 458 MSG_READY, 459 MSG_RESIZE, 460 MSG_SHELL, 461 MSG_SHUTDOWN, 462 MSG_STDERR, 463 MSG_STDIN, 464 MSG_STDOUT, 465 MSG_SUSPEND, 466 MSG_UNLOCK, 467 MSG_WAKEUP, 468 MSG_EXEC, 469 }; 470 471 /* 472 * Message data. 473 * 474 * Don't forget to bump PROTOCOL_VERSION if any of these change! 475 */ 476 struct msg_command_data { 477 int argc; 478 }; /* followed by packed argv */ 479 480 struct msg_stdin_data { 481 ssize_t size; 482 char data[BUFSIZ]; 483 }; 484 485 struct msg_stdout_data { 486 ssize_t size; 487 char data[BUFSIZ]; 488 }; 489 490 struct msg_stderr_data { 491 ssize_t size; 492 char data[BUFSIZ]; 493 }; 494 495 /* Mode keys. */ 496 #define MODEKEY_EMACS 0 497 #define MODEKEY_VI 1 498 499 /* Modes. */ 500 #define MODE_CURSOR 0x1 501 #define MODE_INSERT 0x2 502 #define MODE_KCURSOR 0x4 503 #define MODE_KKEYPAD 0x8 /* set = application, clear = number */ 504 #define MODE_WRAP 0x10 /* whether lines wrap */ 505 #define MODE_MOUSE_STANDARD 0x20 506 #define MODE_MOUSE_BUTTON 0x40 507 #define MODE_BLINKING 0x80 508 #define MODE_MOUSE_UTF8 0x100 509 #define MODE_MOUSE_SGR 0x200 510 #define MODE_BRACKETPASTE 0x400 511 #define MODE_FOCUSON 0x800 512 #define MODE_MOUSE_ALL 0x1000 513 514 #define ALL_MODES 0xffffff 515 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL) 516 517 /* 518 * A single UTF-8 character. UTF8_SIZE must be big enough to hold 519 * combining characters as well, currently at most five (of three 520 * bytes) are supported. 521 */ 522 #define UTF8_SIZE 18 523 struct utf8_data { 524 u_char data[UTF8_SIZE]; 525 526 u_char have; 527 u_char size; 528 529 u_char width; /* 0xff if invalid */ 530 } __packed; 531 enum utf8_state { 532 UTF8_MORE, 533 UTF8_DONE, 534 UTF8_ERROR 535 }; 536 537 /* Colour flags. */ 538 #define COLOUR_FLAG_256 0x01000000 539 #define COLOUR_FLAG_RGB 0x02000000 540 541 /* Grid attributes. Anything above 0xff is stored in an extended cell. */ 542 #define GRID_ATTR_BRIGHT 0x1 543 #define GRID_ATTR_DIM 0x2 544 #define GRID_ATTR_UNDERSCORE 0x4 545 #define GRID_ATTR_BLINK 0x8 546 #define GRID_ATTR_REVERSE 0x10 547 #define GRID_ATTR_HIDDEN 0x20 548 #define GRID_ATTR_ITALICS 0x40 549 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */ 550 #define GRID_ATTR_STRIKETHROUGH 0x100 551 552 /* Grid flags. */ 553 #define GRID_FLAG_FG256 0x1 554 #define GRID_FLAG_BG256 0x2 555 #define GRID_FLAG_PADDING 0x4 556 #define GRID_FLAG_EXTENDED 0x8 557 #define GRID_FLAG_SELECTED 0x10 558 #define GRID_FLAG_NOPALETTE 0x20 559 560 /* Grid line flags. */ 561 #define GRID_LINE_WRAPPED 0x1 562 #define GRID_LINE_EXTENDED 0x2 563 #define GRID_LINE_DEAD 0x4 564 565 /* Grid cell data. */ 566 struct grid_cell { 567 u_char flags; 568 u_short attr; 569 int fg; 570 int bg; 571 struct utf8_data data; 572 }; 573 struct grid_cell_entry { 574 u_char flags; 575 union { 576 u_int offset; 577 struct { 578 u_char attr; 579 u_char fg; 580 u_char bg; 581 u_char data; 582 } data; 583 }; 584 } __packed; 585 586 /* Grid line. */ 587 struct grid_line { 588 u_int cellused; 589 u_int cellsize; 590 struct grid_cell_entry *celldata; 591 592 u_int extdsize; 593 struct grid_cell *extddata; 594 595 int flags; 596 } __packed; 597 598 /* Entire grid of cells. */ 599 struct grid { 600 int flags; 601 #define GRID_HISTORY 0x1 /* scroll lines into history */ 602 603 u_int sx; 604 u_int sy; 605 606 u_int hscrolled; 607 u_int hsize; 608 u_int hlimit; 609 610 struct grid_line *linedata; 611 }; 612 613 /* Hook data structures. */ 614 struct hook { 615 const char *name; 616 617 struct cmd_list *cmdlist; 618 619 RB_ENTRY(hook) entry; 620 }; 621 622 /* Scheduled job. */ 623 struct job; 624 typedef void (*job_update_cb) (struct job *); 625 typedef void (*job_complete_cb) (struct job *); 626 typedef void (*job_free_cb) (void *); 627 struct job { 628 enum { 629 JOB_RUNNING, 630 JOB_DEAD, 631 JOB_CLOSED 632 } state; 633 634 int flags; 635 #define JOB_NOWAIT 0x1 636 637 char *cmd; 638 pid_t pid; 639 int status; 640 641 int fd; 642 struct bufferevent *event; 643 644 job_update_cb updatecb; 645 job_complete_cb completecb; 646 job_free_cb freecb; 647 void *data; 648 649 LIST_ENTRY(job) entry; 650 }; 651 LIST_HEAD(joblist, job); 652 653 /* Virtual screen. */ 654 struct screen_sel; 655 struct screen_titles; 656 struct screen { 657 char *title; 658 struct screen_titles *titles; 659 660 struct grid *grid; /* grid data */ 661 662 u_int cx; /* cursor x */ 663 u_int cy; /* cursor y */ 664 665 u_int cstyle; /* cursor style */ 666 char *ccolour; /* cursor colour string */ 667 668 u_int rupper; /* scroll region top */ 669 u_int rlower; /* scroll region bottom */ 670 671 int mode; 672 673 bitstr_t *tabs; 674 675 struct screen_sel *sel; 676 }; 677 678 /* Screen write context. */ 679 struct screen_write_collect_item; 680 struct screen_write_collect_line; 681 struct screen_write_ctx { 682 struct window_pane *wp; 683 struct screen *s; 684 685 struct screen_write_collect_item *item; 686 struct screen_write_collect_line *list; 687 u_int scrolled; 688 u_int bg; 689 690 u_int cells; 691 u_int written; 692 u_int skipped; 693 }; 694 695 /* Screen size. */ 696 #define screen_size_x(s) ((s)->grid->sx) 697 #define screen_size_y(s) ((s)->grid->sy) 698 #define screen_hsize(s) ((s)->grid->hsize) 699 #define screen_hlimit(s) ((s)->grid->hlimit) 700 701 /* 702 * Window mode. Windows can be in several modes and this is used to call the 703 * right function to handle input and output. 704 */ 705 struct window_mode { 706 const char *name; 707 708 struct screen *(*init)(struct window_pane *, struct cmd_find_state *, 709 struct args *); 710 void (*free)(struct window_pane *); 711 void (*resize)(struct window_pane *, u_int, u_int); 712 void (*key)(struct window_pane *, struct client *, 713 struct session *, key_code, struct mouse_event *); 714 715 const char *(*key_table)(struct window_pane *); 716 void (*command)(struct window_pane *, struct client *, 717 struct session *, struct args *, 718 struct mouse_event *); 719 }; 720 #define WINDOW_MODE_TIMEOUT 180 721 722 /* Child window structure. */ 723 struct window_pane { 724 u_int id; 725 u_int active_point; 726 727 struct window *window; 728 729 struct layout_cell *layout_cell; 730 struct layout_cell *saved_layout_cell; 731 732 u_int sx; 733 u_int sy; 734 735 u_int osx; 736 u_int osy; 737 738 u_int xoff; 739 u_int yoff; 740 741 int flags; 742 #define PANE_REDRAW 0x1 743 #define PANE_DROP 0x2 744 #define PANE_FOCUSED 0x4 745 #define PANE_RESIZE 0x8 746 #define PANE_RESIZEFORCE 0x10 747 #define PANE_FOCUSPUSH 0x20 748 #define PANE_INPUTOFF 0x40 749 #define PANE_CHANGED 0x80 750 #define PANE_EXITED 0x100 751 #define PANE_STATUSREADY 0x200 752 #define PANE_STATUSDRAWN 0x400 753 754 int argc; 755 char **argv; 756 char *shell; 757 const char *cwd; 758 759 pid_t pid; 760 char tty[TTY_NAME_MAX]; 761 int status; 762 763 int fd; 764 struct bufferevent *event; 765 766 struct event resize_timer; 767 768 struct input_ctx *ictx; 769 770 struct grid_cell colgc; 771 772 int *palette; 773 774 int pipe_fd; 775 struct bufferevent *pipe_event; 776 size_t pipe_off; 777 778 struct screen *screen; 779 struct screen base; 780 781 struct screen status_screen; 782 size_t status_size; 783 784 /* Saved in alternative screen mode. */ 785 u_int saved_cx; 786 u_int saved_cy; 787 struct grid *saved_grid; 788 struct grid_cell saved_cell; 789 790 const struct window_mode *mode; 791 void *modedata; 792 struct event modetimer; 793 time_t modelast; 794 u_int modeprefix; 795 char *searchstr; 796 797 TAILQ_ENTRY(window_pane) entry; 798 RB_ENTRY(window_pane) tree_entry; 799 }; 800 TAILQ_HEAD(window_panes, window_pane); 801 RB_HEAD(window_pane_tree, window_pane); 802 803 /* Window structure. */ 804 struct window { 805 u_int id; 806 807 char *name; 808 struct event name_event; 809 struct timeval name_time; 810 811 struct event alerts_timer; 812 813 struct timeval activity_time; 814 815 struct window_pane *active; 816 struct window_pane *last; 817 struct window_panes panes; 818 819 int lastlayout; 820 struct layout_cell *layout_root; 821 struct layout_cell *saved_layout_root; 822 char *old_layout; 823 824 u_int sx; 825 u_int sy; 826 827 int flags; 828 #define WINDOW_BELL 0x1 829 #define WINDOW_ACTIVITY 0x2 830 #define WINDOW_SILENCE 0x4 831 #define WINDOW_ZOOMED 0x8 832 #define WINDOW_FORCEWIDTH 0x10 833 #define WINDOW_FORCEHEIGHT 0x20 834 #define WINDOW_STYLECHANGED 0x40 835 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE) 836 837 int alerts_queued; 838 TAILQ_ENTRY(window) alerts_entry; 839 840 struct options *options; 841 842 struct grid_cell style; 843 struct grid_cell active_style; 844 845 u_int references; 846 TAILQ_HEAD(, winlink) winlinks; 847 848 RB_ENTRY(window) entry; 849 }; 850 RB_HEAD(windows, window); 851 852 /* Entry on local window list. */ 853 struct winlink { 854 int idx; 855 struct session *session; 856 struct window *window; 857 858 size_t status_width; 859 struct grid_cell status_cell; 860 char *status_text; 861 862 int flags; 863 #define WINLINK_BELL 0x1 864 #define WINLINK_ACTIVITY 0x2 865 #define WINLINK_SILENCE 0x4 866 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE) 867 868 RB_ENTRY(winlink) entry; 869 TAILQ_ENTRY(winlink) wentry; 870 TAILQ_ENTRY(winlink) sentry; 871 }; 872 RB_HEAD(winlinks, winlink); 873 TAILQ_HEAD(winlink_stack, winlink); 874 875 /* Layout direction. */ 876 enum layout_type { 877 LAYOUT_LEFTRIGHT, 878 LAYOUT_TOPBOTTOM, 879 LAYOUT_WINDOWPANE 880 }; 881 882 /* Layout cells queue. */ 883 TAILQ_HEAD(layout_cells, layout_cell); 884 885 /* Layout cell. */ 886 struct layout_cell { 887 enum layout_type type; 888 889 struct layout_cell *parent; 890 891 u_int sx; 892 u_int sy; 893 894 u_int xoff; 895 u_int yoff; 896 897 struct window_pane *wp; 898 struct layout_cells cells; 899 900 TAILQ_ENTRY(layout_cell) entry; 901 }; 902 903 /* Environment variable. */ 904 struct environ_entry { 905 char *name; 906 char *value; 907 908 RB_ENTRY(environ_entry) entry; 909 }; 910 911 /* Client session. */ 912 struct session_group { 913 const char *name; 914 TAILQ_HEAD(, session) sessions; 915 916 RB_ENTRY(session_group) entry; 917 }; 918 RB_HEAD(session_groups, session_group); 919 920 struct session { 921 u_int id; 922 923 char *name; 924 const char *cwd; 925 926 struct timeval creation_time; 927 struct timeval last_attached_time; 928 struct timeval activity_time; 929 struct timeval last_activity_time; 930 931 struct event lock_timer; 932 933 u_int sx; 934 u_int sy; 935 936 struct winlink *curw; 937 struct winlink_stack lastw; 938 struct winlinks windows; 939 940 int statusat; 941 942 struct hooks *hooks; 943 struct options *options; 944 945 #define SESSION_UNATTACHED 0x1 /* not attached to any clients */ 946 #define SESSION_PASTING 0x2 947 #define SESSION_ALERTED 0x4 948 int flags; 949 950 u_int attached; 951 952 struct termios *tio; 953 954 struct environ *environ; 955 956 int references; 957 958 TAILQ_ENTRY(session) gentry; 959 RB_ENTRY(session) entry; 960 }; 961 RB_HEAD(sessions, session); 962 963 /* Mouse button masks. */ 964 #define MOUSE_MASK_BUTTONS 3 965 #define MOUSE_MASK_SHIFT 4 966 #define MOUSE_MASK_META 8 967 #define MOUSE_MASK_CTRL 16 968 #define MOUSE_MASK_DRAG 32 969 #define MOUSE_MASK_WHEEL 64 970 971 /* Mouse wheel states. */ 972 #define MOUSE_WHEEL_UP 0 973 #define MOUSE_WHEEL_DOWN 64 974 975 /* Mouse helpers. */ 976 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS) 977 #define MOUSE_WHEEL(b) ((b) & MOUSE_MASK_WHEEL) 978 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG) 979 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3) 980 981 /* Mouse input. */ 982 struct mouse_event { 983 int valid; 984 985 key_code key; 986 int statusat; 987 988 u_int x; 989 u_int y; 990 u_int b; 991 992 u_int lx; 993 u_int ly; 994 u_int lb; 995 996 int s; 997 int w; 998 int wp; 999 1000 u_int sgr_type; 1001 u_int sgr_b; 1002 }; 1003 1004 /* TTY information. */ 1005 struct tty_key { 1006 char ch; 1007 key_code key; 1008 1009 struct tty_key *left; 1010 struct tty_key *right; 1011 1012 struct tty_key *next; 1013 }; 1014 1015 struct tty_code; 1016 struct tty_term { 1017 char *name; 1018 u_int references; 1019 1020 char acs[UCHAR_MAX + 1][2]; 1021 1022 struct tty_code *codes; 1023 1024 #define TERM_256COLOURS 0x1 1025 #define TERM_EARLYWRAP 0x2 1026 int flags; 1027 1028 LIST_ENTRY(tty_term) entry; 1029 }; 1030 LIST_HEAD(tty_terms, tty_term); 1031 1032 struct tty { 1033 struct client *client; 1034 1035 u_int sx; 1036 u_int sy; 1037 1038 u_int cx; 1039 u_int cy; 1040 u_int cstyle; 1041 char *ccolour; 1042 1043 int mode; 1044 1045 u_int rlower; 1046 u_int rupper; 1047 1048 u_int rleft; 1049 u_int rright; 1050 1051 int fd; 1052 struct event event_in; 1053 struct evbuffer *in; 1054 struct event event_out; 1055 struct evbuffer *out; 1056 struct event timer; 1057 size_t discarded; 1058 1059 struct termios tio; 1060 1061 struct grid_cell cell; 1062 1063 int last_wp; 1064 struct grid_cell last_cell; 1065 1066 #define TTY_NOCURSOR 0x1 1067 #define TTY_FREEZE 0x2 1068 #define TTY_TIMER 0x4 1069 #define TTY_UTF8 0x8 1070 #define TTY_STARTED 0x10 1071 #define TTY_OPENED 0x20 1072 #define TTY_FOCUS 0x40 1073 #define TTY_BLOCK 0x80 1074 int flags; 1075 1076 struct tty_term *term; 1077 char *term_name; 1078 int term_flags; 1079 enum { 1080 TTY_VT100, 1081 TTY_VT101, 1082 TTY_VT102, 1083 TTY_VT220, 1084 TTY_VT320, 1085 TTY_VT420, 1086 TTY_UNKNOWN 1087 } term_type; 1088 1089 struct mouse_event mouse; 1090 int mouse_drag_flag; 1091 void (*mouse_drag_update)(struct client *, 1092 struct mouse_event *); 1093 void (*mouse_drag_release)(struct client *, 1094 struct mouse_event *); 1095 1096 struct event key_timer; 1097 struct tty_key *key_tree; 1098 }; 1099 #define TTY_TYPES \ 1100 { "VT100", "VT101", "VT102", "VT220", "VT320", "VT420", "Unknown" } 1101 1102 /* TTY command context. */ 1103 struct tty_ctx { 1104 struct window_pane *wp; 1105 1106 const struct grid_cell *cell; 1107 int wrapped; 1108 1109 u_int num; 1110 void *ptr; 1111 1112 /* 1113 * Cursor and region position before the screen was updated - this is 1114 * where the command should be applied; the values in the screen have 1115 * already been updated. 1116 */ 1117 u_int ocx; 1118 u_int ocy; 1119 1120 u_int orupper; 1121 u_int orlower; 1122 1123 u_int xoff; 1124 u_int yoff; 1125 1126 /* The background colour used for clearing (erasing). */ 1127 u_int bg; 1128 }; 1129 1130 /* Saved message entry. */ 1131 struct message_entry { 1132 char *msg; 1133 u_int msg_num; 1134 time_t msg_time; 1135 TAILQ_ENTRY(message_entry) entry; 1136 }; 1137 1138 /* Parsed arguments structures. */ 1139 struct args_entry; 1140 RB_HEAD(args_tree, args_entry); 1141 struct args { 1142 struct args_tree tree; 1143 int argc; 1144 char **argv; 1145 }; 1146 1147 /* Command find structures. */ 1148 enum cmd_find_type { 1149 CMD_FIND_PANE, 1150 CMD_FIND_WINDOW, 1151 CMD_FIND_SESSION, 1152 }; 1153 struct cmd_find_state { 1154 int flags; 1155 struct cmd_find_state *current; 1156 1157 struct session *s; 1158 struct winlink *wl; 1159 struct window *w; 1160 struct window_pane *wp; 1161 int idx; 1162 }; 1163 1164 /* Command find flags. */ 1165 #define CMD_FIND_PREFER_UNATTACHED 0x1 1166 #define CMD_FIND_QUIET 0x2 1167 #define CMD_FIND_WINDOW_INDEX 0x4 1168 #define CMD_FIND_DEFAULT_MARKED 0x8 1169 #define CMD_FIND_EXACT_SESSION 0x10 1170 #define CMD_FIND_EXACT_WINDOW 0x20 1171 #define CMD_FIND_CANFAIL 0x40 1172 1173 /* Command and list of commands. */ 1174 struct cmd { 1175 const struct cmd_entry *entry; 1176 struct args *args; 1177 1178 char *file; 1179 u_int line; 1180 1181 #define CMD_CONTROL 0x1 1182 int flags; 1183 1184 TAILQ_ENTRY(cmd) qentry; 1185 }; 1186 1187 struct cmd_list { 1188 int references; 1189 TAILQ_HEAD(, cmd) list; 1190 }; 1191 1192 /* Command return values. */ 1193 enum cmd_retval { 1194 CMD_RETURN_ERROR = -1, 1195 CMD_RETURN_NORMAL = 0, 1196 CMD_RETURN_WAIT, 1197 CMD_RETURN_STOP 1198 }; 1199 1200 /* Command queue item type. */ 1201 enum cmdq_type { 1202 CMDQ_COMMAND, 1203 CMDQ_CALLBACK, 1204 }; 1205 1206 /* Command queue item shared state. */ 1207 struct cmdq_shared { 1208 int references; 1209 1210 int flags; 1211 #define CMDQ_SHARED_REPEAT 0x1 1212 1213 struct format_tree *formats; 1214 1215 struct mouse_event mouse; 1216 struct cmd_find_state current; 1217 }; 1218 1219 /* Command queue item. */ 1220 typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *); 1221 struct cmdq_item { 1222 const char *name; 1223 struct cmdq_list *queue; 1224 struct cmdq_item *next; 1225 1226 struct client *client; 1227 1228 enum cmdq_type type; 1229 u_int group; 1230 1231 u_int number; 1232 time_t time; 1233 1234 int flags; 1235 #define CMDQ_FIRED 0x1 1236 #define CMDQ_WAITING 0x2 1237 #define CMDQ_NOHOOKS 0x4 1238 1239 struct cmdq_shared *shared; 1240 struct cmd_find_state source; 1241 struct cmd_find_state target; 1242 1243 struct cmd_list *cmdlist; 1244 struct cmd *cmd; 1245 1246 cmdq_cb cb; 1247 void *data; 1248 1249 TAILQ_ENTRY(cmdq_item) entry; 1250 }; 1251 TAILQ_HEAD(cmdq_list, cmdq_item); 1252 1253 /* Command definition flag. */ 1254 struct cmd_entry_flag { 1255 char flag; 1256 enum cmd_find_type type; 1257 int flags; 1258 }; 1259 1260 /* Command definition. */ 1261 struct cmd_entry { 1262 const char *name; 1263 const char *alias; 1264 1265 struct { 1266 const char *template; 1267 int lower; 1268 int upper; 1269 } args; 1270 const char *usage; 1271 1272 struct cmd_entry_flag source; 1273 struct cmd_entry_flag target; 1274 1275 #define CMD_STARTSERVER 0x1 1276 #define CMD_READONLY 0x2 1277 #define CMD_AFTERHOOK 0x4 1278 int flags; 1279 1280 enum cmd_retval (*exec)(struct cmd *, struct cmdq_item *); 1281 }; 1282 1283 /* Status line. */ 1284 struct status_line { 1285 struct event timer; 1286 struct screen status; 1287 struct screen *old_status; 1288 }; 1289 1290 /* Client connection. */ 1291 typedef int (*prompt_input_cb)(struct client *, void *, const char *, int); 1292 typedef void (*prompt_free_cb)(void *); 1293 struct client { 1294 const char *name; 1295 struct tmuxpeer *peer; 1296 struct cmdq_list queue; 1297 1298 pid_t pid; 1299 int fd; 1300 struct event event; 1301 int retval; 1302 1303 struct timeval creation_time; 1304 struct timeval activity_time; 1305 1306 struct environ *environ; 1307 struct format_job_tree *jobs; 1308 1309 char *title; 1310 const char *cwd; 1311 1312 char *term; 1313 char *ttyname; 1314 struct tty tty; 1315 1316 size_t written; 1317 size_t discarded; 1318 size_t redraw; 1319 1320 void (*stdin_callback)(struct client *, int, void *); 1321 void *stdin_callback_data; 1322 struct evbuffer *stdin_data; 1323 int stdin_closed; 1324 struct evbuffer *stdout_data; 1325 struct evbuffer *stderr_data; 1326 1327 struct event repeat_timer; 1328 1329 struct event click_timer; 1330 u_int click_button; 1331 1332 struct status_line status; 1333 1334 #define CLIENT_TERMINAL 0x1 1335 #define CLIENT_LOGIN 0x2 1336 #define CLIENT_EXIT 0x4 1337 #define CLIENT_REDRAW 0x8 1338 #define CLIENT_STATUS 0x10 1339 #define CLIENT_REPEAT 0x20 1340 #define CLIENT_SUSPENDED 0x40 1341 #define CLIENT_ATTACHED 0x80 1342 #define CLIENT_IDENTIFY 0x100 1343 #define CLIENT_DEAD 0x200 1344 #define CLIENT_BORDERS 0x400 1345 #define CLIENT_READONLY 0x800 1346 #define CLIENT_DETACHING 0x1000 1347 #define CLIENT_CONTROL 0x2000 1348 #define CLIENT_CONTROLCONTROL 0x4000 1349 #define CLIENT_FOCUSED 0x8000 1350 #define CLIENT_UTF8 0x10000 1351 #define CLIENT_256COLOURS 0x20000 1352 #define CLIENT_IDENTIFIED 0x40000 1353 #define CLIENT_STATUSFORCE 0x80000 1354 #define CLIENT_DOUBLECLICK 0x100000 1355 #define CLIENT_TRIPLECLICK 0x200000 1356 #define CLIENT_SIZECHANGED 0x400000 1357 #define CLIENT_STATUSOFF 0x800000 1358 int flags; 1359 struct key_table *keytable; 1360 1361 struct event identify_timer; 1362 void (*identify_callback)(struct client *, 1363 struct window_pane *); 1364 void *identify_callback_data; 1365 struct cmdq_item *identify_callback_item; 1366 1367 char *message_string; 1368 struct event message_timer; 1369 u_int message_next; 1370 TAILQ_HEAD(, message_entry) message_log; 1371 1372 char *prompt_string; 1373 struct utf8_data *prompt_buffer; 1374 size_t prompt_index; 1375 prompt_input_cb prompt_inputcb; 1376 prompt_free_cb prompt_freecb; 1377 void *prompt_data; 1378 u_int prompt_hindex; 1379 enum { PROMPT_ENTRY, PROMPT_COMMAND } prompt_mode; 1380 1381 #define PROMPT_SINGLE 0x1 1382 #define PROMPT_NUMERIC 0x2 1383 #define PROMPT_INCREMENTAL 0x4 1384 #define PROMPT_NOFORMAT 0x8 1385 int prompt_flags; 1386 1387 struct session *session; 1388 struct session *last_session; 1389 1390 int wlmouse; 1391 1392 int references; 1393 1394 TAILQ_ENTRY(client) entry; 1395 }; 1396 TAILQ_HEAD(clients, client); 1397 1398 /* Key binding and key table. */ 1399 struct key_binding { 1400 key_code key; 1401 struct cmd_list *cmdlist; 1402 1403 int flags; 1404 #define KEY_BINDING_REPEAT 0x1 1405 1406 RB_ENTRY(key_binding) entry; 1407 }; 1408 RB_HEAD(key_bindings, key_binding); 1409 1410 struct key_table { 1411 const char *name; 1412 struct key_bindings key_bindings; 1413 1414 u_int references; 1415 1416 RB_ENTRY(key_table) entry; 1417 }; 1418 RB_HEAD(key_tables, key_table); 1419 1420 /* Option table entries. */ 1421 enum options_table_type { 1422 OPTIONS_TABLE_STRING, 1423 OPTIONS_TABLE_NUMBER, 1424 OPTIONS_TABLE_KEY, 1425 OPTIONS_TABLE_COLOUR, 1426 OPTIONS_TABLE_ATTRIBUTES, 1427 OPTIONS_TABLE_FLAG, 1428 OPTIONS_TABLE_CHOICE, 1429 OPTIONS_TABLE_STYLE, 1430 OPTIONS_TABLE_ARRAY, 1431 }; 1432 1433 enum options_table_scope { 1434 OPTIONS_TABLE_NONE, 1435 OPTIONS_TABLE_SERVER, 1436 OPTIONS_TABLE_SESSION, 1437 OPTIONS_TABLE_WINDOW, 1438 }; 1439 1440 struct options_table_entry { 1441 const char *name; 1442 enum options_table_type type; 1443 enum options_table_scope scope; 1444 1445 u_int minimum; 1446 u_int maximum; 1447 const char **choices; 1448 1449 const char *default_str; 1450 long long default_num; 1451 1452 const char *separator; 1453 const char *style; 1454 }; 1455 1456 /* Common command usages. */ 1457 #define CMD_TARGET_PANE_USAGE "[-t target-pane]" 1458 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]" 1459 #define CMD_TARGET_SESSION_USAGE "[-t target-session]" 1460 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]" 1461 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]" 1462 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]" 1463 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]" 1464 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]" 1465 #define CMD_BUFFER_USAGE "[-b buffer-name]" 1466 1467 /* tmux.c */ 1468 extern struct hooks *global_hooks; 1469 extern struct options *global_options; 1470 extern struct options *global_s_options; 1471 extern struct options *global_w_options; 1472 extern struct environ *global_environ; 1473 extern struct timeval start_time; 1474 extern const char *socket_path; 1475 extern const char *shell_command; 1476 extern int ptm_fd; 1477 extern const char *shell_command; 1478 int areshell(const char *); 1479 void setblocking(int, int); 1480 const char *find_home(void); 1481 1482 /* proc.c */ 1483 struct imsg; 1484 int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t); 1485 struct tmuxproc *proc_start(const char *); 1486 void proc_loop(struct tmuxproc *, int (*)(void)); 1487 void proc_exit(struct tmuxproc *); 1488 void proc_set_signals(struct tmuxproc *, void(*)(int)); 1489 void proc_clear_signals(struct tmuxproc *, int); 1490 struct tmuxpeer *proc_add_peer(struct tmuxproc *, int, 1491 void (*)(struct imsg *, void *), void *); 1492 void proc_remove_peer(struct tmuxpeer *); 1493 void proc_kill_peer(struct tmuxpeer *); 1494 void proc_toggle_log(struct tmuxproc *); 1495 1496 /* cfg.c */ 1497 extern int cfg_finished; 1498 void start_cfg(void); 1499 int load_cfg(const char *, struct client *, struct cmdq_item *, int); 1500 void set_cfg_file(const char *); 1501 void printflike(1, 2) cfg_add_cause(const char *, ...); 1502 void cfg_print_causes(struct cmdq_item *); 1503 void cfg_show_causes(struct session *); 1504 1505 /* paste.c */ 1506 struct paste_buffer; 1507 const char *paste_buffer_name(struct paste_buffer *); 1508 u_int paste_buffer_order(struct paste_buffer *); 1509 time_t paste_buffer_created(struct paste_buffer *); 1510 const char *paste_buffer_data(struct paste_buffer *, size_t *); 1511 struct paste_buffer *paste_walk(struct paste_buffer *); 1512 struct paste_buffer *paste_get_top(const char **); 1513 struct paste_buffer *paste_get_name(const char *); 1514 void paste_free(struct paste_buffer *); 1515 void paste_add(char *, size_t); 1516 int paste_rename(const char *, const char *, char **); 1517 int paste_set(char *, size_t, const char *, char **); 1518 char *paste_make_sample(struct paste_buffer *); 1519 1520 /* format.c */ 1521 #define FORMAT_STATUS 0x1 1522 #define FORMAT_FORCE 0x2 1523 #define FORMAT_NOJOBS 0x4 1524 #define FORMAT_NONE 0 1525 #define FORMAT_PANE 0x80000000U 1526 #define FORMAT_WINDOW 0x40000000U 1527 struct format_tree; 1528 int format_true(const char *); 1529 struct format_tree *format_create(struct client *, struct cmdq_item *, int, 1530 int); 1531 void format_free(struct format_tree *); 1532 void printflike(3, 4) format_add(struct format_tree *, const char *, 1533 const char *, ...); 1534 char *format_expand_time(struct format_tree *, const char *, time_t); 1535 char *format_expand(struct format_tree *, const char *); 1536 char *format_single(struct cmdq_item *, const char *, 1537 struct client *, struct session *, struct winlink *, 1538 struct window_pane *); 1539 void format_defaults(struct format_tree *, struct client *, 1540 struct session *, struct winlink *, struct window_pane *); 1541 void format_defaults_window(struct format_tree *, struct window *); 1542 void format_defaults_pane(struct format_tree *, 1543 struct window_pane *); 1544 void format_defaults_paste_buffer(struct format_tree *, 1545 struct paste_buffer *); 1546 void format_lost_client(struct client *); 1547 1548 /* hooks.c */ 1549 struct hook; 1550 struct hooks *hooks_get(struct session *); 1551 struct hooks *hooks_create(struct hooks *); 1552 void hooks_free(struct hooks *); 1553 struct hook *hooks_first(struct hooks *); 1554 struct hook *hooks_next(struct hook *); 1555 void hooks_add(struct hooks *, const char *, struct cmd_list *); 1556 void hooks_copy(struct hooks *, struct hooks *); 1557 void hooks_remove(struct hooks *, const char *); 1558 struct hook *hooks_find(struct hooks *, const char *); 1559 void printflike(4, 5) hooks_insert(struct hooks *, struct cmdq_item *, 1560 struct cmd_find_state *, const char *, ...); 1561 1562 /* notify.c */ 1563 void notify_hook(struct cmdq_item *, const char *); 1564 void notify_input(struct window_pane *, struct evbuffer *); 1565 void notify_client(const char *, struct client *); 1566 void notify_session(const char *, struct session *); 1567 void notify_winlink(const char *, struct winlink *); 1568 void notify_session_window(const char *, struct session *, struct window *); 1569 void notify_window(const char *, struct window *); 1570 void notify_pane(const char *, struct window_pane *); 1571 1572 /* options.c */ 1573 struct options *options_create(struct options *); 1574 void options_free(struct options *); 1575 struct options_entry *options_first(struct options *); 1576 struct options_entry *options_next(struct options_entry *); 1577 struct options_entry *options_empty(struct options *, 1578 const struct options_table_entry *); 1579 struct options_entry *options_default(struct options *, 1580 const struct options_table_entry *); 1581 const char *options_name(struct options_entry *); 1582 const struct options_table_entry *options_table_entry(struct options_entry *); 1583 struct options_entry *options_get_only(struct options *, const char *); 1584 struct options_entry *options_get(struct options *, const char *); 1585 void options_remove(struct options_entry *); 1586 void options_array_clear(struct options_entry *); 1587 const char *options_array_get(struct options_entry *, u_int); 1588 int options_array_set(struct options_entry *, u_int, const char *, 1589 int); 1590 int options_array_size(struct options_entry *, u_int *); 1591 void options_array_assign(struct options_entry *, const char *); 1592 int options_isstring(struct options_entry *); 1593 const char *options_tostring(struct options_entry *, int, int); 1594 char *options_parse(const char *, int *); 1595 struct options_entry *options_parse_get(struct options *, const char *, int *, 1596 int); 1597 char *options_match(const char *, int *, int *); 1598 struct options_entry *options_match_get(struct options *, const char *, int *, 1599 int, int *); 1600 const char *options_get_string(struct options *, const char *); 1601 long long options_get_number(struct options *, const char *); 1602 const struct grid_cell *options_get_style(struct options *, const char *); 1603 struct options_entry * printflike(4, 5) options_set_string(struct options *, 1604 const char *, int, const char *, ...); 1605 struct options_entry *options_set_number(struct options *, const char *, 1606 long long); 1607 struct options_entry *options_set_style(struct options *, const char *, int, 1608 const char *); 1609 enum options_table_scope options_scope_from_flags(struct args *, int, 1610 struct cmd_find_state *, struct options **, char **); 1611 void options_style_update_new(struct options *, 1612 struct options_entry *); 1613 void options_style_update_old(struct options *, 1614 struct options_entry *); 1615 1616 /* options-table.c */ 1617 extern const struct options_table_entry options_table[]; 1618 1619 /* job.c */ 1620 extern struct joblist all_jobs; 1621 struct job *job_run(const char *, struct session *, const char *, 1622 job_update_cb, job_complete_cb, job_free_cb, void *, int); 1623 void job_free(struct job *); 1624 void job_died(struct job *, int); 1625 1626 /* environ.c */ 1627 struct environ *environ_create(void); 1628 void environ_free(struct environ *); 1629 struct environ_entry *environ_first(struct environ *); 1630 struct environ_entry *environ_next(struct environ_entry *); 1631 void environ_copy(struct environ *, struct environ *); 1632 struct environ_entry *environ_find(struct environ *, const char *); 1633 void printflike(3, 4) environ_set(struct environ *, const char *, const char *, 1634 ...); 1635 void environ_clear(struct environ *, const char *); 1636 void environ_put(struct environ *, const char *); 1637 void environ_unset(struct environ *, const char *); 1638 void environ_update(struct options *, struct environ *, struct environ *); 1639 void environ_push(struct environ *); 1640 void printflike(2, 3) environ_log(struct environ *, const char *, ...); 1641 struct environ *environ_for_session(struct session *, int); 1642 1643 /* tty.c */ 1644 void tty_create_log(void); 1645 void tty_raw(struct tty *, const char *); 1646 void tty_attributes(struct tty *, const struct grid_cell *, 1647 const struct window_pane *); 1648 void tty_reset(struct tty *); 1649 void tty_region_off(struct tty *); 1650 void tty_margin_off(struct tty *); 1651 void tty_cursor(struct tty *, u_int, u_int); 1652 void tty_putcode(struct tty *, enum tty_code_code); 1653 void tty_putcode1(struct tty *, enum tty_code_code, int); 1654 void tty_putcode2(struct tty *, enum tty_code_code, int, int); 1655 void tty_putcode3(struct tty *, enum tty_code_code, int, int, int); 1656 void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *); 1657 void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, 1658 const void *); 1659 void tty_puts(struct tty *, const char *); 1660 void tty_putc(struct tty *, u_char); 1661 void tty_putn(struct tty *, const void *, size_t, u_int); 1662 int tty_init(struct tty *, struct client *, int, char *); 1663 void tty_resize(struct tty *); 1664 void tty_set_size(struct tty *, u_int, u_int); 1665 void tty_start_tty(struct tty *); 1666 void tty_stop_tty(struct tty *); 1667 void tty_set_title(struct tty *, const char *); 1668 void tty_update_mode(struct tty *, int, struct screen *); 1669 void tty_draw_pane(struct tty *, const struct window_pane *, u_int, u_int, 1670 u_int); 1671 void tty_draw_line(struct tty *, const struct window_pane *, struct screen *, 1672 u_int, u_int, u_int); 1673 int tty_open(struct tty *, char **); 1674 void tty_close(struct tty *); 1675 void tty_free(struct tty *); 1676 void tty_set_type(struct tty *, int); 1677 void tty_write(void (*)(struct tty *, const struct tty_ctx *), 1678 struct tty_ctx *); 1679 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *); 1680 void tty_cmd_cell(struct tty *, const struct tty_ctx *); 1681 void tty_cmd_cells(struct tty *, const struct tty_ctx *); 1682 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *); 1683 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *); 1684 void tty_cmd_clearline(struct tty *, const struct tty_ctx *); 1685 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *); 1686 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *); 1687 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *); 1688 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *); 1689 void tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *); 1690 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *); 1691 void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *); 1692 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *); 1693 void tty_cmd_insertline(struct tty *, const struct tty_ctx *); 1694 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *); 1695 void tty_cmd_scrollup(struct tty *, const struct tty_ctx *); 1696 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *); 1697 void tty_cmd_setselection(struct tty *, const struct tty_ctx *); 1698 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *); 1699 1700 /* tty-term.c */ 1701 extern struct tty_terms tty_terms; 1702 u_int tty_term_ncodes(void); 1703 struct tty_term *tty_term_find(char *, int, char **); 1704 void tty_term_free(struct tty_term *); 1705 int tty_term_has(struct tty_term *, enum tty_code_code); 1706 const char *tty_term_string(struct tty_term *, enum tty_code_code); 1707 const char *tty_term_string1(struct tty_term *, enum tty_code_code, int); 1708 const char *tty_term_string2(struct tty_term *, enum tty_code_code, int, 1709 int); 1710 const char *tty_term_string3(struct tty_term *, enum tty_code_code, int, 1711 int, int); 1712 const char *tty_term_ptr1(struct tty_term *, enum tty_code_code, 1713 const void *); 1714 const char *tty_term_ptr2(struct tty_term *, enum tty_code_code, 1715 const void *, const void *); 1716 int tty_term_number(struct tty_term *, enum tty_code_code); 1717 int tty_term_flag(struct tty_term *, enum tty_code_code); 1718 const char *tty_term_describe(struct tty_term *, enum tty_code_code); 1719 1720 /* tty-acs.c */ 1721 int tty_acs_needed(struct tty *); 1722 const char *tty_acs_get(struct tty *, u_char); 1723 1724 /* tty-keys.c */ 1725 void tty_keys_build(struct tty *); 1726 void tty_keys_free(struct tty *); 1727 key_code tty_keys_next(struct tty *); 1728 1729 /* arguments.c */ 1730 void args_set(struct args *, u_char, const char *); 1731 struct args *args_parse(const char *, int, char **); 1732 void args_free(struct args *); 1733 char *args_print(struct args *); 1734 int args_has(struct args *, u_char); 1735 const char *args_get(struct args *, u_char); 1736 long long args_strtonum(struct args *, u_char, long long, long long, 1737 char **); 1738 1739 /* cmd-find.c */ 1740 int cmd_find_target(struct cmd_find_state *, struct cmdq_item *, 1741 const char *, enum cmd_find_type, int); 1742 struct client *cmd_find_best_client(struct session *); 1743 struct client *cmd_find_client(struct cmdq_item *, const char *, int); 1744 void cmd_find_clear_state(struct cmd_find_state *, int); 1745 int cmd_find_empty_state(struct cmd_find_state *); 1746 int cmd_find_valid_state(struct cmd_find_state *); 1747 void cmd_find_copy_state(struct cmd_find_state *, 1748 struct cmd_find_state *); 1749 void cmd_find_from_session(struct cmd_find_state *, 1750 struct session *, int); 1751 void cmd_find_from_winlink(struct cmd_find_state *, 1752 struct winlink *, int); 1753 int cmd_find_from_session_window(struct cmd_find_state *, 1754 struct session *, struct window *, int); 1755 int cmd_find_from_window(struct cmd_find_state *, struct window *, 1756 int); 1757 void cmd_find_from_winlink_pane(struct cmd_find_state *, 1758 struct winlink *, struct window_pane *, int); 1759 int cmd_find_from_pane(struct cmd_find_state *, 1760 struct window_pane *, int); 1761 int cmd_find_from_client(struct cmd_find_state *, struct client *, 1762 int); 1763 int cmd_find_from_mouse(struct cmd_find_state *, 1764 struct mouse_event *, int); 1765 int cmd_find_from_nothing(struct cmd_find_state *, int); 1766 1767 /* cmd.c */ 1768 void cmd_log_argv(int, char **, const char *); 1769 int cmd_pack_argv(int, char **, char *, size_t); 1770 int cmd_unpack_argv(char *, size_t, int, char ***); 1771 char **cmd_copy_argv(int, char **); 1772 void cmd_free_argv(int, char **); 1773 char *cmd_stringify_argv(int, char **); 1774 struct cmd *cmd_parse(int, char **, const char *, u_int, char **); 1775 char *cmd_print(struct cmd *); 1776 int cmd_mouse_at(struct window_pane *, struct mouse_event *, 1777 u_int *, u_int *, int); 1778 struct winlink *cmd_mouse_window(struct mouse_event *, struct session **); 1779 struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **, 1780 struct winlink **); 1781 char *cmd_template_replace(const char *, const char *, int); 1782 extern const struct cmd_entry *cmd_table[]; 1783 1784 /* cmd-attach-session.c */ 1785 enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int, 1786 const char *, int); 1787 1788 /* cmd-list.c */ 1789 struct cmd_list *cmd_list_parse(int, char **, const char *, u_int, char **); 1790 void cmd_list_free(struct cmd_list *); 1791 char *cmd_list_print(struct cmd_list *); 1792 1793 /* cmd-queue.c */ 1794 struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, 1795 struct mouse_event *, int); 1796 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) 1797 struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *); 1798 void cmdq_insert_after(struct cmdq_item *, struct cmdq_item *); 1799 void cmdq_append(struct client *, struct cmdq_item *); 1800 void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *, 1801 const char *, ...); 1802 u_int cmdq_next(struct client *); 1803 void cmdq_guard(struct cmdq_item *, const char *, int); 1804 void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...); 1805 void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...); 1806 1807 /* cmd-string.c */ 1808 int cmd_string_split(const char *, int *, char ***); 1809 struct cmd_list *cmd_string_parse(const char *, const char *, u_int, char **); 1810 1811 /* cmd-wait-for.c */ 1812 void cmd_wait_for_flush(void); 1813 1814 /* client.c */ 1815 int client_main(struct event_base *, int, char **, int); 1816 1817 /* key-bindings.c */ 1818 struct key_table *key_bindings_get_table(const char *, int); 1819 struct key_table *key_bindings_first_table(void); 1820 struct key_table *key_bindings_next_table(struct key_table *); 1821 void key_bindings_unref_table(struct key_table *); 1822 struct key_binding *key_bindings_get(struct key_table *, key_code); 1823 struct key_binding *key_bindings_first(struct key_table *); 1824 struct key_binding *key_bindings_next(struct key_table *, struct key_binding *); 1825 void key_bindings_add(const char *, key_code, int, struct cmd_list *); 1826 void key_bindings_remove(const char *, key_code); 1827 void key_bindings_remove_table(const char *); 1828 void key_bindings_init(void); 1829 void key_bindings_dispatch(struct key_binding *, struct cmdq_item *, 1830 struct client *, struct mouse_event *, struct cmd_find_state *); 1831 1832 /* key-string.c */ 1833 key_code key_string_lookup_string(const char *); 1834 const char *key_string_lookup_key(key_code); 1835 1836 /* alerts.c */ 1837 void alerts_reset_all(void); 1838 void alerts_queue(struct window *, int); 1839 void alerts_check_session(struct session *); 1840 1841 /* server.c */ 1842 extern struct tmuxproc *server_proc; 1843 extern struct clients clients; 1844 extern struct cmd_find_state marked_pane; 1845 void server_set_marked(struct session *, struct winlink *, 1846 struct window_pane *); 1847 void server_clear_marked(void); 1848 int server_is_marked(struct session *, struct winlink *, 1849 struct window_pane *); 1850 int server_check_marked(void); 1851 int server_start(struct tmuxproc *, struct event_base *, int, char *); 1852 void server_update_socket(void); 1853 void server_add_accept(int); 1854 1855 /* server-client.c */ 1856 u_int server_client_how_many(void); 1857 void server_client_set_identify(struct client *, u_int); 1858 void server_client_set_key_table(struct client *, const char *); 1859 const char *server_client_get_key_table(struct client *); 1860 int server_client_check_nested(struct client *); 1861 void server_client_handle_key(struct client *, key_code); 1862 struct client *server_client_create(int); 1863 int server_client_open(struct client *, char **); 1864 void server_client_unref(struct client *); 1865 void server_client_lost(struct client *); 1866 void server_client_suspend(struct client *); 1867 void server_client_detach(struct client *, enum msgtype); 1868 void server_client_exec(struct client *, const char *); 1869 void server_client_loop(void); 1870 void server_client_push_stdout(struct client *); 1871 void server_client_push_stderr(struct client *); 1872 void printflike(2, 3) server_client_add_message(struct client *, const char *, 1873 ...); 1874 char *server_client_get_path(struct client *, const char *); 1875 const char *server_client_get_cwd(struct client *, struct session *); 1876 1877 /* server-fn.c */ 1878 void server_redraw_client(struct client *); 1879 void server_status_client(struct client *); 1880 void server_redraw_session(struct session *); 1881 void server_redraw_session_group(struct session *); 1882 void server_status_session(struct session *); 1883 void server_status_session_group(struct session *); 1884 void server_redraw_window(struct window *); 1885 void server_redraw_window_borders(struct window *); 1886 void server_status_window(struct window *); 1887 void server_lock(void); 1888 void server_lock_session(struct session *); 1889 void server_lock_client(struct client *); 1890 void server_kill_pane(struct window_pane *); 1891 void server_kill_window(struct window *); 1892 int server_link_window(struct session *, 1893 struct winlink *, struct session *, int, int, int, char **); 1894 void server_unlink_window(struct session *, struct winlink *); 1895 void server_destroy_pane(struct window_pane *, int); 1896 void server_destroy_session(struct session *); 1897 void server_check_unattached(void); 1898 int server_set_stdin_callback(struct client *, void (*)(struct client *, 1899 int, void *), void *, char **); 1900 void server_unzoom_window(struct window *); 1901 1902 /* status.c */ 1903 void status_timer_start(struct client *); 1904 void status_timer_start_all(void); 1905 void status_update_saved(struct session *s); 1906 int status_at_line(struct client *); 1907 u_int status_line_size(struct session *); 1908 struct window *status_get_window_at(struct client *, u_int); 1909 int status_redraw(struct client *); 1910 void printflike(2, 3) status_message_set(struct client *, const char *, ...); 1911 void status_message_clear(struct client *); 1912 int status_message_redraw(struct client *); 1913 void status_prompt_set(struct client *, const char *, const char *, 1914 prompt_input_cb, prompt_free_cb, void *, int); 1915 void status_prompt_clear(struct client *); 1916 int status_prompt_redraw(struct client *); 1917 int status_prompt_key(struct client *, key_code); 1918 void status_prompt_update(struct client *, const char *, const char *); 1919 void status_prompt_load_history(void); 1920 void status_prompt_save_history(void); 1921 1922 /* resize.c */ 1923 void recalculate_sizes(void); 1924 1925 /* input.c */ 1926 void input_init(struct window_pane *); 1927 void input_free(struct window_pane *); 1928 void input_reset(struct window_pane *, int); 1929 struct evbuffer *input_pending(struct window_pane *); 1930 void input_parse(struct window_pane *); 1931 1932 /* input-key.c */ 1933 void input_key(struct window_pane *, key_code, struct mouse_event *); 1934 1935 /* xterm-keys.c */ 1936 char *xterm_keys_lookup(key_code); 1937 int xterm_keys_find(const char *, size_t, size_t *, key_code *); 1938 1939 /* colour.c */ 1940 int colour_find_rgb(u_char, u_char, u_char); 1941 int colour_join_rgb(u_char, u_char, u_char); 1942 void colour_split_rgb(int, u_char *, u_char *, u_char *); 1943 const char *colour_tostring(int); 1944 int colour_fromstring(const char *s); 1945 u_char colour_256to16(u_char); 1946 1947 /* attributes.c */ 1948 const char *attributes_tostring(int); 1949 int attributes_fromstring(const char *); 1950 1951 /* grid.c */ 1952 extern const struct grid_cell grid_default_cell; 1953 int grid_cells_equal(const struct grid_cell *, const struct grid_cell *); 1954 struct grid *grid_create(u_int, u_int, u_int); 1955 void grid_destroy(struct grid *); 1956 int grid_compare(struct grid *, struct grid *); 1957 void grid_collect_history(struct grid *); 1958 void grid_scroll_history(struct grid *, u_int); 1959 void grid_scroll_history_region(struct grid *, u_int, u_int, u_int); 1960 void grid_clear_history(struct grid *); 1961 const struct grid_line *grid_peek_line(struct grid *, u_int); 1962 void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); 1963 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *); 1964 void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *, 1965 const char *, size_t); 1966 void grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); 1967 void grid_clear_lines(struct grid *, u_int, u_int, u_int); 1968 void grid_move_lines(struct grid *, u_int, u_int, u_int, u_int); 1969 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int); 1970 char *grid_string_cells(struct grid *, u_int, u_int, u_int, 1971 struct grid_cell **, int, int, int); 1972 void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int, 1973 u_int); 1974 void grid_reflow(struct grid *, u_int, u_int *); 1975 struct grid_line *grid_get_line(struct grid *, u_int); 1976 void grid_adjust_lines(struct grid *, u_int); 1977 1978 /* grid-view.c */ 1979 void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *); 1980 void grid_view_set_cell(struct grid *, u_int, u_int, 1981 const struct grid_cell *); 1982 void grid_view_set_cells(struct grid *, u_int, u_int, 1983 const struct grid_cell *, const char *, size_t); 1984 void grid_view_clear_history(struct grid *, u_int); 1985 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); 1986 void grid_view_scroll_region_up(struct grid *, u_int, u_int, u_int); 1987 void grid_view_scroll_region_down(struct grid *, u_int, u_int, u_int); 1988 void grid_view_insert_lines(struct grid *, u_int, u_int, u_int); 1989 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int, 1990 u_int); 1991 void grid_view_delete_lines(struct grid *, u_int, u_int, u_int); 1992 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int, 1993 u_int); 1994 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int); 1995 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int); 1996 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int); 1997 1998 /* screen-write.c */ 1999 void screen_write_start(struct screen_write_ctx *, struct window_pane *, 2000 struct screen *); 2001 void screen_write_stop(struct screen_write_ctx *); 2002 void screen_write_reset(struct screen_write_ctx *); 2003 size_t printflike(1, 2) screen_write_cstrlen(const char *, ...); 2004 void printflike(4, 5) screen_write_cnputs(struct screen_write_ctx *, 2005 ssize_t, const struct grid_cell *, const char *, ...); 2006 size_t printflike(1, 2) screen_write_strlen(const char *, ...); 2007 void printflike(3, 4) screen_write_puts(struct screen_write_ctx *, 2008 const struct grid_cell *, const char *, ...); 2009 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *, 2010 ssize_t, const struct grid_cell *, const char *, ...); 2011 void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx *, ssize_t, 2012 const struct grid_cell *, const char *, va_list); 2013 void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *, 2014 u_char); 2015 void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int, 2016 u_int, u_int, u_int, bitstr_t *, const struct grid_cell *); 2017 void screen_write_fast_copy(struct screen_write_ctx *, struct screen *, 2018 u_int, u_int, u_int, u_int); 2019 void screen_write_hline(struct screen_write_ctx *, u_int, int, int); 2020 void screen_write_vline(struct screen_write_ctx *, u_int, int, int); 2021 void screen_write_box(struct screen_write_ctx *, u_int, u_int); 2022 void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int, 2023 u_int); 2024 void screen_write_backspace(struct screen_write_ctx *); 2025 void screen_write_mode_set(struct screen_write_ctx *, int); 2026 void screen_write_mode_clear(struct screen_write_ctx *, int); 2027 void screen_write_cursorup(struct screen_write_ctx *, u_int); 2028 void screen_write_cursordown(struct screen_write_ctx *, u_int); 2029 void screen_write_cursorright(struct screen_write_ctx *, u_int); 2030 void screen_write_cursorleft(struct screen_write_ctx *, u_int); 2031 void screen_write_alignmenttest(struct screen_write_ctx *); 2032 void screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int); 2033 void screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int); 2034 void screen_write_clearcharacter(struct screen_write_ctx *, u_int, u_int); 2035 void screen_write_insertline(struct screen_write_ctx *, u_int, u_int); 2036 void screen_write_deleteline(struct screen_write_ctx *, u_int, u_int); 2037 void screen_write_clearline(struct screen_write_ctx *, u_int); 2038 void screen_write_clearendofline(struct screen_write_ctx *, u_int); 2039 void screen_write_clearstartofline(struct screen_write_ctx *, u_int); 2040 void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int); 2041 void screen_write_reverseindex(struct screen_write_ctx *, u_int); 2042 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); 2043 void screen_write_linefeed(struct screen_write_ctx *, int, u_int); 2044 void screen_write_scrollup(struct screen_write_ctx *, u_int, u_int); 2045 void screen_write_carriagereturn(struct screen_write_ctx *); 2046 void screen_write_clearendofscreen(struct screen_write_ctx *, u_int); 2047 void screen_write_clearstartofscreen(struct screen_write_ctx *, u_int); 2048 void screen_write_clearscreen(struct screen_write_ctx *, u_int); 2049 void screen_write_clearhistory(struct screen_write_ctx *); 2050 void screen_write_collect_end(struct screen_write_ctx *); 2051 void screen_write_collect_add(struct screen_write_ctx *, 2052 const struct grid_cell *); 2053 void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *); 2054 void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int); 2055 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int); 2056 2057 /* screen-redraw.c */ 2058 void screen_redraw_update(struct client *); 2059 void screen_redraw_screen(struct client *, int, int, int); 2060 void screen_redraw_pane(struct client *, struct window_pane *); 2061 2062 /* screen.c */ 2063 void screen_init(struct screen *, u_int, u_int, u_int); 2064 void screen_reinit(struct screen *); 2065 void screen_free(struct screen *); 2066 void screen_reset_tabs(struct screen *); 2067 void screen_set_cursor_style(struct screen *, u_int); 2068 void screen_set_cursor_colour(struct screen *, const char *); 2069 void screen_set_title(struct screen *, const char *); 2070 void screen_push_title(struct screen *); 2071 void screen_pop_title(struct screen *); 2072 void screen_resize(struct screen *, u_int, u_int, int); 2073 void screen_set_selection(struct screen *, u_int, u_int, u_int, u_int, 2074 u_int, int, struct grid_cell *); 2075 void screen_clear_selection(struct screen *); 2076 void screen_hide_selection(struct screen *); 2077 int screen_check_selection(struct screen *, u_int, u_int); 2078 void screen_select_cell(struct screen *, struct grid_cell *, 2079 const struct grid_cell *); 2080 2081 /* window.c */ 2082 extern struct windows windows; 2083 extern struct window_pane_tree all_window_panes; 2084 int window_cmp(struct window *, struct window *); 2085 RB_PROTOTYPE(windows, window, entry, window_cmp); 2086 int winlink_cmp(struct winlink *, struct winlink *); 2087 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp); 2088 int window_pane_cmp(struct window_pane *, struct window_pane *); 2089 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp); 2090 struct winlink *winlink_find_by_index(struct winlinks *, int); 2091 struct winlink *winlink_find_by_window(struct winlinks *, struct window *); 2092 struct winlink *winlink_find_by_window_id(struct winlinks *, u_int); 2093 u_int winlink_count(struct winlinks *); 2094 struct winlink *winlink_add(struct winlinks *, int); 2095 void winlink_set_window(struct winlink *, struct window *); 2096 void winlink_remove(struct winlinks *, struct winlink *); 2097 struct winlink *winlink_next(struct winlink *); 2098 struct winlink *winlink_previous(struct winlink *); 2099 struct winlink *winlink_next_by_number(struct winlink *, struct session *, 2100 int); 2101 struct winlink *winlink_previous_by_number(struct winlink *, struct session *, 2102 int); 2103 void winlink_stack_push(struct winlink_stack *, struct winlink *); 2104 void winlink_stack_remove(struct winlink_stack *, struct winlink *); 2105 struct window *window_find_by_id_str(const char *); 2106 struct window *window_find_by_id(u_int); 2107 void window_update_activity(struct window *); 2108 struct window *window_create(u_int, u_int); 2109 struct window *window_create_spawn(const char *, int, char **, const char *, 2110 const char *, const char *, struct environ *, 2111 struct termios *, u_int, u_int, u_int, char **); 2112 struct window_pane *window_get_active_at(struct window *, u_int, u_int); 2113 struct window_pane *window_find_string(struct window *, const char *); 2114 int window_has_pane(struct window *, struct window_pane *); 2115 int window_set_active_pane(struct window *, struct window_pane *); 2116 void window_redraw_active_switch(struct window *, 2117 struct window_pane *); 2118 struct window_pane *window_add_pane(struct window *, struct window_pane *, int, 2119 int, u_int); 2120 void window_resize(struct window *, u_int, u_int); 2121 int window_zoom(struct window_pane *); 2122 int window_unzoom(struct window *); 2123 void window_lost_pane(struct window *, struct window_pane *); 2124 void window_remove_pane(struct window *, struct window_pane *); 2125 struct window_pane *window_pane_at_index(struct window *, u_int); 2126 struct window_pane *window_pane_next_by_number(struct window *, 2127 struct window_pane *, u_int); 2128 struct window_pane *window_pane_previous_by_number(struct window *, 2129 struct window_pane *, u_int); 2130 int window_pane_index(struct window_pane *, u_int *); 2131 u_int window_count_panes(struct window *); 2132 void window_destroy_panes(struct window *); 2133 struct window_pane *window_pane_find_by_id_str(const char *); 2134 struct window_pane *window_pane_find_by_id(u_int); 2135 int window_pane_destroy_ready(struct window_pane *); 2136 int window_pane_spawn(struct window_pane *, int, char **, 2137 const char *, const char *, const char *, struct environ *, 2138 struct termios *, char **); 2139 void window_pane_resize(struct window_pane *, u_int, u_int); 2140 void window_pane_alternate_on(struct window_pane *, 2141 struct grid_cell *, int); 2142 void window_pane_alternate_off(struct window_pane *, 2143 struct grid_cell *, int); 2144 void window_pane_set_palette(struct window_pane *, u_int, int); 2145 void window_pane_unset_palette(struct window_pane *, u_int); 2146 void window_pane_reset_palette(struct window_pane *); 2147 int window_pane_get_palette(const struct window_pane *, int); 2148 int window_pane_set_mode(struct window_pane *, 2149 const struct window_mode *, struct cmd_find_state *, 2150 struct args *); 2151 void window_pane_reset_mode(struct window_pane *); 2152 void window_pane_key(struct window_pane *, struct client *, 2153 struct session *, key_code, struct mouse_event *); 2154 int window_pane_visible(struct window_pane *); 2155 u_int window_pane_search(struct window_pane *, const char *); 2156 const char *window_printable_flags(struct winlink *); 2157 struct window_pane *window_pane_find_up(struct window_pane *); 2158 struct window_pane *window_pane_find_down(struct window_pane *); 2159 struct window_pane *window_pane_find_left(struct window_pane *); 2160 struct window_pane *window_pane_find_right(struct window_pane *); 2161 void window_set_name(struct window *, const char *); 2162 void window_add_ref(struct window *, const char *); 2163 void window_remove_ref(struct window *, const char *); 2164 void winlink_clear_flags(struct winlink *); 2165 int winlink_shuffle_up(struct session *, struct winlink *); 2166 2167 /* layout.c */ 2168 u_int layout_count_cells(struct layout_cell *); 2169 struct layout_cell *layout_create_cell(struct layout_cell *); 2170 void layout_free_cell(struct layout_cell *); 2171 void layout_print_cell(struct layout_cell *, const char *, u_int); 2172 void layout_destroy_cell(struct window *, struct layout_cell *, 2173 struct layout_cell **); 2174 void layout_resize_layout(struct window *, struct layout_cell *, 2175 enum layout_type, int, int); 2176 struct layout_cell *layout_search_by_border(struct layout_cell *, u_int, u_int); 2177 void layout_set_size(struct layout_cell *, u_int, u_int, u_int, 2178 u_int); 2179 void layout_make_leaf(struct layout_cell *, struct window_pane *); 2180 void layout_make_node(struct layout_cell *, enum layout_type); 2181 void layout_fix_offsets(struct layout_cell *); 2182 void layout_fix_panes(struct window *, u_int, u_int); 2183 void layout_resize_adjust(struct window *, struct layout_cell *, 2184 enum layout_type, int); 2185 void layout_init(struct window *, struct window_pane *); 2186 void layout_free(struct window *); 2187 void layout_resize(struct window *, u_int, u_int); 2188 void layout_resize_pane(struct window_pane *, enum layout_type, 2189 int, int); 2190 void layout_resize_pane_to(struct window_pane *, enum layout_type, 2191 u_int); 2192 void layout_assign_pane(struct layout_cell *, struct window_pane *); 2193 struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type, 2194 int, int, int); 2195 void layout_close_pane(struct window_pane *); 2196 int layout_spread_cell(struct window *, struct layout_cell *); 2197 void layout_spread_out(struct window_pane *); 2198 2199 /* layout-custom.c */ 2200 char *layout_dump(struct layout_cell *); 2201 int layout_parse(struct window *, const char *); 2202 2203 /* layout-set.c */ 2204 int layout_set_lookup(const char *); 2205 u_int layout_set_select(struct window *, u_int); 2206 u_int layout_set_next(struct window *); 2207 u_int layout_set_previous(struct window *); 2208 2209 /* mode-tree.c */ 2210 typedef void (*mode_tree_build_cb)(void *, u_int, uint64_t *, const char *); 2211 typedef void (*mode_tree_draw_cb)(void *, void *, struct screen_write_ctx *, 2212 u_int, u_int); 2213 typedef int (*mode_tree_search_cb)(void *, void *, const char *); 2214 typedef void (*mode_tree_each_cb)(void *, void *, struct client *, key_code); 2215 u_int mode_tree_count_tagged(struct mode_tree_data *); 2216 void *mode_tree_get_current(struct mode_tree_data *); 2217 void mode_tree_expand_current(struct mode_tree_data *); 2218 void mode_tree_set_current(struct mode_tree_data *, uint64_t); 2219 void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb, 2220 struct client *, key_code, int); 2221 void mode_tree_down(struct mode_tree_data *, int); 2222 struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *, 2223 mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb, 2224 void *, const char **, u_int, struct screen **); 2225 void mode_tree_zoom(struct mode_tree_data *, struct args *); 2226 void mode_tree_build(struct mode_tree_data *); 2227 void mode_tree_free(struct mode_tree_data *); 2228 void mode_tree_resize(struct mode_tree_data *, u_int, u_int); 2229 struct mode_tree_item *mode_tree_add(struct mode_tree_data *, 2230 struct mode_tree_item *, void *, uint64_t, const char *, 2231 const char *, int); 2232 void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *); 2233 void mode_tree_draw(struct mode_tree_data *); 2234 int mode_tree_key(struct mode_tree_data *, struct client *, key_code *, 2235 struct mouse_event *, u_int *, u_int *); 2236 void mode_tree_run_command(struct client *, struct cmd_find_state *, 2237 const char *, const char *); 2238 2239 /* window-buffer.c */ 2240 extern const struct window_mode window_buffer_mode; 2241 2242 /* window-tree.c */ 2243 extern const struct window_mode window_tree_mode; 2244 2245 /* window-clock.c */ 2246 extern const struct window_mode window_clock_mode; 2247 extern const char window_clock_table[14][5][5]; 2248 2249 /* window-client.c */ 2250 extern const struct window_mode window_client_mode; 2251 2252 /* window-copy.c */ 2253 extern const struct window_mode window_copy_mode; 2254 void window_copy_init_from_pane(struct window_pane *, int); 2255 void window_copy_init_for_output(struct window_pane *); 2256 void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...); 2257 void printflike(2, 0) window_copy_vadd(struct window_pane *, const char *, va_list); 2258 void window_copy_pageup(struct window_pane *, int); 2259 void window_copy_start_drag(struct client *, struct mouse_event *); 2260 void window_copy_add_formats(struct window_pane *, 2261 struct format_tree *); 2262 2263 /* names.c */ 2264 void check_window_name(struct window *); 2265 char *default_window_name(struct window *); 2266 char *parse_window_name(const char *); 2267 2268 /* control.c */ 2269 void control_callback(struct client *, int, void *); 2270 void printflike(2, 3) control_write(struct client *, const char *, ...); 2271 void control_write_buffer(struct client *, struct evbuffer *); 2272 2273 /* control-notify.c */ 2274 void control_notify_input(struct client *, struct window_pane *, 2275 struct evbuffer *); 2276 void control_notify_pane_mode_changed(int); 2277 void control_notify_window_layout_changed(struct window *); 2278 void control_notify_window_pane_changed(struct window *); 2279 void control_notify_window_unlinked(struct session *, struct window *); 2280 void control_notify_window_linked(struct session *, struct window *); 2281 void control_notify_window_renamed(struct window *); 2282 void control_notify_client_session_changed(struct client *); 2283 void control_notify_session_renamed(struct session *); 2284 void control_notify_session_created(struct session *); 2285 void control_notify_session_closed(struct session *); 2286 void control_notify_session_window_changed(struct session *); 2287 2288 /* session.c */ 2289 extern struct sessions sessions; 2290 int session_cmp(struct session *, struct session *); 2291 RB_PROTOTYPE(sessions, session, entry, session_cmp); 2292 int session_alive(struct session *); 2293 struct session *session_find(const char *); 2294 struct session *session_find_by_id_str(const char *); 2295 struct session *session_find_by_id(u_int); 2296 struct session *session_create(const char *, const char *, int, char **, 2297 const char *, const char *, struct environ *, 2298 struct termios *, int, u_int, u_int, char **); 2299 void session_destroy(struct session *, const char *); 2300 void session_add_ref(struct session *, const char *); 2301 void session_remove_ref(struct session *, const char *); 2302 int session_check_name(const char *); 2303 void session_update_activity(struct session *, struct timeval *); 2304 struct session *session_next_session(struct session *); 2305 struct session *session_previous_session(struct session *); 2306 struct winlink *session_new(struct session *, const char *, int, char **, 2307 const char *, const char *, int, char **); 2308 struct winlink *session_attach(struct session *, struct window *, int, 2309 char **); 2310 int session_detach(struct session *, struct winlink *); 2311 int session_has(struct session *, struct window *); 2312 int session_is_linked(struct session *, struct window *); 2313 int session_next(struct session *, int); 2314 int session_previous(struct session *, int); 2315 int session_select(struct session *, int); 2316 int session_last(struct session *); 2317 int session_set_current(struct session *, struct winlink *); 2318 struct session_group *session_group_contains(struct session *); 2319 struct session_group *session_group_find(const char *); 2320 struct session_group *session_group_new(const char *); 2321 void session_group_add(struct session_group *, struct session *); 2322 void session_group_synchronize_to(struct session *); 2323 void session_group_synchronize_from(struct session *); 2324 u_int session_group_count(struct session_group *); 2325 void session_renumber_windows(struct session *); 2326 2327 /* utf8.c */ 2328 void utf8_set(struct utf8_data *, u_char); 2329 void utf8_copy(struct utf8_data *, const struct utf8_data *); 2330 enum utf8_state utf8_open(struct utf8_data *, u_char); 2331 enum utf8_state utf8_append(struct utf8_data *, u_char); 2332 enum utf8_state utf8_combine(const struct utf8_data *, wchar_t *); 2333 enum utf8_state utf8_split(wchar_t, struct utf8_data *); 2334 int utf8_isvalid(const char *); 2335 int utf8_strvis(char *, const char *, size_t, int); 2336 int utf8_stravis(char **, const char *, int); 2337 char *utf8_sanitize(const char *); 2338 size_t utf8_strlen(const struct utf8_data *); 2339 u_int utf8_strwidth(const struct utf8_data *, ssize_t); 2340 struct utf8_data *utf8_fromcstr(const char *); 2341 char *utf8_tocstr(struct utf8_data *); 2342 u_int utf8_cstrwidth(const char *); 2343 char *utf8_rtrimcstr(const char *, u_int); 2344 char *utf8_trimcstr(const char *, u_int); 2345 char *utf8_padcstr(const char *, u_int); 2346 2347 /* osdep-*.c */ 2348 char *osdep_get_name(int, char *); 2349 char *osdep_get_cwd(int); 2350 struct event_base *osdep_event_init(void); 2351 2352 /* log.c */ 2353 void log_add_level(void); 2354 int log_get_level(void); 2355 void log_open(const char *); 2356 void log_toggle(const char *); 2357 void log_close(void); 2358 void printflike(1, 2) log_debug(const char *, ...); 2359 __dead void printflike(1, 2) fatal(const char *, ...); 2360 __dead void printflike(1, 2) fatalx(const char *, ...); 2361 2362 /* style.c */ 2363 int style_parse(const struct grid_cell *, 2364 struct grid_cell *, const char *); 2365 const char *style_tostring(struct grid_cell *); 2366 void style_apply(struct grid_cell *, struct options *, 2367 const char *); 2368 void style_apply_update(struct grid_cell *, struct options *, 2369 const char *); 2370 int style_equal(const struct grid_cell *, 2371 const struct grid_cell *); 2372 2373 #endif /* TMUX_H */ 2374