options-table.c 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. /* $OpenBSD$ */
  2. /*
  3. * Copyright (c) 2011 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. #include <sys/types.h>
  18. #include <string.h>
  19. #include "tmux.h"
  20. /*
  21. * This file has a tables with all the server, session and window
  22. * options. These tables are the master copy of the options with their real
  23. * (user-visible) types, range limits and default values. At start these are
  24. * copied into the runtime global options trees (which only has number and
  25. * string types). These tables are then used to look up the real type when the
  26. * user sets an option or its value needs to be shown.
  27. */
  28. /* Choice option type lists. */
  29. const char *options_table_mode_keys_list[] = {
  30. "emacs", "vi", NULL
  31. };
  32. const char *options_table_clock_mode_style_list[] = {
  33. "12", "24", NULL
  34. };
  35. const char *options_table_status_keys_list[] = {
  36. "emacs", "vi", NULL
  37. };
  38. const char *options_table_status_justify_list[] = {
  39. "left", "centre", "right", NULL
  40. };
  41. const char *options_table_status_position_list[] = {
  42. "top", "bottom", NULL
  43. };
  44. const char *options_table_bell_action_list[] = {
  45. "none", "any", "current", "other", NULL
  46. };
  47. /* Server options. */
  48. const struct options_table_entry options_table[] = {
  49. { .name = "buffer-limit",
  50. .type = OPTIONS_TABLE_NUMBER,
  51. .scope = OPTIONS_TABLE_SERVER,
  52. .minimum = 1,
  53. .maximum = INT_MAX,
  54. .default_num = 20
  55. },
  56. { .name = "default-terminal",
  57. .type = OPTIONS_TABLE_STRING,
  58. .scope = OPTIONS_TABLE_SERVER,
  59. #ifdef TMATE
  60. .default_str = "screen-256color"
  61. #else
  62. .default_str = "screen"
  63. #endif
  64. },
  65. { .name = "escape-time",
  66. .type = OPTIONS_TABLE_NUMBER,
  67. .scope = OPTIONS_TABLE_SERVER,
  68. .minimum = 0,
  69. .maximum = INT_MAX,
  70. .default_num = 500
  71. },
  72. { .name = "exit-unattached",
  73. .type = OPTIONS_TABLE_FLAG,
  74. .scope = OPTIONS_TABLE_SERVER,
  75. .default_num = 0
  76. },
  77. { .name = "focus-events",
  78. .type = OPTIONS_TABLE_FLAG,
  79. .scope = OPTIONS_TABLE_SERVER,
  80. .default_num = 0
  81. },
  82. { .name = "history-file",
  83. .type = OPTIONS_TABLE_STRING,
  84. .scope = OPTIONS_TABLE_SERVER,
  85. .default_str = ""
  86. },
  87. { .name = "message-limit",
  88. .type = OPTIONS_TABLE_NUMBER,
  89. .scope = OPTIONS_TABLE_SERVER,
  90. .minimum = 0,
  91. .maximum = INT_MAX,
  92. #ifdef TMATE
  93. .default_num = 500
  94. #else
  95. .default_num = 100
  96. #endif
  97. },
  98. { .name = "quiet",
  99. .type = OPTIONS_TABLE_FLAG,
  100. .scope = OPTIONS_TABLE_SERVER,
  101. .default_num = 0
  102. },
  103. { .name = "set-clipboard",
  104. .type = OPTIONS_TABLE_FLAG,
  105. .scope = OPTIONS_TABLE_SERVER,
  106. .default_num = 1
  107. },
  108. { .name = "terminal-overrides",
  109. .type = OPTIONS_TABLE_STRING,
  110. .scope = OPTIONS_TABLE_SERVER,
  111. .default_str = "xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
  112. ":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
  113. ":Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT"
  114. },
  115. { .name = "assume-paste-time",
  116. .type = OPTIONS_TABLE_NUMBER,
  117. .scope = OPTIONS_TABLE_SESSION,
  118. .minimum = 0,
  119. .maximum = INT_MAX,
  120. .default_num = 1,
  121. },
  122. { .name = "base-index",
  123. .type = OPTIONS_TABLE_NUMBER,
  124. .scope = OPTIONS_TABLE_SESSION,
  125. .minimum = 0,
  126. .maximum = INT_MAX,
  127. .default_num = 0
  128. },
  129. { .name = "bell-action",
  130. .type = OPTIONS_TABLE_CHOICE,
  131. .scope = OPTIONS_TABLE_SESSION,
  132. .choices = options_table_bell_action_list,
  133. .default_num = BELL_ANY
  134. },
  135. { .name = "bell-on-alert",
  136. .type = OPTIONS_TABLE_FLAG,
  137. .scope = OPTIONS_TABLE_SESSION,
  138. .default_num = 0
  139. },
  140. { .name = "default-command",
  141. .type = OPTIONS_TABLE_STRING,
  142. .scope = OPTIONS_TABLE_SESSION,
  143. .default_str = ""
  144. },
  145. { .name = "default-shell",
  146. .type = OPTIONS_TABLE_STRING,
  147. .scope = OPTIONS_TABLE_SESSION,
  148. .default_str = _PATH_BSHELL
  149. },
  150. { .name = "destroy-unattached",
  151. .type = OPTIONS_TABLE_FLAG,
  152. .scope = OPTIONS_TABLE_SESSION,
  153. .default_num = 0
  154. },
  155. { .name = "detach-on-destroy",
  156. .type = OPTIONS_TABLE_FLAG,
  157. .scope = OPTIONS_TABLE_SESSION,
  158. .default_num = 1
  159. },
  160. { .name = "display-panes-active-colour",
  161. .type = OPTIONS_TABLE_COLOUR,
  162. .scope = OPTIONS_TABLE_SESSION,
  163. .default_num = 1
  164. },
  165. { .name = "display-panes-colour",
  166. .type = OPTIONS_TABLE_COLOUR,
  167. .scope = OPTIONS_TABLE_SESSION,
  168. .default_num = 4
  169. },
  170. { .name = "display-panes-time",
  171. .type = OPTIONS_TABLE_NUMBER,
  172. .scope = OPTIONS_TABLE_SESSION,
  173. .minimum = 1,
  174. .maximum = INT_MAX,
  175. .default_num = 1000
  176. },
  177. { .name = "display-time",
  178. .type = OPTIONS_TABLE_NUMBER,
  179. .scope = OPTIONS_TABLE_SESSION,
  180. .minimum = 0,
  181. .maximum = INT_MAX,
  182. .default_num = 750
  183. },
  184. { .name = "history-limit",
  185. .type = OPTIONS_TABLE_NUMBER,
  186. .scope = OPTIONS_TABLE_SESSION,
  187. .minimum = 0,
  188. .maximum = INT_MAX,
  189. .default_num = 2000
  190. },
  191. { .name = "key-table",
  192. .type = OPTIONS_TABLE_STRING,
  193. .scope = OPTIONS_TABLE_SESSION,
  194. .default_str = "root"
  195. },
  196. { .name = "lock-after-time",
  197. .type = OPTIONS_TABLE_NUMBER,
  198. .scope = OPTIONS_TABLE_SESSION,
  199. .minimum = 0,
  200. .maximum = INT_MAX,
  201. .default_num = 0
  202. },
  203. { .name = "lock-command",
  204. .type = OPTIONS_TABLE_STRING,
  205. .scope = OPTIONS_TABLE_SESSION,
  206. .default_str = "lock -np"
  207. },
  208. { .name = "message-attr",
  209. .type = OPTIONS_TABLE_ATTRIBUTES,
  210. .scope = OPTIONS_TABLE_SESSION,
  211. .default_num = 0,
  212. .style = "message-style"
  213. },
  214. { .name = "message-bg",
  215. .type = OPTIONS_TABLE_COLOUR,
  216. .scope = OPTIONS_TABLE_SESSION,
  217. .default_num = 3,
  218. .style = "message-style"
  219. },
  220. { .name = "message-command-attr",
  221. .type = OPTIONS_TABLE_ATTRIBUTES,
  222. .scope = OPTIONS_TABLE_SESSION,
  223. .default_num = 0,
  224. .style = "message-command-style"
  225. },
  226. { .name = "message-command-bg",
  227. .type = OPTIONS_TABLE_COLOUR,
  228. .scope = OPTIONS_TABLE_SESSION,
  229. .default_num = 0,
  230. .style = "message-command-style"
  231. },
  232. { .name = "message-command-fg",
  233. .type = OPTIONS_TABLE_COLOUR,
  234. .scope = OPTIONS_TABLE_SESSION,
  235. .default_num = 3,
  236. .style = "message-command-style"
  237. },
  238. { .name = "message-command-style",
  239. .type = OPTIONS_TABLE_STYLE,
  240. .scope = OPTIONS_TABLE_SESSION,
  241. .default_str = "bg=black,fg=yellow"
  242. },
  243. { .name = "message-fg",
  244. .type = OPTIONS_TABLE_COLOUR,
  245. .scope = OPTIONS_TABLE_SESSION,
  246. .default_num = 0,
  247. .style = "message-style"
  248. },
  249. { .name = "message-style",
  250. .type = OPTIONS_TABLE_STYLE,
  251. .scope = OPTIONS_TABLE_SESSION,
  252. .default_str = "bg=yellow,fg=black"
  253. },
  254. { .name = "mouse",
  255. .type = OPTIONS_TABLE_FLAG,
  256. .scope = OPTIONS_TABLE_SESSION,
  257. .default_num = 0
  258. },
  259. { .name = "prefix",
  260. .type = OPTIONS_TABLE_KEY,
  261. .scope = OPTIONS_TABLE_SESSION,
  262. .default_num = '\002',
  263. },
  264. { .name = "prefix2",
  265. .type = OPTIONS_TABLE_KEY,
  266. .scope = OPTIONS_TABLE_SESSION,
  267. .default_num = KEYC_NONE,
  268. },
  269. { .name = "renumber-windows",
  270. .type = OPTIONS_TABLE_FLAG,
  271. .scope = OPTIONS_TABLE_SESSION,
  272. .default_num = 0
  273. },
  274. { .name = "repeat-time",
  275. .type = OPTIONS_TABLE_NUMBER,
  276. .scope = OPTIONS_TABLE_SESSION,
  277. .minimum = 0,
  278. .maximum = SHRT_MAX,
  279. .default_num = 500
  280. },
  281. { .name = "set-remain-on-exit",
  282. .type = OPTIONS_TABLE_FLAG,
  283. .scope = OPTIONS_TABLE_SESSION,
  284. .default_num = 0
  285. },
  286. { .name = "set-titles",
  287. .type = OPTIONS_TABLE_FLAG,
  288. .scope = OPTIONS_TABLE_SESSION,
  289. .default_num = 0
  290. },
  291. { .name = "set-titles-string",
  292. .type = OPTIONS_TABLE_STRING,
  293. .scope = OPTIONS_TABLE_SESSION,
  294. .default_str = "#S:#I:#W - \"#T\" #{session_alerts}"
  295. },
  296. { .name = "status",
  297. .type = OPTIONS_TABLE_FLAG,
  298. .scope = OPTIONS_TABLE_SESSION,
  299. .default_num = 1
  300. },
  301. { .name = "status-attr",
  302. .type = OPTIONS_TABLE_ATTRIBUTES,
  303. .scope = OPTIONS_TABLE_SESSION,
  304. .default_num = 0,
  305. .style = "status-style"
  306. },
  307. { .name = "status-bg",
  308. .type = OPTIONS_TABLE_COLOUR,
  309. .scope = OPTIONS_TABLE_SESSION,
  310. .default_num = 2,
  311. .style = "status-style"
  312. },
  313. { .name = "status-fg",
  314. .type = OPTIONS_TABLE_COLOUR,
  315. .scope = OPTIONS_TABLE_SESSION,
  316. .default_num = 0,
  317. .style = "status-style"
  318. },
  319. { .name = "status-interval",
  320. .type = OPTIONS_TABLE_NUMBER,
  321. .scope = OPTIONS_TABLE_SESSION,
  322. .minimum = 0,
  323. .maximum = INT_MAX,
  324. .default_num = 15
  325. },
  326. { .name = "status-justify",
  327. .type = OPTIONS_TABLE_CHOICE,
  328. .scope = OPTIONS_TABLE_SESSION,
  329. .choices = options_table_status_justify_list,
  330. .default_num = 0
  331. },
  332. { .name = "status-keys",
  333. .type = OPTIONS_TABLE_CHOICE,
  334. .scope = OPTIONS_TABLE_SESSION,
  335. .choices = options_table_status_keys_list,
  336. .default_num = MODEKEY_EMACS
  337. },
  338. { .name = "status-left",
  339. .type = OPTIONS_TABLE_STRING,
  340. .scope = OPTIONS_TABLE_SESSION,
  341. .default_str = "[#S] "
  342. },
  343. { .name = "status-left-attr",
  344. .type = OPTIONS_TABLE_ATTRIBUTES,
  345. .scope = OPTIONS_TABLE_SESSION,
  346. .default_num = 0,
  347. .style = "status-left-style"
  348. },
  349. { .name = "status-left-bg",
  350. .type = OPTIONS_TABLE_COLOUR,
  351. .scope = OPTIONS_TABLE_SESSION,
  352. .default_num = 8,
  353. .style = "status-left-style"
  354. },
  355. { .name = "status-left-fg",
  356. .type = OPTIONS_TABLE_COLOUR,
  357. .scope = OPTIONS_TABLE_SESSION,
  358. .default_num = 8,
  359. .style = "status-left-style"
  360. },
  361. { .name = "status-left-length",
  362. .type = OPTIONS_TABLE_NUMBER,
  363. .scope = OPTIONS_TABLE_SESSION,
  364. .minimum = 0,
  365. .maximum = SHRT_MAX,
  366. .default_num = 10
  367. },
  368. { .name = "status-left-style",
  369. .type = OPTIONS_TABLE_STYLE,
  370. .scope = OPTIONS_TABLE_SESSION,
  371. .default_str = "default"
  372. },
  373. { .name = "status-position",
  374. .type = OPTIONS_TABLE_CHOICE,
  375. .scope = OPTIONS_TABLE_SESSION,
  376. .choices = options_table_status_position_list,
  377. .default_num = 1
  378. },
  379. { .name = "status-right",
  380. .type = OPTIONS_TABLE_STRING,
  381. .scope = OPTIONS_TABLE_SESSION,
  382. .default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
  383. },
  384. { .name = "status-right-attr",
  385. .type = OPTIONS_TABLE_ATTRIBUTES,
  386. .scope = OPTIONS_TABLE_SESSION,
  387. .default_num = 0,
  388. .style = "status-right-style"
  389. },
  390. { .name = "status-right-bg",
  391. .type = OPTIONS_TABLE_COLOUR,
  392. .scope = OPTIONS_TABLE_SESSION,
  393. .default_num = 8,
  394. .style = "status-right-style"
  395. },
  396. { .name = "status-right-fg",
  397. .type = OPTIONS_TABLE_COLOUR,
  398. .scope = OPTIONS_TABLE_SESSION,
  399. .default_num = 8,
  400. .style = "status-right-style"
  401. },
  402. { .name = "status-right-length",
  403. .type = OPTIONS_TABLE_NUMBER,
  404. .scope = OPTIONS_TABLE_SESSION,
  405. .minimum = 0,
  406. .maximum = SHRT_MAX,
  407. .default_num = 40
  408. },
  409. { .name = "status-right-style",
  410. .type = OPTIONS_TABLE_STYLE,
  411. .scope = OPTIONS_TABLE_SESSION,
  412. .default_str = "default"
  413. },
  414. { .name = "status-style",
  415. .type = OPTIONS_TABLE_STYLE,
  416. .scope = OPTIONS_TABLE_SESSION,
  417. .default_str = "bg=green,fg=black"
  418. },
  419. { .name = "update-environment",
  420. .type = OPTIONS_TABLE_STRING,
  421. .scope = OPTIONS_TABLE_SESSION,
  422. .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
  423. "SSH_CONNECTION WINDOWID XAUTHORITY"
  424. },
  425. { .name = "visual-activity",
  426. .type = OPTIONS_TABLE_FLAG,
  427. .scope = OPTIONS_TABLE_SESSION,
  428. .default_num = 0
  429. },
  430. { .name = "visual-bell",
  431. .type = OPTIONS_TABLE_FLAG,
  432. .scope = OPTIONS_TABLE_SESSION,
  433. .default_num = 0
  434. },
  435. { .name = "visual-silence",
  436. .type = OPTIONS_TABLE_FLAG,
  437. .scope = OPTIONS_TABLE_SESSION,
  438. .default_num = 0
  439. },
  440. { .name = "word-separators",
  441. .type = OPTIONS_TABLE_STRING,
  442. .scope = OPTIONS_TABLE_SESSION,
  443. .default_str = " -_@"
  444. },
  445. { .name = "aggressive-resize",
  446. .type = OPTIONS_TABLE_FLAG,
  447. .scope = OPTIONS_TABLE_WINDOW,
  448. .default_num = 0
  449. },
  450. { .name = "allow-rename",
  451. .type = OPTIONS_TABLE_FLAG,
  452. .scope = OPTIONS_TABLE_WINDOW,
  453. .default_num = 1
  454. },
  455. { .name = "alternate-screen",
  456. .type = OPTIONS_TABLE_FLAG,
  457. .scope = OPTIONS_TABLE_WINDOW,
  458. .default_num = 1
  459. },
  460. { .name = "automatic-rename",
  461. .type = OPTIONS_TABLE_FLAG,
  462. .scope = OPTIONS_TABLE_WINDOW,
  463. .default_num = 1
  464. },
  465. { .name = "automatic-rename-format",
  466. .type = OPTIONS_TABLE_STRING,
  467. .scope = OPTIONS_TABLE_WINDOW,
  468. .default_str = "#{?pane_in_mode,[tmux],#{pane_current_command}}"
  469. "#{?pane_dead,[dead],}"
  470. },
  471. { .name = "clock-mode-colour",
  472. .type = OPTIONS_TABLE_COLOUR,
  473. .scope = OPTIONS_TABLE_WINDOW,
  474. .default_num = 4
  475. },
  476. { .name = "clock-mode-style",
  477. .type = OPTIONS_TABLE_CHOICE,
  478. .scope = OPTIONS_TABLE_WINDOW,
  479. .choices = options_table_clock_mode_style_list,
  480. .default_num = 1
  481. },
  482. { .name = "force-height",
  483. .type = OPTIONS_TABLE_NUMBER,
  484. .scope = OPTIONS_TABLE_WINDOW,
  485. .minimum = 0,
  486. .maximum = INT_MAX,
  487. .default_num = 0
  488. },
  489. { .name = "force-width",
  490. .type = OPTIONS_TABLE_NUMBER,
  491. .scope = OPTIONS_TABLE_WINDOW,
  492. .minimum = 0,
  493. .maximum = INT_MAX,
  494. .default_num = 0
  495. },
  496. { .name = "main-pane-height",
  497. .type = OPTIONS_TABLE_NUMBER,
  498. .scope = OPTIONS_TABLE_WINDOW,
  499. .minimum = 1,
  500. .maximum = INT_MAX,
  501. .default_num = 24
  502. },
  503. { .name = "main-pane-width",
  504. .type = OPTIONS_TABLE_NUMBER,
  505. .scope = OPTIONS_TABLE_WINDOW,
  506. .minimum = 1,
  507. .maximum = INT_MAX,
  508. .default_num = 80
  509. },
  510. { .name = "mode-attr",
  511. .type = OPTIONS_TABLE_ATTRIBUTES,
  512. .scope = OPTIONS_TABLE_WINDOW,
  513. .default_num = 0,
  514. .style = "mode-style"
  515. },
  516. { .name = "mode-bg",
  517. .type = OPTIONS_TABLE_COLOUR,
  518. .scope = OPTIONS_TABLE_WINDOW,
  519. .default_num = 3,
  520. .style = "mode-style"
  521. },
  522. { .name = "mode-fg",
  523. .type = OPTIONS_TABLE_COLOUR,
  524. .scope = OPTIONS_TABLE_WINDOW,
  525. .default_num = 0,
  526. .style = "mode-style"
  527. },
  528. { .name = "mode-keys",
  529. .type = OPTIONS_TABLE_CHOICE,
  530. .scope = OPTIONS_TABLE_WINDOW,
  531. .choices = options_table_mode_keys_list,
  532. .default_num = MODEKEY_EMACS
  533. },
  534. { .name = "mode-style",
  535. .type = OPTIONS_TABLE_STYLE,
  536. .scope = OPTIONS_TABLE_WINDOW,
  537. .default_str = "bg=yellow,fg=black"
  538. },
  539. { .name = "monitor-activity",
  540. .type = OPTIONS_TABLE_FLAG,
  541. .scope = OPTIONS_TABLE_WINDOW,
  542. .default_num = 0
  543. },
  544. { .name = "monitor-silence",
  545. .type = OPTIONS_TABLE_NUMBER,
  546. .scope = OPTIONS_TABLE_WINDOW,
  547. .minimum = 0,
  548. .maximum = INT_MAX,
  549. .default_num = 0
  550. },
  551. { .name = "other-pane-height",
  552. .type = OPTIONS_TABLE_NUMBER,
  553. .scope = OPTIONS_TABLE_WINDOW,
  554. .minimum = 0,
  555. .maximum = INT_MAX,
  556. .default_num = 0
  557. },
  558. { .name = "other-pane-width",
  559. .type = OPTIONS_TABLE_NUMBER,
  560. .scope = OPTIONS_TABLE_WINDOW,
  561. .minimum = 0,
  562. .maximum = INT_MAX,
  563. .default_num = 0
  564. },
  565. { .name = "pane-active-border-bg",
  566. .type = OPTIONS_TABLE_COLOUR,
  567. .scope = OPTIONS_TABLE_WINDOW,
  568. .default_num = 8,
  569. .style = "pane-active-border-style"
  570. },
  571. { .name = "pane-active-border-fg",
  572. .type = OPTIONS_TABLE_COLOUR,
  573. .scope = OPTIONS_TABLE_WINDOW,
  574. .default_num = 2,
  575. .style = "pane-active-border-style"
  576. },
  577. { .name = "pane-active-border-style",
  578. .type = OPTIONS_TABLE_STYLE,
  579. .scope = OPTIONS_TABLE_WINDOW,
  580. .default_str = "fg=green"
  581. },
  582. { .name = "pane-base-index",
  583. .type = OPTIONS_TABLE_NUMBER,
  584. .scope = OPTIONS_TABLE_WINDOW,
  585. .minimum = 0,
  586. .maximum = USHRT_MAX,
  587. .default_num = 0
  588. },
  589. { .name = "pane-border-bg",
  590. .type = OPTIONS_TABLE_COLOUR,
  591. .scope = OPTIONS_TABLE_WINDOW,
  592. .default_num = 8,
  593. .style = "pane-border-style"
  594. },
  595. { .name = "pane-border-fg",
  596. .type = OPTIONS_TABLE_COLOUR,
  597. .scope = OPTIONS_TABLE_WINDOW,
  598. .default_num = 8,
  599. .style = "pane-border-style"
  600. },
  601. { .name = "pane-border-style",
  602. .type = OPTIONS_TABLE_STYLE,
  603. .scope = OPTIONS_TABLE_WINDOW,
  604. .default_str = "default"
  605. },
  606. { .name = "remain-on-exit",
  607. .type = OPTIONS_TABLE_FLAG,
  608. .scope = OPTIONS_TABLE_WINDOW,
  609. .default_num = 0
  610. },
  611. { .name = "synchronize-panes",
  612. .type = OPTIONS_TABLE_FLAG,
  613. .scope = OPTIONS_TABLE_WINDOW,
  614. .default_num = 0
  615. },
  616. { .name = "window-active-style",
  617. .type = OPTIONS_TABLE_STYLE,
  618. .scope = OPTIONS_TABLE_WINDOW,
  619. .default_str = "default"
  620. },
  621. { .name = "window-style",
  622. .type = OPTIONS_TABLE_STYLE,
  623. .scope = OPTIONS_TABLE_WINDOW,
  624. .default_str = "default"
  625. },
  626. { .name = "window-status-activity-attr",
  627. .type = OPTIONS_TABLE_ATTRIBUTES,
  628. .scope = OPTIONS_TABLE_WINDOW,
  629. .default_num = GRID_ATTR_REVERSE,
  630. .style = "window-status-activity-style"
  631. },
  632. { .name = "window-status-activity-bg",
  633. .type = OPTIONS_TABLE_COLOUR,
  634. .scope = OPTIONS_TABLE_WINDOW,
  635. .default_num = 8,
  636. .style = "window-status-activity-style"
  637. },
  638. { .name = "window-status-activity-fg",
  639. .type = OPTIONS_TABLE_COLOUR,
  640. .scope = OPTIONS_TABLE_WINDOW,
  641. .default_num = 8,
  642. .style = "window-status-activity-style"
  643. },
  644. { .name = "window-status-activity-style",
  645. .type = OPTIONS_TABLE_STYLE,
  646. .scope = OPTIONS_TABLE_WINDOW,
  647. .default_str = "reverse"
  648. },
  649. { .name = "window-status-attr",
  650. .type = OPTIONS_TABLE_ATTRIBUTES,
  651. .scope = OPTIONS_TABLE_WINDOW,
  652. .default_num = 0,
  653. .style = "window-status-style"
  654. },
  655. { .name = "window-status-bell-attr",
  656. .type = OPTIONS_TABLE_ATTRIBUTES,
  657. .scope = OPTIONS_TABLE_WINDOW,
  658. .default_num = GRID_ATTR_REVERSE,
  659. .style = "window-status-bell-style"
  660. },
  661. { .name = "window-status-bell-bg",
  662. .type = OPTIONS_TABLE_COLOUR,
  663. .scope = OPTIONS_TABLE_WINDOW,
  664. .default_num = 8,
  665. .style = "window-status-bell-style"
  666. },
  667. { .name = "window-status-bell-fg",
  668. .type = OPTIONS_TABLE_COLOUR,
  669. .scope = OPTIONS_TABLE_WINDOW,
  670. .default_num = 8,
  671. .style = "window-status-bell-style"
  672. },
  673. { .name = "window-status-bell-style",
  674. .type = OPTIONS_TABLE_STYLE,
  675. .scope = OPTIONS_TABLE_WINDOW,
  676. .default_str = "reverse"
  677. },
  678. { .name = "window-status-bg",
  679. .type = OPTIONS_TABLE_COLOUR,
  680. .scope = OPTIONS_TABLE_WINDOW,
  681. .default_num = 8,
  682. .style = "window-status-style"
  683. },
  684. { .name = "window-status-current-attr",
  685. .type = OPTIONS_TABLE_ATTRIBUTES,
  686. .scope = OPTIONS_TABLE_WINDOW,
  687. .default_num = 0,
  688. .style = "window-status-current-style"
  689. },
  690. { .name = "window-status-current-bg",
  691. .type = OPTIONS_TABLE_COLOUR,
  692. .scope = OPTIONS_TABLE_WINDOW,
  693. .default_num = 8,
  694. .style = "window-status-current-style"
  695. },
  696. { .name = "window-status-current-fg",
  697. .type = OPTIONS_TABLE_COLOUR,
  698. .scope = OPTIONS_TABLE_WINDOW,
  699. .default_num = 8,
  700. .style = "window-status-current-style"
  701. },
  702. { .name = "window-status-current-format",
  703. .type = OPTIONS_TABLE_STRING,
  704. .scope = OPTIONS_TABLE_WINDOW,
  705. .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
  706. },
  707. { .name = "window-status-current-style",
  708. .type = OPTIONS_TABLE_STYLE,
  709. .scope = OPTIONS_TABLE_WINDOW,
  710. .default_str = "default"
  711. },
  712. { .name = "window-status-fg",
  713. .type = OPTIONS_TABLE_COLOUR,
  714. .scope = OPTIONS_TABLE_WINDOW,
  715. .default_num = 8,
  716. .style = "window-status-style"
  717. },
  718. { .name = "window-status-format",
  719. .type = OPTIONS_TABLE_STRING,
  720. .scope = OPTIONS_TABLE_WINDOW,
  721. .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
  722. },
  723. { .name = "window-status-last-attr",
  724. .type = OPTIONS_TABLE_ATTRIBUTES,
  725. .scope = OPTIONS_TABLE_WINDOW,
  726. .default_num = 0,
  727. .style = "window-status-last-style"
  728. },
  729. { .name = "window-status-last-bg",
  730. .type = OPTIONS_TABLE_COLOUR,
  731. .scope = OPTIONS_TABLE_WINDOW,
  732. .default_num = 8,
  733. .style = "window-status-last-style"
  734. },
  735. { .name = "window-status-last-fg",
  736. .type = OPTIONS_TABLE_COLOUR,
  737. .scope = OPTIONS_TABLE_WINDOW,
  738. .default_num = 8,
  739. .style = "window-status-last-style"
  740. },
  741. { .name = "window-status-last-style",
  742. .type = OPTIONS_TABLE_STYLE,
  743. .scope = OPTIONS_TABLE_WINDOW,
  744. .default_str = "default"
  745. },
  746. { .name = "window-status-separator",
  747. .type = OPTIONS_TABLE_STRING,
  748. .scope = OPTIONS_TABLE_WINDOW,
  749. .default_str = " "
  750. },
  751. { .name = "window-status-style",
  752. .type = OPTIONS_TABLE_STYLE,
  753. .scope = OPTIONS_TABLE_WINDOW,
  754. .default_str = "default"
  755. },
  756. { .name = "wrap-search",
  757. .type = OPTIONS_TABLE_FLAG,
  758. .scope = OPTIONS_TABLE_WINDOW,
  759. .default_num = 1
  760. },
  761. { .name = "xterm-keys",
  762. .type = OPTIONS_TABLE_FLAG,
  763. .scope = OPTIONS_TABLE_WINDOW,
  764. .default_num = 0
  765. },
  766. #ifdef TMATE
  767. { .name = "tmate-identity",
  768. .type = OPTIONS_TABLE_STRING,
  769. .scope = OPTIONS_TABLE_SERVER,
  770. .default_str = ""
  771. },
  772. { .name = "tmate-server-host",
  773. .type = OPTIONS_TABLE_STRING,
  774. .scope = OPTIONS_TABLE_SERVER,
  775. .default_str = "ssh.tmate.io"
  776. },
  777. { .name = "tmate-server-port",
  778. .type = OPTIONS_TABLE_NUMBER,
  779. .scope = OPTIONS_TABLE_SERVER,
  780. .minimum = 1,
  781. .maximum = 65535,
  782. .default_num = 22
  783. },
  784. { .name = "tmate-server-dsa-fingerprint",
  785. .type = OPTIONS_TABLE_STRING,
  786. .scope = OPTIONS_TABLE_SERVER,
  787. .default_str = "obsolete"
  788. },
  789. { .name = "tmate-server-rsa-fingerprint",
  790. .type = OPTIONS_TABLE_STRING,
  791. .scope = OPTIONS_TABLE_SERVER,
  792. .default_str = "af:2d:81:c1:fe:49:70:2d:7f:09:a9:d7:4b:32:e3:be"
  793. },
  794. { .name = "tmate-server-ecdsa-fingerprint",
  795. .type = OPTIONS_TABLE_STRING,
  796. .scope = OPTIONS_TABLE_SERVER,
  797. .default_str = "c7:a1:51:36:d2:bb:35:4b:0a:1a:c0:43:97:74:ea:42"
  798. },
  799. { .name = "tmate-display-time",
  800. .type = OPTIONS_TABLE_NUMBER,
  801. .scope = OPTIONS_TABLE_SESSION,
  802. .minimum = 1,
  803. .maximum = INT_MAX,
  804. .default_num = 15000
  805. },
  806. { .name = "tmate-webhook-userdata",
  807. .type = OPTIONS_TABLE_STRING,
  808. .scope = OPTIONS_TABLE_SERVER,
  809. .default_str = ""
  810. },
  811. { .name = "tmate-webhook-url",
  812. .type = OPTIONS_TABLE_STRING,
  813. .scope = OPTIONS_TABLE_SERVER,
  814. .default_str = ""
  815. },
  816. #endif
  817. { .name = NULL }
  818. };
  819. /* Populate an options tree from a table. */
  820. void
  821. options_table_populate_tree(enum options_table_scope scope, struct options *oo)
  822. {
  823. const struct options_table_entry *oe;
  824. for (oe = options_table; oe->name != NULL; oe++) {
  825. if (oe->scope == OPTIONS_TABLE_NONE)
  826. fatalx("no scope for %s", oe->name);
  827. if (oe->scope != scope)
  828. continue;
  829. switch (oe->type) {
  830. case OPTIONS_TABLE_STRING:
  831. options_set_string(oo, oe->name, "%s", oe->default_str);
  832. break;
  833. case OPTIONS_TABLE_STYLE:
  834. options_set_style(oo, oe->name, oe->default_str, 0);
  835. break;
  836. default:
  837. options_set_number(oo, oe->name, oe->default_num);
  838. break;
  839. }
  840. }
  841. }
  842. /* Print an option using its type from the table. */
  843. const char *
  844. options_table_print_entry(const struct options_table_entry *oe,
  845. struct options_entry *o, int no_quotes)
  846. {
  847. static char out[BUFSIZ];
  848. const char *s;
  849. *out = '\0';
  850. switch (oe->type) {
  851. case OPTIONS_TABLE_STRING:
  852. if (no_quotes)
  853. xsnprintf(out, sizeof out, "%s", o->str);
  854. else
  855. xsnprintf(out, sizeof out, "\"%s\"", o->str);
  856. break;
  857. case OPTIONS_TABLE_NUMBER:
  858. xsnprintf(out, sizeof out, "%lld", o->num);
  859. break;
  860. case OPTIONS_TABLE_KEY:
  861. xsnprintf(out, sizeof out, "%s",
  862. key_string_lookup_key(o->num));
  863. break;
  864. case OPTIONS_TABLE_COLOUR:
  865. s = colour_tostring(o->num);
  866. xsnprintf(out, sizeof out, "%s", s);
  867. break;
  868. case OPTIONS_TABLE_ATTRIBUTES:
  869. s = attributes_tostring(o->num);
  870. xsnprintf(out, sizeof out, "%s", s);
  871. break;
  872. case OPTIONS_TABLE_FLAG:
  873. if (o->num)
  874. strlcpy(out, "on", sizeof out);
  875. else
  876. strlcpy(out, "off", sizeof out);
  877. break;
  878. case OPTIONS_TABLE_CHOICE:
  879. s = oe->choices[o->num];
  880. xsnprintf(out, sizeof out, "%s", s);
  881. break;
  882. case OPTIONS_TABLE_STYLE:
  883. s = style_tostring(&o->style);
  884. xsnprintf(out, sizeof out, "%s", s);
  885. break;
  886. }
  887. return (out);
  888. }
  889. /* Find an option. */
  890. int
  891. options_table_find(const char *optstr, const struct options_table_entry **oe)
  892. {
  893. const struct options_table_entry *oe_loop;
  894. for (oe_loop = options_table; oe_loop->name != NULL; oe_loop++) {
  895. if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
  896. continue;
  897. /* If already found, ambiguous. */
  898. if (*oe != NULL)
  899. return (-1);
  900. *oe = oe_loop;
  901. /* Bail now if an exact match. */
  902. if (strcmp(oe_loop->name, optstr) == 0)
  903. break;
  904. }
  905. return (0);
  906. }