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 TAILQ_ENTRY (image) all_entry; 940 TAILQ_ENTRY (image) entry; 941 }; 942 TAILQ_HEAD(images, image); 943 #endif 944 945 /* Cursor style. */ 946 enum screen_cursor_style { 947 SCREEN_CURSOR_DEFAULT, 948 SCREEN_CURSOR_BLOCK, 949 SCREEN_CURSOR_UNDERLINE, 950 SCREEN_CURSOR_BAR 951 }; 952 953 /* Virtual screen. */ 954 struct screen_sel; 955 struct screen_titles; 956 struct screen { 957 char *title; 958 char *path; 959 struct screen_titles *titles; 960 961 struct grid *grid; /* grid data */ 962 963 u_int cx; /* cursor x */ 964 u_int cy; /* cursor y */ 965 966 enum screen_cursor_style cstyle; /* cursor style */ 967 enum screen_cursor_style default_cstyle; 968 int ccolour; /* cursor colour */ 969 int default_ccolour; 970 971 u_int rupper; /* scroll region top */ 972 u_int rlower; /* scroll region bottom */ 973 974 int mode; 975 int default_mode; 976 977 u_int saved_cx; 978 u_int saved_cy; 979 struct grid *saved_grid; 980 struct grid_cell saved_cell; 981 int saved_flags; 982 983 bitstr_t *tabs; 984 struct screen_sel *sel; 985 986 #ifdef ENABLE_SIXEL 987 struct images images; 988 struct images saved_images; 989 #endif 990 991 struct screen_write_cline *write_list; 992 993 struct hyperlinks *hyperlinks; 994 }; 995 996 /* Screen write context. */ 997 typedef void (*screen_write_init_ctx_cb)(struct screen_write_ctx *, 998 struct tty_ctx *); 999 struct screen_write_ctx { 1000 struct window_pane *wp; 1001 struct screen *s; 1002 1003 int flags; 1004 #define SCREEN_WRITE_SYNC 0x1 1005 1006 screen_write_init_ctx_cb init_ctx_cb; 1007 void *arg; 1008 1009 struct screen_write_citem *item; 1010 u_int scrolled; 1011 u_int bg; 1012 }; 1013 1014 /* Box border lines option. */ 1015 enum box_lines { 1016 BOX_LINES_DEFAULT = -1, 1017 BOX_LINES_SINGLE, 1018 BOX_LINES_DOUBLE, 1019 BOX_LINES_HEAVY, 1020 BOX_LINES_SIMPLE, 1021 BOX_LINES_ROUNDED, 1022 BOX_LINES_PADDED, 1023 BOX_LINES_NONE 1024 }; 1025 1026 /* Pane border lines option. */ 1027 enum pane_lines { 1028 PANE_LINES_SINGLE, 1029 PANE_LINES_DOUBLE, 1030 PANE_LINES_HEAVY, 1031 PANE_LINES_SIMPLE, 1032 PANE_LINES_NUMBER, 1033 PANE_LINES_SPACES 1034 }; 1035 1036 /* Pane border indicator option. */ 1037 #define PANE_BORDER_OFF 0 1038 #define PANE_BORDER_COLOUR 1 1039 #define PANE_BORDER_ARROWS 2 1040 #define PANE_BORDER_BOTH 3 1041 1042 /* Mode returned by window_pane_mode function. */ 1043 #define WINDOW_PANE_NO_MODE 0 1044 #define WINDOW_PANE_COPY_MODE 1 1045 #define WINDOW_PANE_VIEW_MODE 2 1046 1047 /* Screen redraw context. */ 1048 struct screen_redraw_ctx { 1049 struct client *c; 1050 1051 u_int statuslines; 1052 int statustop; 1053 1054 int pane_status; 1055 enum pane_lines pane_lines; 1056 1057 int pane_scrollbars; 1058 int pane_scrollbars_pos; 1059 1060 struct grid_cell no_pane_gc; 1061 int no_pane_gc_set; 1062 1063 u_int sx; 1064 u_int sy; 1065 u_int ox; 1066 u_int oy; 1067 }; 1068 1069 /* Screen size. */ 1070 #define screen_size_x(s) ((s)->grid->sx) 1071 #define screen_size_y(s) ((s)->grid->sy) 1072 #define screen_hsize(s) ((s)->grid->hsize) 1073 #define screen_hlimit(s) ((s)->grid->hlimit) 1074 1075 /* Menu. */ 1076 struct menu_item { 1077 const char *name; 1078 key_code key; 1079 const char *command; 1080 }; 1081 struct menu { 1082 const char *title; 1083 struct menu_item *items; 1084 u_int count; 1085 u_int width; 1086 }; 1087 typedef void (*menu_choice_cb)(struct menu *, u_int, key_code, void *); 1088 1089 /* 1090 * Window mode. Windows can be in several modes and this is used to call the 1091 * right function to handle input and output. 1092 */ 1093 struct window_mode_entry; 1094 struct window_mode { 1095 const char *name; 1096 const char *default_format; 1097 1098 struct screen *(*init)(struct window_mode_entry *, 1099 struct cmd_find_state *, struct args *); 1100 void (*free)(struct window_mode_entry *); 1101 void (*resize)(struct window_mode_entry *, u_int, u_int); 1102 void (*update)(struct window_mode_entry *); 1103 void (*key)(struct window_mode_entry *, struct client *, 1104 struct session *, struct winlink *, key_code, 1105 struct mouse_event *); 1106 1107 const char *(*key_table)(struct window_mode_entry *); 1108 void (*command)(struct window_mode_entry *, struct client *, 1109 struct session *, struct winlink *, struct args *, 1110 struct mouse_event *); 1111 void (*formats)(struct window_mode_entry *, 1112 struct format_tree *); 1113 struct screen *(*get_screen)(struct window_mode_entry *); 1114 }; 1115 1116 /* Active window mode. */ 1117 struct window_mode_entry { 1118 struct window_pane *wp; 1119 struct window_pane *swp; 1120 1121 const struct window_mode *mode; 1122 void *data; 1123 1124 struct screen *screen; 1125 u_int prefix; 1126 1127 TAILQ_ENTRY(window_mode_entry) entry; 1128 }; 1129 1130 /* Type of request to client. */ 1131 enum input_request_type { 1132 INPUT_REQUEST_PALETTE, 1133 INPUT_REQUEST_QUEUE 1134 }; 1135 1136 /* Palette request reply data. */ 1137 struct input_request_palette_data { 1138 int idx; 1139 int c; 1140 }; 1141 1142 /* Request sent to client on behalf of pane. */ 1143 TAILQ_HEAD(input_requests, input_request); 1144 1145 /* Offsets into pane buffer. */ 1146 struct window_pane_offset { 1147 size_t used; 1148 }; 1149 1150 /* Queued pane resize. */ 1151 struct window_pane_resize { 1152 u_int sx; 1153 u_int sy; 1154 1155 u_int osx; 1156 u_int osy; 1157 1158 TAILQ_ENTRY(window_pane_resize) entry; 1159 }; 1160 TAILQ_HEAD(window_pane_resizes, window_pane_resize); 1161 1162 /* Child window structure. */ 1163 struct window_pane { 1164 u_int id; 1165 u_int active_point; 1166 1167 struct window *window; 1168 struct options *options; 1169 1170 struct layout_cell *layout_cell; 1171 struct layout_cell *saved_layout_cell; 1172 1173 u_int sx; 1174 u_int sy; 1175 1176 u_int xoff; 1177 u_int yoff; 1178 1179 int flags; 1180 #define PANE_REDRAW 0x1 1181 #define PANE_DROP 0x2 1182 #define PANE_FOCUSED 0x4 1183 #define PANE_VISITED 0x8 1184 /* 0x10 unused */ 1185 /* 0x20 unused */ 1186 #define PANE_INPUTOFF 0x40 1187 #define PANE_CHANGED 0x80 1188 #define PANE_EXITED 0x100 1189 #define PANE_STATUSREADY 0x200 1190 #define PANE_STATUSDRAWN 0x400 1191 #define PANE_EMPTY 0x800 1192 #define PANE_STYLECHANGED 0x1000 1193 #define PANE_THEMECHANGED 0x2000 1194 #define PANE_UNSEENCHANGES 0x4000 1195 #define PANE_REDRAWSCROLLBAR 0x8000 1196 1197 u_int sb_slider_y; 1198 u_int sb_slider_h; 1199 1200 int argc; 1201 char **argv; 1202 char *shell; 1203 char *cwd; 1204 1205 pid_t pid; 1206 char tty[TTY_NAME_MAX]; 1207 int status; 1208 struct timeval dead_time; 1209 1210 int fd; 1211 struct bufferevent *event; 1212 1213 struct window_pane_offset offset; 1214 size_t base_offset; 1215 1216 struct window_pane_resizes resize_queue; 1217 struct event resize_timer; 1218 1219 struct input_ctx *ictx; 1220 1221 struct grid_cell cached_gc; 1222 struct grid_cell cached_active_gc; 1223 struct colour_palette palette; 1224 1225 int pipe_fd; 1226 struct bufferevent *pipe_event; 1227 struct window_pane_offset pipe_offset; 1228 1229 struct screen *screen; 1230 struct screen base; 1231 1232 struct screen status_screen; 1233 size_t status_size; 1234 1235 TAILQ_HEAD(, window_mode_entry) modes; 1236 1237 char *searchstr; 1238 int searchregex; 1239 1240 int border_gc_set; 1241 struct grid_cell border_gc; 1242 1243 int control_bg; 1244 int control_fg; 1245 1246 struct style scrollbar_style; 1247 1248 TAILQ_ENTRY(window_pane) entry; /* link in list of all panes */ 1249 TAILQ_ENTRY(window_pane) sentry; /* link in list of last visited */ 1250 RB_ENTRY(window_pane) tree_entry; 1251 }; 1252 TAILQ_HEAD(window_panes, window_pane); 1253 RB_HEAD(window_pane_tree, window_pane); 1254 1255 /* Window structure. */ 1256 struct window { 1257 u_int id; 1258 void *latest; 1259 1260 char *name; 1261 struct event name_event; 1262 struct timeval name_time; 1263 1264 struct event alerts_timer; 1265 struct event offset_timer; 1266 1267 struct timeval activity_time; 1268 1269 struct window_pane *active; 1270 struct window_panes last_panes; 1271 struct window_panes panes; 1272 1273 int lastlayout; 1274 struct layout_cell *layout_root; 1275 struct layout_cell *saved_layout_root; 1276 char *old_layout; 1277 1278 u_int sx; 1279 u_int sy; 1280 u_int manual_sx; 1281 u_int manual_sy; 1282 u_int xpixel; 1283 u_int ypixel; 1284 1285 u_int new_sx; 1286 u_int new_sy; 1287 u_int new_xpixel; 1288 u_int new_ypixel; 1289 1290 struct utf8_data *fill_character; 1291 int flags; 1292 #define WINDOW_BELL 0x1 1293 #define WINDOW_ACTIVITY 0x2 1294 #define WINDOW_SILENCE 0x4 1295 #define WINDOW_ZOOMED 0x8 1296 #define WINDOW_WASZOOMED 0x10 1297 #define WINDOW_RESIZE 0x20 1298 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE) 1299 1300 int alerts_queued; 1301 TAILQ_ENTRY(window) alerts_entry; 1302 1303 struct options *options; 1304 1305 u_int references; 1306 TAILQ_HEAD(, winlink) winlinks; 1307 1308 RB_ENTRY(window) entry; 1309 }; 1310 RB_HEAD(windows, window); 1311 1312 /* Entry on local window list. */ 1313 struct winlink { 1314 int idx; 1315 struct session *session; 1316 struct window *window; 1317 1318 int flags; 1319 #define WINLINK_BELL 0x1 1320 #define WINLINK_ACTIVITY 0x2 1321 #define WINLINK_SILENCE 0x4 1322 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE) 1323 #define WINLINK_VISITED 0x8 1324 1325 RB_ENTRY(winlink) entry; 1326 TAILQ_ENTRY(winlink) wentry; 1327 TAILQ_ENTRY(winlink) sentry; 1328 }; 1329 RB_HEAD(winlinks, winlink); 1330 TAILQ_HEAD(winlink_stack, winlink); 1331 1332 /* Window size option. */ 1333 #define WINDOW_SIZE_LARGEST 0 1334 #define WINDOW_SIZE_SMALLEST 1 1335 #define WINDOW_SIZE_MANUAL 2 1336 #define WINDOW_SIZE_LATEST 3 1337 1338 /* Pane border status option. */ 1339 #define PANE_STATUS_OFF 0 1340 #define PANE_STATUS_TOP 1 1341 #define PANE_STATUS_BOTTOM 2 1342 1343 /* Pane scrollbars option. */ 1344 #define PANE_SCROLLBARS_OFF 0 1345 #define PANE_SCROLLBARS_MODAL 1 1346 #define PANE_SCROLLBARS_ALWAYS 2 1347 1348 /* Pane scrollbars position option. */ 1349 #define PANE_SCROLLBARS_RIGHT 0 1350 #define PANE_SCROLLBARS_LEFT 1 1351 1352 /* Pane scrollbars width, padding and fill character. */ 1353 #define PANE_SCROLLBARS_DEFAULT_PADDING 0 1354 #define PANE_SCROLLBARS_DEFAULT_WIDTH 1 1355 #define PANE_SCROLLBARS_CHARACTER ' ' 1356 1357 /* True if screen in alternate screen. */ 1358 #define SCREEN_IS_ALTERNATE(s) ((s)->saved_grid != NULL) 1359 1360 /* Layout direction. */ 1361 enum layout_type { 1362 LAYOUT_LEFTRIGHT, 1363 LAYOUT_TOPBOTTOM, 1364 LAYOUT_WINDOWPANE 1365 }; 1366 1367 /* Layout cells queue. */ 1368 TAILQ_HEAD(layout_cells, layout_cell); 1369 1370 /* Layout cell. */ 1371 struct layout_cell { 1372 enum layout_type type; 1373 1374 struct layout_cell *parent; 1375 1376 u_int sx; 1377 u_int sy; 1378 1379 u_int xoff; 1380 u_int yoff; 1381 1382 struct window_pane *wp; 1383 struct layout_cells cells; 1384 1385 TAILQ_ENTRY(layout_cell) entry; 1386 }; 1387 1388 /* Environment variable. */ 1389 struct environ_entry { 1390 char *name; 1391 char *value; 1392 1393 int flags; 1394 #define ENVIRON_HIDDEN 0x1 1395 1396 RB_ENTRY(environ_entry) entry; 1397 }; 1398 1399 /* Client session. */ 1400 struct session_group { 1401 const char *name; 1402 TAILQ_HEAD(, session) sessions; 1403 1404 RB_ENTRY(session_group) entry; 1405 }; 1406 RB_HEAD(session_groups, session_group); 1407 1408 struct session { 1409 u_int id; 1410 1411 char *name; 1412 const char *cwd; 1413 1414 struct timeval creation_time; 1415 struct timeval last_attached_time; 1416 struct timeval activity_time; 1417 struct timeval last_activity_time; 1418 1419 struct event lock_timer; 1420 1421 struct winlink *curw; 1422 struct winlink_stack lastw; 1423 struct winlinks windows; 1424 1425 int statusat; 1426 u_int statuslines; 1427 1428 struct options *options; 1429 1430 #define SESSION_ALERTED 0x1 1431 int flags; 1432 1433 u_int attached; 1434 1435 struct termios *tio; 1436 1437 struct environ *environ; 1438 1439 int references; 1440 1441 TAILQ_ENTRY(session) gentry; 1442 RB_ENTRY(session) entry; 1443 }; 1444 RB_HEAD(sessions, session); 1445 1446 /* Mouse button masks. */ 1447 #define MOUSE_MASK_BUTTONS 195 1448 #define MOUSE_MASK_SHIFT 4 1449 #define MOUSE_MASK_META 8 1450 #define MOUSE_MASK_CTRL 16 1451 #define MOUSE_MASK_DRAG 32 1452 #define MOUSE_MASK_MODIFIERS (MOUSE_MASK_SHIFT|MOUSE_MASK_META|MOUSE_MASK_CTRL) 1453 1454 /* Mouse wheel type. */ 1455 #define MOUSE_WHEEL_UP 64 1456 #define MOUSE_WHEEL_DOWN 65 1457 1458 /* Mouse button type. */ 1459 #define MOUSE_BUTTON_1 0 1460 #define MOUSE_BUTTON_2 1 1461 #define MOUSE_BUTTON_3 2 1462 #define MOUSE_BUTTON_6 66 1463 #define MOUSE_BUTTON_7 67 1464 #define MOUSE_BUTTON_8 128 1465 #define MOUSE_BUTTON_9 129 1466 #define MOUSE_BUTTON_10 130 1467 #define MOUSE_BUTTON_11 131 1468 1469 /* Mouse helpers. */ 1470 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS) 1471 #define MOUSE_WHEEL(b) \ 1472 (((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_UP || \ 1473 ((b) & MOUSE_MASK_BUTTONS) == MOUSE_WHEEL_DOWN) 1474 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG) 1475 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3) 1476 1477 /* Mouse input. */ 1478 struct mouse_event { 1479 int valid; 1480 int ignore; 1481 1482 key_code key; 1483 1484 int statusat; 1485 u_int statuslines; 1486 1487 u_int x; 1488 u_int y; 1489 u_int b; 1490 1491 u_int lx; 1492 u_int ly; 1493 u_int lb; 1494 1495 u_int ox; 1496 u_int oy; 1497 1498 int s; 1499 int w; 1500 int wp; 1501 1502 u_int sgr_type; 1503 u_int sgr_b; 1504 }; 1505 1506 /* Key event. */ 1507 struct key_event { 1508 key_code key; 1509 struct mouse_event m; 1510 1511 char *buf; 1512 size_t len; 1513 }; 1514 1515 /* Terminal definition. */ 1516 struct tty_term { 1517 char *name; 1518 struct tty *tty; 1519 int features; 1520 1521 char acs[UCHAR_MAX + 1][2]; 1522 1523 struct tty_code *codes; 1524 1525 #define TERM_256COLOURS 0x1 1526 #define TERM_NOAM 0x2 1527 #define TERM_DECSLRM 0x4 1528 #define TERM_DECFRA 0x8 1529 #define TERM_RGBCOLOURS 0x10 1530 #define TERM_VT100LIKE 0x20 1531 #define TERM_SIXEL 0x40 1532 int flags; 1533 1534 LIST_ENTRY(tty_term) entry; 1535 }; 1536 LIST_HEAD(tty_terms, tty_term); 1537 1538 /* Client terminal. */ 1539 struct tty { 1540 struct client *client; 1541 struct event start_timer; 1542 struct event clipboard_timer; 1543 time_t last_requests; 1544 1545 u_int sx; 1546 u_int sy; 1547 /* Cell size in pixels. */ 1548 u_int xpixel; 1549 u_int ypixel; 1550 1551 u_int cx; 1552 u_int cy; 1553 enum screen_cursor_style cstyle; 1554 int ccolour; 1555 1556 /* Properties of the area being drawn on. */ 1557 /* When true, the drawing area is bigger than the terminal. */ 1558 int oflag; 1559 u_int oox; 1560 u_int ooy; 1561 u_int osx; 1562 u_int osy; 1563 1564 int mode; 1565 int fg; 1566 int bg; 1567 1568 u_int rlower; 1569 u_int rupper; 1570 1571 u_int rleft; 1572 u_int rright; 1573 1574 struct event event_in; 1575 struct evbuffer *in; 1576 struct event event_out; 1577 struct evbuffer *out; 1578 struct event timer; 1579 size_t discarded; 1580 1581 struct termios tio; 1582 1583 struct grid_cell cell; 1584 struct grid_cell last_cell; 1585 1586 #define TTY_NOCURSOR 0x1 1587 #define TTY_FREEZE 0x2 1588 #define TTY_TIMER 0x4 1589 #define TTY_NOBLOCK 0x8 1590 #define TTY_STARTED 0x10 1591 #define TTY_OPENED 0x20 1592 #define TTY_OSC52QUERY 0x40 1593 #define TTY_BLOCK 0x80 1594 #define TTY_HAVEDA 0x100 1595 #define TTY_HAVEXDA 0x200 1596 #define TTY_SYNCING 0x400 1597 #define TTY_HAVEDA2 0x800 1598 #define TTY_WINSIZEQUERY 0x1000 1599 #define TTY_WAITFG 0x2000 1600 #define TTY_WAITBG 0x4000 1601 #define TTY_ALL_REQUEST_FLAGS \ 1602 (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA) 1603 int flags; 1604 1605 struct tty_term *term; 1606 1607 u_int mouse_last_x; 1608 u_int mouse_last_y; 1609 u_int mouse_last_b; 1610 int mouse_drag_flag; 1611 int mouse_scrolling_flag; 1612 int mouse_slider_mpos; 1613 1614 void (*mouse_drag_update)(struct client *, 1615 struct mouse_event *); 1616 void (*mouse_drag_release)(struct client *, 1617 struct mouse_event *); 1618 1619 struct event key_timer; 1620 struct tty_key *key_tree; 1621 }; 1622 1623 /* Terminal command context. */ 1624 typedef void (*tty_ctx_redraw_cb)(const struct tty_ctx *); 1625 typedef int (*tty_ctx_set_client_cb)(struct tty_ctx *, struct client *); 1626 struct tty_ctx { 1627 struct screen *s; 1628 1629 tty_ctx_redraw_cb redraw_cb; 1630 tty_ctx_set_client_cb set_client_cb; 1631 void *arg; 1632 1633 const struct grid_cell *cell; 1634 int wrapped; 1635 1636 u_int num; 1637 void *ptr; 1638 void *ptr2; 1639 1640 /* 1641 * Whether this command should be sent even when the pane is not 1642 * visible (used for a passthrough sequence when allow-passthrough is 1643 * "all"). 1644 */ 1645 int allow_invisible_panes; 1646 1647 /* 1648 * Cursor and region position before the screen was updated - this is 1649 * where the command should be applied; the values in the screen have 1650 * already been updated. 1651 */ 1652 u_int ocx; 1653 u_int ocy; 1654 1655 u_int orupper; 1656 u_int orlower; 1657 1658 /* Target region (usually pane) offset and size. */ 1659 u_int xoff; 1660 u_int yoff; 1661 u_int rxoff; 1662 u_int ryoff; 1663 u_int sx; 1664 u_int sy; 1665 1666 /* The background colour used for clearing (erasing). */ 1667 u_int bg; 1668 1669 /* The default colours and palette. */ 1670 struct grid_cell defaults; 1671 struct colour_palette *palette; 1672 1673 /* Containing region (usually window) offset and size. */ 1674 int bigger; 1675 u_int wox; 1676 u_int woy; 1677 u_int wsx; 1678 u_int wsy; 1679 }; 1680 1681 /* Saved message entry. */ 1682 struct message_entry { 1683 char *msg; 1684 u_int msg_num; 1685 struct timeval msg_time; 1686 1687 TAILQ_ENTRY(message_entry) entry; 1688 }; 1689 TAILQ_HEAD(message_list, message_entry); 1690 1691 /* Argument type. */ 1692 enum args_type { 1693 ARGS_NONE, 1694 ARGS_STRING, 1695 ARGS_COMMANDS 1696 }; 1697 1698 /* Argument value. */ 1699 struct args_value { 1700 enum args_type type; 1701 union { 1702 char *string; 1703 struct cmd_list *cmdlist; 1704 }; 1705 char *cached; 1706 TAILQ_ENTRY(args_value) entry; 1707 }; 1708 1709 /* Arguments set. */ 1710 struct args_entry; 1711 RB_HEAD(args_tree, args_entry); 1712 1713 /* Arguments parsing type. */ 1714 enum args_parse_type { 1715 ARGS_PARSE_INVALID, 1716 ARGS_PARSE_STRING, 1717 ARGS_PARSE_COMMANDS_OR_STRING, 1718 ARGS_PARSE_COMMANDS 1719 }; 1720 1721 /* Arguments parsing state. */ 1722 typedef enum args_parse_type (*args_parse_cb)(struct args *, u_int, char **); 1723 struct args_parse { 1724 const char *template; 1725 int lower; 1726 int upper; 1727 args_parse_cb cb; 1728 }; 1729 1730 /* Command find structures. */ 1731 enum cmd_find_type { 1732 CMD_FIND_PANE, 1733 CMD_FIND_WINDOW, 1734 CMD_FIND_SESSION, 1735 }; 1736 struct cmd_find_state { 1737 int flags; 1738 struct cmd_find_state *current; 1739 1740 struct session *s; 1741 struct winlink *wl; 1742 struct window *w; 1743 struct window_pane *wp; 1744 int idx; 1745 }; 1746 1747 /* Command find flags. */ 1748 #define CMD_FIND_PREFER_UNATTACHED 0x1 1749 #define CMD_FIND_QUIET 0x2 1750 #define CMD_FIND_WINDOW_INDEX 0x4 1751 #define CMD_FIND_DEFAULT_MARKED 0x8 1752 #define CMD_FIND_EXACT_SESSION 0x10 1753 #define CMD_FIND_EXACT_WINDOW 0x20 1754 #define CMD_FIND_CANFAIL 0x40 1755 1756 /* List of commands. */ 1757 struct cmd_list { 1758 int references; 1759 u_int group; 1760 struct cmds *list; 1761 }; 1762 1763 /* Command return values. */ 1764 enum cmd_retval { 1765 CMD_RETURN_ERROR = -1, 1766 CMD_RETURN_NORMAL = 0, 1767 CMD_RETURN_WAIT, 1768 CMD_RETURN_STOP 1769 }; 1770 1771 /* Command parse result. */ 1772 enum cmd_parse_status { 1773 CMD_PARSE_ERROR, 1774 CMD_PARSE_SUCCESS 1775 }; 1776 struct cmd_parse_result { 1777 enum cmd_parse_status status; 1778 struct cmd_list *cmdlist; 1779 char *error; 1780 }; 1781 struct cmd_parse_input { 1782 int flags; 1783 #define CMD_PARSE_QUIET 0x1 1784 #define CMD_PARSE_PARSEONLY 0x2 1785 #define CMD_PARSE_NOALIAS 0x4 1786 #define CMD_PARSE_VERBOSE 0x8 1787 #define CMD_PARSE_ONEGROUP 0x10 1788 1789 const char *file; 1790 u_int line; 1791 1792 struct cmdq_item *item; 1793 struct client *c; 1794 struct cmd_find_state fs; 1795 }; 1796 1797 /* Command queue flags. */ 1798 #define CMDQ_STATE_REPEAT 0x1 1799 #define CMDQ_STATE_CONTROL 0x2 1800 #define CMDQ_STATE_NOHOOKS 0x4 1801 1802 /* Command queue callback. */ 1803 typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *); 1804 1805 /* Command definition flag. */ 1806 struct cmd_entry_flag { 1807 char flag; 1808 enum cmd_find_type type; 1809 int flags; 1810 }; 1811 1812 /* Command definition. */ 1813 struct cmd_entry { 1814 const char *name; 1815 const char *alias; 1816 1817 struct args_parse args; 1818 const char *usage; 1819 1820 struct cmd_entry_flag source; 1821 struct cmd_entry_flag target; 1822 1823 #define CMD_STARTSERVER 0x1 1824 #define CMD_READONLY 0x2 1825 #define CMD_AFTERHOOK 0x4 1826 #define CMD_CLIENT_CFLAG 0x8 1827 #define CMD_CLIENT_TFLAG 0x10 1828 #define CMD_CLIENT_CANFAIL 0x20 1829 int flags; 1830 1831 enum cmd_retval (*exec)(struct cmd *, struct cmdq_item *); 1832 }; 1833 1834 /* Status line. */ 1835 #define STATUS_LINES_LIMIT 5 1836 struct status_line_entry { 1837 char *expanded; 1838 struct style_ranges ranges; 1839 }; 1840 struct status_line { 1841 struct event timer; 1842 1843 struct screen screen; 1844 struct screen *active; 1845 int references; 1846 1847 struct grid_cell style; 1848 struct status_line_entry entries[STATUS_LINES_LIMIT]; 1849 }; 1850 1851 /* Prompt type. */ 1852 #define PROMPT_NTYPES 4 1853 enum prompt_type { 1854 PROMPT_TYPE_COMMAND, 1855 PROMPT_TYPE_SEARCH, 1856 PROMPT_TYPE_TARGET, 1857 PROMPT_TYPE_WINDOW_TARGET, 1858 PROMPT_TYPE_INVALID = 0xff 1859 }; 1860 1861 /* File in client. */ 1862 typedef void (*client_file_cb) (struct client *, const char *, int, int, 1863 struct evbuffer *, void *); 1864 struct client_file { 1865 struct client *c; 1866 struct tmuxpeer *peer; 1867 struct client_files *tree; 1868 int references; 1869 int stream; 1870 1871 char *path; 1872 struct evbuffer *buffer; 1873 struct bufferevent *event; 1874 1875 int fd; 1876 int error; 1877 int closed; 1878 1879 client_file_cb cb; 1880 void *data; 1881 1882 RB_ENTRY(client_file) entry; 1883 }; 1884 RB_HEAD(client_files, client_file); 1885 1886 /* Client window. */ 1887 struct client_window { 1888 u_int window; 1889 struct window_pane *pane; 1890 1891 u_int sx; 1892 u_int sy; 1893 1894 RB_ENTRY(client_window) entry; 1895 }; 1896 RB_HEAD(client_windows, client_window); 1897 1898 /* Visible areas not obstructed by overlays. */ 1899 #define OVERLAY_MAX_RANGES 3 1900 struct overlay_ranges { 1901 u_int px[OVERLAY_MAX_RANGES]; 1902 u_int nx[OVERLAY_MAX_RANGES]; 1903 }; 1904 1905 /* 1906 * Client theme, this is worked out from the background colour if not reported 1907 * by terminal. 1908 */ 1909 enum client_theme { 1910 THEME_UNKNOWN, 1911 THEME_LIGHT, 1912 THEME_DARK 1913 }; 1914 1915 /* Client connection. */ 1916 typedef int (*prompt_input_cb)(struct client *, void *, const char *, int); 1917 typedef void (*prompt_free_cb)(void *); 1918 typedef void (*overlay_check_cb)(struct client*, void *, u_int, u_int, u_int, 1919 struct overlay_ranges *); 1920 typedef struct screen *(*overlay_mode_cb)(struct client *, void *, u_int *, 1921 u_int *); 1922 typedef void (*overlay_draw_cb)(struct client *, void *, 1923 struct screen_redraw_ctx *); 1924 typedef int (*overlay_key_cb)(struct client *, void *, struct key_event *); 1925 typedef void (*overlay_free_cb)(struct client *, void *); 1926 typedef void (*overlay_resize_cb)(struct client *, void *); 1927 struct client { 1928 const char *name; 1929 struct tmuxpeer *peer; 1930 struct cmdq_list *queue; 1931 1932 struct client_windows windows; 1933 1934 struct control_state *control_state; 1935 u_int pause_age; 1936 1937 pid_t pid; 1938 int fd; 1939 int out_fd; 1940 struct event event; 1941 int retval; 1942 1943 struct timeval creation_time; 1944 struct timeval activity_time; 1945 struct timeval last_activity_time; 1946 1947 struct environ *environ; 1948 struct format_job_tree *jobs; 1949 1950 char *title; 1951 char *path; 1952 const char *cwd; 1953 1954 char *term_name; 1955 int term_features; 1956 char *term_type; 1957 char **term_caps; 1958 u_int term_ncaps; 1959 1960 char *ttyname; 1961 struct tty tty; 1962 1963 size_t written; 1964 size_t discarded; 1965 size_t redraw; 1966 1967 struct event repeat_timer; 1968 1969 struct event click_timer; 1970 u_int click_button; 1971 struct mouse_event click_event; 1972 1973 struct status_line status; 1974 enum client_theme theme; 1975 1976 struct input_requests input_requests; 1977 1978 #define CLIENT_TERMINAL 0x1 1979 #define CLIENT_LOGIN 0x2 1980 #define CLIENT_EXIT 0x4 1981 #define CLIENT_REDRAWWINDOW 0x8 1982 #define CLIENT_REDRAWSTATUS 0x10 1983 #define CLIENT_REPEAT 0x20 1984 #define CLIENT_SUSPENDED 0x40 1985 #define CLIENT_ATTACHED 0x80 1986 #define CLIENT_EXITED 0x100 1987 #define CLIENT_DEAD 0x200 1988 #define CLIENT_REDRAWBORDERS 0x400 1989 #define CLIENT_READONLY 0x800 1990 #define CLIENT_NOSTARTSERVER 0x1000 1991 #define CLIENT_CONTROL 0x2000 1992 #define CLIENT_CONTROLCONTROL 0x4000 1993 #define CLIENT_FOCUSED 0x8000 1994 #define CLIENT_UTF8 0x10000 1995 #define CLIENT_IGNORESIZE 0x20000 1996 #define CLIENT_IDENTIFIED 0x40000 1997 #define CLIENT_STATUSFORCE 0x80000 1998 #define CLIENT_DOUBLECLICK 0x100000 1999 #define CLIENT_TRIPLECLICK 0x200000 2000 #define CLIENT_SIZECHANGED 0x400000 2001 #define CLIENT_STATUSOFF 0x800000 2002 #define CLIENT_REDRAWSTATUSALWAYS 0x1000000 2003 #define CLIENT_REDRAWOVERLAY 0x2000000 2004 #define CLIENT_CONTROL_NOOUTPUT 0x4000000 2005 #define CLIENT_DEFAULTSOCKET 0x8000000 2006 #define CLIENT_STARTSERVER 0x10000000 2007 #define CLIENT_REDRAWPANES 0x20000000 2008 #define CLIENT_NOFORK 0x40000000 2009 #define CLIENT_ACTIVEPANE 0x80000000ULL 2010 #define CLIENT_CONTROL_PAUSEAFTER 0x100000000ULL 2011 #define CLIENT_CONTROL_WAITEXIT 0x200000000ULL 2012 #define CLIENT_WINDOWSIZECHANGED 0x400000000ULL 2013 #define CLIENT_CLIPBOARDBUFFER 0x800000000ULL 2014 #define CLIENT_BRACKETPASTING 0x1000000000ULL 2015 #define CLIENT_ASSUMEPASTING 0x2000000000ULL 2016 #define CLIENT_REDRAWSCROLLBARS 0x4000000000ULL 2017 #define CLIENT_NO_DETACH_ON_DESTROY 0x8000000000ULL 2018 #define CLIENT_ALLREDRAWFLAGS \ 2019 (CLIENT_REDRAWWINDOW| \ 2020 CLIENT_REDRAWSTATUS| \ 2021 CLIENT_REDRAWSTATUSALWAYS| \ 2022 CLIENT_REDRAWBORDERS| \ 2023 CLIENT_REDRAWOVERLAY| \ 2024 CLIENT_REDRAWPANES| \ 2025 CLIENT_REDRAWSCROLLBARS) 2026 #define CLIENT_UNATTACHEDFLAGS \ 2027 (CLIENT_DEAD| \ 2028 CLIENT_SUSPENDED| \ 2029 CLIENT_EXIT) 2030 #define CLIENT_NODETACHFLAGS \ 2031 (CLIENT_DEAD| \ 2032 CLIENT_EXIT) 2033 #define CLIENT_NOSIZEFLAGS \ 2034 (CLIENT_DEAD| \ 2035 CLIENT_SUSPENDED| \ 2036 CLIENT_EXIT) 2037 uint64_t flags; 2038 2039 enum { 2040 CLIENT_EXIT_RETURN, 2041 CLIENT_EXIT_SHUTDOWN, 2042 CLIENT_EXIT_DETACH 2043 } exit_type; 2044 enum msgtype exit_msgtype; 2045 char *exit_session; 2046 char *exit_message; 2047 2048 struct key_table *keytable; 2049 key_code last_key; 2050 2051 uint64_t redraw_panes; 2052 uint64_t redraw_scrollbars; 2053 2054 int message_ignore_keys; 2055 int message_ignore_styles; 2056 char *message_string; 2057 struct event message_timer; 2058 2059 char *prompt_string; 2060 struct format_tree *prompt_formats; 2061 struct utf8_data *prompt_buffer; 2062 char *prompt_last; 2063 size_t prompt_index; 2064 prompt_input_cb prompt_inputcb; 2065 prompt_free_cb prompt_freecb; 2066 void *prompt_data; 2067 u_int prompt_hindex[PROMPT_NTYPES]; 2068 enum { 2069 PROMPT_ENTRY, 2070 PROMPT_COMMAND 2071 } prompt_mode; 2072 struct utf8_data *prompt_saved; 2073 #define PROMPT_SINGLE 0x1 2074 #define PROMPT_NUMERIC 0x2 2075 #define PROMPT_INCREMENTAL 0x4 2076 #define PROMPT_NOFORMAT 0x8 2077 #define PROMPT_KEY 0x10 2078 #define PROMPT_ACCEPT 0x20 2079 #define PROMPT_QUOTENEXT 0x40 2080 int prompt_flags; 2081 enum prompt_type prompt_type; 2082 int prompt_cursor; 2083 2084 struct session *session; 2085 struct session *last_session; 2086 2087 int references; 2088 2089 void *pan_window; 2090 u_int pan_ox; 2091 u_int pan_oy; 2092 2093 overlay_check_cb overlay_check; 2094 overlay_mode_cb overlay_mode; 2095 overlay_draw_cb overlay_draw; 2096 overlay_key_cb overlay_key; 2097 overlay_free_cb overlay_free; 2098 overlay_resize_cb overlay_resize; 2099 void *overlay_data; 2100 struct event overlay_timer; 2101 2102 struct client_files files; 2103 u_int source_file_depth; 2104 2105 u_int *clipboard_panes; 2106 u_int clipboard_npanes; 2107 2108 TAILQ_ENTRY(client) entry; 2109 }; 2110 TAILQ_HEAD(clients, client); 2111 2112 /* Control mode subscription type. */ 2113 enum control_sub_type { 2114 CONTROL_SUB_SESSION, 2115 CONTROL_SUB_PANE, 2116 CONTROL_SUB_ALL_PANES, 2117 CONTROL_SUB_WINDOW, 2118 CONTROL_SUB_ALL_WINDOWS 2119 }; 2120 2121 /* Key binding and key table. */ 2122 struct key_binding { 2123 key_code key; 2124 struct cmd_list *cmdlist; 2125 const char *note; 2126 2127 int flags; 2128 #define KEY_BINDING_REPEAT 0x1 2129 2130 RB_ENTRY(key_binding) entry; 2131 }; 2132 RB_HEAD(key_bindings, key_binding); 2133 2134 struct key_table { 2135 const char *name; 2136 struct timeval activity_time; 2137 struct key_bindings key_bindings; 2138 struct key_bindings default_key_bindings; 2139 2140 u_int references; 2141 2142 RB_ENTRY(key_table) entry; 2143 }; 2144 RB_HEAD(key_tables, key_table); 2145 2146 /* Option data. */ 2147 RB_HEAD(options_array, options_array_item); 2148 union options_value { 2149 char *string; 2150 long long number; 2151 struct style style; 2152 struct options_array array; 2153 struct cmd_list *cmdlist; 2154 }; 2155 2156 /* Option table entries. */ 2157 enum options_table_type { 2158 OPTIONS_TABLE_STRING, 2159 OPTIONS_TABLE_NUMBER, 2160 OPTIONS_TABLE_KEY, 2161 OPTIONS_TABLE_COLOUR, 2162 OPTIONS_TABLE_FLAG, 2163 OPTIONS_TABLE_CHOICE, 2164 OPTIONS_TABLE_COMMAND 2165 }; 2166 2167 #define OPTIONS_TABLE_NONE 0 2168 #define OPTIONS_TABLE_SERVER 0x1 2169 #define OPTIONS_TABLE_SESSION 0x2 2170 #define OPTIONS_TABLE_WINDOW 0x4 2171 #define OPTIONS_TABLE_PANE 0x8 2172 2173 #define OPTIONS_TABLE_IS_ARRAY 0x1 2174 #define OPTIONS_TABLE_IS_HOOK 0x2 2175 #define OPTIONS_TABLE_IS_STYLE 0x4 2176 2177 struct options_table_entry { 2178 const char *name; 2179 const char *alternative_name; 2180 enum options_table_type type; 2181 int scope; 2182 int flags; 2183 2184 u_int minimum; 2185 u_int maximum; 2186 const char **choices; 2187 2188 const char *default_str; 2189 long long default_num; 2190 const char **default_arr; 2191 2192 const char *separator; 2193 const char *pattern; 2194 2195 const char *text; 2196 const char *unit; 2197 }; 2198 2199 struct options_name_map { 2200 const char *from; 2201 const char *to; 2202 }; 2203 2204 /* Common command usages. */ 2205 #define CMD_TARGET_PANE_USAGE "[-t target-pane]" 2206 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]" 2207 #define CMD_TARGET_SESSION_USAGE "[-t target-session]" 2208 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]" 2209 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]" 2210 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]" 2211 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]" 2212 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]" 2213 #define CMD_BUFFER_USAGE "[-b buffer-name]" 2214 2215 /* Spawn common context. */ 2216 struct spawn_context { 2217 struct cmdq_item *item; 2218 2219 struct session *s; 2220 struct winlink *wl; 2221 struct client *tc; 2222 2223 struct window_pane *wp0; 2224 struct layout_cell *lc; 2225 2226 const char *name; 2227 char **argv; 2228 int argc; 2229 struct environ *environ; 2230 2231 int idx; 2232 const char *cwd; 2233 2234 int flags; 2235 #define SPAWN_KILL 0x1 2236 #define SPAWN_DETACHED 0x2 2237 #define SPAWN_RESPAWN 0x4 2238 #define SPAWN_BEFORE 0x8 2239 #define SPAWN_NONOTIFY 0x10 2240 #define SPAWN_FULLSIZE 0x20 2241 #define SPAWN_EMPTY 0x40 2242 #define SPAWN_ZOOM 0x80 2243 }; 2244 2245 /* Mode tree sort order. */ 2246 struct mode_tree_sort_criteria { 2247 u_int field; 2248 int reversed; 2249 }; 2250 2251 /* tmux.c */ 2252 extern struct options *global_options; 2253 extern struct options *global_s_options; 2254 extern struct options *global_w_options; 2255 extern struct environ *global_environ; 2256 extern struct timeval start_time; 2257 extern const char *socket_path; 2258 extern const char *shell_command; 2259 extern int ptm_fd; 2260 extern const char *shell_command; 2261 int checkshell(const char *); 2262 void setblocking(int, int); 2263 char *shell_argv0(const char *, int); 2264 uint64_t get_timer(void); 2265 const char *sig2name(int); 2266 const char *find_cwd(void); 2267 const char *find_home(void); 2268 const char *getversion(void); 2269 2270 /* proc.c */ 2271 struct imsg; 2272 int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t); 2273 struct tmuxproc *proc_start(const char *); 2274 void proc_loop(struct tmuxproc *, int (*)(void)); 2275 void proc_exit(struct tmuxproc *); 2276 void proc_set_signals(struct tmuxproc *, void(*)(int)); 2277 void proc_clear_signals(struct tmuxproc *, int); 2278 struct tmuxpeer *proc_add_peer(struct tmuxproc *, int, 2279 void (*)(struct imsg *, void *), void *); 2280 void proc_remove_peer(struct tmuxpeer *); 2281 void proc_kill_peer(struct tmuxpeer *); 2282 void proc_flush_peer(struct tmuxpeer *); 2283 void proc_toggle_log(struct tmuxproc *); 2284 pid_t proc_fork_and_daemon(int *); 2285 uid_t proc_get_peer_uid(struct tmuxpeer *); 2286 2287 /* cfg.c */ 2288 extern int cfg_finished; 2289 extern struct client *cfg_client; 2290 extern char **cfg_files; 2291 extern u_int cfg_nfiles; 2292 extern int cfg_quiet; 2293 void start_cfg(void); 2294 int load_cfg(const char *, struct client *, struct cmdq_item *, 2295 struct cmd_find_state *, int, struct cmdq_item **); 2296 int load_cfg_from_buffer(const void *, size_t, const char *, 2297 struct client *, struct cmdq_item *, struct cmd_find_state *, 2298 int, struct cmdq_item **); 2299 void printflike(1, 2) cfg_add_cause(const char *, ...); 2300 void cfg_print_causes(struct cmdq_item *); 2301 void cfg_show_causes(struct session *); 2302 2303 /* paste.c */ 2304 struct paste_buffer; 2305 const char *paste_buffer_name(struct paste_buffer *); 2306 u_int paste_buffer_order(struct paste_buffer *); 2307 time_t paste_buffer_created(struct paste_buffer *); 2308 const char *paste_buffer_data(struct paste_buffer *, size_t *); 2309 struct paste_buffer *paste_walk(struct paste_buffer *); 2310 int paste_is_empty(void); 2311 struct paste_buffer *paste_get_top(const char **); 2312 struct paste_buffer *paste_get_name(const char *); 2313 void paste_free(struct paste_buffer *); 2314 void paste_add(const char *, char *, size_t); 2315 int paste_rename(const char *, const char *, char **); 2316 int paste_set(char *, size_t, const char *, char **); 2317 void paste_replace(struct paste_buffer *, char *, size_t); 2318 char *paste_make_sample(struct paste_buffer *); 2319 2320 /* format.c */ 2321 #define FORMAT_STATUS 0x1 2322 #define FORMAT_FORCE 0x2 2323 #define FORMAT_NOJOBS 0x4 2324 #define FORMAT_VERBOSE 0x8 2325 #define FORMAT_LAST 0x10 2326 #define FORMAT_NONE 0 2327 #define FORMAT_PANE 0x80000000U 2328 #define FORMAT_WINDOW 0x40000000U 2329 struct format_tree; 2330 struct format_modifier; 2331 typedef void *(*format_cb)(struct format_tree *); 2332 void format_tidy_jobs(void); 2333 const char *format_skip(const char *, const char *); 2334 int format_true(const char *); 2335 struct format_tree *format_create(struct client *, struct cmdq_item *, int, 2336 int); 2337 void format_free(struct format_tree *); 2338 void format_merge(struct format_tree *, struct format_tree *); 2339 struct window_pane *format_get_pane(struct format_tree *); 2340 void printflike(3, 4) format_add(struct format_tree *, const char *, 2341 const char *, ...); 2342 void format_add_tv(struct format_tree *, const char *, 2343 struct timeval *); 2344 void format_add_cb(struct format_tree *, const char *, format_cb); 2345 void format_log_debug(struct format_tree *, const char *); 2346 void format_each(struct format_tree *, void (*)(const char *, 2347 const char *, void *), void *); 2348 char *format_pretty_time(time_t, int); 2349 char *format_expand_time(struct format_tree *, const char *); 2350 char *format_expand(struct format_tree *, const char *); 2351 char *format_single(struct cmdq_item *, const char *, 2352 struct client *, struct session *, struct winlink *, 2353 struct window_pane *); 2354 char *format_single_from_state(struct cmdq_item *, const char *, 2355 struct client *, struct cmd_find_state *); 2356 char *format_single_from_target(struct cmdq_item *, const char *); 2357 struct format_tree *format_create_defaults(struct cmdq_item *, struct client *, 2358 struct session *, struct winlink *, struct window_pane *); 2359 struct format_tree *format_create_from_state(struct cmdq_item *, 2360 struct client *, struct cmd_find_state *); 2361 struct format_tree *format_create_from_target(struct cmdq_item *); 2362 void format_defaults(struct format_tree *, struct client *, 2363 struct session *, struct winlink *, struct window_pane *); 2364 void format_defaults_window(struct format_tree *, struct window *); 2365 void format_defaults_pane(struct format_tree *, 2366 struct window_pane *); 2367 void format_defaults_paste_buffer(struct format_tree *, 2368 struct paste_buffer *); 2369 void format_lost_client(struct client *); 2370 char *format_grid_word(struct grid *, u_int, u_int); 2371 char *format_grid_hyperlink(struct grid *, u_int, u_int, 2372 struct screen *); 2373 char *format_grid_line(struct grid *, u_int); 2374 2375 /* format-draw.c */ 2376 void format_draw(struct screen_write_ctx *, 2377 const struct grid_cell *, u_int, const char *, 2378 struct style_ranges *, int); 2379 u_int format_width(const char *); 2380 char *format_trim_left(const char *, u_int); 2381 char *format_trim_right(const char *, u_int); 2382 2383 /* notify.c */ 2384 void notify_hook(struct cmdq_item *, const char *); 2385 void notify_client(const char *, struct client *); 2386 void notify_session(const char *, struct session *); 2387 void notify_winlink(const char *, struct winlink *); 2388 void notify_session_window(const char *, struct session *, struct window *); 2389 void notify_window(const char *, struct window *); 2390 void notify_pane(const char *, struct window_pane *); 2391 void notify_paste_buffer(const char *, int); 2392 2393 /* options.c */ 2394 struct options *options_create(struct options *); 2395 void options_free(struct options *); 2396 struct options *options_get_parent(struct options *); 2397 void options_set_parent(struct options *, struct options *); 2398 struct options_entry *options_first(struct options *); 2399 struct options_entry *options_next(struct options_entry *); 2400 struct options_entry *options_empty(struct options *, 2401 const struct options_table_entry *); 2402 struct options_entry *options_default(struct options *, 2403 const struct options_table_entry *); 2404 char *options_default_to_string(const struct options_table_entry *); 2405 const char *options_name(struct options_entry *); 2406 struct options *options_owner(struct options_entry *); 2407 const struct options_table_entry *options_table_entry(struct options_entry *); 2408 struct options_entry *options_get_only(struct options *, const char *); 2409 struct options_entry *options_get(struct options *, const char *); 2410 void options_array_clear(struct options_entry *); 2411 union options_value *options_array_get(struct options_entry *, u_int); 2412 int options_array_set(struct options_entry *, u_int, const char *, 2413 int, char **); 2414 int options_array_assign(struct options_entry *, const char *, 2415 char **); 2416 struct options_array_item *options_array_first(struct options_entry *); 2417 struct options_array_item *options_array_next(struct options_array_item *); 2418 u_int options_array_item_index(struct options_array_item *); 2419 union options_value *options_array_item_value(struct options_array_item *); 2420 int options_is_array(struct options_entry *); 2421 int options_is_string(struct options_entry *); 2422 char *options_to_string(struct options_entry *, int, int); 2423 char *options_parse(const char *, int *); 2424 struct options_entry *options_parse_get(struct options *, const char *, int *, 2425 int); 2426 char *options_match(const char *, int *, int *); 2427 struct options_entry *options_match_get(struct options *, const char *, int *, 2428 int, int *); 2429 const char *options_get_string(struct options *, const char *); 2430 long long options_get_number(struct options *, const char *); 2431 const struct cmd_list *options_get_command(struct options *, const char *); 2432 struct options_entry * printflike(4, 5) options_set_string(struct options *, 2433 const char *, int, const char *, ...); 2434 struct options_entry *options_set_number(struct options *, const char *, 2435 long long); 2436 struct options_entry *options_set_command(struct options *, const char *, 2437 struct cmd_list *); 2438 int options_scope_from_name(struct args *, int, 2439 const char *, struct cmd_find_state *, struct options **, 2440 char **); 2441 int options_scope_from_flags(struct args *, int, 2442 struct cmd_find_state *, struct options **, char **); 2443 struct style *options_string_to_style(struct options *, const char *, 2444 struct format_tree *); 2445 int options_from_string(struct options *, 2446 const struct options_table_entry *, const char *, 2447 const char *, int, char **); 2448 int options_find_choice(const struct options_table_entry *, 2449 const char *, char **); 2450 void options_push_changes(const char *); 2451 int options_remove_or_default(struct options_entry *, int, 2452 char **); 2453 2454 /* options-table.c */ 2455 extern const struct options_table_entry options_table[]; 2456 extern const struct options_name_map options_other_names[]; 2457 2458 /* job.c */ 2459 typedef void (*job_update_cb) (struct job *); 2460 typedef void (*job_complete_cb) (struct job *); 2461 typedef void (*job_free_cb) (void *); 2462 #define JOB_NOWAIT 0x1 2463 #define JOB_KEEPWRITE 0x2 2464 #define JOB_PTY 0x4 2465 #define JOB_DEFAULTSHELL 0x8 2466 #define JOB_SHOWSTDERR 0x10 2467 struct job *job_run(const char *, int, char **, struct environ *, 2468 struct session *, const char *, job_update_cb, 2469 job_complete_cb, job_free_cb, void *, int, int, int); 2470 void job_free(struct job *); 2471 int job_transfer(struct job *, pid_t *, char *, size_t); 2472 void job_resize(struct job *, u_int, u_int); 2473 void job_check_died(pid_t, int); 2474 int job_get_status(struct job *); 2475 void *job_get_data(struct job *); 2476 struct bufferevent *job_get_event(struct job *); 2477 void job_kill_all(void); 2478 int job_still_running(void); 2479 void job_print_summary(struct cmdq_item *, int); 2480 2481 /* environ.c */ 2482 struct environ *environ_create(void); 2483 void environ_free(struct environ *); 2484 struct environ_entry *environ_first(struct environ *); 2485 struct environ_entry *environ_next(struct environ_entry *); 2486 void environ_copy(struct environ *, struct environ *); 2487 struct environ_entry *environ_find(struct environ *, const char *); 2488 void printflike(4, 5) environ_set(struct environ *, const char *, int, 2489 const char *, ...); 2490 void environ_clear(struct environ *, const char *); 2491 void environ_put(struct environ *, const char *, int); 2492 void environ_unset(struct environ *, const char *); 2493 void environ_update(struct options *, struct environ *, struct environ *); 2494 void environ_push(struct environ *); 2495 void printflike(2, 3) environ_log(struct environ *, const char *, ...); 2496 struct environ *environ_for_session(struct session *, int); 2497 2498 /* tty.c */ 2499 void tty_create_log(void); 2500 int tty_window_bigger(struct tty *); 2501 int tty_window_offset(struct tty *, u_int *, u_int *, u_int *, u_int *); 2502 void tty_update_window_offset(struct window *); 2503 void tty_update_client_offset(struct client *); 2504 void tty_raw(struct tty *, const char *); 2505 void tty_attributes(struct tty *, const struct grid_cell *, 2506 const struct grid_cell *, struct colour_palette *, 2507 struct hyperlinks *); 2508 void tty_reset(struct tty *); 2509 void tty_region_off(struct tty *); 2510 void tty_margin_off(struct tty *); 2511 void tty_cursor(struct tty *, u_int, u_int); 2512 void tty_clipboard_query(struct tty *); 2513 void tty_putcode(struct tty *, enum tty_code_code); 2514 void tty_putcode_i(struct tty *, enum tty_code_code, int); 2515 void tty_putcode_ii(struct tty *, enum tty_code_code, int, int); 2516 void tty_putcode_iii(struct tty *, enum tty_code_code, int, int, int); 2517 void tty_putcode_s(struct tty *, enum tty_code_code, const char *); 2518 void tty_putcode_ss(struct tty *, enum tty_code_code, const char *, 2519 const char *); 2520 void tty_puts(struct tty *, const char *); 2521 void tty_putc(struct tty *, u_char); 2522 void tty_putn(struct tty *, const void *, size_t, u_int); 2523 void tty_cell(struct tty *, const struct grid_cell *, 2524 const struct grid_cell *, struct colour_palette *, 2525 struct hyperlinks *); 2526 int tty_init(struct tty *, struct client *); 2527 void tty_resize(struct tty *); 2528 void tty_set_size(struct tty *, u_int, u_int, u_int, u_int); 2529 void tty_invalidate(struct tty *); 2530 void tty_start_tty(struct tty *); 2531 void tty_send_requests(struct tty *); 2532 void tty_repeat_requests(struct tty *, int); 2533 void tty_stop_tty(struct tty *); 2534 void tty_set_title(struct tty *, const char *); 2535 void tty_set_path(struct tty *, const char *); 2536 void tty_update_mode(struct tty *, int, struct screen *); 2537 void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int, 2538 u_int, u_int, const struct grid_cell *, struct colour_palette *); 2539 2540 #ifdef ENABLE_SIXEL 2541 void tty_draw_images(struct client *, struct window_pane *, struct screen *); 2542 #endif 2543 2544 void tty_sync_start(struct tty *); 2545 void tty_sync_end(struct tty *); 2546 int tty_open(struct tty *, char **); 2547 void tty_close(struct tty *); 2548 void tty_free(struct tty *); 2549 void tty_update_features(struct tty *); 2550 void tty_set_selection(struct tty *, const char *, const char *, size_t); 2551 void tty_write(void (*)(struct tty *, const struct tty_ctx *), 2552 struct tty_ctx *); 2553 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *); 2554 void tty_cmd_cell(struct tty *, const struct tty_ctx *); 2555 void tty_cmd_cells(struct tty *, const struct tty_ctx *); 2556 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *); 2557 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *); 2558 void tty_cmd_clearline(struct tty *, const struct tty_ctx *); 2559 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *); 2560 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *); 2561 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *); 2562 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *); 2563 void tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *); 2564 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *); 2565 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *); 2566 void tty_cmd_insertline(struct tty *, const struct tty_ctx *); 2567 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *); 2568 void tty_cmd_scrollup(struct tty *, const struct tty_ctx *); 2569 void tty_cmd_scrolldown(struct tty *, const struct tty_ctx *); 2570 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *); 2571 void tty_cmd_setselection(struct tty *, const struct tty_ctx *); 2572 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *); 2573 2574 #ifdef ENABLE_SIXEL 2575 void tty_cmd_sixelimage(struct tty *, const struct tty_ctx *); 2576 #endif 2577 2578 void tty_cmd_syncstart(struct tty *, const struct tty_ctx *); 2579 void tty_default_colours(struct grid_cell *, struct window_pane *); 2580 2581 /* tty-term.c */ 2582 extern struct tty_terms tty_terms; 2583 u_int tty_term_ncodes(void); 2584 void tty_term_apply(struct tty_term *, const char *, int); 2585 void tty_term_apply_overrides(struct tty_term *); 2586 struct tty_term *tty_term_create(struct tty *, char *, char **, u_int, int *, 2587 char **); 2588 void tty_term_free(struct tty_term *); 2589 int tty_term_read_list(const char *, int, char ***, u_int *, 2590 char **); 2591 void tty_term_free_list(char **, u_int); 2592 int tty_term_has(struct tty_term *, enum tty_code_code); 2593 const char *tty_term_string(struct tty_term *, enum tty_code_code); 2594 const char *tty_term_string_i(struct tty_term *, enum tty_code_code, int); 2595 const char *tty_term_string_ii(struct tty_term *, enum tty_code_code, int, 2596 int); 2597 const char *tty_term_string_iii(struct tty_term *, enum tty_code_code, int, 2598 int, int); 2599 const char *tty_term_string_s(struct tty_term *, enum tty_code_code, 2600 const char *); 2601 const char *tty_term_string_ss(struct tty_term *, enum tty_code_code, 2602 const char *, const char *); 2603 int tty_term_number(struct tty_term *, enum tty_code_code); 2604 int tty_term_flag(struct tty_term *, enum tty_code_code); 2605 const char *tty_term_describe(struct tty_term *, enum tty_code_code); 2606 2607 /* tty-features.c */ 2608 void tty_add_features(int *, const char *, const char *); 2609 const char *tty_get_features(int); 2610 int tty_apply_features(struct tty_term *, int); 2611 void tty_default_features(int *, const char *, u_int); 2612 2613 /* tty-acs.c */ 2614 int tty_acs_needed(struct tty *); 2615 const char *tty_acs_get(struct tty *, u_char); 2616 int tty_acs_reverse_get(struct tty *, const char *, size_t); 2617 const struct utf8_data *tty_acs_double_borders(int); 2618 const struct utf8_data *tty_acs_heavy_borders(int); 2619 const struct utf8_data *tty_acs_rounded_borders(int); 2620 2621 /* tty-keys.c */ 2622 void tty_keys_build(struct tty *); 2623 void tty_keys_free(struct tty *); 2624 int tty_keys_next(struct tty *); 2625 int tty_keys_colours(struct tty *, const char *, size_t, size_t *, 2626 int *, int *); 2627 2628 /* arguments.c */ 2629 void args_set(struct args *, u_char, struct args_value *, int); 2630 struct args *args_create(void); 2631 struct args *args_parse(const struct args_parse *, struct args_value *, 2632 u_int, char **); 2633 struct args *args_copy(struct args *, int, char **); 2634 void args_to_vector(struct args *, int *, char ***); 2635 struct args_value *args_from_vector(int, char **); 2636 void args_free_value(struct args_value *); 2637 void args_free_values(struct args_value *, u_int); 2638 void args_free(struct args *); 2639 char *args_print(struct args *); 2640 char *args_escape(const char *); 2641 int args_has(struct args *, u_char); 2642 const char *args_get(struct args *, u_char); 2643 u_char args_first(struct args *, struct args_entry **); 2644 u_char args_next(struct args_entry **); 2645 u_int args_count(struct args *); 2646 struct args_value *args_values(struct args *); 2647 struct args_value *args_value(struct args *, u_int); 2648 const char *args_string(struct args *, u_int); 2649 struct cmd_list *args_make_commands_now(struct cmd *, struct cmdq_item *, 2650 u_int, int); 2651 struct args_command_state *args_make_commands_prepare(struct cmd *, 2652 struct cmdq_item *, u_int, const char *, int, int); 2653 struct cmd_list *args_make_commands(struct args_command_state *, int, char **, 2654 char **); 2655 void args_make_commands_free(struct args_command_state *); 2656 char *args_make_commands_get_command(struct args_command_state *); 2657 struct args_value *args_first_value(struct args *, u_char); 2658 struct args_value *args_next_value(struct args_value *); 2659 long long args_strtonum(struct args *, u_char, long long, long long, 2660 char **); 2661 long long args_strtonum_and_expand(struct args *, u_char, long long, 2662 long long, struct cmdq_item *, char **); 2663 long long args_percentage(struct args *, u_char, long long, 2664 long long, long long, char **); 2665 long long args_string_percentage(const char *, long long, long long, 2666 long long, char **); 2667 long long args_percentage_and_expand(struct args *, u_char, long long, 2668 long long, long long, struct cmdq_item *, char **); 2669 long long args_string_percentage_and_expand(const char *, long long, 2670 long long, long long, struct cmdq_item *, char **); 2671 2672 /* cmd-find.c */ 2673 int cmd_find_target(struct cmd_find_state *, struct cmdq_item *, 2674 const char *, enum cmd_find_type, int); 2675 struct client *cmd_find_best_client(struct session *); 2676 struct client *cmd_find_client(struct cmdq_item *, const char *, int); 2677 void cmd_find_clear_state(struct cmd_find_state *, int); 2678 int cmd_find_empty_state(struct cmd_find_state *); 2679 int cmd_find_valid_state(struct cmd_find_state *); 2680 void cmd_find_copy_state(struct cmd_find_state *, 2681 struct cmd_find_state *); 2682 void cmd_find_from_session(struct cmd_find_state *, 2683 struct session *, int); 2684 void cmd_find_from_winlink(struct cmd_find_state *, 2685 struct winlink *, int); 2686 int cmd_find_from_session_window(struct cmd_find_state *, 2687 struct session *, struct window *, int); 2688 int cmd_find_from_window(struct cmd_find_state *, struct window *, 2689 int); 2690 void cmd_find_from_winlink_pane(struct cmd_find_state *, 2691 struct winlink *, struct window_pane *, int); 2692 int cmd_find_from_pane(struct cmd_find_state *, 2693 struct window_pane *, int); 2694 int cmd_find_from_client(struct cmd_find_state *, struct client *, 2695 int); 2696 int cmd_find_from_mouse(struct cmd_find_state *, 2697 struct mouse_event *, int); 2698 int cmd_find_from_nothing(struct cmd_find_state *, int); 2699 2700 /* cmd.c */ 2701 extern const struct cmd_entry *cmd_table[]; 2702 const struct cmd_entry *cmd_find(const char *, char **); 2703 void printflike(3, 4) cmd_log_argv(int, char **, const char *, ...); 2704 void cmd_prepend_argv(int *, char ***, const char *); 2705 void cmd_append_argv(int *, char ***, const char *); 2706 int cmd_pack_argv(int, char **, char *, size_t); 2707 int cmd_unpack_argv(char *, size_t, int, char ***); 2708 char **cmd_copy_argv(int, char **); 2709 void cmd_free_argv(int, char **); 2710 char *cmd_stringify_argv(int, char **); 2711 char *cmd_get_alias(const char *); 2712 const struct cmd_entry *cmd_get_entry(struct cmd *); 2713 struct args *cmd_get_args(struct cmd *); 2714 u_int cmd_get_group(struct cmd *); 2715 void cmd_get_source(struct cmd *, const char **, u_int *); 2716 int cmd_get_parse_flags(struct cmd *); 2717 struct cmd *cmd_parse(struct args_value *, u_int, const char *, u_int, int, 2718 char **); 2719 struct cmd *cmd_copy(struct cmd *, int, char **); 2720 void cmd_free(struct cmd *); 2721 char *cmd_print(struct cmd *); 2722 struct cmd_list *cmd_list_new(void); 2723 struct cmd_list *cmd_list_copy(const struct cmd_list *, int, char **); 2724 void cmd_list_append(struct cmd_list *, struct cmd *); 2725 void cmd_list_append_all(struct cmd_list *, struct cmd_list *); 2726 void cmd_list_move(struct cmd_list *, struct cmd_list *); 2727 void cmd_list_free(struct cmd_list *); 2728 char *cmd_list_print(const struct cmd_list *, int); 2729 struct cmd *cmd_list_first(struct cmd_list *); 2730 struct cmd *cmd_list_next(struct cmd *); 2731 int cmd_list_all_have(struct cmd_list *, int); 2732 int cmd_list_any_have(struct cmd_list *, int); 2733 int cmd_mouse_at(struct window_pane *, struct mouse_event *, 2734 u_int *, u_int *, int); 2735 struct winlink *cmd_mouse_window(struct mouse_event *, struct session **); 2736 struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **, 2737 struct winlink **); 2738 char *cmd_template_replace(const char *, const char *, int); 2739 2740 /* cmd-attach-session.c */ 2741 enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int, 2742 int, const char *, int, const char *); 2743 2744 /* cmd-parse.c */ 2745 struct cmd_parse_result *cmd_parse_from_file(FILE *, struct cmd_parse_input *); 2746 struct cmd_parse_result *cmd_parse_from_string(const char *, 2747 struct cmd_parse_input *); 2748 enum cmd_parse_status cmd_parse_and_insert(const char *, 2749 struct cmd_parse_input *, struct cmdq_item *, 2750 struct cmdq_state *, char **); 2751 enum cmd_parse_status cmd_parse_and_append(const char *, 2752 struct cmd_parse_input *, struct client *, 2753 struct cmdq_state *, char **); 2754 struct cmd_parse_result *cmd_parse_from_buffer(const void *, size_t, 2755 struct cmd_parse_input *); 2756 struct cmd_parse_result *cmd_parse_from_arguments(struct args_value *, u_int, 2757 struct cmd_parse_input *); 2758 2759 /* cmd-queue.c */ 2760 struct cmdq_state *cmdq_new_state(struct cmd_find_state *, struct key_event *, 2761 int); 2762 struct cmdq_state *cmdq_link_state(struct cmdq_state *); 2763 struct cmdq_state *cmdq_copy_state(struct cmdq_state *, 2764 struct cmd_find_state *); 2765 void cmdq_free_state(struct cmdq_state *); 2766 void printflike(3, 4) cmdq_add_format(struct cmdq_state *, const char *, 2767 const char *, ...); 2768 void cmdq_add_formats(struct cmdq_state *, struct format_tree *); 2769 void cmdq_merge_formats(struct cmdq_item *, struct format_tree *); 2770 struct cmdq_list *cmdq_new(void); 2771 void cmdq_free(struct cmdq_list *); 2772 const char *cmdq_get_name(struct cmdq_item *); 2773 struct client *cmdq_get_client(struct cmdq_item *); 2774 struct client *cmdq_get_target_client(struct cmdq_item *); 2775 struct cmdq_state *cmdq_get_state(struct cmdq_item *); 2776 struct cmd_find_state *cmdq_get_target(struct cmdq_item *); 2777 struct cmd_find_state *cmdq_get_source(struct cmdq_item *); 2778 struct key_event *cmdq_get_event(struct cmdq_item *); 2779 struct cmd_find_state *cmdq_get_current(struct cmdq_item *); 2780 int cmdq_get_flags(struct cmdq_item *); 2781 struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmdq_state *); 2782 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) 2783 struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *); 2784 struct cmdq_item *cmdq_get_error(const char *); 2785 struct cmdq_item *cmdq_insert_after(struct cmdq_item *, struct cmdq_item *); 2786 struct cmdq_item *cmdq_append(struct client *, struct cmdq_item *); 2787 void printflike(4, 5) cmdq_insert_hook(struct session *, struct cmdq_item *, 2788 struct cmd_find_state *, const char *, ...); 2789 void cmdq_continue(struct cmdq_item *); 2790 u_int cmdq_next(struct client *); 2791 struct cmdq_item *cmdq_running(struct client *); 2792 void cmdq_guard(struct cmdq_item *, const char *, int); 2793 void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...); 2794 void cmdq_print_data(struct cmdq_item *, struct evbuffer *); 2795 void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...); 2796 2797 /* cmd-wait-for.c */ 2798 void cmd_wait_for_flush(void); 2799 2800 /* client.c */ 2801 int client_main(struct event_base *, int, char **, uint64_t, int); 2802 2803 /* key-bindings.c */ 2804 struct key_table *key_bindings_get_table(const char *, int); 2805 struct key_table *key_bindings_first_table(void); 2806 struct key_table *key_bindings_next_table(struct key_table *); 2807 void key_bindings_unref_table(struct key_table *); 2808 struct key_binding *key_bindings_get(struct key_table *, key_code); 2809 struct key_binding *key_bindings_get_default(struct key_table *, key_code); 2810 struct key_binding *key_bindings_first(struct key_table *); 2811 struct key_binding *key_bindings_next(struct key_table *, struct key_binding *); 2812 void key_bindings_add(const char *, key_code, const char *, int, 2813 struct cmd_list *); 2814 void key_bindings_remove(const char *, key_code); 2815 void key_bindings_reset(const char *, key_code); 2816 void key_bindings_remove_table(const char *); 2817 void key_bindings_reset_table(const char *); 2818 void key_bindings_init(void); 2819 struct cmdq_item *key_bindings_dispatch(struct key_binding *, 2820 struct cmdq_item *, struct client *, struct key_event *, 2821 struct cmd_find_state *); 2822 2823 /* key-string.c */ 2824 key_code key_string_lookup_string(const char *); 2825 const char *key_string_lookup_key(key_code, int); 2826 2827 /* alerts.c */ 2828 void alerts_reset_all(void); 2829 void alerts_queue(struct window *, int); 2830 void alerts_check_session(struct session *); 2831 2832 /* file.c */ 2833 int file_cmp(struct client_file *, struct client_file *); 2834 RB_PROTOTYPE(client_files, client_file, entry, file_cmp); 2835 struct client_file *file_create_with_peer(struct tmuxpeer *, 2836 struct client_files *, int, client_file_cb, void *); 2837 struct client_file *file_create_with_client(struct client *, int, 2838 client_file_cb, void *); 2839 void file_free(struct client_file *); 2840 void file_fire_done(struct client_file *); 2841 void file_fire_read(struct client_file *); 2842 int file_can_print(struct client *); 2843 void printflike(2, 3) file_print(struct client *, const char *, ...); 2844 void printflike(2, 0) file_vprint(struct client *, const char *, va_list); 2845 void file_print_buffer(struct client *, void *, size_t); 2846 void printflike(2, 3) file_error(struct client *, const char *, ...); 2847 void file_write(struct client *, const char *, int, const void *, size_t, 2848 client_file_cb, void *); 2849 struct client_file *file_read(struct client *, const char *, client_file_cb, 2850 void *); 2851 void file_cancel(struct client_file *); 2852 void file_push(struct client_file *); 2853 int file_write_left(struct client_files *); 2854 void file_write_open(struct client_files *, struct tmuxpeer *, 2855 struct imsg *, int, int, client_file_cb, void *); 2856 void file_write_data(struct client_files *, struct imsg *); 2857 void file_write_close(struct client_files *, struct imsg *); 2858 void file_read_open(struct client_files *, struct tmuxpeer *, struct imsg *, 2859 int, int, client_file_cb, void *); 2860 void file_write_ready(struct client_files *, struct imsg *); 2861 void file_read_data(struct client_files *, struct imsg *); 2862 void file_read_done(struct client_files *, struct imsg *); 2863 void file_read_cancel(struct client_files *, struct imsg *); 2864 2865 /* server.c */ 2866 extern struct tmuxproc *server_proc; 2867 extern struct clients clients; 2868 extern struct cmd_find_state marked_pane; 2869 extern struct message_list message_log; 2870 extern time_t current_time; 2871 void server_set_marked(struct session *, struct winlink *, 2872 struct window_pane *); 2873 void server_clear_marked(void); 2874 int server_is_marked(struct session *, struct winlink *, 2875 struct window_pane *); 2876 int server_check_marked(void); 2877 int server_start(struct tmuxproc *, uint64_t, struct event_base *, int, 2878 char *); 2879 void server_update_socket(void); 2880 void server_add_accept(int); 2881 void printflike(1, 2) server_add_message(const char *, ...); 2882 int server_create_socket(uint64_t, char **); 2883 2884 /* server-client.c */ 2885 RB_PROTOTYPE(client_windows, client_window, entry, server_client_window_cmp); 2886 u_int server_client_how_many(void); 2887 void server_client_set_overlay(struct client *, u_int, overlay_check_cb, 2888 overlay_mode_cb, overlay_draw_cb, overlay_key_cb, 2889 overlay_free_cb, overlay_resize_cb, void *); 2890 void server_client_clear_overlay(struct client *); 2891 void server_client_overlay_range(u_int, u_int, u_int, u_int, u_int, u_int, 2892 u_int, struct overlay_ranges *); 2893 void server_client_set_key_table(struct client *, const char *); 2894 const char *server_client_get_key_table(struct client *); 2895 int server_client_check_nested(struct client *); 2896 int server_client_handle_key(struct client *, struct key_event *); 2897 struct client *server_client_create(int); 2898 int server_client_open(struct client *, char **); 2899 void server_client_unref(struct client *); 2900 void server_client_set_session(struct client *, struct session *); 2901 void server_client_lost(struct client *); 2902 void server_client_suspend(struct client *); 2903 void server_client_detach(struct client *, enum msgtype); 2904 void server_client_exec(struct client *, const char *); 2905 void server_client_loop(void); 2906 const char *server_client_get_cwd(struct client *, struct session *); 2907 void server_client_set_flags(struct client *, const char *); 2908 const char *server_client_get_flags(struct client *); 2909 struct client_window *server_client_get_client_window(struct client *, u_int); 2910 struct client_window *server_client_add_client_window(struct client *, u_int); 2911 struct window_pane *server_client_get_pane(struct client *); 2912 void server_client_set_pane(struct client *, struct window_pane *); 2913 void server_client_remove_pane(struct window_pane *); 2914 void server_client_print(struct client *, int, struct evbuffer *); 2915 2916 /* server-fn.c */ 2917 void server_redraw_client(struct client *); 2918 void server_status_client(struct client *); 2919 void server_redraw_session(struct session *); 2920 void server_redraw_session_group(struct session *); 2921 void server_status_session(struct session *); 2922 void server_status_session_group(struct session *); 2923 void server_redraw_window(struct window *); 2924 void server_redraw_window_borders(struct window *); 2925 void server_status_window(struct window *); 2926 void server_lock(void); 2927 void server_lock_session(struct session *); 2928 void server_lock_client(struct client *); 2929 void server_kill_pane(struct window_pane *); 2930 void server_kill_window(struct window *, int); 2931 void server_renumber_session(struct session *); 2932 void server_renumber_all(void); 2933 int server_link_window(struct session *, 2934 struct winlink *, struct session *, int, int, int, char **); 2935 void server_unlink_window(struct session *, struct winlink *); 2936 void server_destroy_pane(struct window_pane *, int); 2937 void server_destroy_session(struct session *); 2938 void server_check_unattached(void); 2939 void server_unzoom_window(struct window *); 2940 2941 /* status.c */ 2942 extern char **status_prompt_hlist[]; 2943 extern u_int status_prompt_hsize[]; 2944 void status_timer_start(struct client *); 2945 void status_timer_start_all(void); 2946 void status_update_cache(struct session *); 2947 u_int status_prompt_line_at(struct client *); 2948 int status_at_line(struct client *); 2949 u_int status_line_size(struct client *); 2950 struct style_range *status_get_range(struct client *, u_int, u_int); 2951 void status_init(struct client *); 2952 void status_free(struct client *); 2953 int status_redraw(struct client *); 2954 void printflike(6, 7) status_message_set(struct client *, int, int, int, int, 2955 const char *, ...); 2956 void status_message_clear(struct client *); 2957 int status_message_redraw(struct client *); 2958 void status_prompt_set(struct client *, struct cmd_find_state *, 2959 const char *, const char *, prompt_input_cb, prompt_free_cb, 2960 void *, int, enum prompt_type); 2961 void status_prompt_clear(struct client *); 2962 int status_prompt_redraw(struct client *); 2963 int status_prompt_key(struct client *, key_code); 2964 void status_prompt_update(struct client *, const char *, const char *); 2965 void status_prompt_load_history(void); 2966 void status_prompt_save_history(void); 2967 const char *status_prompt_type_string(u_int); 2968 enum prompt_type status_prompt_type(const char *type); 2969 2970 /* resize.c */ 2971 void resize_window(struct window *, u_int, u_int, int, int); 2972 void default_window_size(struct client *, struct session *, struct window *, 2973 u_int *, u_int *, u_int *, u_int *, int); 2974 void recalculate_size(struct window *, int); 2975 void recalculate_sizes(void); 2976 void recalculate_sizes_now(int); 2977 2978 /* input.c */ 2979 #define INPUT_BUF_DEFAULT_SIZE 1048576 2980 struct input_ctx *input_init(struct window_pane *, struct bufferevent *, 2981 struct colour_palette *); 2982 void input_free(struct input_ctx *); 2983 void input_reset(struct input_ctx *, int); 2984 struct evbuffer *input_pending(struct input_ctx *); 2985 void input_parse_pane(struct window_pane *); 2986 void input_parse_buffer(struct window_pane *, u_char *, size_t); 2987 void input_parse_screen(struct input_ctx *, struct screen *, 2988 screen_write_init_ctx_cb, void *, u_char *, size_t); 2989 void input_reply_clipboard(struct bufferevent *, const char *, size_t, 2990 const char *); 2991 void input_set_buffer_size(size_t); 2992 void input_request_reply(struct client *, enum input_request_type, void *); 2993 void input_cancel_requests(struct client *); 2994 2995 /* input-key.c */ 2996 void input_key_build(void); 2997 int input_key_pane(struct window_pane *, key_code, struct mouse_event *); 2998 int input_key(struct screen *, struct bufferevent *, key_code); 2999 int input_key_get_mouse(struct screen *, struct mouse_event *, u_int, 3000 u_int, const char **, size_t *); 3001 3002 /* colour.c */ 3003 int colour_find_rgb(u_char, u_char, u_char); 3004 int colour_join_rgb(u_char, u_char, u_char); 3005 void colour_split_rgb(int, u_char *, u_char *, u_char *); 3006 int colour_force_rgb(int); 3007 const char *colour_tostring(int); 3008 enum client_theme colour_totheme(int); 3009 int colour_fromstring(const char *); 3010 int colour_256toRGB(int); 3011 int colour_256to16(int); 3012 int colour_byname(const char *); 3013 int colour_parseX11(const char *); 3014 void colour_palette_init(struct colour_palette *); 3015 void colour_palette_clear(struct colour_palette *); 3016 void colour_palette_free(struct colour_palette *); 3017 int colour_palette_get(struct colour_palette *, int); 3018 int colour_palette_set(struct colour_palette *, int, int); 3019 void colour_palette_from_option(struct colour_palette *, struct options *); 3020 3021 /* attributes.c */ 3022 const char *attributes_tostring(int); 3023 int attributes_fromstring(const char *); 3024 3025 /* grid.c */ 3026 extern const struct grid_cell grid_default_cell; 3027 void grid_empty_line(struct grid *, u_int, u_int); 3028 void grid_set_tab(struct grid_cell *, u_int); 3029 int grid_cells_equal(const struct grid_cell *, const struct grid_cell *); 3030 int grid_cells_look_equal(const struct grid_cell *, 3031 const struct grid_cell *); 3032 struct grid *grid_create(u_int, u_int, u_int); 3033 void grid_destroy(struct grid *); 3034 int grid_compare(struct grid *, struct grid *); 3035 void grid_collect_history(struct grid *); 3036 void grid_remove_history(struct grid *, u_int ); 3037 void grid_scroll_history(struct grid *, u_int); 3038 void grid_scroll_history_region(struct grid *, u_int, u_int, u_int); 3039 void grid_clear_history(struct grid *); 3040 const struct grid_line *grid_peek_line(struct grid *, u_int); 3041 void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); 3042 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *); 3043 void grid_set_padding(struct grid *, u_int, u_int); 3044 void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *, 3045 const char *, size_t); 3046 struct grid_line *grid_get_line(struct grid *, u_int); 3047 void grid_adjust_lines(struct grid *, u_int); 3048 void grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); 3049 void grid_clear_lines(struct grid *, u_int, u_int, u_int); 3050 void grid_move_lines(struct grid *, u_int, u_int, u_int, u_int); 3051 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int); 3052 char *grid_string_cells(struct grid *, u_int, u_int, u_int, 3053 struct grid_cell **, int, struct screen *); 3054 void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int, 3055 u_int); 3056 void grid_reflow(struct grid *, u_int); 3057 void grid_wrap_position(struct grid *, u_int, u_int, u_int *, u_int *); 3058 void grid_unwrap_position(struct grid *, u_int *, u_int *, u_int, u_int); 3059 u_int grid_line_length(struct grid *, u_int); 3060 int grid_in_set(struct grid *, u_int, u_int, const char *); 3061 3062 /* grid-reader.c */ 3063 void grid_reader_start(struct grid_reader *, struct grid *, u_int, u_int); 3064 void grid_reader_get_cursor(struct grid_reader *, u_int *, u_int *); 3065 u_int grid_reader_line_length(struct grid_reader *); 3066 int grid_reader_in_set(struct grid_reader *, const char *); 3067 void grid_reader_cursor_right(struct grid_reader *, int, int); 3068 void grid_reader_cursor_left(struct grid_reader *, int); 3069 void grid_reader_cursor_down(struct grid_reader *); 3070 void grid_reader_cursor_up(struct grid_reader *); 3071 void grid_reader_cursor_start_of_line(struct grid_reader *, int); 3072 void grid_reader_cursor_end_of_line(struct grid_reader *, int, int); 3073 void grid_reader_cursor_next_word(struct grid_reader *, const char *); 3074 void grid_reader_cursor_next_word_end(struct grid_reader *, const char *); 3075 void grid_reader_cursor_previous_word(struct grid_reader *, const char *, 3076 int, int); 3077 int grid_reader_cursor_jump(struct grid_reader *, 3078 const struct utf8_data *); 3079 int grid_reader_cursor_jump_back(struct grid_reader *, 3080 const struct utf8_data *); 3081 void grid_reader_cursor_back_to_indentation(struct grid_reader *); 3082 3083 /* grid-view.c */ 3084 void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *); 3085 void grid_view_set_cell(struct grid *, u_int, u_int, 3086 const struct grid_cell *); 3087 void grid_view_set_padding(struct grid *, u_int, u_int); 3088 void grid_view_set_cells(struct grid *, u_int, u_int, 3089 const struct grid_cell *, const char *, size_t); 3090 void grid_view_clear_history(struct grid *, u_int); 3091 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); 3092 void grid_view_scroll_region_up(struct grid *, u_int, u_int, u_int); 3093 void grid_view_scroll_region_down(struct grid *, u_int, u_int, u_int); 3094 void grid_view_insert_lines(struct grid *, u_int, u_int, u_int); 3095 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int, 3096 u_int); 3097 void grid_view_delete_lines(struct grid *, u_int, u_int, u_int); 3098 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int, 3099 u_int); 3100 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int); 3101 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int); 3102 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int); 3103 3104 /* screen-write.c */ 3105 void screen_write_make_list(struct screen *); 3106 void screen_write_free_list(struct screen *); 3107 void screen_write_start_pane(struct screen_write_ctx *, 3108 struct window_pane *, struct screen *); 3109 void screen_write_start(struct screen_write_ctx *, struct screen *); 3110 void screen_write_start_callback(struct screen_write_ctx *, struct screen *, 3111 screen_write_init_ctx_cb, void *); 3112 void screen_write_stop(struct screen_write_ctx *); 3113 void screen_write_reset(struct screen_write_ctx *); 3114 size_t printflike(1, 2) screen_write_strlen(const char *, ...); 3115 int printflike(7, 8) screen_write_text(struct screen_write_ctx *, u_int, u_int, 3116 u_int, int, const struct grid_cell *, const char *, ...); 3117 void printflike(3, 4) screen_write_puts(struct screen_write_ctx *, 3118 const struct grid_cell *, const char *, ...); 3119 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *, 3120 ssize_t, const struct grid_cell *, const char *, ...); 3121 void printflike(4, 0) screen_write_vnputs(struct screen_write_ctx *, ssize_t, 3122 const struct grid_cell *, const char *, va_list); 3123 void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *, 3124 u_char); 3125 void screen_write_fast_copy(struct screen_write_ctx *, struct screen *, 3126 u_int, u_int, u_int, u_int); 3127 void screen_write_hline(struct screen_write_ctx *, u_int, int, int, 3128 enum box_lines, const struct grid_cell *); 3129 void screen_write_vline(struct screen_write_ctx *, u_int, int, int); 3130 void screen_write_menu(struct screen_write_ctx *, struct menu *, int, 3131 enum box_lines, const struct grid_cell *, const struct grid_cell *, 3132 const struct grid_cell *); 3133 void screen_write_box(struct screen_write_ctx *, u_int, u_int, 3134 enum box_lines, const struct grid_cell *, const char *); 3135 void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int, 3136 u_int); 3137 void screen_write_backspace(struct screen_write_ctx *); 3138 void screen_write_mode_set(struct screen_write_ctx *, int); 3139 void screen_write_mode_clear(struct screen_write_ctx *, int); 3140 void screen_write_cursorup(struct screen_write_ctx *, u_int); 3141 void screen_write_cursordown(struct screen_write_ctx *, u_int); 3142 void screen_write_cursorright(struct screen_write_ctx *, u_int); 3143 void screen_write_cursorleft(struct screen_write_ctx *, u_int); 3144 void screen_write_alignmenttest(struct screen_write_ctx *); 3145 void screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int); 3146 void screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int); 3147 void screen_write_clearcharacter(struct screen_write_ctx *, u_int, u_int); 3148 void screen_write_insertline(struct screen_write_ctx *, u_int, u_int); 3149 void screen_write_deleteline(struct screen_write_ctx *, u_int, u_int); 3150 void screen_write_clearline(struct screen_write_ctx *, u_int); 3151 void screen_write_clearendofline(struct screen_write_ctx *, u_int); 3152 void screen_write_clearstartofline(struct screen_write_ctx *, u_int); 3153 void screen_write_cursormove(struct screen_write_ctx *, int, int, int); 3154 void screen_write_reverseindex(struct screen_write_ctx *, u_int); 3155 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); 3156 void screen_write_linefeed(struct screen_write_ctx *, int, u_int); 3157 void screen_write_scrollup(struct screen_write_ctx *, u_int, u_int); 3158 void screen_write_scrolldown(struct screen_write_ctx *, u_int, u_int); 3159 void screen_write_carriagereturn(struct screen_write_ctx *); 3160 void screen_write_clearendofscreen(struct screen_write_ctx *, u_int); 3161 void screen_write_clearstartofscreen(struct screen_write_ctx *, u_int); 3162 void screen_write_clearscreen(struct screen_write_ctx *, u_int); 3163 void screen_write_clearhistory(struct screen_write_ctx *); 3164 void screen_write_fullredraw(struct screen_write_ctx *); 3165 void screen_write_collect_end(struct screen_write_ctx *); 3166 void screen_write_collect_add(struct screen_write_ctx *, 3167 const struct grid_cell *); 3168 void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *); 3169 void screen_write_setselection(struct screen_write_ctx *, const char *, 3170 u_char *, u_int); 3171 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int, 3172 int); 3173 #ifdef ENABLE_SIXEL 3174 void screen_write_sixelimage(struct screen_write_ctx *, 3175 struct sixel_image *, u_int); 3176 #endif 3177 void screen_write_alternateon(struct screen_write_ctx *, 3178 struct grid_cell *, int); 3179 void screen_write_alternateoff(struct screen_write_ctx *, 3180 struct grid_cell *, int); 3181 3182 /* screen-redraw.c */ 3183 void screen_redraw_screen(struct client *); 3184 void screen_redraw_pane(struct client *, struct window_pane *, int); 3185 3186 /* screen.c */ 3187 void screen_init(struct screen *, u_int, u_int, u_int); 3188 void screen_reinit(struct screen *); 3189 void screen_free(struct screen *); 3190 void screen_reset_tabs(struct screen *); 3191 void screen_reset_hyperlinks(struct screen *); 3192 void screen_set_default_cursor(struct screen *, struct options *); 3193 void screen_set_cursor_style(u_int, enum screen_cursor_style *, int *); 3194 void screen_set_cursor_colour(struct screen *, int); 3195 int screen_set_title(struct screen *, const char *); 3196 void screen_set_path(struct screen *, const char *); 3197 void screen_push_title(struct screen *); 3198 void screen_pop_title(struct screen *); 3199 void screen_resize(struct screen *, u_int, u_int, int); 3200 void screen_resize_cursor(struct screen *, u_int, u_int, int, int, int); 3201 void screen_set_selection(struct screen *, u_int, u_int, u_int, u_int, 3202 u_int, int, struct grid_cell *); 3203 void screen_clear_selection(struct screen *); 3204 void screen_hide_selection(struct screen *); 3205 int screen_check_selection(struct screen *, u_int, u_int); 3206 void screen_select_cell(struct screen *, struct grid_cell *, 3207 const struct grid_cell *); 3208 void screen_alternate_on(struct screen *, struct grid_cell *, int); 3209 void screen_alternate_off(struct screen *, struct grid_cell *, int); 3210 const char *screen_mode_to_string(int); 3211 3212 /* window.c */ 3213 extern struct windows windows; 3214 extern struct window_pane_tree all_window_panes; 3215 int window_cmp(struct window *, struct window *); 3216 RB_PROTOTYPE(windows, window, entry, window_cmp); 3217 int winlink_cmp(struct winlink *, struct winlink *); 3218 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp); 3219 int window_pane_cmp(struct window_pane *, struct window_pane *); 3220 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp); 3221 struct winlink *winlink_find_by_index(struct winlinks *, int); 3222 struct winlink *winlink_find_by_window(struct winlinks *, struct window *); 3223 struct winlink *winlink_find_by_window_id(struct winlinks *, u_int); 3224 u_int winlink_count(struct winlinks *); 3225 struct winlink *winlink_add(struct winlinks *, int); 3226 void winlink_set_window(struct winlink *, struct window *); 3227 void winlink_remove(struct winlinks *, struct winlink *); 3228 struct winlink *winlink_next(struct winlink *); 3229 struct winlink *winlink_previous(struct winlink *); 3230 struct winlink *winlink_next_by_number(struct winlink *, struct session *, 3231 int); 3232 struct winlink *winlink_previous_by_number(struct winlink *, struct session *, 3233 int); 3234 void winlink_stack_push(struct winlink_stack *, struct winlink *); 3235 void winlink_stack_remove(struct winlink_stack *, struct winlink *); 3236 struct window *window_find_by_id_str(const char *); 3237 struct window *window_find_by_id(u_int); 3238 void window_update_activity(struct window *); 3239 struct window *window_create(u_int, u_int, u_int, u_int); 3240 void window_pane_set_event(struct window_pane *); 3241 struct window_pane *window_get_active_at(struct window *, u_int, u_int); 3242 struct window_pane *window_find_string(struct window *, const char *); 3243 int window_has_pane(struct window *, struct window_pane *); 3244 int window_set_active_pane(struct window *, struct window_pane *, 3245 int); 3246 void window_update_focus(struct window *); 3247 void window_pane_update_focus(struct window_pane *); 3248 void window_redraw_active_switch(struct window *, 3249 struct window_pane *); 3250 struct window_pane *window_add_pane(struct window *, struct window_pane *, 3251 u_int, int); 3252 void window_resize(struct window *, u_int, u_int, int, int); 3253 void window_pane_send_resize(struct window_pane *, u_int, u_int); 3254 int window_zoom(struct window_pane *); 3255 int window_unzoom(struct window *, int); 3256 int window_push_zoom(struct window *, int, int); 3257 int window_pop_zoom(struct window *); 3258 void window_lost_pane(struct window *, struct window_pane *); 3259 void window_remove_pane(struct window *, struct window_pane *); 3260 struct window_pane *window_pane_at_index(struct window *, u_int); 3261 struct window_pane *window_pane_next_by_number(struct window *, 3262 struct window_pane *, u_int); 3263 struct window_pane *window_pane_previous_by_number(struct window *, 3264 struct window_pane *, u_int); 3265 int window_pane_index(struct window_pane *, u_int *); 3266 u_int window_count_panes(struct window *); 3267 void window_destroy_panes(struct window *); 3268 struct window_pane *window_pane_find_by_id_str(const char *); 3269 struct window_pane *window_pane_find_by_id(u_int); 3270 int window_pane_destroy_ready(struct window_pane *); 3271 void window_pane_resize(struct window_pane *, u_int, u_int); 3272 int window_pane_set_mode(struct window_pane *, 3273 struct window_pane *, const struct window_mode *, 3274 struct cmd_find_state *, struct args *); 3275 void window_pane_reset_mode(struct window_pane *); 3276 void window_pane_reset_mode_all(struct window_pane *); 3277 int window_pane_key(struct window_pane *, struct client *, 3278 struct session *, struct winlink *, key_code, 3279 struct mouse_event *); 3280 void window_pane_paste(struct window_pane *, key_code, char *, 3281 size_t); 3282 int window_pane_visible(struct window_pane *); 3283 int window_pane_exited(struct window_pane *); 3284 u_int window_pane_search(struct window_pane *, const char *, int, 3285 int); 3286 const char *window_printable_flags(struct winlink *, int); 3287 struct window_pane *window_pane_find_up(struct window_pane *); 3288 struct window_pane *window_pane_find_down(struct window_pane *); 3289 struct window_pane *window_pane_find_left(struct window_pane *); 3290 struct window_pane *window_pane_find_right(struct window_pane *); 3291 void window_pane_stack_push(struct window_panes *, 3292 struct window_pane *); 3293 void window_pane_stack_remove(struct window_panes *, 3294 struct window_pane *); 3295 void window_set_name(struct window *, const char *); 3296 void window_add_ref(struct window *, const char *); 3297 void window_remove_ref(struct window *, const char *); 3298 void winlink_clear_flags(struct winlink *); 3299 int winlink_shuffle_up(struct session *, struct winlink *, int); 3300 int window_pane_start_input(struct window_pane *, 3301 struct cmdq_item *, char **); 3302 void *window_pane_get_new_data(struct window_pane *, 3303 struct window_pane_offset *, size_t *); 3304 void window_pane_update_used_data(struct window_pane *, 3305 struct window_pane_offset *, size_t); 3306 void window_set_fill_character(struct window *); 3307 void window_pane_default_cursor(struct window_pane *); 3308 int window_pane_mode(struct window_pane *); 3309 int window_pane_show_scrollbar(struct window_pane *, int); 3310 int window_pane_get_bg(struct window_pane *); 3311 int window_pane_get_fg(struct window_pane *); 3312 int window_pane_get_fg_control_client(struct window_pane *); 3313 int window_pane_get_bg_control_client(struct window_pane *); 3314 int window_get_bg_client(struct window_pane *); 3315 enum client_theme window_pane_get_theme(struct window_pane *); 3316 void window_pane_send_theme_update(struct window_pane *); 3317 3318 /* layout.c */ 3319 u_int layout_count_cells(struct layout_cell *); 3320 struct layout_cell *layout_create_cell(struct layout_cell *); 3321 void layout_free_cell(struct layout_cell *); 3322 void layout_print_cell(struct layout_cell *, const char *, u_int); 3323 void layout_destroy_cell(struct window *, struct layout_cell *, 3324 struct layout_cell **); 3325 void layout_resize_layout(struct window *, struct layout_cell *, 3326 enum layout_type, int, int); 3327 struct layout_cell *layout_search_by_border(struct layout_cell *, u_int, u_int); 3328 void layout_set_size(struct layout_cell *, u_int, u_int, u_int, 3329 u_int); 3330 void layout_make_leaf(struct layout_cell *, struct window_pane *); 3331 void layout_make_node(struct layout_cell *, enum layout_type); 3332 void layout_fix_offsets(struct window *); 3333 void layout_fix_panes(struct window *, struct window_pane *); 3334 void layout_resize_adjust(struct window *, struct layout_cell *, 3335 enum layout_type, int); 3336 void layout_init(struct window *, struct window_pane *); 3337 void layout_free(struct window *); 3338 void layout_resize(struct window *, u_int, u_int); 3339 void layout_resize_pane(struct window_pane *, enum layout_type, 3340 int, int); 3341 void layout_resize_pane_to(struct window_pane *, enum layout_type, 3342 u_int); 3343 void layout_assign_pane(struct layout_cell *, struct window_pane *, 3344 int); 3345 struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type, 3346 int, int); 3347 void layout_close_pane(struct window_pane *); 3348 int layout_spread_cell(struct window *, struct layout_cell *); 3349 void layout_spread_out(struct window_pane *); 3350 3351 /* layout-custom.c */ 3352 char *layout_dump(struct layout_cell *); 3353 int layout_parse(struct window *, const char *, char **); 3354 3355 /* layout-set.c */ 3356 int layout_set_lookup(const char *); 3357 u_int layout_set_select(struct window *, u_int); 3358 u_int layout_set_next(struct window *); 3359 u_int layout_set_previous(struct window *); 3360 3361 /* mode-tree.c */ 3362 typedef void (*mode_tree_build_cb)(void *, struct mode_tree_sort_criteria *, 3363 uint64_t *, const char *); 3364 typedef void (*mode_tree_draw_cb)(void *, void *, struct screen_write_ctx *, 3365 u_int, u_int); 3366 typedef int (*mode_tree_search_cb)(void *, void *, const char *, int); 3367 typedef void (*mode_tree_menu_cb)(void *, struct client *, key_code); 3368 typedef u_int (*mode_tree_height_cb)(void *, u_int); 3369 typedef key_code (*mode_tree_key_cb)(void *, void *, u_int); 3370 typedef int (*mode_tree_swap_cb)(void *, void *); 3371 typedef void (*mode_tree_each_cb)(void *, void *, struct client *, key_code); 3372 u_int mode_tree_count_tagged(struct mode_tree_data *); 3373 void *mode_tree_get_current(struct mode_tree_data *); 3374 const char *mode_tree_get_current_name(struct mode_tree_data *); 3375 void mode_tree_expand_current(struct mode_tree_data *); 3376 void mode_tree_collapse_current(struct mode_tree_data *); 3377 void mode_tree_expand(struct mode_tree_data *, uint64_t); 3378 int mode_tree_set_current(struct mode_tree_data *, uint64_t); 3379 void mode_tree_each_tagged(struct mode_tree_data *, mode_tree_each_cb, 3380 struct client *, key_code, int); 3381 void mode_tree_up(struct mode_tree_data *, int); 3382 int mode_tree_down(struct mode_tree_data *, int); 3383 struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *, 3384 mode_tree_build_cb, mode_tree_draw_cb, mode_tree_search_cb, 3385 mode_tree_menu_cb, mode_tree_height_cb, mode_tree_key_cb, 3386 mode_tree_swap_cb, void *, const struct menu_item *, const char **, 3387 u_int, struct screen **); 3388 void mode_tree_zoom(struct mode_tree_data *, struct args *); 3389 void mode_tree_build(struct mode_tree_data *); 3390 void mode_tree_free(struct mode_tree_data *); 3391 void mode_tree_resize(struct mode_tree_data *, u_int, u_int); 3392 struct mode_tree_item *mode_tree_add(struct mode_tree_data *, 3393 struct mode_tree_item *, void *, uint64_t, const char *, 3394 const char *, int); 3395 void mode_tree_draw_as_parent(struct mode_tree_item *); 3396 void mode_tree_no_tag(struct mode_tree_item *); 3397 void mode_tree_align(struct mode_tree_item *, int); 3398 void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *); 3399 void mode_tree_draw(struct mode_tree_data *); 3400 int mode_tree_key(struct mode_tree_data *, struct client *, key_code *, 3401 struct mouse_event *, u_int *, u_int *); 3402 void mode_tree_run_command(struct client *, struct cmd_find_state *, 3403 const char *, const char *); 3404 3405 /* window-buffer.c */ 3406 extern const struct window_mode window_buffer_mode; 3407 3408 /* window-tree.c */ 3409 extern const struct window_mode window_tree_mode; 3410 3411 /* window-clock.c */ 3412 extern const struct window_mode window_clock_mode; 3413 extern const char window_clock_table[14][5][5]; 3414 3415 /* window-client.c */ 3416 extern const struct window_mode window_client_mode; 3417 3418 /* window-copy.c */ 3419 extern const struct window_mode window_copy_mode; 3420 extern const struct window_mode window_view_mode; 3421 void printflike(3, 4) window_copy_add(struct window_pane *, int, const char *, 3422 ...); 3423 void printflike(3, 0) window_copy_vadd(struct window_pane *, int, const char *, 3424 va_list); 3425 void window_copy_scroll(struct window_pane *, int, u_int, int); 3426 void window_copy_pageup(struct window_pane *, int); 3427 void window_copy_pagedown(struct window_pane *, int, int); 3428 void window_copy_start_drag(struct client *, struct mouse_event *); 3429 char *window_copy_get_word(struct window_pane *, u_int, u_int); 3430 char *window_copy_get_line(struct window_pane *, u_int); 3431 int window_copy_get_current_offset(struct window_pane *, u_int *, 3432 u_int *); 3433 char *window_copy_get_hyperlink(struct window_pane *, u_int, u_int); 3434 3435 /* window-option.c */ 3436 extern const struct window_mode window_customize_mode; 3437 3438 /* names.c */ 3439 void check_window_name(struct window *); 3440 char *default_window_name(struct window *); 3441 char *parse_window_name(const char *); 3442 3443 /* control.c */ 3444 void control_discard(struct client *); 3445 void control_start(struct client *); 3446 void control_ready(struct client *); 3447 void control_stop(struct client *); 3448 void control_set_pane_on(struct client *, struct window_pane *); 3449 void control_set_pane_off(struct client *, struct window_pane *); 3450 void control_continue_pane(struct client *, struct window_pane *); 3451 void control_pause_pane(struct client *, struct window_pane *); 3452 struct window_pane_offset *control_pane_offset(struct client *, 3453 struct window_pane *, int *); 3454 void control_reset_offsets(struct client *); 3455 void printflike(2, 3) control_write(struct client *, const char *, ...); 3456 void control_write_output(struct client *, struct window_pane *); 3457 int control_all_done(struct client *); 3458 void control_add_sub(struct client *, const char *, enum control_sub_type, 3459 int, const char *); 3460 void control_remove_sub(struct client *, const char *); 3461 3462 /* control-notify.c */ 3463 void control_notify_pane_mode_changed(int); 3464 void control_notify_window_layout_changed(struct window *); 3465 void control_notify_window_pane_changed(struct window *); 3466 void control_notify_window_unlinked(struct session *, struct window *); 3467 void control_notify_window_linked(struct session *, struct window *); 3468 void control_notify_window_renamed(struct window *); 3469 void control_notify_client_session_changed(struct client *); 3470 void control_notify_client_detached(struct client *); 3471 void control_notify_session_renamed(struct session *); 3472 void control_notify_session_created(struct session *); 3473 void control_notify_session_closed(struct session *); 3474 void control_notify_session_window_changed(struct session *); 3475 void control_notify_paste_buffer_changed(const char *); 3476 void control_notify_paste_buffer_deleted(const char *); 3477 3478 /* session.c */ 3479 extern struct sessions sessions; 3480 extern struct session_groups session_groups; 3481 extern u_int next_session_id; 3482 int session_cmp(struct session *, struct session *); 3483 RB_PROTOTYPE(sessions, session, entry, session_cmp); 3484 int session_group_cmp(struct session_group *, struct session_group *s2); 3485 RB_PROTOTYPE(session_groups, session_group, entry, session_group_cmp); 3486 int session_alive(struct session *); 3487 struct session *session_find(const char *); 3488 struct session *session_find_by_id_str(const char *); 3489 struct session *session_find_by_id(u_int); 3490 struct session *session_create(const char *, const char *, const char *, 3491 struct environ *, struct options *, struct termios *); 3492 void session_destroy(struct session *, int, const char *); 3493 void session_add_ref(struct session *, const char *); 3494 void session_remove_ref(struct session *, const char *); 3495 char *session_check_name(const char *); 3496 void session_update_activity(struct session *, struct timeval *); 3497 struct session *session_next_session(struct session *); 3498 struct session *session_previous_session(struct session *); 3499 struct winlink *session_attach(struct session *, struct window *, int, 3500 char **); 3501 int session_detach(struct session *, struct winlink *); 3502 int session_has(struct session *, struct window *); 3503 int session_is_linked(struct session *, struct window *); 3504 int session_next(struct session *, int); 3505 int session_previous(struct session *, int); 3506 int session_select(struct session *, int); 3507 int session_last(struct session *); 3508 int session_set_current(struct session *, struct winlink *); 3509 struct session_group *session_group_contains(struct session *); 3510 struct session_group *session_group_find(const char *); 3511 struct session_group *session_group_new(const char *); 3512 void session_group_add(struct session_group *, struct session *); 3513 void session_group_synchronize_to(struct session *); 3514 void session_group_synchronize_from(struct session *); 3515 u_int session_group_count(struct session_group *); 3516 u_int session_group_attached_count(struct session_group *); 3517 void session_renumber_windows(struct session *); 3518 void session_theme_changed(struct session *); 3519 3520 /* utf8.c */ 3521 enum utf8_state utf8_towc (const struct utf8_data *, wchar_t *); 3522 enum utf8_state utf8_fromwc(wchar_t wc, struct utf8_data *); 3523 void utf8_update_width_cache(void); 3524 utf8_char utf8_build_one(u_char); 3525 enum utf8_state utf8_from_data(const struct utf8_data *, utf8_char *); 3526 void utf8_to_data(utf8_char, struct utf8_data *); 3527 void utf8_set(struct utf8_data *, u_char); 3528 void utf8_copy(struct utf8_data *, const struct utf8_data *); 3529 enum utf8_state utf8_open(struct utf8_data *, u_char); 3530 enum utf8_state utf8_append(struct utf8_data *, u_char); 3531 int utf8_isvalid(const char *); 3532 int utf8_strvis(char *, const char *, size_t, int); 3533 int utf8_stravis(char **, const char *, int); 3534 int utf8_stravisx(char **, const char *, size_t, int); 3535 char *utf8_sanitize(const char *); 3536 size_t utf8_strlen(const struct utf8_data *); 3537 u_int utf8_strwidth(const struct utf8_data *, ssize_t); 3538 struct utf8_data *utf8_fromcstr(const char *); 3539 char *utf8_tocstr(struct utf8_data *); 3540 u_int utf8_cstrwidth(const char *); 3541 char *utf8_padcstr(const char *, u_int); 3542 char *utf8_rpadcstr(const char *, u_int); 3543 int utf8_cstrhas(const char *, const struct utf8_data *); 3544 3545 /* osdep-*.c */ 3546 char *osdep_get_name(int, char *); 3547 char *osdep_get_cwd(int); 3548 struct event_base *osdep_event_init(void); 3549 3550 /* utf8-combined.c */ 3551 int utf8_has_zwj(const struct utf8_data *); 3552 int utf8_is_zwj(const struct utf8_data *); 3553 int utf8_is_vs(const struct utf8_data *); 3554 int utf8_is_hangul_filler(const struct utf8_data *); 3555 int utf8_should_combine(const struct utf8_data *, 3556 const struct utf8_data *); 3557 enum hanguljamo_state hanguljamo_check_state(const struct utf8_data *, 3558 const struct utf8_data *); 3559 3560 /* log.c */ 3561 void log_add_level(void); 3562 int log_get_level(void); 3563 void log_open(const char *); 3564 void log_toggle(const char *); 3565 void log_close(void); 3566 void printflike(1, 2) log_debug(const char *, ...); 3567 __dead void printflike(1, 2) fatal(const char *, ...); 3568 __dead void printflike(1, 2) fatalx(const char *, ...); 3569 3570 /* menu.c */ 3571 #define MENU_NOMOUSE 0x1 3572 #define MENU_TAB 0x2 3573 #define MENU_STAYOPEN 0x4 3574 struct menu *menu_create(const char *); 3575 void menu_add_items(struct menu *, const struct menu_item *, 3576 struct cmdq_item *, struct client *, 3577 struct cmd_find_state *); 3578 void menu_add_item(struct menu *, const struct menu_item *, 3579 struct cmdq_item *, struct client *, 3580 struct cmd_find_state *); 3581 void menu_free(struct menu *); 3582 struct menu_data *menu_prepare(struct menu *, int, int, struct cmdq_item *, 3583 u_int, u_int, struct client *, enum box_lines, const char *, 3584 const char *, const char *, struct cmd_find_state *, 3585 menu_choice_cb, void *); 3586 int menu_display(struct menu *, int, int, struct cmdq_item *, 3587 u_int, u_int, struct client *, enum box_lines, const char *, 3588 const char *, const char *, struct cmd_find_state *, 3589 menu_choice_cb, void *); 3590 struct screen *menu_mode_cb(struct client *, void *, u_int *, u_int *); 3591 void menu_check_cb(struct client *, void *, u_int, u_int, u_int, 3592 struct overlay_ranges *); 3593 void menu_draw_cb(struct client *, void *, 3594 struct screen_redraw_ctx *); 3595 void menu_free_cb(struct client *, void *); 3596 int menu_key_cb(struct client *, void *, struct key_event *); 3597 3598 /* popup.c */ 3599 #define POPUP_CLOSEEXIT 0x1 3600 #define POPUP_CLOSEEXITZERO 0x2 3601 #define POPUP_INTERNAL 0x4 3602 #define POPUP_CLOSEANYKEY 0x8 3603 typedef void (*popup_close_cb)(int, void *); 3604 typedef void (*popup_finish_edit_cb)(char *, size_t, void *); 3605 int popup_display(int, enum box_lines, struct cmdq_item *, u_int, 3606 u_int, u_int, u_int, struct environ *, const char *, int, 3607 char **, const char *, const char *, struct client *, 3608 struct session *, const char *, const char *, 3609 popup_close_cb, void *); 3610 int popup_editor(struct client *, const char *, size_t, 3611 popup_finish_edit_cb, void *); 3612 int popup_present(struct client *); 3613 int popup_modify(struct client *, const char *, const char *, 3614 const char *, enum box_lines, int); 3615 3616 /* style.c */ 3617 int style_parse(struct style *,const struct grid_cell *, 3618 const char *); 3619 const char *style_tostring(struct style *); 3620 void style_add(struct grid_cell *, struct options *, 3621 const char *, struct format_tree *); 3622 void style_apply(struct grid_cell *, struct options *, 3623 const char *, struct format_tree *); 3624 void style_set(struct style *, const struct grid_cell *); 3625 void style_copy(struct style *, struct style *); 3626 void style_set_scrollbar_style_from_option(struct style *, 3627 struct options *); 3628 3629 /* spawn.c */ 3630 struct winlink *spawn_window(struct spawn_context *, char **); 3631 struct window_pane *spawn_pane(struct spawn_context *, char **); 3632 3633 /* regsub.c */ 3634 char *regsub(const char *, const char *, const char *, int); 3635 3636 #ifdef ENABLE_SIXEL 3637 /* image.c */ 3638 int image_free_all(struct screen *); 3639 struct image *image_store(struct screen *, struct sixel_image *); 3640 int image_check_line(struct screen *, u_int, u_int); 3641 int image_check_area(struct screen *, u_int, u_int, u_int, u_int); 3642 int image_scroll_up(struct screen *, u_int); 3643 3644 /* image-sixel.c */ 3645 #define SIXEL_COLOUR_REGISTERS 1024 3646 struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int, u_int); 3647 void sixel_free(struct sixel_image *); 3648 void sixel_log(struct sixel_image *); 3649 void sixel_size_in_cells(struct sixel_image *, u_int *, u_int *); 3650 struct sixel_image *sixel_scale(struct sixel_image *, u_int, u_int, u_int, 3651 u_int, u_int, u_int, int); 3652 char *sixel_print(struct sixel_image *, struct sixel_image *, 3653 size_t *); 3654 struct screen *sixel_to_screen(struct sixel_image *); 3655 #endif 3656 3657 /* server-acl.c */ 3658 void server_acl_init(void); 3659 struct server_acl_user *server_acl_user_find(uid_t); 3660 void server_acl_display(struct cmdq_item *); 3661 void server_acl_user_allow(uid_t); 3662 void server_acl_user_deny(uid_t); 3663 void server_acl_user_allow_write(uid_t); 3664 void server_acl_user_deny_write(uid_t); 3665 int server_acl_join(struct client *); 3666 uid_t server_acl_get_uid(struct server_acl_user *); 3667 3668 /* hyperlink.c */ 3669 u_int hyperlinks_put(struct hyperlinks *, const char *, 3670 const char *); 3671 int hyperlinks_get(struct hyperlinks *, u_int, 3672 const char **, const char **, const char **); 3673 struct hyperlinks *hyperlinks_init(void); 3674 struct hyperlinks *hyperlinks_copy(struct hyperlinks *); 3675 void hyperlinks_reset(struct hyperlinks *); 3676 void hyperlinks_free(struct hyperlinks *); 3677 3678 #endif /* TMUX_H */ 3679