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