tmux.h 66 KB

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