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