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