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