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