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