1 /* $OpenBSD: tmux.h,v 1.701 2017/01/18 10:08:05 nicm Exp $ */ 2 3 /* 4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER 15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef TMUX_H 20 #define TMUX_H 21 22 #define PROTOCOL_VERSION 8 23 24 #include <sys/time.h> 25 #include <sys/queue.h> 26 #include <sys/tree.h> 27 28 #include <bitstring.h> 29 #include <event.h> 30 #include <limits.h> 31 #include <stdarg.h> 32 #include <stdint.h> 33 #include <stdio.h> 34 #include <termios.h> 35 #include <wchar.h> 36 37 #include "xmalloc.h" 38 39 extern char **environ; 40 41 struct args; 42 struct client; 43 struct cmdq_item; 44 struct cmdq_list; 45 struct environ; 46 struct input_ctx; 47 struct mode_key_cmdstr; 48 struct mouse_event; 49 struct options; 50 struct options_entry; 51 struct session; 52 struct tmuxpeer; 53 struct tmuxproc; 54 55 /* Default global configuration file. */ 56 #define TMUX_CONF "/etc/tmux.conf" 57 58 /* 59 * Minimum layout cell size, NOT including separator line. The scroll region 60 * cannot be one line in height so this must be at least two. 61 */ 62 #define PANE_MINIMUM 2 63 64 /* Automatic name refresh interval, in microseconds. Must be < 1 second. */ 65 #define NAME_INTERVAL 500000 66 67 /* 68 * Event watermarks. We start with FAST then if we hit full size for HITS reads 69 * in succession switch to SLOW, and return when we hit EMPTY the same number 70 * of times. 71 */ 72 #define READ_FAST_SIZE 4096 73 #define READ_SLOW_SIZE 128 74 75 #define READ_FULL_SIZE (4096 - 16) 76 #define READ_EMPTY_SIZE 16 77 78 #define READ_CHANGE_HITS 3 79 80 /* Attribute to make GCC check printf-like arguments. */ 81 #define printflike(a, b) __attribute__ ((format (printf, a, b))) 82 83 /* Number of items in array. */ 84 #ifndef nitems 85 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 86 #endif 87 88 /* Bell option values. */ 89 #define BELL_NONE 0 90 #define BELL_ANY 1 91 #define BELL_CURRENT 2 92 #define BELL_OTHER 3 93 94 /* Special key codes. */ 95 #define KEYC_NONE 0xffff00000000ULL 96 #define KEYC_UNKNOWN 0xfffe00000000ULL 97 #define KEYC_BASE 0x000010000000ULL 98 99 /* Key modifier bits. */ 100 #define KEYC_ESCAPE 0x200000000000ULL 101 #define KEYC_CTRL 0x400000000000ULL 102 #define KEYC_SHIFT 0x800000000000ULL 103 104 /* Mask to obtain key w/o modifiers. */ 105 #define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT) 106 #define KEYC_MASK_KEY (~KEYC_MASK_MOD) 107 108 /* Is this a mouse key? */ 109 #define KEYC_IS_MOUSE(key) (((key) & KEYC_MASK_KEY) >= KEYC_MOUSE && \ 110 ((key) & KEYC_MASK_KEY) < KEYC_BSPACE) 111 112 /* Multiple click timeout. */ 113 #define KEYC_CLICK_TIMEOUT 300 114 115 /* Mouse key codes. */ 116 #define KEYC_MOUSE_KEY(name) \ 117 KEYC_ ## name ## _PANE, \ 118 KEYC_ ## name ## _STATUS, \ 119 KEYC_ ## name ## _BORDER 120 #define KEYC_MOUSE_STRING(name, s) \ 121 { #s "Pane", KEYC_ ## name ## _PANE }, \ 122 { #s "Status", KEYC_ ## name ## _STATUS }, \ 123 { #s "Border", KEYC_ ## name ## _BORDER } 124 125 /* 126 * A single key. This can be ASCII or Unicode or one of the keys starting at 127 * KEYC_BASE. 128 */ 129 typedef unsigned long long key_code; 130 131 /* Special key codes. */ 132 enum { 133 /* Focus events. */ 134 KEYC_FOCUS_IN = KEYC_BASE, 135 KEYC_FOCUS_OUT, 136 137 /* Mouse keys. */ 138 KEYC_MOUSE, /* unclassified mouse event */ 139 KEYC_DRAGGING, /* dragging in progress */ 140 KEYC_MOUSE_KEY(MOUSEDOWN1), 141 KEYC_MOUSE_KEY(MOUSEDOWN2), 142 KEYC_MOUSE_KEY(MOUSEDOWN3), 143 KEYC_MOUSE_KEY(MOUSEUP1), 144 KEYC_MOUSE_KEY(MOUSEUP2), 145 KEYC_MOUSE_KEY(MOUSEUP3), 146 KEYC_MOUSE_KEY(MOUSEDRAG1), 147 KEYC_MOUSE_KEY(MOUSEDRAG2), 148 KEYC_MOUSE_KEY(MOUSEDRAG3), 149 KEYC_MOUSE_KEY(MOUSEDRAGEND1), 150 KEYC_MOUSE_KEY(MOUSEDRAGEND2), 151 KEYC_MOUSE_KEY(MOUSEDRAGEND3), 152 KEYC_MOUSE_KEY(WHEELUP), 153 KEYC_MOUSE_KEY(WHEELDOWN), 154 KEYC_MOUSE_KEY(DOUBLECLICK1), 155 KEYC_MOUSE_KEY(DOUBLECLICK2), 156 KEYC_MOUSE_KEY(DOUBLECLICK3), 157 KEYC_MOUSE_KEY(TRIPLECLICK1), 158 KEYC_MOUSE_KEY(TRIPLECLICK2), 159 KEYC_MOUSE_KEY(TRIPLECLICK3), 160 161 /* Backspace key. */ 162 KEYC_BSPACE, 163 164 /* Function keys. */ 165 KEYC_F1, 166 KEYC_F2, 167 KEYC_F3, 168 KEYC_F4, 169 KEYC_F5, 170 KEYC_F6, 171 KEYC_F7, 172 KEYC_F8, 173 KEYC_F9, 174 KEYC_F10, 175 KEYC_F11, 176 KEYC_F12, 177 KEYC_IC, 178 KEYC_DC, 179 KEYC_HOME, 180 KEYC_END, 181 KEYC_NPAGE, 182 KEYC_PPAGE, 183 KEYC_BTAB, 184 185 /* Arrow keys. */ 186 KEYC_UP, 187 KEYC_DOWN, 188 KEYC_LEFT, 189 KEYC_RIGHT, 190 191 /* Numeric keypad. */ 192 KEYC_KP_SLASH, 193 KEYC_KP_STAR, 194 KEYC_KP_MINUS, 195 KEYC_KP_SEVEN, 196 KEYC_KP_EIGHT, 197 KEYC_KP_NINE, 198 KEYC_KP_PLUS, 199 KEYC_KP_FOUR, 200 KEYC_KP_FIVE, 201 KEYC_KP_SIX, 202 KEYC_KP_ONE, 203 KEYC_KP_TWO, 204 KEYC_KP_THREE, 205 KEYC_KP_ENTER, 206 KEYC_KP_ZERO, 207 KEYC_KP_PERIOD, 208 }; 209 210 /* Termcap codes. */ 211 enum tty_code_code { 212 TTYC_AX = 0, 213 TTYC_ACSC, /* acs_chars, ac */ 214 TTYC_BCE, /* back_color_erase, ut */ 215 TTYC_BEL, /* bell, bl */ 216 TTYC_BLINK, /* enter_blink_mode, mb */ 217 TTYC_BOLD, /* enter_bold_mode, md */ 218 TTYC_CIVIS, /* cursor_invisible, vi */ 219 TTYC_CLEAR, /* clear_screen, cl */ 220 TTYC_CNORM, /* cursor_normal, ve */ 221 TTYC_COLORS, /* max_colors, Co */ 222 TTYC_CR, /* restore cursor colour, Cr */ 223 TTYC_CS, /* set cursor colour, Cs */ 224 TTYC_CSR, /* change_scroll_region, cs */ 225 TTYC_CUB, /* parm_left_cursor, LE */ 226 TTYC_CUB1, /* cursor_left, le */ 227 TTYC_CUD, /* parm_down_cursor, DO */ 228 TTYC_CUD1, /* cursor_down, do */ 229 TTYC_CUF, /* parm_right_cursor, RI */ 230 TTYC_CUF1, /* cursor_right, nd */ 231 TTYC_CUP, /* cursor_address, cm */ 232 TTYC_CUU, /* parm_up_cursor, UP */ 233 TTYC_CUU1, /* cursor_up, up */ 234 TTYC_CVVIS, /* cursor_visible, vs */ 235 TTYC_DCH, /* parm_dch, DC */ 236 TTYC_DCH1, /* delete_character, dc */ 237 TTYC_DIM, /* enter_dim_mode, mh */ 238 TTYC_DL, /* parm_delete_line, DL */ 239 TTYC_DL1, /* delete_line, dl */ 240 TTYC_E3, 241 TTYC_ECH, /* erase_chars, ec */ 242 TTYC_EL, /* clr_eol, ce */ 243 TTYC_EL1, /* clr_bol, cb */ 244 TTYC_ENACS, /* ena_acs, eA */ 245 TTYC_FSL, /* from_status_line, fsl */ 246 TTYC_HOME, /* cursor_home, ho */ 247 TTYC_HPA, /* column_address, ch */ 248 TTYC_ICH, /* parm_ich, IC */ 249 TTYC_ICH1, /* insert_character, ic */ 250 TTYC_IL, /* parm_insert_line, IL */ 251 TTYC_IL1, /* insert_line, il */ 252 TTYC_INVIS, /* enter_secure_mode, mk */ 253 TTYC_IS1, /* init_1string, i1 */ 254 TTYC_IS2, /* init_2string, i2 */ 255 TTYC_IS3, /* init_3string, i3 */ 256 TTYC_KCBT, /* key_btab, kB */ 257 TTYC_KCUB1, /* key_left, kl */ 258 TTYC_KCUD1, /* key_down, kd */ 259 TTYC_KCUF1, /* key_right, kr */ 260 TTYC_KCUU1, /* key_up, ku */ 261 TTYC_KDC2, 262 TTYC_KDC3, 263 TTYC_KDC4, 264 TTYC_KDC5, 265 TTYC_KDC6, 266 TTYC_KDC7, 267 TTYC_KDCH1, /* key_dc, kD */ 268 TTYC_KDN2, 269 TTYC_KDN3, 270 TTYC_KDN4, 271 TTYC_KDN5, 272 TTYC_KDN6, 273 TTYC_KDN7, 274 TTYC_KEND, /* key_end, ke */ 275 TTYC_KEND2, 276 TTYC_KEND3, 277 TTYC_KEND4, 278 TTYC_KEND5, 279 TTYC_KEND6, 280 TTYC_KEND7, 281 TTYC_KF1, 282 TTYC_KF10, 283 TTYC_KF11, 284 TTYC_KF12, 285 TTYC_KF13, 286 TTYC_KF14, 287 TTYC_KF15, 288 TTYC_KF16, 289 TTYC_KF17, 290 TTYC_KF18, 291 TTYC_KF19, 292 TTYC_KF2, 293 TTYC_KF20, 294 TTYC_KF21, 295 TTYC_KF22, 296 TTYC_KF23, 297 TTYC_KF24, 298 TTYC_KF25, 299 TTYC_KF26, 300 TTYC_KF27, 301 TTYC_KF28, 302 TTYC_KF29, 303 TTYC_KF3, 304 TTYC_KF30, 305 TTYC_KF31, 306 TTYC_KF32, 307 TTYC_KF33, 308 TTYC_KF34, 309 TTYC_KF35, 310 TTYC_KF36, 311 TTYC_KF37, 312 TTYC_KF38, 313 TTYC_KF39, 314 TTYC_KF4, 315 TTYC_KF40, 316 TTYC_KF41, 317 TTYC_KF42, 318 TTYC_KF43, 319 TTYC_KF44, 320 TTYC_KF45, 321 TTYC_KF46, 322 TTYC_KF47, 323 TTYC_KF48, 324 TTYC_KF49, 325 TTYC_KF5, 326 TTYC_KF50, 327 TTYC_KF51, 328 TTYC_KF52, 329 TTYC_KF53, 330 TTYC_KF54, 331 TTYC_KF55, 332 TTYC_KF56, 333 TTYC_KF57, 334 TTYC_KF58, 335 TTYC_KF59, 336 TTYC_KF6, 337 TTYC_KF60, 338 TTYC_KF61, 339 TTYC_KF62, 340 TTYC_KF63, 341 TTYC_KF7, 342 TTYC_KF8, 343 TTYC_KF9, 344 TTYC_KHOM2, 345 TTYC_KHOM3, 346 TTYC_KHOM4, 347 TTYC_KHOM5, 348 TTYC_KHOM6, 349 TTYC_KHOM7, 350 TTYC_KHOME, /* key_home, kh */ 351 TTYC_KIC2, 352 TTYC_KIC3, 353 TTYC_KIC4, 354 TTYC_KIC5, 355 TTYC_KIC6, 356 TTYC_KIC7, 357 TTYC_KICH1, /* key_ic, kI */ 358 TTYC_KLFT2, 359 TTYC_KLFT3, 360 TTYC_KLFT4, 361 TTYC_KLFT5, 362 TTYC_KLFT6, 363 TTYC_KLFT7, 364 TTYC_KMOUS, /* key_mouse, Km */ 365 TTYC_KNP, /* key_npage, kN */ 366 TTYC_KNXT2, 367 TTYC_KNXT3, 368 TTYC_KNXT4, 369 TTYC_KNXT5, 370 TTYC_KNXT6, 371 TTYC_KNXT7, 372 TTYC_KPP, /* key_ppage, kP */ 373 TTYC_KPRV2, 374 TTYC_KPRV3, 375 TTYC_KPRV4, 376 TTYC_KPRV5, 377 TTYC_KPRV6, 378 TTYC_KPRV7, 379 TTYC_KRIT2, 380 TTYC_KRIT3, 381 TTYC_KRIT4, 382 TTYC_KRIT5, 383 TTYC_KRIT6, 384 TTYC_KRIT7, 385 TTYC_KUP2, 386 TTYC_KUP3, 387 TTYC_KUP4, 388 TTYC_KUP5, 389 TTYC_KUP6, 390 TTYC_KUP7, 391 TTYC_MS, /* modify xterm(1) selection */ 392 TTYC_OP, /* orig_pair, op */ 393 TTYC_REV, /* enter_reverse_mode, mr */ 394 TTYC_RI, /* scroll_reverse, sr */ 395 TTYC_RMACS, /* exit_alt_charset_mode */ 396 TTYC_RMCUP, /* exit_ca_mode, te */ 397 TTYC_RMKX, /* keypad_local, ke */ 398 TTYC_SE, /* reset cursor style, Se */ 399 TTYC_SETAB, /* set_a_background, AB */ 400 TTYC_SETAF, /* set_a_foreground, AF */ 401 TTYC_SGR0, /* exit_attribute_mode, me */ 402 TTYC_SITM, /* enter_italics_mode, it */ 403 TTYC_SMACS, /* enter_alt_charset_mode, as */ 404 TTYC_SMCUP, /* enter_ca_mode, ti */ 405 TTYC_SMKX, /* keypad_xmit, ks */ 406 TTYC_SMSO, /* enter_standout_mode, so */ 407 TTYC_SMUL, /* enter_underline_mode, us */ 408 TTYC_SS, /* set cursor style, Ss */ 409 TTYC_TC, /* 24-bit "true" colour, Tc */ 410 TTYC_TSL, /* to_status_line, tsl */ 411 TTYC_VPA, /* row_address, cv */ 412 TTYC_XENL, /* eat_newline_glitch, xn */ 413 TTYC_XT, /* xterm(1)-compatible title, XT */ 414 }; 415 416 /* Message codes. */ 417 enum msgtype { 418 MSG_VERSION = 12, 419 420 MSG_IDENTIFY_FLAGS = 100, 421 MSG_IDENTIFY_TERM, 422 MSG_IDENTIFY_TTYNAME, 423 MSG_IDENTIFY_OLDCWD, /* unused */ 424 MSG_IDENTIFY_STDIN, 425 MSG_IDENTIFY_ENVIRON, 426 MSG_IDENTIFY_DONE, 427 MSG_IDENTIFY_CLIENTPID, 428 MSG_IDENTIFY_CWD, 429 430 MSG_COMMAND = 200, 431 MSG_DETACH, 432 MSG_DETACHKILL, 433 MSG_EXIT, 434 MSG_EXITED, 435 MSG_EXITING, 436 MSG_LOCK, 437 MSG_READY, 438 MSG_RESIZE, 439 MSG_SHELL, 440 MSG_SHUTDOWN, 441 MSG_STDERR, 442 MSG_STDIN, 443 MSG_STDOUT, 444 MSG_SUSPEND, 445 MSG_UNLOCK, 446 MSG_WAKEUP, 447 MSG_EXEC, 448 }; 449 450 /* 451 * Message data. 452 * 453 * Don't forget to bump PROTOCOL_VERSION if any of these change! 454 */ 455 struct msg_command_data { 456 int argc; 457 }; /* followed by packed argv */ 458 459 struct msg_stdin_data { 460 ssize_t size; 461 char data[BUFSIZ]; 462 }; 463 464 struct msg_stdout_data { 465 ssize_t size; 466 char data[BUFSIZ]; 467 }; 468 469 struct msg_stderr_data { 470 ssize_t size; 471 char data[BUFSIZ]; 472 }; 473 474 /* Mode key commands. */ 475 enum mode_key_cmd { 476 MODEKEY_NONE, 477 MODEKEY_OTHER, 478 479 /* Menu (choice) keys. */ 480 MODEKEYCHOICE_BACKSPACE, 481 MODEKEYCHOICE_BOTTOMLINE, 482 MODEKEYCHOICE_CANCEL, 483 MODEKEYCHOICE_CHOOSE, 484 MODEKEYCHOICE_DOWN, 485 MODEKEYCHOICE_ENDOFLIST, 486 MODEKEYCHOICE_PAGEDOWN, 487 MODEKEYCHOICE_PAGEUP, 488 MODEKEYCHOICE_SCROLLDOWN, 489 MODEKEYCHOICE_SCROLLUP, 490 MODEKEYCHOICE_STARTNUMBERPREFIX, 491 MODEKEYCHOICE_STARTOFLIST, 492 MODEKEYCHOICE_TOPLINE, 493 MODEKEYCHOICE_TREE_COLLAPSE, 494 MODEKEYCHOICE_TREE_COLLAPSE_ALL, 495 MODEKEYCHOICE_TREE_EXPAND, 496 MODEKEYCHOICE_TREE_EXPAND_ALL, 497 MODEKEYCHOICE_TREE_TOGGLE, 498 MODEKEYCHOICE_UP, 499 }; 500 501 /* Data required while mode keys are in use. */ 502 struct mode_key_data { 503 struct mode_key_tree *tree; 504 }; 505 #define MODEKEY_EMACS 0 506 #define MODEKEY_VI 1 507 508 /* Binding between a key and a command. */ 509 struct mode_key_binding { 510 key_code key; 511 enum mode_key_cmd cmd; 512 513 RB_ENTRY(mode_key_binding) entry; 514 }; 515 RB_HEAD(mode_key_tree, mode_key_binding); 516 517 /* Named mode key table description. */ 518 struct mode_key_entry; 519 struct mode_key_table { 520 const char *name; 521 const struct mode_key_cmdstr *cmdstr; 522 struct mode_key_tree *tree; 523 const struct mode_key_entry *table; /* default entries */ 524 }; 525 526 /* Modes. */ 527 #define MODE_CURSOR 0x1 528 #define MODE_INSERT 0x2 529 #define MODE_KCURSOR 0x4 530 #define MODE_KKEYPAD 0x8 /* set = application, clear = number */ 531 #define MODE_WRAP 0x10 /* whether lines wrap */ 532 #define MODE_MOUSE_STANDARD 0x20 533 #define MODE_MOUSE_BUTTON 0x40 534 #define MODE_BLINKING 0x80 535 #define MODE_MOUSE_UTF8 0x100 536 #define MODE_MOUSE_SGR 0x200 537 #define MODE_BRACKETPASTE 0x400 538 #define MODE_FOCUSON 0x800 539 540 #define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON) 541 542 /* 543 * A single UTF-8 character. UTF8_SIZE must be big enough to hold at least one 544 * combining character as well. 545 */ 546 #define UTF8_SIZE 9 547 struct utf8_data { 548 u_char data[UTF8_SIZE]; 549 550 u_char have; 551 u_char size; 552 553 u_char width; /* 0xff if invalid */ 554 } __packed; 555 enum utf8_state { 556 UTF8_MORE, 557 UTF8_DONE, 558 UTF8_ERROR 559 }; 560 561 /* Colour flags. */ 562 #define COLOUR_FLAG_256 0x01000000 563 #define COLOUR_FLAG_RGB 0x02000000 564 565 /* Grid attributes. */ 566 #define GRID_ATTR_BRIGHT 0x1 567 #define GRID_ATTR_DIM 0x2 568 #define GRID_ATTR_UNDERSCORE 0x4 569 #define GRID_ATTR_BLINK 0x8 570 #define GRID_ATTR_REVERSE 0x10 571 #define GRID_ATTR_HIDDEN 0x20 572 #define GRID_ATTR_ITALICS 0x40 573 #define GRID_ATTR_CHARSET 0x80 /* alternative character set */ 574 575 /* Grid flags. */ 576 #define GRID_FLAG_FG256 0x1 577 #define GRID_FLAG_BG256 0x2 578 #define GRID_FLAG_PADDING 0x4 579 #define GRID_FLAG_EXTENDED 0x8 580 #define GRID_FLAG_SELECTED 0x10 581 #define GRID_FLAG_NOPALETTE 0x20 582 583 /* Grid line flags. */ 584 #define GRID_LINE_WRAPPED 0x1 585 #define GRID_LINE_EXTENDED 0x2 586 587 /* Grid cell data. */ 588 struct grid_cell { 589 u_char flags; 590 u_char attr; 591 int fg; 592 int bg; 593 struct utf8_data data; 594 595 }; 596 struct grid_cell_entry { 597 u_char flags; 598 union { 599 u_int offset; 600 struct { 601 u_char attr; 602 u_char fg; 603 u_char bg; 604 u_char data; 605 } data; 606 }; 607 } __packed; 608 609 /* Grid line. */ 610 struct grid_line { 611 u_int cellused; 612 u_int cellsize; 613 struct grid_cell_entry *celldata; 614 615 u_int extdsize; 616 struct grid_cell *extddata; 617 618 int flags; 619 } __packed; 620 621 /* Entire grid of cells. */ 622 struct grid { 623 int flags; 624 #define GRID_HISTORY 0x1 /* scroll lines into history */ 625 626 u_int sx; 627 u_int sy; 628 629 u_int hscrolled; 630 u_int hsize; 631 u_int hlimit; 632 633 struct grid_line *linedata; 634 }; 635 636 /* Hook data structures. */ 637 struct hook { 638 const char *name; 639 640 struct cmd_list *cmdlist; 641 642 RB_ENTRY(hook) entry; 643 }; 644 645 /* Scheduled job. */ 646 struct job { 647 enum { 648 JOB_RUNNING, 649 JOB_DEAD, 650 JOB_CLOSED 651 } state; 652 653 char *cmd; 654 pid_t pid; 655 int status; 656 657 int fd; 658 struct bufferevent *event; 659 660 void (*callbackfn)(struct job *); 661 void (*freefn)(void *); 662 void *data; 663 664 LIST_ENTRY(job) lentry; 665 }; 666 LIST_HEAD(joblist, job); 667 668 /* Screen selection. */ 669 struct screen_sel { 670 int flag; 671 int hidden; 672 673 int rectflag; 674 enum { 675 LINE_SEL_NONE, 676 LINE_SEL_LEFT_RIGHT, 677 LINE_SEL_RIGHT_LEFT, 678 } lineflag; 679 680 int modekeys; 681 682 u_int sx; 683 u_int sy; 684 685 u_int ex; 686 u_int ey; 687 688 struct grid_cell cell; 689 }; 690 691 /* Virtual screen. */ 692 struct screen { 693 char *title; 694 695 struct grid *grid; /* grid data */ 696 697 u_int cx; /* cursor x */ 698 u_int cy; /* cursor y */ 699 700 u_int cstyle; /* cursor style */ 701 char *ccolour; /* cursor colour string */ 702 703 u_int rupper; /* scroll region top */ 704 u_int rlower; /* scroll region bottom */ 705 706 int mode; 707 708 bitstr_t *tabs; 709 710 bitstr_t *dirty; 711 u_int dirtysize; 712 713 struct screen_sel sel; 714 }; 715 716 /* Screen write context. */ 717 struct screen_write_ctx { 718 struct window_pane *wp; 719 struct screen *s; 720 u_int dirty; 721 722 u_int cells; 723 u_int written; 724 u_int skipped; 725 }; 726 727 /* Screen size. */ 728 #define screen_size_x(s) ((s)->grid->sx) 729 #define screen_size_y(s) ((s)->grid->sy) 730 #define screen_hsize(s) ((s)->grid->hsize) 731 #define screen_hlimit(s) ((s)->grid->hlimit) 732 733 /* 734 * Window mode. Windows can be in several modes and this is used to call the 735 * right function to handle input and output. 736 */ 737 struct window_mode { 738 struct screen *(*init)(struct window_pane *); 739 void (*free)(struct window_pane *); 740 void (*resize)(struct window_pane *, u_int, u_int); 741 void (*key)(struct window_pane *, struct client *, struct session *, 742 key_code, struct mouse_event *); 743 744 const char *(*key_table)(struct window_pane *); 745 void (*command)(struct window_pane *, struct client *, 746 struct session *, struct args *, struct mouse_event *); 747 }; 748 #define WINDOW_MODE_TIMEOUT 180 749 750 /* Structures for choose mode. */ 751 struct window_choose_data { 752 struct client *start_client; 753 struct session *start_session; 754 755 u_int idx; 756 int type; 757 #define TREE_OTHER 0x0 758 #define TREE_WINDOW 0x1 759 #define TREE_SESSION 0x2 760 761 struct session *tree_session; /* session of items in tree */ 762 763 struct winlink *wl; 764 int pane_id; 765 766 char *ft_template; 767 struct format_tree *ft; 768 769 char *command; 770 }; 771 772 /* Child window structure. */ 773 struct window_pane { 774 u_int id; 775 u_int active_point; 776 777 struct window *window; 778 779 struct layout_cell *layout_cell; 780 struct layout_cell *saved_layout_cell; 781 782 u_int sx; 783 u_int sy; 784 785 u_int xoff; 786 u_int yoff; 787 788 int flags; 789 #define PANE_REDRAW 0x1 790 #define PANE_DROP 0x2 791 #define PANE_FOCUSED 0x4 792 #define PANE_RESIZE 0x8 793 #define PANE_FOCUSPUSH 0x10 794 #define PANE_INPUTOFF 0x20 795 #define PANE_CHANGED 0x40 796 797 int argc; 798 char **argv; 799 char *shell; 800 const char *cwd; 801 802 pid_t pid; 803 char tty[TTY_NAME_MAX]; 804 int status; 805 806 int fd; 807 struct bufferevent *event; 808 809 struct event resize_timer; 810 811 u_int wmark_size; 812 u_int wmark_hits; 813 814 struct input_ctx *ictx; 815 816 struct grid_cell colgc; 817 818 int *palette; 819 820 int pipe_fd; 821 struct bufferevent *pipe_event; 822 size_t pipe_off; 823 824 struct screen *screen; 825 struct screen base; 826 827 struct screen status_screen; 828 size_t status_size; 829 830 /* Saved in alternative screen mode. */ 831 u_int saved_cx; 832 u_int saved_cy; 833 struct grid *saved_grid; 834 struct grid_cell saved_cell; 835 836 const struct window_mode *mode; 837 void *modedata; 838 struct event modetimer; 839 time_t modelast; 840 u_int modeprefix; 841 842 TAILQ_ENTRY(window_pane) entry; 843 RB_ENTRY(window_pane) tree_entry; 844 }; 845 TAILQ_HEAD(window_panes, window_pane); 846 RB_HEAD(window_pane_tree, window_pane); 847 848 /* Window structure. */ 849 struct window { 850 u_int id; 851 852 char *name; 853 struct event name_event; 854 struct timeval name_time; 855 856 struct event alerts_timer; 857 858 struct timeval activity_time; 859 860 struct window_pane *active; 861 struct window_pane *last; 862 struct window_panes panes; 863 864 int lastlayout; 865 struct layout_cell *layout_root; 866 struct layout_cell *saved_layout_root; 867 char *old_layout; 868 869 u_int sx; 870 u_int sy; 871 872 int flags; 873 #define WINDOW_BELL 0x1 874 #define WINDOW_ACTIVITY 0x2 875 #define WINDOW_REDRAW 0x4 876 #define WINDOW_SILENCE 0x8 877 #define WINDOW_ZOOMED 0x1000 878 #define WINDOW_FORCEWIDTH 0x2000 879 #define WINDOW_FORCEHEIGHT 0x4000 880 #define WINDOW_STYLECHANGED 0x8000 881 #define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE) 882 883 int alerts_queued; 884 TAILQ_ENTRY(window) alerts_entry; 885 886 struct options *options; 887 888 struct grid_cell style; 889 struct grid_cell active_style; 890 891 u_int references; 892 TAILQ_HEAD(, winlink) winlinks; 893 894 RB_ENTRY(window) entry; 895 }; 896 RB_HEAD(windows, window); 897 898 /* Entry on local window list. */ 899 struct winlink { 900 int idx; 901 struct session *session; 902 struct window *window; 903 904 size_t status_width; 905 struct grid_cell status_cell; 906 char *status_text; 907 908 int flags; 909 #define WINLINK_BELL 0x1 910 #define WINLINK_ACTIVITY 0x2 911 #define WINLINK_SILENCE 0x4 912 #define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_SILENCE) 913 914 RB_ENTRY(winlink) entry; 915 TAILQ_ENTRY(winlink) wentry; 916 TAILQ_ENTRY(winlink) sentry; 917 }; 918 RB_HEAD(winlinks, winlink); 919 TAILQ_HEAD(winlink_stack, winlink); 920 921 /* Layout direction. */ 922 enum layout_type { 923 LAYOUT_LEFTRIGHT, 924 LAYOUT_TOPBOTTOM, 925 LAYOUT_WINDOWPANE 926 }; 927 928 /* Layout cells queue. */ 929 TAILQ_HEAD(layout_cells, layout_cell); 930 931 /* Layout cell. */ 932 struct layout_cell { 933 enum layout_type type; 934 935 struct layout_cell *parent; 936 937 u_int sx; 938 u_int sy; 939 940 u_int xoff; 941 u_int yoff; 942 943 struct window_pane *wp; 944 struct layout_cells cells; 945 946 TAILQ_ENTRY(layout_cell) entry; 947 }; 948 949 /* Environment variable. */ 950 struct environ_entry { 951 char *name; 952 char *value; 953 954 RB_ENTRY(environ_entry) entry; 955 }; 956 957 /* Client session. */ 958 struct session_group { 959 TAILQ_HEAD(, session) sessions; 960 961 TAILQ_ENTRY(session_group) entry; 962 }; 963 TAILQ_HEAD(session_groups, session_group); 964 965 struct session { 966 u_int id; 967 968 char *name; 969 const char *cwd; 970 971 struct timeval creation_time; 972 struct timeval last_attached_time; 973 struct timeval activity_time; 974 struct timeval last_activity_time; 975 976 struct event lock_timer; 977 978 u_int sx; 979 u_int sy; 980 981 struct winlink *curw; 982 struct winlink_stack lastw; 983 struct winlinks windows; 984 985 struct hooks *hooks; 986 struct options *options; 987 988 #define SESSION_UNATTACHED 0x1 /* not attached to any clients */ 989 #define SESSION_PASTING 0x2 990 #define SESSION_ALERTED 0x4 991 int flags; 992 993 u_int attached; 994 995 struct termios *tio; 996 997 struct environ *environ; 998 999 int references; 1000 1001 TAILQ_ENTRY(session) gentry; 1002 RB_ENTRY(session) entry; 1003 }; 1004 RB_HEAD(sessions, session); 1005 1006 /* Mouse button masks. */ 1007 #define MOUSE_MASK_BUTTONS 3 1008 #define MOUSE_MASK_SHIFT 4 1009 #define MOUSE_MASK_META 8 1010 #define MOUSE_MASK_CTRL 16 1011 #define MOUSE_MASK_DRAG 32 1012 #define MOUSE_MASK_WHEEL 64 1013 1014 /* Mouse wheel states. */ 1015 #define MOUSE_WHEEL_UP 0 1016 #define MOUSE_WHEEL_DOWN 64 1017 1018 /* Mouse helpers. */ 1019 #define MOUSE_BUTTONS(b) ((b) & MOUSE_MASK_BUTTONS) 1020 #define MOUSE_WHEEL(b) ((b) & MOUSE_MASK_WHEEL) 1021 #define MOUSE_DRAG(b) ((b) & MOUSE_MASK_DRAG) 1022 #define MOUSE_RELEASE(b) (((b) & MOUSE_MASK_BUTTONS) == 3) 1023 1024 /* Mouse input. */ 1025 struct mouse_event { 1026 int valid; 1027 1028 key_code key; 1029 int statusat; 1030 1031 u_int x; 1032 u_int y; 1033 u_int b; 1034 1035 u_int lx; 1036 u_int ly; 1037 u_int lb; 1038 1039 int s; 1040 int w; 1041 int wp; 1042 1043 u_int sgr_type; 1044 u_int sgr_b; 1045 }; 1046 1047 /* TTY information. */ 1048 struct tty_key { 1049 char ch; 1050 key_code key; 1051 1052 struct tty_key *left; 1053 struct tty_key *right; 1054 1055 struct tty_key *next; 1056 }; 1057 1058 struct tty_code; 1059 struct tty_term { 1060 char *name; 1061 u_int references; 1062 1063 char acs[UCHAR_MAX + 1][2]; 1064 1065 struct tty_code *codes; 1066 1067 #define TERM_256COLOURS 0x1 1068 #define TERM_EARLYWRAP 0x2 1069 int flags; 1070 1071 LIST_ENTRY(tty_term) entry; 1072 }; 1073 LIST_HEAD(tty_terms, tty_term); 1074 1075 struct tty { 1076 struct client *client; 1077 char *path; 1078 1079 u_int sx; 1080 u_int sy; 1081 1082 u_int cx; 1083 u_int cy; 1084 u_int cstyle; 1085 char *ccolour; 1086 1087 int mode; 1088 1089 u_int rlower; 1090 u_int rupper; 1091 1092 u_int rleft; 1093 u_int rright; 1094 1095 int fd; 1096 struct bufferevent *event; 1097 1098 struct termios tio; 1099 1100 struct grid_cell cell; 1101 1102 #define TTY_NOCURSOR 0x1 1103 #define TTY_FREEZE 0x2 1104 #define TTY_TIMER 0x4 1105 #define TTY_UTF8 0x8 1106 #define TTY_STARTED 0x10 1107 #define TTY_OPENED 0x20 1108 #define TTY_FOCUS 0x40 1109 int flags; 1110 1111 struct tty_term *term; 1112 char *term_name; 1113 int term_flags; 1114 enum { 1115 TTY_VT100, 1116 TTY_VT101, 1117 TTY_VT102, 1118 TTY_VT220, 1119 TTY_VT320, 1120 TTY_VT420, 1121 TTY_UNKNOWN 1122 } term_type; 1123 1124 struct mouse_event mouse; 1125 int mouse_drag_flag; 1126 void (*mouse_drag_update)(struct client *, 1127 struct mouse_event *); 1128 void (*mouse_drag_release)(struct client *, 1129 struct mouse_event *); 1130 1131 struct event key_timer; 1132 struct tty_key *key_tree; 1133 }; 1134 #define TTY_TYPES \ 1135 { "VT100", "VT101", "VT102", "VT220", "VT320", "VT420", "UNKNOWN" } 1136 1137 /* TTY command context. */ 1138 struct tty_ctx { 1139 struct window_pane *wp; 1140 1141 const struct grid_cell *cell; 1142 1143 u_int num; 1144 void *ptr; 1145 1146 /* 1147 * Cursor and region position before the screen was updated - this is 1148 * where the command should be applied; the values in the screen have 1149 * already been updated. 1150 */ 1151 u_int ocx; 1152 u_int ocy; 1153 1154 u_int orupper; 1155 u_int orlower; 1156 1157 u_int xoff; 1158 u_int yoff; 1159 1160 /* The background colour used for clearing (erasing). */ 1161 u_int bg; 1162 1163 /* Saved last cell on line. */ 1164 struct grid_cell last_cell; 1165 }; 1166 1167 /* Saved message entry. */ 1168 struct message_entry { 1169 char *msg; 1170 u_int msg_num; 1171 time_t msg_time; 1172 TAILQ_ENTRY(message_entry) entry; 1173 }; 1174 1175 /* Parsed arguments structures. */ 1176 struct args_entry; 1177 RB_HEAD(args_tree, args_entry); 1178 struct args { 1179 struct args_tree tree; 1180 int argc; 1181 char **argv; 1182 }; 1183 1184 /* Command find structures. */ 1185 enum cmd_find_type { 1186 CMD_FIND_PANE, 1187 CMD_FIND_WINDOW, 1188 CMD_FIND_SESSION, 1189 }; 1190 struct cmd_find_state { 1191 struct cmdq_item *item; 1192 int flags; 1193 struct cmd_find_state *current; 1194 1195 struct session *s; 1196 struct winlink *wl; 1197 struct window *w; 1198 struct window_pane *wp; 1199 int idx; 1200 }; 1201 1202 /* Command find flags. */ 1203 #define CMD_FIND_PREFER_UNATTACHED 0x1 1204 #define CMD_FIND_QUIET 0x2 1205 #define CMD_FIND_WINDOW_INDEX 0x4 1206 #define CMD_FIND_DEFAULT_MARKED 0x8 1207 #define CMD_FIND_EXACT_SESSION 0x10 1208 #define CMD_FIND_EXACT_WINDOW 0x20 1209 1210 /* Context for command being executed. */ 1211 struct cmd_state { 1212 struct client *c; 1213 struct cmd_find_state tflag; 1214 struct cmd_find_state sflag; 1215 }; 1216 1217 /* Command and list of commands. */ 1218 struct cmd { 1219 const struct cmd_entry *entry; 1220 struct args *args; 1221 1222 char *file; 1223 u_int line; 1224 1225 #define CMD_CONTROL 0x1 1226 int flags; 1227 1228 TAILQ_ENTRY(cmd) qentry; 1229 }; 1230 1231 struct cmd_list { 1232 int references; 1233 TAILQ_HEAD(, cmd) list; 1234 }; 1235 1236 /* Command return values. */ 1237 enum cmd_retval { 1238 CMD_RETURN_ERROR = -1, 1239 CMD_RETURN_NORMAL = 0, 1240 CMD_RETURN_WAIT, 1241 CMD_RETURN_STOP 1242 }; 1243 1244 /* Command queue item type. */ 1245 enum cmdq_type { 1246 CMDQ_COMMAND, 1247 CMDQ_CALLBACK, 1248 }; 1249 1250 /* Command queue item. */ 1251 typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *); 1252 struct cmdq_item { 1253 const char *name; 1254 struct cmdq_list *queue; 1255 struct cmdq_item *next; 1256 1257 struct client *client; 1258 1259 enum cmdq_type type; 1260 u_int group; 1261 1262 u_int number; 1263 time_t time; 1264 1265 struct format_tree *formats; 1266 1267 int flags; 1268 #define CMDQ_FIRED 0x1 1269 #define CMDQ_WAITING 0x2 1270 #define CMDQ_NOHOOKS 0x4 1271 1272 struct cmd_list *cmdlist; 1273 struct cmd *cmd; 1274 1275 cmdq_cb cb; 1276 void *data; 1277 1278 struct cmd_find_state current; 1279 struct cmd_state state; 1280 1281 struct mouse_event mouse; 1282 1283 TAILQ_ENTRY(cmdq_item) entry; 1284 }; 1285 TAILQ_HEAD(cmdq_list, cmdq_item); 1286 1287 /* Command -c, -t or -s flags. */ 1288 enum cmd_entry_flag { 1289 CMD_NONE, 1290 1291 CMD_CLIENT, 1292 CMD_CLIENT_CANFAIL, 1293 1294 CMD_SESSION, 1295 CMD_SESSION_CANFAIL, 1296 CMD_SESSION_PREFERUNATTACHED, 1297 CMD_SESSION_WITHPANE, /* implies PREFERUNATTACHED */ 1298 1299 CMD_WINDOW, 1300 CMD_WINDOW_CANFAIL, 1301 CMD_WINDOW_MARKED, 1302 CMD_WINDOW_INDEX, 1303 1304 CMD_PANE, 1305 CMD_PANE_CANFAIL, 1306 CMD_PANE_MARKED, 1307 1308 CMD_MOVEW_R, 1309 }; 1310 1311 /* Command definition. */ 1312 struct cmd_entry { 1313 const char *name; 1314 const char *alias; 1315 1316 struct { 1317 const char *template; 1318 int lower; 1319 int upper; 1320 } args; 1321 const char *usage; 1322 1323 enum cmd_entry_flag tflag; 1324 enum cmd_entry_flag sflag; 1325 enum cmd_entry_flag cflag; 1326 1327 #define CMD_STARTSERVER 0x1 1328 #define CMD_READONLY 0x2 1329 #define CMD_AFTERHOOK 0x4 1330 int flags; 1331 1332 enum cmd_retval (*exec)(struct cmd *, struct cmdq_item *); 1333 }; 1334 1335 /* Client connection. */ 1336 struct client { 1337 struct tmuxpeer *peer; 1338 struct cmdq_list queue; 1339 1340 pid_t pid; 1341 int fd; 1342 struct event event; 1343 int retval; 1344 1345 struct timeval creation_time; 1346 struct timeval activity_time; 1347 1348 struct environ *environ; 1349 1350 char *title; 1351 const char *cwd; 1352 1353 char *term; 1354 char *ttyname; 1355 struct tty tty; 1356 1357 void (*stdin_callback)(struct client *, int, void *); 1358 void *stdin_callback_data; 1359 struct evbuffer *stdin_data; 1360 int stdin_closed; 1361 struct evbuffer *stdout_data; 1362 struct evbuffer *stderr_data; 1363 1364 struct event repeat_timer; 1365 1366 struct event click_timer; 1367 u_int click_button; 1368 1369 struct event status_timer; 1370 struct screen status; 1371 1372 #define CLIENT_TERMINAL 0x1 1373 #define CLIENT_LOGIN 0x2 1374 #define CLIENT_EXIT 0x4 1375 #define CLIENT_REDRAW 0x8 1376 #define CLIENT_STATUS 0x10 1377 #define CLIENT_REPEAT 0x20 1378 #define CLIENT_SUSPENDED 0x40 1379 #define CLIENT_ATTACHED 0x80 1380 #define CLIENT_IDENTIFY 0x100 1381 #define CLIENT_DEAD 0x200 1382 #define CLIENT_BORDERS 0x400 1383 #define CLIENT_READONLY 0x800 1384 #define CLIENT_REDRAWWINDOW 0x1000 1385 #define CLIENT_CONTROL 0x2000 1386 #define CLIENT_CONTROLCONTROL 0x4000 1387 #define CLIENT_FOCUSED 0x8000 1388 #define CLIENT_UTF8 0x10000 1389 #define CLIENT_256COLOURS 0x20000 1390 #define CLIENT_IDENTIFIED 0x40000 1391 #define CLIENT_STATUSFORCE 0x80000 1392 #define CLIENT_DOUBLECLICK 0x100000 1393 #define CLIENT_TRIPLECLICK 0x200000 1394 int flags; 1395 struct key_table *keytable; 1396 1397 struct event identify_timer; 1398 void (*identify_callback)(struct client *, struct window_pane *); 1399 void *identify_callback_data; 1400 1401 char *message_string; 1402 struct event message_timer; 1403 u_int message_next; 1404 TAILQ_HEAD(, message_entry) message_log; 1405 1406 char *prompt_string; 1407 struct utf8_data *prompt_buffer; 1408 size_t prompt_index; 1409 int (*prompt_callbackfn)(void *, const char *, int); 1410 void (*prompt_freefn)(void *); 1411 void *prompt_data; 1412 u_int prompt_hindex; 1413 enum { PROMPT_ENTRY, PROMPT_COMMAND } prompt_mode; 1414 1415 #define PROMPT_SINGLE 0x1 1416 #define PROMPT_NUMERIC 0x2 1417 #define PROMPT_INCREMENTAL 0x4 1418 int prompt_flags; 1419 1420 struct session *session; 1421 struct session *last_session; 1422 1423 int wlmouse; 1424 1425 int references; 1426 1427 TAILQ_ENTRY(client) entry; 1428 }; 1429 TAILQ_HEAD(clients, client); 1430 1431 /* Key binding and key table. */ 1432 struct key_binding { 1433 key_code key; 1434 struct cmd_list *cmdlist; 1435 int can_repeat; 1436 1437 RB_ENTRY(key_binding) entry; 1438 }; 1439 RB_HEAD(key_bindings, key_binding); 1440 1441 struct key_table { 1442 const char *name; 1443 struct key_bindings key_bindings; 1444 1445 u_int references; 1446 1447 RB_ENTRY(key_table) entry; 1448 }; 1449 RB_HEAD(key_tables, key_table); 1450 1451 /* Option table entries. */ 1452 enum options_table_type { 1453 OPTIONS_TABLE_STRING, 1454 OPTIONS_TABLE_NUMBER, 1455 OPTIONS_TABLE_KEY, 1456 OPTIONS_TABLE_COLOUR, 1457 OPTIONS_TABLE_ATTRIBUTES, 1458 OPTIONS_TABLE_FLAG, 1459 OPTIONS_TABLE_CHOICE, 1460 OPTIONS_TABLE_STYLE, 1461 OPTIONS_TABLE_ARRAY, 1462 }; 1463 enum options_table_scope { 1464 OPTIONS_TABLE_NONE, 1465 OPTIONS_TABLE_SERVER, 1466 OPTIONS_TABLE_SESSION, 1467 OPTIONS_TABLE_WINDOW, 1468 }; 1469 1470 struct options_table_entry { 1471 const char *name; 1472 enum options_table_type type; 1473 enum options_table_scope scope; 1474 1475 u_int minimum; 1476 u_int maximum; 1477 const char **choices; 1478 1479 const char *default_str; 1480 long long default_num; 1481 1482 const char *style; 1483 }; 1484 1485 /* Common command usages. */ 1486 #define CMD_TARGET_PANE_USAGE "[-t target-pane]" 1487 #define CMD_TARGET_WINDOW_USAGE "[-t target-window]" 1488 #define CMD_TARGET_SESSION_USAGE "[-t target-session]" 1489 #define CMD_TARGET_CLIENT_USAGE "[-t target-client]" 1490 #define CMD_SRCDST_PANE_USAGE "[-s src-pane] [-t dst-pane]" 1491 #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]" 1492 #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]" 1493 #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]" 1494 #define CMD_BUFFER_USAGE "[-b buffer-name]" 1495 1496 /* tmux.c */ 1497 extern struct hooks *global_hooks; 1498 extern struct options *global_options; 1499 extern struct options *global_s_options; 1500 extern struct options *global_w_options; 1501 extern struct environ *global_environ; 1502 extern struct timeval start_time; 1503 extern const char *socket_path; 1504 int areshell(const char *); 1505 void setblocking(int, int); 1506 const char *find_home(void); 1507 1508 /* proc.c */ 1509 struct imsg; 1510 int proc_send(struct tmuxpeer *, enum msgtype, int, const void *, size_t); 1511 int proc_send_s(struct tmuxpeer *, enum msgtype, const char *); 1512 struct tmuxproc *proc_start(const char *, struct event_base *, int, 1513 void (*)(int)); 1514 void proc_loop(struct tmuxproc *, int (*)(void)); 1515 void proc_exit(struct tmuxproc *); 1516 struct tmuxpeer *proc_add_peer(struct tmuxproc *, int, 1517 void (*)(struct imsg *, void *), void *); 1518 void proc_remove_peer(struct tmuxpeer *); 1519 void proc_kill_peer(struct tmuxpeer *); 1520 1521 /* cfg.c */ 1522 extern int cfg_finished; 1523 extern struct client *cfg_client; 1524 void start_cfg(void); 1525 int load_cfg(const char *, struct client *, struct cmdq_item *, int); 1526 void set_cfg_file(const char *); 1527 void printflike(1, 2) cfg_add_cause(const char *, ...); 1528 void cfg_print_causes(struct cmdq_item *); 1529 void cfg_show_causes(struct session *); 1530 1531 /* paste.c */ 1532 struct paste_buffer; 1533 const char *paste_buffer_name(struct paste_buffer *); 1534 u_int paste_buffer_order(struct paste_buffer *); 1535 time_t paste_buffer_created(struct paste_buffer *); 1536 const char *paste_buffer_data(struct paste_buffer *, size_t *); 1537 struct paste_buffer *paste_walk(struct paste_buffer *); 1538 struct paste_buffer *paste_get_top(const char **); 1539 struct paste_buffer *paste_get_name(const char *); 1540 void paste_free(struct paste_buffer *); 1541 void paste_add(char *, size_t); 1542 int paste_rename(const char *, const char *, char **); 1543 int paste_set(char *, size_t, const char *, char **); 1544 char *paste_make_sample(struct paste_buffer *); 1545 1546 /* format.c */ 1547 #define FORMAT_STATUS 0x1 1548 #define FORMAT_FORCE 0x2 1549 #define FORMAT_NOJOBS 0x4 1550 struct format_tree; 1551 struct format_tree *format_create(struct cmdq_item *, int); 1552 void format_free(struct format_tree *); 1553 void printflike(3, 4) format_add(struct format_tree *, const char *, 1554 const char *, ...); 1555 char *format_expand_time(struct format_tree *, const char *, time_t); 1556 char *format_expand(struct format_tree *, const char *); 1557 void format_defaults(struct format_tree *, struct client *, 1558 struct session *, struct winlink *, struct window_pane *); 1559 void format_defaults_window(struct format_tree *, struct window *); 1560 void format_defaults_pane(struct format_tree *, 1561 struct window_pane *); 1562 void format_defaults_paste_buffer(struct format_tree *, 1563 struct paste_buffer *); 1564 1565 /* hooks.c */ 1566 struct hook; 1567 struct hooks *hooks_get(struct session *); 1568 struct hooks *hooks_create(struct hooks *); 1569 void hooks_free(struct hooks *); 1570 struct hook *hooks_first(struct hooks *); 1571 struct hook *hooks_next(struct hook *); 1572 void hooks_add(struct hooks *, const char *, struct cmd_list *); 1573 void hooks_copy(struct hooks *, struct hooks *); 1574 void hooks_remove(struct hooks *, const char *); 1575 struct hook *hooks_find(struct hooks *, const char *); 1576 void printflike(4, 5) hooks_run(struct hooks *, struct client *, 1577 struct cmd_find_state *, const char *, ...); 1578 void printflike(4, 5) hooks_insert(struct hooks *, struct cmdq_item *, 1579 struct cmd_find_state *, const char *, ...); 1580 1581 /* mode-key.c */ 1582 extern struct mode_key_tree mode_key_tree_vi_choice; 1583 extern struct mode_key_tree mode_key_tree_emacs_choice; 1584 int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *); 1585 RB_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); 1586 const char *mode_key_tostring(const struct mode_key_cmdstr *, 1587 enum mode_key_cmd); 1588 enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *, 1589 const char *); 1590 const struct mode_key_table *mode_key_findtable(const char *); 1591 void mode_key_init_trees(void); 1592 void mode_key_init(struct mode_key_data *, struct mode_key_tree *); 1593 enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code); 1594 1595 /* notify.c */ 1596 void notify_input(struct window_pane *, struct evbuffer *); 1597 void notify_client(const char *, struct client *); 1598 void notify_session(const char *, struct session *); 1599 void notify_winlink(const char *, struct session *, struct winlink *); 1600 void notify_session_window(const char *, struct session *, struct window *); 1601 void notify_window(const char *, struct window *); 1602 void notify_pane(const char *, struct window_pane *); 1603 1604 /* options.c */ 1605 struct options *options_create(struct options *); 1606 void options_free(struct options *); 1607 struct options_entry *options_first(struct options *); 1608 struct options_entry *options_next(struct options_entry *); 1609 struct options_entry *options_empty(struct options *, 1610 const struct options_table_entry *); 1611 struct options_entry *options_default(struct options *, 1612 const struct options_table_entry *); 1613 const char *options_name(struct options_entry *); 1614 const struct options_table_entry *options_table_entry(struct options_entry *); 1615 struct options_entry *options_get_only(struct options *, const char *); 1616 struct options_entry *options_get(struct options *, const char *); 1617 void options_remove(struct options_entry *); 1618 const char *options_array_get(struct options_entry *, u_int); 1619 int options_array_set(struct options_entry *, u_int, const char *); 1620 int options_array_size(struct options_entry *, u_int *); 1621 int options_isstring(struct options_entry *); 1622 const char *options_tostring(struct options_entry *, int); 1623 char *options_parse(const char *, int *); 1624 struct options_entry *options_parse_get(struct options *, const char *, int *, 1625 int); 1626 char *options_match(const char *, int *, int *); 1627 struct options_entry *options_match_get(struct options *, const char *, int *, 1628 int, int *); 1629 const char *options_get_string(struct options *, const char *); 1630 long long options_get_number(struct options *, const char *); 1631 const struct grid_cell *options_get_style(struct options *, const char *); 1632 struct options_entry * printflike(4, 5) options_set_string(struct options *, 1633 const char *, int, const char *, ...); 1634 struct options_entry *options_set_number(struct options *, const char *, 1635 long long); 1636 struct options_entry *options_set_style(struct options *, const char *, int, 1637 const char *); 1638 enum options_table_scope options_scope_from_flags(struct args *, int, 1639 struct cmd_find_state *, struct options **, char **); 1640 void options_style_update_new(struct options *, 1641 struct options_entry *); 1642 void options_style_update_old(struct options *, 1643 struct options_entry *); 1644 1645 /* options-table.c */ 1646 extern const struct options_table_entry options_table[]; 1647 1648 /* job.c */ 1649 extern struct joblist all_jobs; 1650 struct job *job_run(const char *, struct session *, const char *, 1651 void (*)(struct job *), void (*)(void *), void *); 1652 void job_free(struct job *); 1653 void job_died(struct job *, int); 1654 1655 /* environ.c */ 1656 struct environ *environ_create(void); 1657 void environ_free(struct environ *); 1658 struct environ_entry *environ_first(struct environ *); 1659 struct environ_entry *environ_next(struct environ_entry *); 1660 void environ_copy(struct environ *, struct environ *); 1661 struct environ_entry *environ_find(struct environ *, const char *); 1662 void printflike(3, 4) environ_set(struct environ *, const char *, const char *, 1663 ...); 1664 void environ_clear(struct environ *, const char *); 1665 void environ_put(struct environ *, const char *); 1666 void environ_unset(struct environ *, const char *); 1667 void environ_update(const char *, struct environ *, struct environ *); 1668 void environ_push(struct environ *); 1669 void environ_log(struct environ *, const char *); 1670 1671 /* tty.c */ 1672 void tty_create_log(void); 1673 void tty_raw(struct tty *, const char *); 1674 void tty_attributes(struct tty *, const struct grid_cell *, 1675 const struct window_pane *); 1676 void tty_reset(struct tty *); 1677 void tty_region_off(struct tty *); 1678 void tty_margin_off(struct tty *); 1679 void tty_cursor(struct tty *, u_int, u_int); 1680 void tty_putcode(struct tty *, enum tty_code_code); 1681 void tty_putcode1(struct tty *, enum tty_code_code, int); 1682 void tty_putcode2(struct tty *, enum tty_code_code, int, int); 1683 void tty_putcode_ptr1(struct tty *, enum tty_code_code, const void *); 1684 void tty_putcode_ptr2(struct tty *, enum tty_code_code, const void *, 1685 const void *); 1686 void tty_puts(struct tty *, const char *); 1687 void tty_putc(struct tty *, u_char); 1688 void tty_putn(struct tty *, const void *, size_t, u_int); 1689 int tty_init(struct tty *, struct client *, int, char *); 1690 int tty_resize(struct tty *); 1691 int tty_set_size(struct tty *, u_int, u_int); 1692 void tty_start_tty(struct tty *); 1693 void tty_stop_tty(struct tty *); 1694 void tty_set_title(struct tty *, const char *); 1695 void tty_update_mode(struct tty *, int, struct screen *); 1696 void tty_draw_pane(struct tty *, const struct window_pane *, u_int, u_int, 1697 u_int); 1698 void tty_draw_line(struct tty *, const struct window_pane *, struct screen *, 1699 u_int, u_int, u_int); 1700 int tty_open(struct tty *, char **); 1701 void tty_close(struct tty *); 1702 void tty_free(struct tty *); 1703 void tty_set_type(struct tty *, int); 1704 void tty_write(void (*)(struct tty *, const struct tty_ctx *), 1705 struct tty_ctx *); 1706 void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *); 1707 void tty_cmd_cell(struct tty *, const struct tty_ctx *); 1708 void tty_cmd_clearendofline(struct tty *, const struct tty_ctx *); 1709 void tty_cmd_clearendofscreen(struct tty *, const struct tty_ctx *); 1710 void tty_cmd_clearline(struct tty *, const struct tty_ctx *); 1711 void tty_cmd_clearscreen(struct tty *, const struct tty_ctx *); 1712 void tty_cmd_clearstartofline(struct tty *, const struct tty_ctx *); 1713 void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *); 1714 void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *); 1715 void tty_cmd_clearcharacter(struct tty *, const struct tty_ctx *); 1716 void tty_cmd_deleteline(struct tty *, const struct tty_ctx *); 1717 void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *); 1718 void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *); 1719 void tty_cmd_insertline(struct tty *, const struct tty_ctx *); 1720 void tty_cmd_linefeed(struct tty *, const struct tty_ctx *); 1721 void tty_cmd_utf8character(struct tty *, const struct tty_ctx *); 1722 void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *); 1723 void tty_cmd_setselection(struct tty *, const struct tty_ctx *); 1724 void tty_cmd_rawstring(struct tty *, const struct tty_ctx *); 1725 1726 /* tty-term.c */ 1727 extern struct tty_terms tty_terms; 1728 u_int tty_term_ncodes(void); 1729 struct tty_term *tty_term_find(char *, int, char **); 1730 void tty_term_free(struct tty_term *); 1731 int tty_term_has(struct tty_term *, enum tty_code_code); 1732 const char *tty_term_string(struct tty_term *, enum tty_code_code); 1733 const char *tty_term_string1(struct tty_term *, enum tty_code_code, int); 1734 const char *tty_term_string2(struct tty_term *, enum tty_code_code, int, 1735 int); 1736 const char *tty_term_ptr1(struct tty_term *, enum tty_code_code, 1737 const void *); 1738 const char *tty_term_ptr2(struct tty_term *, enum tty_code_code, 1739 const void *, const void *); 1740 int tty_term_number(struct tty_term *, enum tty_code_code); 1741 int tty_term_flag(struct tty_term *, enum tty_code_code); 1742 const char *tty_term_describe(struct tty_term *, enum tty_code_code); 1743 1744 /* tty-acs.c */ 1745 const char *tty_acs_get(struct tty *, u_char); 1746 1747 /* tty-keys.c */ 1748 void tty_keys_build(struct tty *); 1749 void tty_keys_free(struct tty *); 1750 key_code tty_keys_next(struct tty *); 1751 1752 /* arguments.c */ 1753 struct args *args_parse(const char *, int, char **); 1754 void args_free(struct args *); 1755 char *args_print(struct args *); 1756 int args_has(struct args *, u_char); 1757 const char *args_get(struct args *, u_char); 1758 long long args_strtonum(struct args *, u_char, long long, long long, 1759 char **); 1760 1761 /* cmd-find.c */ 1762 int cmd_find_current(struct cmd_find_state *, struct cmdq_item *, 1763 int); 1764 int cmd_find_target(struct cmd_find_state *, 1765 struct cmd_find_state *, struct cmdq_item *, const char *, 1766 enum cmd_find_type, int); 1767 struct client *cmd_find_client(struct cmdq_item *, const char *, int); 1768 void cmd_find_clear_state(struct cmd_find_state *, 1769 struct cmdq_item *, int); 1770 int cmd_find_empty_state(struct cmd_find_state *); 1771 int cmd_find_valid_state(struct cmd_find_state *); 1772 void cmd_find_copy_state(struct cmd_find_state *, 1773 struct cmd_find_state *); 1774 void cmd_find_log_state(const char *, struct cmd_find_state *); 1775 int cmd_find_from_session(struct cmd_find_state *, 1776 struct session *); 1777 int cmd_find_from_winlink(struct cmd_find_state *, 1778 struct session *, struct winlink *); 1779 int cmd_find_from_session_window(struct cmd_find_state *, 1780 struct session *, struct window *); 1781 int cmd_find_from_window(struct cmd_find_state *, struct window *); 1782 int cmd_find_from_pane(struct cmd_find_state *, 1783 struct window_pane *); 1784 1785 /* cmd.c */ 1786 int cmd_pack_argv(int, char **, char *, size_t); 1787 int cmd_unpack_argv(char *, size_t, int, char ***); 1788 char **cmd_copy_argv(int, char **); 1789 void cmd_free_argv(int, char **); 1790 char *cmd_stringify_argv(int, char **); 1791 struct cmd *cmd_parse(int, char **, const char *, u_int, char **); 1792 int cmd_prepare_state(struct cmd *, struct cmdq_item *); 1793 char *cmd_print(struct cmd *); 1794 int cmd_mouse_at(struct window_pane *, struct mouse_event *, 1795 u_int *, u_int *, int); 1796 struct winlink *cmd_mouse_window(struct mouse_event *, struct session **); 1797 struct window_pane *cmd_mouse_pane(struct mouse_event *, struct session **, 1798 struct winlink **); 1799 char *cmd_template_replace(const char *, const char *, int); 1800 extern const struct cmd_entry *cmd_table[]; 1801 1802 /* cmd-attach-session.c */ 1803 enum cmd_retval cmd_attach_session(struct cmdq_item *, int, int, const char *, 1804 int); 1805 1806 /* cmd-list.c */ 1807 struct cmd_list *cmd_list_parse(int, char **, const char *, u_int, char **); 1808 void cmd_list_free(struct cmd_list *); 1809 char *cmd_list_print(struct cmd_list *); 1810 1811 /* cmd-queue.c */ 1812 struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, 1813 struct mouse_event *, int); 1814 #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) 1815 struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *); 1816 void cmdq_insert_after(struct cmdq_item *, struct cmdq_item *); 1817 void cmdq_append(struct client *, struct cmdq_item *); 1818 void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *, 1819 const char *, ...); 1820 u_int cmdq_next(struct client *); 1821 void cmdq_guard(struct cmdq_item *, const char *, int); 1822 void printflike(2, 3) cmdq_print(struct cmdq_item *, const char *, ...); 1823 void printflike(2, 3) cmdq_error(struct cmdq_item *, const char *, ...); 1824 1825 /* cmd-string.c */ 1826 struct cmd_list *cmd_string_parse(const char *, const char *, u_int, char **); 1827 1828 /* cmd-wait-for.c */ 1829 void cmd_wait_for_flush(void); 1830 1831 /* client.c */ 1832 int client_main(struct event_base *, int, char **, int, const char *); 1833 1834 /* key-bindings.c */ 1835 RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp); 1836 RB_PROTOTYPE(key_tables, key_table, entry, key_table_cmp); 1837 extern struct key_tables key_tables; 1838 int key_table_cmp(struct key_table *, struct key_table *); 1839 int key_bindings_cmp(struct key_binding *, struct key_binding *); 1840 struct key_table *key_bindings_get_table(const char *, int); 1841 void key_bindings_unref_table(struct key_table *); 1842 void key_bindings_add(const char *, key_code, int, struct cmd_list *); 1843 void key_bindings_remove(const char *, key_code); 1844 void key_bindings_remove_table(const char *); 1845 void key_bindings_init(void); 1846 void key_bindings_dispatch(struct key_binding *, struct client *, 1847 struct mouse_event *, struct cmd_find_state *); 1848 1849 /* key-string.c */ 1850 key_code key_string_lookup_string(const char *); 1851 const char *key_string_lookup_key(key_code); 1852 1853 /* alerts.c */ 1854 void alerts_reset_all(void); 1855 void alerts_queue(struct window *, int); 1856 void alerts_check_session(struct session *); 1857 1858 /* server.c */ 1859 extern struct tmuxproc *server_proc; 1860 extern struct clients clients; 1861 extern struct cmd_find_state marked_pane; 1862 void server_set_marked(struct session *, struct winlink *, 1863 struct window_pane *); 1864 void server_clear_marked(void); 1865 int server_is_marked(struct session *, struct winlink *, 1866 struct window_pane *); 1867 int server_check_marked(void); 1868 int server_start(struct event_base *, int, char *); 1869 void server_update_socket(void); 1870 void server_add_accept(int); 1871 1872 /* server-client.c */ 1873 void server_client_set_key_table(struct client *, const char *); 1874 const char *server_client_get_key_table(struct client *); 1875 int server_client_is_default_key_table(struct client *); 1876 int server_client_check_nested(struct client *); 1877 void server_client_handle_key(struct client *, key_code); 1878 void server_client_create(int); 1879 int server_client_open(struct client *, char **); 1880 void server_client_unref(struct client *); 1881 void server_client_lost(struct client *); 1882 void server_client_detach(struct client *, enum msgtype); 1883 void server_client_exec(struct client *, const char *); 1884 void server_client_loop(void); 1885 void server_client_push_stdout(struct client *); 1886 void server_client_push_stderr(struct client *); 1887 1888 /* server-fn.c */ 1889 void server_fill_environ(struct session *, struct environ *); 1890 void server_redraw_client(struct client *); 1891 void server_status_client(struct client *); 1892 void server_redraw_session(struct session *); 1893 void server_redraw_session_group(struct session *); 1894 void server_status_session(struct session *); 1895 void server_status_session_group(struct session *); 1896 void server_redraw_window(struct window *); 1897 void server_redraw_window_borders(struct window *); 1898 void server_status_window(struct window *); 1899 void server_lock(void); 1900 void server_lock_session(struct session *); 1901 void server_lock_client(struct client *); 1902 void server_kill_window(struct window *); 1903 int server_link_window(struct session *, 1904 struct winlink *, struct session *, int, int, int, char **); 1905 void server_unlink_window(struct session *, struct winlink *); 1906 void server_destroy_pane(struct window_pane *, int); 1907 void server_destroy_session(struct session *); 1908 void server_check_unattached(void); 1909 void server_set_identify(struct client *); 1910 void server_clear_identify(struct client *, struct window_pane *); 1911 int server_set_stdin_callback(struct client *, void (*)(struct client *, 1912 int, void *), void *, char **); 1913 void server_unzoom_window(struct window *); 1914 1915 /* status.c */ 1916 void status_timer_start(struct client *); 1917 void status_timer_start_all(void); 1918 int status_at_line(struct client *); 1919 struct window *status_get_window_at(struct client *, u_int); 1920 int status_redraw(struct client *); 1921 void printflike(2, 3) status_message_set(struct client *, const char *, ...); 1922 void status_message_clear(struct client *); 1923 int status_message_redraw(struct client *); 1924 void status_prompt_set(struct client *, const char *, const char *, 1925 int (*)(void *, const char *, int), void (*)(void *), void *, int); 1926 void status_prompt_clear(struct client *); 1927 int status_prompt_redraw(struct client *); 1928 int status_prompt_key(struct client *, key_code); 1929 void status_prompt_update(struct client *, const char *, const char *); 1930 void status_prompt_load_history(void); 1931 void status_prompt_save_history(void); 1932 1933 /* resize.c */ 1934 void recalculate_sizes(void); 1935 1936 /* input.c */ 1937 void input_init(struct window_pane *); 1938 void input_free(struct window_pane *); 1939 void input_reset(struct window_pane *, int); 1940 struct evbuffer *input_pending(struct window_pane *); 1941 void input_parse(struct window_pane *); 1942 1943 /* input-key.c */ 1944 void input_key(struct window_pane *, key_code, struct mouse_event *); 1945 1946 /* xterm-keys.c */ 1947 char *xterm_keys_lookup(key_code); 1948 int xterm_keys_find(const char *, size_t, size_t *, key_code *); 1949 1950 /* colour.c */ 1951 int colour_find_rgb(u_char, u_char, u_char); 1952 int colour_join_rgb(u_char, u_char, u_char); 1953 void colour_split_rgb(int, u_char *, u_char *, u_char *); 1954 const char *colour_tostring(int); 1955 int colour_fromstring(const char *s); 1956 u_char colour_256to16(u_char); 1957 1958 /* attributes.c */ 1959 const char *attributes_tostring(u_char); 1960 int attributes_fromstring(const char *); 1961 1962 /* grid.c */ 1963 extern const struct grid_cell grid_default_cell; 1964 int grid_cells_equal(const struct grid_cell *, const struct grid_cell *); 1965 struct grid *grid_create(u_int, u_int, u_int); 1966 void grid_destroy(struct grid *); 1967 int grid_compare(struct grid *, struct grid *); 1968 void grid_collect_history(struct grid *, u_int); 1969 void grid_scroll_history(struct grid *, u_int); 1970 void grid_scroll_history_region(struct grid *, u_int, u_int); 1971 void grid_clear_history(struct grid *); 1972 const struct grid_line *grid_peek_line(struct grid *, u_int); 1973 void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); 1974 void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *); 1975 void grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); 1976 void grid_clear_lines(struct grid *, u_int, u_int, u_int); 1977 void grid_move_lines(struct grid *, u_int, u_int, u_int, u_int); 1978 void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int); 1979 char *grid_string_cells(struct grid *, u_int, u_int, u_int, 1980 struct grid_cell **, int, int, int); 1981 void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int, 1982 u_int); 1983 u_int grid_reflow(struct grid *, struct grid *, u_int); 1984 1985 /* grid-view.c */ 1986 void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *); 1987 void grid_view_set_cell(struct grid *, u_int, u_int, 1988 const struct grid_cell *); 1989 void grid_view_clear_history(struct grid *, u_int); 1990 void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); 1991 void grid_view_scroll_region_up(struct grid *, u_int, u_int); 1992 void grid_view_scroll_region_down(struct grid *, u_int, u_int); 1993 void grid_view_insert_lines(struct grid *, u_int, u_int, u_int); 1994 void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int, 1995 u_int); 1996 void grid_view_delete_lines(struct grid *, u_int, u_int, u_int); 1997 void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int, 1998 u_int); 1999 void grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int); 2000 void grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int); 2001 char *grid_view_string_cells(struct grid *, u_int, u_int, u_int); 2002 2003 /* screen-write.c */ 2004 void screen_write_start(struct screen_write_ctx *, struct window_pane *, 2005 struct screen *); 2006 void screen_write_stop(struct screen_write_ctx *); 2007 void screen_write_reset(struct screen_write_ctx *); 2008 size_t printflike(1, 2) screen_write_cstrlen(const char *, ...); 2009 void printflike(4, 5) screen_write_cnputs(struct screen_write_ctx *, 2010 ssize_t, const struct grid_cell *, const char *, ...); 2011 size_t printflike(1, 2) screen_write_strlen(const char *, ...); 2012 void printflike(3, 4) screen_write_puts(struct screen_write_ctx *, 2013 const struct grid_cell *, const char *, ...); 2014 void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *, 2015 ssize_t, const struct grid_cell *, const char *, ...); 2016 void screen_write_vnputs(struct screen_write_ctx *, ssize_t, 2017 const struct grid_cell *, const char *, va_list); 2018 void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *, 2019 u_char); 2020 void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int, 2021 u_int, u_int, u_int, bitstr_t *, const struct grid_cell *); 2022 void screen_write_backspace(struct screen_write_ctx *); 2023 void screen_write_mode_set(struct screen_write_ctx *, int); 2024 void screen_write_mode_clear(struct screen_write_ctx *, int); 2025 void screen_write_cursorup(struct screen_write_ctx *, u_int); 2026 void screen_write_cursordown(struct screen_write_ctx *, u_int); 2027 void screen_write_cursorright(struct screen_write_ctx *, u_int); 2028 void screen_write_cursorleft(struct screen_write_ctx *, u_int); 2029 void screen_write_alignmenttest(struct screen_write_ctx *); 2030 void screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int); 2031 void screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int); 2032 void screen_write_clearcharacter(struct screen_write_ctx *, u_int); 2033 void screen_write_insertline(struct screen_write_ctx *, u_int, u_int); 2034 void screen_write_deleteline(struct screen_write_ctx *, u_int, u_int); 2035 void screen_write_clearline(struct screen_write_ctx *, u_int); 2036 void screen_write_clearendofline(struct screen_write_ctx *, u_int); 2037 void screen_write_clearstartofline(struct screen_write_ctx *, u_int); 2038 void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int); 2039 void screen_write_reverseindex(struct screen_write_ctx *); 2040 void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); 2041 void screen_write_linefeed(struct screen_write_ctx *, int); 2042 void screen_write_carriagereturn(struct screen_write_ctx *); 2043 void screen_write_clearendofscreen(struct screen_write_ctx *, u_int); 2044 void screen_write_clearstartofscreen(struct screen_write_ctx *); 2045 void screen_write_clearscreen(struct screen_write_ctx *, u_int); 2046 void screen_write_clearhistory(struct screen_write_ctx *); 2047 void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *); 2048 void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int); 2049 void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int); 2050 2051 /* screen-redraw.c */ 2052 void screen_redraw_update(struct client *); 2053 void screen_redraw_screen(struct client *, int, int, int); 2054 void screen_redraw_pane(struct client *, struct window_pane *); 2055 2056 /* screen.c */ 2057 void screen_init(struct screen *, u_int, u_int, u_int); 2058 void screen_reinit(struct screen *); 2059 void screen_free(struct screen *); 2060 void screen_reset_tabs(struct screen *); 2061 void screen_set_cursor_style(struct screen *, u_int); 2062 void screen_set_cursor_colour(struct screen *, const char *); 2063 void screen_set_title(struct screen *, const char *); 2064 void screen_resize(struct screen *, u_int, u_int, int); 2065 void screen_set_selection(struct screen *, 2066 u_int, u_int, u_int, u_int, u_int, struct grid_cell *); 2067 void screen_clear_selection(struct screen *); 2068 void screen_hide_selection(struct screen *); 2069 int screen_check_selection(struct screen *, u_int, u_int); 2070 void screen_select_cell(struct screen *, struct grid_cell *, 2071 const struct grid_cell *); 2072 2073 /* window.c */ 2074 extern struct windows windows; 2075 extern struct window_pane_tree all_window_panes; 2076 int window_cmp(struct window *, struct window *); 2077 RB_PROTOTYPE(windows, window, entry, window_cmp); 2078 int winlink_cmp(struct winlink *, struct winlink *); 2079 RB_PROTOTYPE(winlinks, winlink, entry, winlink_cmp); 2080 int window_pane_cmp(struct window_pane *, struct window_pane *); 2081 RB_PROTOTYPE(window_pane_tree, window_pane, tree_entry, window_pane_cmp); 2082 struct winlink *winlink_find_by_index(struct winlinks *, int); 2083 struct winlink *winlink_find_by_window(struct winlinks *, struct window *); 2084 struct winlink *winlink_find_by_window_id(struct winlinks *, u_int); 2085 u_int winlink_count(struct winlinks *); 2086 struct winlink *winlink_add(struct winlinks *, int); 2087 void winlink_set_window(struct winlink *, struct window *); 2088 void winlink_remove(struct winlinks *, struct winlink *); 2089 struct winlink *winlink_next(struct winlink *); 2090 struct winlink *winlink_previous(struct winlink *); 2091 struct winlink *winlink_next_by_number(struct winlink *, struct session *, 2092 int); 2093 struct winlink *winlink_previous_by_number(struct winlink *, struct session *, 2094 int); 2095 void winlink_stack_push(struct winlink_stack *, struct winlink *); 2096 void winlink_stack_remove(struct winlink_stack *, struct winlink *); 2097 struct window *window_find_by_id_str(const char *); 2098 struct window *window_find_by_id(u_int); 2099 void window_update_activity(struct window *); 2100 struct window *window_create(u_int, u_int); 2101 struct window *window_create_spawn(const char *, int, char **, const char *, 2102 const char *, const char *, struct environ *, 2103 struct termios *, u_int, u_int, u_int, char **); 2104 struct window_pane *window_get_active_at(struct window *, u_int, u_int); 2105 struct window_pane *window_find_string(struct window *, const char *); 2106 int window_has_pane(struct window *, struct window_pane *); 2107 int window_set_active_pane(struct window *, struct window_pane *); 2108 void window_redraw_active_switch(struct window *, 2109 struct window_pane *); 2110 struct window_pane *window_add_pane(struct window *, struct window_pane *, 2111 u_int); 2112 void window_resize(struct window *, u_int, u_int); 2113 int window_zoom(struct window_pane *); 2114 int window_unzoom(struct window *); 2115 void window_lost_pane(struct window *, struct window_pane *); 2116 void window_remove_pane(struct window *, struct window_pane *); 2117 struct window_pane *window_pane_at_index(struct window *, u_int); 2118 struct window_pane *window_pane_next_by_number(struct window *, 2119 struct window_pane *, u_int); 2120 struct window_pane *window_pane_previous_by_number(struct window *, 2121 struct window_pane *, u_int); 2122 int window_pane_index(struct window_pane *, u_int *); 2123 u_int window_count_panes(struct window *); 2124 void window_destroy_panes(struct window *); 2125 struct window_pane *window_pane_find_by_id_str(const char *); 2126 struct window_pane *window_pane_find_by_id(u_int); 2127 int window_pane_spawn(struct window_pane *, int, char **, 2128 const char *, const char *, const char *, struct environ *, 2129 struct termios *, char **); 2130 void window_pane_resize(struct window_pane *, u_int, u_int); 2131 void window_pane_alternate_on(struct window_pane *, 2132 struct grid_cell *, int); 2133 void window_pane_alternate_off(struct window_pane *, 2134 struct grid_cell *, int); 2135 void window_pane_set_palette(struct window_pane *, u_int, int); 2136 void window_pane_unset_palette(struct window_pane *, u_int); 2137 void window_pane_reset_palette(struct window_pane *); 2138 int window_pane_get_palette(const struct window_pane *, int); 2139 int window_pane_set_mode(struct window_pane *, 2140 const struct window_mode *); 2141 void window_pane_reset_mode(struct window_pane *); 2142 void window_pane_key(struct window_pane *, struct client *, 2143 struct session *, key_code, struct mouse_event *); 2144 int window_pane_outside(struct window_pane *); 2145 int window_pane_visible(struct window_pane *); 2146 char *window_pane_search(struct window_pane *, const char *, 2147 u_int *); 2148 char *window_printable_flags(struct session *, struct winlink *); 2149 struct window_pane *window_pane_find_up(struct window_pane *); 2150 struct window_pane *window_pane_find_down(struct window_pane *); 2151 struct window_pane *window_pane_find_left(struct window_pane *); 2152 struct window_pane *window_pane_find_right(struct window_pane *); 2153 void window_set_name(struct window *, const char *); 2154 void window_remove_ref(struct window *); 2155 void winlink_clear_flags(struct winlink *); 2156 int winlink_shuffle_up(struct session *, struct winlink *); 2157 2158 /* layout.c */ 2159 u_int layout_count_cells(struct layout_cell *); 2160 struct layout_cell *layout_create_cell(struct layout_cell *); 2161 void layout_free_cell(struct layout_cell *); 2162 void layout_print_cell(struct layout_cell *, const char *, u_int); 2163 void layout_destroy_cell(struct window *, struct layout_cell *, 2164 struct layout_cell **); 2165 void layout_set_size(struct layout_cell *, u_int, u_int, u_int, 2166 u_int); 2167 void layout_make_leaf(struct layout_cell *, struct window_pane *); 2168 void layout_make_node(struct layout_cell *, enum layout_type); 2169 void layout_fix_offsets(struct layout_cell *); 2170 void layout_fix_panes(struct window *, u_int, u_int); 2171 void layout_resize_adjust(struct window *, struct layout_cell *, 2172 enum layout_type, int); 2173 void layout_init(struct window *, struct window_pane *); 2174 void layout_free(struct window *); 2175 void layout_resize(struct window *, u_int, u_int); 2176 void layout_resize_pane(struct window_pane *, enum layout_type, 2177 int, int); 2178 void layout_resize_pane_to(struct window_pane *, enum layout_type, 2179 u_int); 2180 void layout_assign_pane(struct layout_cell *, struct window_pane *); 2181 struct layout_cell *layout_split_pane(struct window_pane *, enum layout_type, 2182 int, int, int); 2183 void layout_close_pane(struct window_pane *); 2184 2185 /* layout-custom.c */ 2186 char *layout_dump(struct layout_cell *); 2187 int layout_parse(struct window *, const char *); 2188 2189 /* layout-set.c */ 2190 int layout_set_lookup(const char *); 2191 u_int layout_set_select(struct window *, u_int); 2192 u_int layout_set_next(struct window *); 2193 u_int layout_set_previous(struct window *); 2194 2195 /* window-clock.c */ 2196 extern const struct window_mode window_clock_mode; 2197 extern const char window_clock_table[14][5][5]; 2198 2199 /* window-copy.c */ 2200 extern const struct window_mode window_copy_mode; 2201 void window_copy_init_from_pane(struct window_pane *, int); 2202 void window_copy_init_for_output(struct window_pane *); 2203 void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...); 2204 void window_copy_vadd(struct window_pane *, const char *, va_list); 2205 void window_copy_pageup(struct window_pane *, int); 2206 void window_copy_start_drag(struct client *, struct mouse_event *); 2207 int window_copy_scroll_position(struct window_pane *); 2208 2209 /* window-choose.c */ 2210 extern const struct window_mode window_choose_mode; 2211 void window_choose_add(struct window_pane *, 2212 struct window_choose_data *); 2213 void window_choose_ready(struct window_pane *, 2214 u_int, void (*)(struct window_choose_data *)); 2215 struct window_choose_data *window_choose_data_create (int, 2216 struct client *, struct session *); 2217 void window_choose_data_run(struct window_choose_data *); 2218 struct window_choose_data *window_choose_add_window(struct window_pane *, 2219 struct client *, struct session *, struct winlink *, 2220 const char *, const char *, u_int); 2221 struct window_choose_data *window_choose_add_session(struct window_pane *, 2222 struct client *, struct session *, const char *, 2223 const char *, u_int); 2224 void window_choose_expand_all(struct window_pane *); 2225 void window_choose_set_current(struct window_pane *, u_int); 2226 2227 /* names.c */ 2228 void check_window_name(struct window *); 2229 char *default_window_name(struct window *); 2230 char *parse_window_name(const char *); 2231 2232 /* signal.c */ 2233 void set_signals(void(*)(int, short, void *), void *); 2234 void clear_signals(int); 2235 2236 /* control.c */ 2237 void control_callback(struct client *, int, void *); 2238 void printflike(2, 3) control_write(struct client *, const char *, ...); 2239 void control_write_buffer(struct client *, struct evbuffer *); 2240 2241 /* control-notify.c */ 2242 void control_notify_input(struct client *, struct window_pane *, 2243 struct evbuffer *); 2244 void control_notify_window_layout_changed(struct window *); 2245 void control_notify_window_unlinked(struct session *, struct window *); 2246 void control_notify_window_linked(struct session *, struct window *); 2247 void control_notify_window_renamed(struct window *); 2248 void control_notify_client_session_changed(struct client *); 2249 void control_notify_session_renamed(struct session *); 2250 void control_notify_session_created(struct session *); 2251 void control_notify_session_closed(struct session *); 2252 2253 /* session.c */ 2254 extern struct sessions sessions; 2255 extern struct session_groups session_groups; 2256 int session_cmp(struct session *, struct session *); 2257 RB_PROTOTYPE(sessions, session, entry, session_cmp); 2258 int session_alive(struct session *); 2259 struct session *session_find(const char *); 2260 struct session *session_find_by_id_str(const char *); 2261 struct session *session_find_by_id(u_int); 2262 struct session *session_create(const char *, int, char **, const char *, 2263 const char *, struct environ *, struct termios *, int, 2264 u_int, u_int, char **); 2265 void session_destroy(struct session *); 2266 void session_unref(struct session *); 2267 int session_check_name(const char *); 2268 void session_update_activity(struct session *, struct timeval *); 2269 struct session *session_next_session(struct session *); 2270 struct session *session_previous_session(struct session *); 2271 struct winlink *session_new(struct session *, const char *, int, char **, 2272 const char *, const char *, int, char **); 2273 struct winlink *session_attach(struct session *, struct window *, int, 2274 char **); 2275 int session_detach(struct session *, struct winlink *); 2276 int session_has(struct session *, struct window *); 2277 int session_is_linked(struct session *, struct window *); 2278 int session_next(struct session *, int); 2279 int session_previous(struct session *, int); 2280 int session_select(struct session *, int); 2281 int session_last(struct session *); 2282 int session_set_current(struct session *, struct winlink *); 2283 struct session_group *session_group_find(struct session *); 2284 u_int session_group_index(struct session_group *); 2285 void session_group_add(struct session *, struct session *); 2286 void session_group_synchronize_to(struct session *); 2287 void session_group_synchronize_from(struct session *); 2288 void session_renumber_windows(struct session *); 2289 2290 /* utf8.c */ 2291 void utf8_set(struct utf8_data *, u_char); 2292 void utf8_copy(struct utf8_data *, const struct utf8_data *); 2293 enum utf8_state utf8_open(struct utf8_data *, u_char); 2294 enum utf8_state utf8_append(struct utf8_data *, u_char); 2295 enum utf8_state utf8_combine(const struct utf8_data *, wchar_t *); 2296 enum utf8_state utf8_split(wchar_t, struct utf8_data *); 2297 int utf8_strvis(char *, const char *, size_t, int); 2298 int utf8_stravis(char **, const char *, int); 2299 char *utf8_sanitize(const char *); 2300 size_t utf8_strlen(const struct utf8_data *); 2301 u_int utf8_strwidth(const struct utf8_data *, ssize_t); 2302 struct utf8_data *utf8_fromcstr(const char *); 2303 char *utf8_tocstr(struct utf8_data *); 2304 u_int utf8_cstrwidth(const char *); 2305 char *utf8_rtrimcstr(const char *, u_int); 2306 char *utf8_trimcstr(const char *, u_int); 2307 char *utf8_padcstr(const char *, u_int); 2308 2309 /* procname.c */ 2310 char *get_proc_name(int, char *); 2311 2312 /* log.c */ 2313 void log_add_level(void); 2314 int log_get_level(void); 2315 void log_open(const char *); 2316 void log_close(void); 2317 void printflike(1, 2) log_debug(const char *, ...); 2318 __dead void printflike(1, 2) fatal(const char *, ...); 2319 __dead void printflike(1, 2) fatalx(const char *, ...); 2320 2321 /* style.c */ 2322 int style_parse(const struct grid_cell *, 2323 struct grid_cell *, const char *); 2324 const char *style_tostring(struct grid_cell *); 2325 void style_apply(struct grid_cell *, struct options *, 2326 const char *); 2327 void style_apply_update(struct grid_cell *, struct options *, 2328 const char *); 2329 int style_equal(const struct grid_cell *, 2330 const struct grid_cell *); 2331 2332 #endif /* TMUX_H */ 2333