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