tmux  3.2a
About: tmux is a terminal multiplexer that lets you switch easily between several programs in one terminal.
  Fossies Dox: tmux-3.2a.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

tty-term.c
Go to the documentation of this file.
1 /* $OpenBSD$ */
2 
3 /*
4  * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include <sys/types.h>
20 
21 #if defined(HAVE_CURSES_H)
22 #include <curses.h>
23 #elif defined(HAVE_NCURSES_H)
24 #include <ncurses.h>
25 #endif
26 #include <fnmatch.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <term.h>
30 
31 #include "tmux.h"
32 
33 static char *tty_term_strip(const char *);
34 
35 struct tty_terms tty_terms = LIST_HEAD_INITIALIZER(tty_terms);
36 
42 };
43 
44 struct tty_code {
45  enum tty_code_type type;
46  union {
47  char *string;
48  int number;
49  int flag;
50  } value;
51 };
52 
54  enum tty_code_type type;
55  const char *name;
56 };
57 
58 static const struct tty_term_code_entry tty_term_codes[] = {
59  [TTYC_ACSC] = { TTYCODE_STRING, "acsc" },
60  [TTYC_AM] = { TTYCODE_FLAG, "am" },
61  [TTYC_AX] = { TTYCODE_FLAG, "AX" },
62  [TTYC_BCE] = { TTYCODE_FLAG, "bce" },
63  [TTYC_BEL] = { TTYCODE_STRING, "bel" },
64  [TTYC_BIDI] = { TTYCODE_STRING, "Bidi" },
65  [TTYC_BLINK] = { TTYCODE_STRING, "blink" },
66  [TTYC_BOLD] = { TTYCODE_STRING, "bold" },
67  [TTYC_CIVIS] = { TTYCODE_STRING, "civis" },
68  [TTYC_CLEAR] = { TTYCODE_STRING, "clear" },
69  [TTYC_CLMG] = { TTYCODE_STRING, "Clmg" },
70  [TTYC_CMG] = { TTYCODE_STRING, "Cmg" },
71  [TTYC_CNORM] = { TTYCODE_STRING, "cnorm" },
72  [TTYC_COLORS] = { TTYCODE_NUMBER, "colors" },
73  [TTYC_CR] = { TTYCODE_STRING, "Cr" },
74  [TTYC_CSR] = { TTYCODE_STRING, "csr" },
75  [TTYC_CS] = { TTYCODE_STRING, "Cs" },
76  [TTYC_CUB1] = { TTYCODE_STRING, "cub1" },
77  [TTYC_CUB] = { TTYCODE_STRING, "cub" },
78  [TTYC_CUD1] = { TTYCODE_STRING, "cud1" },
79  [TTYC_CUD] = { TTYCODE_STRING, "cud" },
80  [TTYC_CUF1] = { TTYCODE_STRING, "cuf1" },
81  [TTYC_CUF] = { TTYCODE_STRING, "cuf" },
82  [TTYC_CUP] = { TTYCODE_STRING, "cup" },
83  [TTYC_CUU1] = { TTYCODE_STRING, "cuu1" },
84  [TTYC_CUU] = { TTYCODE_STRING, "cuu" },
85  [TTYC_CVVIS] = { TTYCODE_STRING, "cvvis" },
86  [TTYC_DCH1] = { TTYCODE_STRING, "dch1" },
87  [TTYC_DCH] = { TTYCODE_STRING, "dch" },
88  [TTYC_DIM] = { TTYCODE_STRING, "dim" },
89  [TTYC_DL1] = { TTYCODE_STRING, "dl1" },
90  [TTYC_DL] = { TTYCODE_STRING, "dl" },
91  [TTYC_DSEKS] = { TTYCODE_STRING, "Dseks" },
92  [TTYC_DSFCS] = { TTYCODE_STRING, "Dsfcs" },
93  [TTYC_DSBP] = { TTYCODE_STRING, "Dsbp" },
94  [TTYC_DSMG] = { TTYCODE_STRING, "Dsmg" },
95  [TTYC_E3] = { TTYCODE_STRING, "E3" },
96  [TTYC_ECH] = { TTYCODE_STRING, "ech" },
97  [TTYC_ED] = { TTYCODE_STRING, "ed" },
98  [TTYC_EL1] = { TTYCODE_STRING, "el1" },
99  [TTYC_EL] = { TTYCODE_STRING, "el" },
100  [TTYC_ENACS] = { TTYCODE_STRING, "enacs" },
101  [TTYC_ENBP] = { TTYCODE_STRING, "Enbp" },
102  [TTYC_ENEKS] = { TTYCODE_STRING, "Eneks" },
103  [TTYC_ENFCS] = { TTYCODE_STRING, "Enfcs" },
104  [TTYC_ENMG] = { TTYCODE_STRING, "Enmg" },
105  [TTYC_FSL] = { TTYCODE_STRING, "fsl" },
106  [TTYC_HOME] = { TTYCODE_STRING, "home" },
107  [TTYC_HPA] = { TTYCODE_STRING, "hpa" },
108  [TTYC_ICH1] = { TTYCODE_STRING, "ich1" },
109  [TTYC_ICH] = { TTYCODE_STRING, "ich" },
110  [TTYC_IL1] = { TTYCODE_STRING, "il1" },
111  [TTYC_IL] = { TTYCODE_STRING, "il" },
112  [TTYC_INDN] = { TTYCODE_STRING, "indn" },
113  [TTYC_INVIS] = { TTYCODE_STRING, "invis" },
114  [TTYC_KCBT] = { TTYCODE_STRING, "kcbt" },
115  [TTYC_KCUB1] = { TTYCODE_STRING, "kcub1" },
116  [TTYC_KCUD1] = { TTYCODE_STRING, "kcud1" },
117  [TTYC_KCUF1] = { TTYCODE_STRING, "kcuf1" },
118  [TTYC_KCUU1] = { TTYCODE_STRING, "kcuu1" },
119  [TTYC_KDC2] = { TTYCODE_STRING, "kDC" },
120  [TTYC_KDC3] = { TTYCODE_STRING, "kDC3" },
121  [TTYC_KDC4] = { TTYCODE_STRING, "kDC4" },
122  [TTYC_KDC5] = { TTYCODE_STRING, "kDC5" },
123  [TTYC_KDC6] = { TTYCODE_STRING, "kDC6" },
124  [TTYC_KDC7] = { TTYCODE_STRING, "kDC7" },
125  [TTYC_KDCH1] = { TTYCODE_STRING, "kdch1" },
126  [TTYC_KDN2] = { TTYCODE_STRING, "kDN" }, /* not kDN2 */
127  [TTYC_KDN3] = { TTYCODE_STRING, "kDN3" },
128  [TTYC_KDN4] = { TTYCODE_STRING, "kDN4" },
129  [TTYC_KDN5] = { TTYCODE_STRING, "kDN5" },
130  [TTYC_KDN6] = { TTYCODE_STRING, "kDN6" },
131  [TTYC_KDN7] = { TTYCODE_STRING, "kDN7" },
132  [TTYC_KEND2] = { TTYCODE_STRING, "kEND" },
133  [TTYC_KEND3] = { TTYCODE_STRING, "kEND3" },
134  [TTYC_KEND4] = { TTYCODE_STRING, "kEND4" },
135  [TTYC_KEND5] = { TTYCODE_STRING, "kEND5" },
136  [TTYC_KEND6] = { TTYCODE_STRING, "kEND6" },
137  [TTYC_KEND7] = { TTYCODE_STRING, "kEND7" },
138  [TTYC_KEND] = { TTYCODE_STRING, "kend" },
139  [TTYC_KF10] = { TTYCODE_STRING, "kf10" },
140  [TTYC_KF11] = { TTYCODE_STRING, "kf11" },
141  [TTYC_KF12] = { TTYCODE_STRING, "kf12" },
142  [TTYC_KF13] = { TTYCODE_STRING, "kf13" },
143  [TTYC_KF14] = { TTYCODE_STRING, "kf14" },
144  [TTYC_KF15] = { TTYCODE_STRING, "kf15" },
145  [TTYC_KF16] = { TTYCODE_STRING, "kf16" },
146  [TTYC_KF17] = { TTYCODE_STRING, "kf17" },
147  [TTYC_KF18] = { TTYCODE_STRING, "kf18" },
148  [TTYC_KF19] = { TTYCODE_STRING, "kf19" },
149  [TTYC_KF1] = { TTYCODE_STRING, "kf1" },
150  [TTYC_KF20] = { TTYCODE_STRING, "kf20" },
151  [TTYC_KF21] = { TTYCODE_STRING, "kf21" },
152  [TTYC_KF22] = { TTYCODE_STRING, "kf22" },
153  [TTYC_KF23] = { TTYCODE_STRING, "kf23" },
154  [TTYC_KF24] = { TTYCODE_STRING, "kf24" },
155  [TTYC_KF25] = { TTYCODE_STRING, "kf25" },
156  [TTYC_KF26] = { TTYCODE_STRING, "kf26" },
157  [TTYC_KF27] = { TTYCODE_STRING, "kf27" },
158  [TTYC_KF28] = { TTYCODE_STRING, "kf28" },
159  [TTYC_KF29] = { TTYCODE_STRING, "kf29" },
160  [TTYC_KF2] = { TTYCODE_STRING, "kf2" },
161  [TTYC_KF30] = { TTYCODE_STRING, "kf30" },
162  [TTYC_KF31] = { TTYCODE_STRING, "kf31" },
163  [TTYC_KF32] = { TTYCODE_STRING, "kf32" },
164  [TTYC_KF33] = { TTYCODE_STRING, "kf33" },
165  [TTYC_KF34] = { TTYCODE_STRING, "kf34" },
166  [TTYC_KF35] = { TTYCODE_STRING, "kf35" },
167  [TTYC_KF36] = { TTYCODE_STRING, "kf36" },
168  [TTYC_KF37] = { TTYCODE_STRING, "kf37" },
169  [TTYC_KF38] = { TTYCODE_STRING, "kf38" },
170  [TTYC_KF39] = { TTYCODE_STRING, "kf39" },
171  [TTYC_KF3] = { TTYCODE_STRING, "kf3" },
172  [TTYC_KF40] = { TTYCODE_STRING, "kf40" },
173  [TTYC_KF41] = { TTYCODE_STRING, "kf41" },
174  [TTYC_KF42] = { TTYCODE_STRING, "kf42" },
175  [TTYC_KF43] = { TTYCODE_STRING, "kf43" },
176  [TTYC_KF44] = { TTYCODE_STRING, "kf44" },
177  [TTYC_KF45] = { TTYCODE_STRING, "kf45" },
178  [TTYC_KF46] = { TTYCODE_STRING, "kf46" },
179  [TTYC_KF47] = { TTYCODE_STRING, "kf47" },
180  [TTYC_KF48] = { TTYCODE_STRING, "kf48" },
181  [TTYC_KF49] = { TTYCODE_STRING, "kf49" },
182  [TTYC_KF4] = { TTYCODE_STRING, "kf4" },
183  [TTYC_KF50] = { TTYCODE_STRING, "kf50" },
184  [TTYC_KF51] = { TTYCODE_STRING, "kf51" },
185  [TTYC_KF52] = { TTYCODE_STRING, "kf52" },
186  [TTYC_KF53] = { TTYCODE_STRING, "kf53" },
187  [TTYC_KF54] = { TTYCODE_STRING, "kf54" },
188  [TTYC_KF55] = { TTYCODE_STRING, "kf55" },
189  [TTYC_KF56] = { TTYCODE_STRING, "kf56" },
190  [TTYC_KF57] = { TTYCODE_STRING, "kf57" },
191  [TTYC_KF58] = { TTYCODE_STRING, "kf58" },
192  [TTYC_KF59] = { TTYCODE_STRING, "kf59" },
193  [TTYC_KF5] = { TTYCODE_STRING, "kf5" },
194  [TTYC_KF60] = { TTYCODE_STRING, "kf60" },
195  [TTYC_KF61] = { TTYCODE_STRING, "kf61" },
196  [TTYC_KF62] = { TTYCODE_STRING, "kf62" },
197  [TTYC_KF63] = { TTYCODE_STRING, "kf63" },
198  [TTYC_KF6] = { TTYCODE_STRING, "kf6" },
199  [TTYC_KF7] = { TTYCODE_STRING, "kf7" },
200  [TTYC_KF8] = { TTYCODE_STRING, "kf8" },
201  [TTYC_KF9] = { TTYCODE_STRING, "kf9" },
202  [TTYC_KHOM2] = { TTYCODE_STRING, "kHOM" },
203  [TTYC_KHOM3] = { TTYCODE_STRING, "kHOM3" },
204  [TTYC_KHOM4] = { TTYCODE_STRING, "kHOM4" },
205  [TTYC_KHOM5] = { TTYCODE_STRING, "kHOM5" },
206  [TTYC_KHOM6] = { TTYCODE_STRING, "kHOM6" },
207  [TTYC_KHOM7] = { TTYCODE_STRING, "kHOM7" },
208  [TTYC_KHOME] = { TTYCODE_STRING, "khome" },
209  [TTYC_KIC2] = { TTYCODE_STRING, "kIC" },
210  [TTYC_KIC3] = { TTYCODE_STRING, "kIC3" },
211  [TTYC_KIC4] = { TTYCODE_STRING, "kIC4" },
212  [TTYC_KIC5] = { TTYCODE_STRING, "kIC5" },
213  [TTYC_KIC6] = { TTYCODE_STRING, "kIC6" },
214  [TTYC_KIC7] = { TTYCODE_STRING, "kIC7" },
215  [TTYC_KICH1] = { TTYCODE_STRING, "kich1" },
216  [TTYC_KIND] = { TTYCODE_STRING, "kind" },
217  [TTYC_KLFT2] = { TTYCODE_STRING, "kLFT" },
218  [TTYC_KLFT3] = { TTYCODE_STRING, "kLFT3" },
219  [TTYC_KLFT4] = { TTYCODE_STRING, "kLFT4" },
220  [TTYC_KLFT5] = { TTYCODE_STRING, "kLFT5" },
221  [TTYC_KLFT6] = { TTYCODE_STRING, "kLFT6" },
222  [TTYC_KLFT7] = { TTYCODE_STRING, "kLFT7" },
223  [TTYC_KMOUS] = { TTYCODE_STRING, "kmous" },
224  [TTYC_KNP] = { TTYCODE_STRING, "knp" },
225  [TTYC_KNXT2] = { TTYCODE_STRING, "kNXT" },
226  [TTYC_KNXT3] = { TTYCODE_STRING, "kNXT3" },
227  [TTYC_KNXT4] = { TTYCODE_STRING, "kNXT4" },
228  [TTYC_KNXT5] = { TTYCODE_STRING, "kNXT5" },
229  [TTYC_KNXT6] = { TTYCODE_STRING, "kNXT6" },
230  [TTYC_KNXT7] = { TTYCODE_STRING, "kNXT7" },
231  [TTYC_KPP] = { TTYCODE_STRING, "kpp" },
232  [TTYC_KPRV2] = { TTYCODE_STRING, "kPRV" },
233  [TTYC_KPRV3] = { TTYCODE_STRING, "kPRV3" },
234  [TTYC_KPRV4] = { TTYCODE_STRING, "kPRV4" },
235  [TTYC_KPRV5] = { TTYCODE_STRING, "kPRV5" },
236  [TTYC_KPRV6] = { TTYCODE_STRING, "kPRV6" },
237  [TTYC_KPRV7] = { TTYCODE_STRING, "kPRV7" },
238  [TTYC_KRIT2] = { TTYCODE_STRING, "kRIT" },
239  [TTYC_KRIT3] = { TTYCODE_STRING, "kRIT3" },
240  [TTYC_KRIT4] = { TTYCODE_STRING, "kRIT4" },
241  [TTYC_KRIT5] = { TTYCODE_STRING, "kRIT5" },
242  [TTYC_KRIT6] = { TTYCODE_STRING, "kRIT6" },
243  [TTYC_KRIT7] = { TTYCODE_STRING, "kRIT7" },
244  [TTYC_KRI] = { TTYCODE_STRING, "kri" },
245  [TTYC_KUP2] = { TTYCODE_STRING, "kUP" }, /* not kUP2 */
246  [TTYC_KUP3] = { TTYCODE_STRING, "kUP3" },
247  [TTYC_KUP4] = { TTYCODE_STRING, "kUP4" },
248  [TTYC_KUP5] = { TTYCODE_STRING, "kUP5" },
249  [TTYC_KUP6] = { TTYCODE_STRING, "kUP6" },
250  [TTYC_KUP7] = { TTYCODE_STRING, "kUP7" },
251  [TTYC_MS] = { TTYCODE_STRING, "Ms" },
252  [TTYC_OL] = { TTYCODE_STRING, "ol" },
253  [TTYC_OP] = { TTYCODE_STRING, "op" },
254  [TTYC_RECT] = { TTYCODE_STRING, "Rect" },
255  [TTYC_REV] = { TTYCODE_STRING, "rev" },
256  [TTYC_RGB] = { TTYCODE_FLAG, "RGB" },
257  [TTYC_RIN] = { TTYCODE_STRING, "rin" },
258  [TTYC_RI] = { TTYCODE_STRING, "ri" },
259  [TTYC_RMACS] = { TTYCODE_STRING, "rmacs" },
260  [TTYC_RMCUP] = { TTYCODE_STRING, "rmcup" },
261  [TTYC_RMKX] = { TTYCODE_STRING, "rmkx" },
262  [TTYC_SETAB] = { TTYCODE_STRING, "setab" },
263  [TTYC_SETAF] = { TTYCODE_STRING, "setaf" },
264  [TTYC_SETAL] = { TTYCODE_STRING, "setal" },
265  [TTYC_SETRGBB] = { TTYCODE_STRING, "setrgbb" },
266  [TTYC_SETRGBF] = { TTYCODE_STRING, "setrgbf" },
267  [TTYC_SETULC] = { TTYCODE_STRING, "Setulc" },
268  [TTYC_SE] = { TTYCODE_STRING, "Se" },
269  [TTYC_SGR0] = { TTYCODE_STRING, "sgr0" },
270  [TTYC_SITM] = { TTYCODE_STRING, "sitm" },
271  [TTYC_SMACS] = { TTYCODE_STRING, "smacs" },
272  [TTYC_SMCUP] = { TTYCODE_STRING, "smcup" },
273  [TTYC_SMKX] = { TTYCODE_STRING, "smkx" },
274  [TTYC_SMOL] = { TTYCODE_STRING, "Smol" },
275  [TTYC_SMSO] = { TTYCODE_STRING, "smso" },
276  [TTYC_SMULX] = { TTYCODE_STRING, "Smulx" },
277  [TTYC_SMUL] = { TTYCODE_STRING, "smul" },
278  [TTYC_SMXX] = { TTYCODE_STRING, "smxx" },
279  [TTYC_SS] = { TTYCODE_STRING, "Ss" },
280  [TTYC_SYNC] = { TTYCODE_STRING, "Sync" },
281  [TTYC_TC] = { TTYCODE_FLAG, "Tc" },
282  [TTYC_TSL] = { TTYCODE_STRING, "tsl" },
283  [TTYC_U8] = { TTYCODE_NUMBER, "U8" },
284  [TTYC_VPA] = { TTYCODE_STRING, "vpa" },
285  [TTYC_XT] = { TTYCODE_FLAG, "XT" }
286 };
287 
288 u_int
290 {
291  return (nitems(tty_term_codes));
292 }
293 
294 static char *
295 tty_term_strip(const char *s)
296 {
297  const char *ptr;
298  static char buf[8192];
299  size_t len;
300 
301  /* Ignore strings with no padding. */
302  if (strchr(s, '$') == NULL)
303  return (xstrdup(s));
304 
305  len = 0;
306  for (ptr = s; *ptr != '\0'; ptr++) {
307  if (*ptr == '$' && *(ptr + 1) == '<') {
308  while (*ptr != '\0' && *ptr != '>')
309  ptr++;
310  if (*ptr == '>')
311  ptr++;
312  if (*ptr == '\0')
313  break;
314  }
315 
316  buf[len++] = *ptr;
317  if (len == (sizeof buf) - 1)
318  break;
319  }
320  buf[len] = '\0';
321 
322  return (xstrdup(buf));
323 }
324 
325 static char *
326 tty_term_override_next(const char *s, size_t *offset)
327 {
328  static char value[8192];
329  size_t n = 0, at = *offset;
330 
331  if (s[at] == '\0')
332  return (NULL);
333 
334  while (s[at] != '\0') {
335  if (s[at] == ':') {
336  if (s[at + 1] == ':') {
337  value[n++] = ':';
338  at += 2;
339  } else
340  break;
341  } else {
342  value[n++] = s[at];
343  at++;
344  }
345  if (n == (sizeof value) - 1)
346  return (NULL);
347  }
348  if (s[at] != '\0')
349  *offset = at + 1;
350  else
351  *offset = at;
352  value[n] = '\0';
353  return (value);
354 }
355 
356 void
357 tty_term_apply(struct tty_term *term, const char *capabilities, int quiet)
358 {
359  const struct tty_term_code_entry *ent;
360  struct tty_code *code;
361  size_t offset = 0;
362  char *cp, *value, *s;
363  const char *errstr, *name = term->name;
364  u_int i;
365  int n, remove;
366 
367  while ((s = tty_term_override_next(capabilities, &offset)) != NULL) {
368  if (*s == '\0')
369  continue;
370  value = NULL;
371 
372  remove = 0;
373  if ((cp = strchr(s, '=')) != NULL) {
374  *cp++ = '\0';
375  value = xstrdup(cp);
376  if (strunvis(value, cp) == -1) {
377  free(value);
378  value = xstrdup(cp);
379  }
380  } else if (s[strlen(s) - 1] == '@') {
381  s[strlen(s) - 1] = '\0';
382  remove = 1;
383  } else
384  value = xstrdup("");
385 
386  if (!quiet) {
387  if (remove)
388  log_debug("%s override: %s@", name, s);
389  else if (*value == '\0')
390  log_debug("%s override: %s", name, s);
391  else
392  log_debug("%s override: %s=%s", name, s, value);
393  }
394 
395  for (i = 0; i < tty_term_ncodes(); i++) {
396  ent = &tty_term_codes[i];
397  if (strcmp(s, ent->name) != 0)
398  continue;
399  code = &term->codes[i];
400 
401  if (remove) {
402  code->type = TTYCODE_NONE;
403  continue;
404  }
405  switch (ent->type) {
406  case TTYCODE_NONE:
407  break;
408  case TTYCODE_STRING:
409  if (code->type == TTYCODE_STRING)
410  free(code->value.string);
411  code->value.string = xstrdup(value);
412  code->type = ent->type;
413  break;
414  case TTYCODE_NUMBER:
415  n = strtonum(value, 0, INT_MAX, &errstr);
416  if (errstr != NULL)
417  break;
418  code->value.number = n;
419  code->type = ent->type;
420  break;
421  case TTYCODE_FLAG:
422  code->value.flag = 1;
423  code->type = ent->type;
424  break;
425  }
426  }
427 
428  free(value);
429  }
430 }
431 
432 void
434 {
435  struct options_entry *o;
436  struct options_array_item *a;
437  union options_value *ov;
438  const char *s, *acs;
439  size_t offset;
440  char *first;
441 
442  /* Update capabilities from the option. */
443  o = options_get_only(global_options, "terminal-overrides");
444  a = options_array_first(o);
445  while (a != NULL) {
446  ov = options_array_item_value(a);
447  s = ov->string;
448 
449  offset = 0;
450  first = tty_term_override_next(s, &offset);
451  if (first != NULL && fnmatch(first, term->name, 0) == 0)
452  tty_term_apply(term, s + offset, 0);
453  a = options_array_next(a);
454  }
455 
456  /* Update the RGB flag if the terminal has RGB colours. */
457  if (tty_term_has(term, TTYC_SETRGBF) &&
458  tty_term_has(term, TTYC_SETRGBB))
459  term->flags |= TERM_RGBCOLOURS;
460  else
461  term->flags &= ~~TERM_RGBCOLOURS;
462  log_debug("RGBCOLOURS flag is %d", !!(term->flags & TERM_RGBCOLOURS));
463 
464  /*
465  * Set or clear the DECSLRM flag if the terminal has the margin
466  * capabilities.
467  */
468  if (tty_term_has(term, TTYC_CMG) && tty_term_has(term, TTYC_CLMG))
469  term->flags |= TERM_DECSLRM;
470  else
471  term->flags &= ~~TERM_DECSLRM;
472  log_debug("DECSLRM flag is %d", !!(term->flags & TERM_DECSLRM));
473 
474  /*
475  * Set or clear the DECFRA flag if the terminal has the rectangle
476  * capability.
477  */
478  if (tty_term_has(term, TTYC_RECT))
479  term->flags |= TERM_DECFRA;
480  else
481  term->flags &= ~~TERM_DECFRA;
482  log_debug("DECFRA flag is %d", !!(term->flags & TERM_DECFRA));
483 
484  /*
485  * Terminals without am (auto right margin) wrap at at $COLUMNS - 1
486  * rather than $COLUMNS (the cursor can never be beyond $COLUMNS - 1).
487  *
488  * Terminals without xenl (eat newline glitch) ignore a newline beyond
489  * the right edge of the terminal, but tmux doesn't care about this -
490  * it always uses absolute only moves the cursor with a newline when
491  * also sending a linefeed.
492  *
493  * This is irritating, most notably because it is painful to write to
494  * the very bottom-right of the screen without scrolling.
495  *
496  * Flag the terminal here and apply some workarounds in other places to
497  * do the best possible.
498  */
499  if (!tty_term_flag(term, TTYC_AM))
500  term->flags |= TERM_NOAM;
501  else
502  term->flags &= ~~TERM_NOAM;
503  log_debug("NOAM flag is %d", !!(term->flags & TERM_NOAM));
504 
505  /* Generate ACS table. If none is present, use nearest ASCII. */
506  memset(term->acs, 0, sizeof term->acs);
507  if (tty_term_has(term, TTYC_ACSC))
508  acs = tty_term_string(term, TTYC_ACSC);
509  else
510  acs = "a#j+k+l+m+n+o-p-q-r-s-t+u+v+w+x|y<z>~.";
511  for (; acs[0] != '\0' && acs[1] != '\0'; acs += 2)
512  term->acs[(u_char) acs[0]][0] = acs[1];
513 }
514 
515 struct tty_term *
516 tty_term_create(struct tty *tty, char *name, char **caps, u_int ncaps,
517  int *feat, char **cause)
518 {
519  struct tty_term *term;
520  const struct tty_term_code_entry *ent;
521  struct tty_code *code;
522  struct options_entry *o;
523  struct options_array_item *a;
524  union options_value *ov;
525  u_int i, j;
526  const char *s, *value;
527  size_t offset, namelen;
528  char *first;
529 
530  log_debug("adding term %s", name);
531 
532  term = xcalloc(1, sizeof *term);
533  term->tty = tty;
534  term->name = xstrdup(name);
535  term->codes = xcalloc(tty_term_ncodes(), sizeof *term->codes);
536  LIST_INSERT_HEAD(&tty_terms, term, entry);
537 
538  /* Fill in codes. */
539  for (i = 0; i < ncaps; i++) {
540  namelen = strcspn(caps[i], "=");
541  if (namelen == 0)
542  continue;
543  value = caps[i] + namelen + 1;
544 
545  for (j = 0; j < tty_term_ncodes(); j++) {
546  ent = &tty_term_codes[j];
547  if (strncmp(ent->name, caps[i], namelen) != 0)
548  continue;
549  if (ent->name[namelen] != '\0')
550  continue;
551 
552  code = &term->codes[j];
553  code->type = TTYCODE_NONE;
554  switch (ent->type) {
555  case TTYCODE_NONE:
556  break;
557  case TTYCODE_STRING:
558  code->type = TTYCODE_STRING;
559  code->value.string = tty_term_strip(value);
560  break;
561  case TTYCODE_NUMBER:
562  code->type = TTYCODE_NUMBER;
563  code->value.number = atoi(value);
564  break;
565  case TTYCODE_FLAG:
566  code->type = TTYCODE_FLAG;
567  code->value.flag = (*value == '1');
568  break;
569  }
570  }
571  }
572 
573  /* Apply terminal features. */
574  o = options_get_only(global_options, "terminal-features");
575  a = options_array_first(o);
576  while (a != NULL) {
577  ov = options_array_item_value(a);
578  s = ov->string;
579 
580  offset = 0;
581  first = tty_term_override_next(s, &offset);
582  if (first != NULL && fnmatch(first, term->name, 0) == 0)
583  tty_add_features(feat, s + offset, ":");
584  a = options_array_next(a);
585  }
586 
587  /* Delete curses data. */
588 #if !defined(NCURSES_VERSION_MAJOR) || NCURSES_VERSION_MAJOR > 5 || \
589  (NCURSES_VERSION_MAJOR == 5 && NCURSES_VERSION_MINOR > 6)
590  del_curterm(cur_term);
591 #endif
592 
593  /* Apply overrides so any capabilities used for features are changed. */
595 
596  /* These are always required. */
597  if (!tty_term_has(term, TTYC_CLEAR)) {
598  xasprintf(cause, "terminal does not support clear");
599  goto error;
600  }
601  if (!tty_term_has(term, TTYC_CUP)) {
602  xasprintf(cause, "terminal does not support cup");
603  goto error;
604  }
605 
606  /*
607  * If TERM has XT or clear starts with CSI then it is safe to assume
608  * the terminal is derived from the VT100. This controls whether device
609  * attributes requests are sent to get more information.
610  *
611  * This is a bit of a hack but there aren't that many alternatives.
612  * Worst case tmux will just fall back to using whatever terminfo(5)
613  * says without trying to correct anything that is missing.
614  *
615  * Also add few features that VT100-like terminals should either
616  * support or safely ignore.
617  */
618  s = tty_term_string(term, TTYC_CLEAR);
619  if (tty_term_flag(term, TTYC_XT) || strncmp(s, "\033[", 2) == 0) {
620  term->flags |= TERM_VT100LIKE;
621  tty_add_features(feat, "bpaste,focus,title", ",");
622  }
623 
624  /* Add RGB feature if terminal has RGB colours. */
625  if ((tty_term_flag(term, TTYC_TC) || tty_term_has(term, TTYC_RGB)) &&
626  (!tty_term_has(term, TTYC_SETRGBF) ||
627  !tty_term_has(term, TTYC_SETRGBB)))
628  tty_add_features(feat, "RGB", ",");
629 
630  /* Apply the features and overrides again. */
631  if (tty_apply_features(term, *feat))
633 
634  /* Log the capabilities. */
635  for (i = 0; i < tty_term_ncodes(); i++)
636  log_debug("%s%s", name, tty_term_describe(term, i));
637 
638  return (term);
639 
640 error:
641  tty_term_free(term);
642  return (NULL);
643 }
644 
645 void
646 tty_term_free(struct tty_term *term)
647 {
648  u_int i;
649 
650  log_debug("removing term %s", term->name);
651 
652  for (i = 0; i < tty_term_ncodes(); i++) {
653  if (term->codes[i].type == TTYCODE_STRING)
654  free(term->codes[i].value.string);
655  }
656  free(term->codes);
657 
658  LIST_REMOVE(term, entry);
659  free(term->name);
660  free(term);
661 }
662 
663 int
664 tty_term_read_list(const char *name, int fd, char ***caps, u_int *ncaps,
665  char **cause)
666 {
667  const struct tty_term_code_entry *ent;
668  int error, n;
669  u_int i;
670  const char *s;
671  char tmp[11];
672 
673  if (setupterm(name, fd, &error) != OK) {
674  switch (error) {
675  case 1:
676  xasprintf(cause, "can't use hardcopy terminal: %s",
677  name);
678  break;
679  case 0:
680  xasprintf(cause, "missing or unsuitable terminal: %s",
681  name);
682  break;
683  case -1:
684  xasprintf(cause, "can't find terminfo database");
685  break;
686  default:
687  xasprintf(cause, "unknown error");
688  break;
689  }
690  return (-1);
691  }
692 
693  *ncaps = 0;
694  *caps = NULL;
695 
696  for (i = 0; i < tty_term_ncodes(); i++) {
697  ent = &tty_term_codes[i];
698  switch (ent->type) {
699  case TTYCODE_NONE:
700  continue;
701  case TTYCODE_STRING:
702  s = tigetstr((char *)ent->name);
703  if (s == NULL || s == (char *)-1)
704  continue;
705  break;
706  case TTYCODE_NUMBER:
707  n = tigetnum((char *)ent->name);
708  if (n == -1 || n == -2)
709  continue;
710  xsnprintf(tmp, sizeof tmp, "%d", n);
711  s = tmp;
712  break;
713  case TTYCODE_FLAG:
714  n = tigetflag((char *) ent->name);
715  if (n == -1)
716  continue;
717  if (n)
718  s = "1";
719  else
720  s = "0";
721  break;
722  }
723  *caps = xreallocarray(*caps, (*ncaps) + 1, sizeof **caps);
724  xasprintf(&(*caps)[*ncaps], "%s=%s", ent->name, s);
725  (*ncaps)++;
726  }
727 
728 #if !defined(NCURSES_VERSION_MAJOR) || NCURSES_VERSION_MAJOR > 5 || \
729  (NCURSES_VERSION_MAJOR == 5 && NCURSES_VERSION_MINOR > 6)
730  del_curterm(cur_term);
731 #endif
732  return (0);
733 }
734 
735 void
736 tty_term_free_list(char **caps, u_int ncaps)
737 {
738  u_int i;
739 
740  for (i = 0; i < ncaps; i++)
741  free(caps[i]);
742  free(caps);
743 }
744 
745 int
746 tty_term_has(struct tty_term *term, enum tty_code_code code)
747 {
748  return (term->codes[code].type != TTYCODE_NONE);
749 }
750 
751 const char *
752 tty_term_string(struct tty_term *term, enum tty_code_code code)
753 {
754  if (!tty_term_has(term, code))
755  return ("");
756  if (term->codes[code].type != TTYCODE_STRING)
757  fatalx("not a string: %d", code);
758  return (term->codes[code].value.string);
759 }
760 
761 const char *
762 tty_term_string1(struct tty_term *term, enum tty_code_code code, int a)
763 {
764  return (tparm((char *) tty_term_string(term, code), a, 0, 0, 0, 0, 0, 0, 0, 0));
765 }
766 
767 const char *
768 tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b)
769 {
770  return (tparm((char *) tty_term_string(term, code), a, b, 0, 0, 0, 0, 0, 0, 0));
771 }
772 
773 const char *
774 tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b,
775  int c)
776 {
777  return (tparm((char *) tty_term_string(term, code), a, b, c, 0, 0, 0, 0, 0, 0));
778 }
779 
780 const char *
781 tty_term_ptr1(struct tty_term *term, enum tty_code_code code, const void *a)
782 {
783  return (tparm((char *) tty_term_string(term, code), (long)a, 0, 0, 0, 0, 0, 0, 0, 0));
784 }
785 
786 const char *
787 tty_term_ptr2(struct tty_term *term, enum tty_code_code code, const void *a,
788  const void *b)
789 {
790  return (tparm((char *) tty_term_string(term, code), (long)a, (long)b, 0, 0, 0, 0, 0, 0, 0));
791 }
792 
793 int
794 tty_term_number(struct tty_term *term, enum tty_code_code code)
795 {
796  if (!tty_term_has(term, code))
797  return (0);
798  if (term->codes[code].type != TTYCODE_NUMBER)
799  fatalx("not a number: %d", code);
800  return (term->codes[code].value.number);
801 }
802 
803 int
804 tty_term_flag(struct tty_term *term, enum tty_code_code code)
805 {
806  if (!tty_term_has(term, code))
807  return (0);
808  if (term->codes[code].type != TTYCODE_FLAG)
809  fatalx("not a flag: %d", code);
810  return (term->codes[code].value.flag);
811 }
812 
813 const char *
814 tty_term_describe(struct tty_term *term, enum tty_code_code code)
815 {
816  static char s[256];
817  char out[128];
818 
819  switch (term->codes[code].type) {
820  case TTYCODE_NONE:
821  xsnprintf(s, sizeof s, "%4u: %s: [missing]",
822  code, tty_term_codes[code].name);
823  break;
824  case TTYCODE_STRING:
825  strnvis(out, term->codes[code].value.string, sizeof out,
826  VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
827  xsnprintf(s, sizeof s, "%4u: %s: (string) %s",
828  code, tty_term_codes[code].name,
829  out);
830  break;
831  case TTYCODE_NUMBER:
832  xsnprintf(s, sizeof s, "%4u: %s: (number) %d",
833  code, tty_term_codes[code].name,
834  term->codes[code].value.number);
835  break;
836  case TTYCODE_FLAG:
837  xsnprintf(s, sizeof s, "%4u: %s: (flag) %s",
838  code, tty_term_codes[code].name,
839  term->codes[code].value.flag ? "true" : "false");
840  break;
841  }
842  return (s);
843 }
long long strtonum(const char *, long long, long long, const char **)
const char * name
Definition: layout-set.c:38
void fatalx(const char *msg,...)
Definition: log.c:159
void log_debug(const char *msg,...)
Definition: log.c:130
union options_value * options_array_item_value(struct options_array_item *a)
Definition: options.c:549
struct options_array_item * options_array_first(struct options_entry *o)
Definition: options.c:529
struct options_array_item * options_array_next(struct options_array_item *a)
Definition: options.c:537
struct options_entry * options_get_only(struct options *oo, const char *name)
Definition: options.c:216
#define nitems(_a)
Definition: options.c:50
enum tty_code_type type
Definition: tty-term.c:45
int flag
Definition: tty-term.c:49
int number
Definition: tty-term.c:48
union tty_code::@19 value
char * string
Definition: tty-term.c:47
Definition: tty-term.c:53
enum tty_code_type type
Definition: tty-term.c:54
const char * name
Definition: tty-term.c:55
struct tty_code * codes
Definition: tmux.h:1290
char acs[UCHAR_MAX+1][2]
Definition: tmux.h:1288
struct tty * tty
Definition: tmux.h:1285
int flags
Definition: tmux.h:1298
char * name
Definition: tmux.h:1284
Definition: tmux.h:1304
struct options * global_options
Definition: tmux.c:36
int tty_apply_features(struct tty_term *, int)
Definition: tty-features.c:311
void tty_add_features(int *, const char *, const char *)
Definition: tty-features.c:262
tty_code_code
Definition: tmux.h:274
@ TTYC_KIC6
Definition: tmux.h:429
@ TTYC_KF7
Definition: tmux.h:415
@ TTYC_OL
Definition: tmux.h:468
@ TTYC_KEND4
Definition: tmux.h:351
@ TTYC_KF32
Definition: tmux.h:380
@ TTYC_KDC4
Definition: tmux.h:337
@ TTYC_KEND5
Definition: tmux.h:352
@ TTYC_CLMG
Definition: tmux.h:285
@ TTYC_KCUF1
Definition: tmux.h:333
@ TTYC_KF4
Definition: tmux.h:388
@ TTYC_U8
Definition: tmux.h:499
@ TTYC_KCUU1
Definition: tmux.h:334
@ TTYC_KF34
Definition: tmux.h:382
@ TTYC_ENACS
Definition: tmux.h:316
@ TTYC_CMG
Definition: tmux.h:286
@ TTYC_KHOM2
Definition: tmux.h:418
@ TTYC_KRIT6
Definition: tmux.h:459
@ TTYC_KF13
Definition: tmux.h:359
@ TTYC_E3
Definition: tmux.h:311
@ TTYC_KF10
Definition: tmux.h:356
@ TTYC_KEND2
Definition: tmux.h:349
@ TTYC_DSMG
Definition: tmux.h:310
@ TTYC_KF15
Definition: tmux.h:361
@ TTYC_KPRV4
Definition: tmux.h:450
@ TTYC_KMOUS
Definition: tmux.h:439
@ TTYC_ENMG
Definition: tmux.h:320
@ TTYC_SMOL
Definition: tmux.h:490
@ TTYC_RMACS
Definition: tmux.h:475
@ TTYC_IL1
Definition: tmux.h:327
@ TTYC_KNXT2
Definition: tmux.h:441
@ TTYC_KF53
Definition: tmux.h:403
@ TTYC_REV
Definition: tmux.h:471
@ TTYC_SMACS
Definition: tmux.h:487
@ TTYC_KCUB1
Definition: tmux.h:331
@ TTYC_INVIS
Definition: tmux.h:329
@ TTYC_KIC5
Definition: tmux.h:428
@ TTYC_KF30
Definition: tmux.h:378
@ TTYC_CUD1
Definition: tmux.h:295
@ TTYC_KLFT7
Definition: tmux.h:438
@ TTYC_CUP
Definition: tmux.h:298
@ TTYC_KRIT3
Definition: tmux.h:456
@ TTYC_KF26
Definition: tmux.h:373
@ TTYC_KF54
Definition: tmux.h:404
@ TTYC_KF36
Definition: tmux.h:384
@ TTYC_KF29
Definition: tmux.h:376
@ TTYC_AM
Definition: tmux.h:276
@ TTYC_EL
Definition: tmux.h:314
@ TTYC_KDN4
Definition: tmux.h:344
@ TTYC_SITM
Definition: tmux.h:486
@ TTYC_CUU1
Definition: tmux.h:300
@ TTYC_KNXT6
Definition: tmux.h:445
@ TTYC_CIVIS
Definition: tmux.h:283
@ TTYC_CUF
Definition: tmux.h:296
@ TTYC_KEND3
Definition: tmux.h:350
@ TTYC_KF45
Definition: tmux.h:394
@ TTYC_KDC7
Definition: tmux.h:340
@ TTYC_OP
Definition: tmux.h:469
@ TTYC_KF51
Definition: tmux.h:401
@ TTYC_CS
Definition: tmux.h:290
@ TTYC_KF20
Definition: tmux.h:367
@ TTYC_KF31
Definition: tmux.h:379
@ TTYC_ENBP
Definition: tmux.h:317
@ TTYC_KF55
Definition: tmux.h:405
@ TTYC_SE
Definition: tmux.h:478
@ TTYC_BEL
Definition: tmux.h:279
@ TTYC_KF3
Definition: tmux.h:377
@ TTYC_XT
Definition: tmux.h:501
@ TTYC_KCUD1
Definition: tmux.h:332
@ TTYC_SETAB
Definition: tmux.h:479
@ TTYC_KIND
Definition: tmux.h:432
@ TTYC_KF21
Definition: tmux.h:368
@ TTYC_KUP6
Definition: tmux.h:465
@ TTYC_KF9
Definition: tmux.h:417
@ TTYC_KNP
Definition: tmux.h:440
@ TTYC_CUB
Definition: tmux.h:292
@ TTYC_KF27
Definition: tmux.h:374
@ TTYC_KF61
Definition: tmux.h:412
@ TTYC_KF44
Definition: tmux.h:393
@ TTYC_KF8
Definition: tmux.h:416
@ TTYC_KICH1
Definition: tmux.h:431
@ TTYC_KDN7
Definition: tmux.h:347
@ TTYC_KIC2
Definition: tmux.h:425
@ TTYC_KF33
Definition: tmux.h:381
@ TTYC_BIDI
Definition: tmux.h:280
@ TTYC_KF24
Definition: tmux.h:371
@ TTYC_DCH
Definition: tmux.h:302
@ TTYC_DSFCS
Definition: tmux.h:309
@ TTYC_SETAF
Definition: tmux.h:480
@ TTYC_CR
Definition: tmux.h:289
@ TTYC_KDN5
Definition: tmux.h:345
@ TTYC_KLFT3
Definition: tmux.h:434
@ TTYC_KRIT2
Definition: tmux.h:455
@ TTYC_SYNC
Definition: tmux.h:496
@ TTYC_KF42
Definition: tmux.h:391
@ TTYC_KRIT7
Definition: tmux.h:460
@ TTYC_KRIT4
Definition: tmux.h:457
@ TTYC_DIM
Definition: tmux.h:304
@ TTYC_KF37
Definition: tmux.h:385
@ TTYC_KNXT4
Definition: tmux.h:443
@ TTYC_KPRV3
Definition: tmux.h:449
@ TTYC_KIC7
Definition: tmux.h:430
@ TTYC_KIC4
Definition: tmux.h:427
@ TTYC_KPP
Definition: tmux.h:447
@ TTYC_FSL
Definition: tmux.h:321
@ TTYC_ED
Definition: tmux.h:313
@ TTYC_KF38
Definition: tmux.h:386
@ TTYC_KHOM7
Definition: tmux.h:423
@ TTYC_CVVIS
Definition: tmux.h:301
@ TTYC_KDC5
Definition: tmux.h:338
@ TTYC_KF63
Definition: tmux.h:414
@ TTYC_KHOM4
Definition: tmux.h:420
@ TTYC_KF11
Definition: tmux.h:357
@ TTYC_KDN6
Definition: tmux.h:346
@ TTYC_KLFT5
Definition: tmux.h:436
@ TTYC_KRIT5
Definition: tmux.h:458
@ TTYC_KF48
Definition: tmux.h:397
@ TTYC_ACSC
Definition: tmux.h:275
@ TTYC_KF62
Definition: tmux.h:413
@ TTYC_KF18
Definition: tmux.h:364
@ TTYC_CUF1
Definition: tmux.h:297
@ TTYC_CUD
Definition: tmux.h:294
@ TTYC_KF56
Definition: tmux.h:406
@ TTYC_KDCH1
Definition: tmux.h:341
@ TTYC_KHOM5
Definition: tmux.h:421
@ TTYC_KF59
Definition: tmux.h:409
@ TTYC_AX
Definition: tmux.h:277
@ TTYC_SMSO
Definition: tmux.h:491
@ TTYC_BOLD
Definition: tmux.h:282
@ TTYC_KF46
Definition: tmux.h:395
@ TTYC_KF35
Definition: tmux.h:383
@ TTYC_TSL
Definition: tmux.h:498
@ TTYC_KIC3
Definition: tmux.h:426
@ TTYC_SMKX
Definition: tmux.h:489
@ TTYC_KF47
Definition: tmux.h:396
@ TTYC_KF28
Definition: tmux.h:375
@ TTYC_KHOM6
Definition: tmux.h:422
@ TTYC_KLFT2
Definition: tmux.h:433
@ TTYC_KLFT4
Definition: tmux.h:435
@ TTYC_KPRV2
Definition: tmux.h:448
@ TTYC_KF16
Definition: tmux.h:362
@ TTYC_SMCUP
Definition: tmux.h:488
@ TTYC_KF50
Definition: tmux.h:400
@ TTYC_KUP3
Definition: tmux.h:462
@ TTYC_SETRGBF
Definition: tmux.h:483
@ TTYC_KF60
Definition: tmux.h:411
@ TTYC_RIN
Definition: tmux.h:474
@ TTYC_ENEKS
Definition: tmux.h:318
@ TTYC_KF14
Definition: tmux.h:360
@ TTYC_VPA
Definition: tmux.h:500
@ TTYC_KEND6
Definition: tmux.h:353
@ TTYC_KF57
Definition: tmux.h:407
@ TTYC_KRI
Definition: tmux.h:454
@ TTYC_SETULC
Definition: tmux.h:484
@ TTYC_KNXT7
Definition: tmux.h:446
@ TTYC_HPA
Definition: tmux.h:323
@ TTYC_SMXX
Definition: tmux.h:494
@ TTYC_KF19
Definition: tmux.h:365
@ TTYC_KF49
Definition: tmux.h:398
@ TTYC_DSBP
Definition: tmux.h:307
@ TTYC_KUP5
Definition: tmux.h:464
@ TTYC_KNXT3
Definition: tmux.h:442
@ TTYC_RMCUP
Definition: tmux.h:476
@ TTYC_ICH
Definition: tmux.h:324
@ TTYC_KF2
Definition: tmux.h:366
@ TTYC_SETAL
Definition: tmux.h:481
@ TTYC_MS
Definition: tmux.h:467
@ TTYC_EL1
Definition: tmux.h:315
@ TTYC_HOME
Definition: tmux.h:322
@ TTYC_BCE
Definition: tmux.h:278
@ TTYC_DL
Definition: tmux.h:305
@ TTYC_CSR
Definition: tmux.h:291
@ TTYC_KDC3
Definition: tmux.h:336
@ TTYC_KF5
Definition: tmux.h:399
@ TTYC_KF25
Definition: tmux.h:372
@ TTYC_RECT
Definition: tmux.h:470
@ TTYC_KPRV7
Definition: tmux.h:453
@ TTYC_KF12
Definition: tmux.h:358
@ TTYC_KHOME
Definition: tmux.h:424
@ TTYC_SGR0
Definition: tmux.h:485
@ TTYC_KUP2
Definition: tmux.h:461
@ TTYC_DL1
Definition: tmux.h:306
@ TTYC_IL
Definition: tmux.h:326
@ TTYC_DSEKS
Definition: tmux.h:308
@ TTYC_KF43
Definition: tmux.h:392
@ TTYC_KF23
Definition: tmux.h:370
@ TTYC_KDC6
Definition: tmux.h:339
@ TTYC_KLFT6
Definition: tmux.h:437
@ TTYC_KEND
Definition: tmux.h:348
@ TTYC_INDN
Definition: tmux.h:328
@ TTYC_KCBT
Definition: tmux.h:330
@ TTYC_TC
Definition: tmux.h:497
@ TTYC_DCH1
Definition: tmux.h:303
@ TTYC_KF39
Definition: tmux.h:387
@ TTYC_KF22
Definition: tmux.h:369
@ TTYC_RGB
Definition: tmux.h:472
@ TTYC_CNORM
Definition: tmux.h:287
@ TTYC_ENFCS
Definition: tmux.h:319
@ TTYC_KPRV6
Definition: tmux.h:452
@ TTYC_KDN3
Definition: tmux.h:343
@ TTYC_CUB1
Definition: tmux.h:293
@ TTYC_SMULX
Definition: tmux.h:493
@ TTYC_SETRGBB
Definition: tmux.h:482
@ TTYC_KF17
Definition: tmux.h:363
@ TTYC_CLEAR
Definition: tmux.h:284
@ TTYC_CUU
Definition: tmux.h:299
@ TTYC_KF58
Definition: tmux.h:408
@ TTYC_KDC2
Definition: tmux.h:335
@ TTYC_KF41
Definition: tmux.h:390
@ TTYC_KF40
Definition: tmux.h:389
@ TTYC_BLINK
Definition: tmux.h:281
@ TTYC_KF52
Definition: tmux.h:402
@ TTYC_KF6
Definition: tmux.h:410
@ TTYC_KEND7
Definition: tmux.h:354
@ TTYC_ICH1
Definition: tmux.h:325
@ TTYC_KPRV5
Definition: tmux.h:451
@ TTYC_RI
Definition: tmux.h:473
@ TTYC_KUP4
Definition: tmux.h:463
@ TTYC_KNXT5
Definition: tmux.h:444
@ TTYC_RMKX
Definition: tmux.h:477
@ TTYC_COLORS
Definition: tmux.h:288
@ TTYC_ECH
Definition: tmux.h:312
@ TTYC_KHOM3
Definition: tmux.h:419
@ TTYC_SMUL
Definition: tmux.h:492
@ TTYC_SS
Definition: tmux.h:495
@ TTYC_KUP7
Definition: tmux.h:466
@ TTYC_KDN2
Definition: tmux.h:342
@ TTYC_KF1
Definition: tmux.h:355
#define TERM_RGBCOLOURS
Definition: tmux.h:1296
#define TERM_DECSLRM
Definition: tmux.h:1294
#define TERM_NOAM
Definition: tmux.h:1293
#define TERM_DECFRA
Definition: tmux.h:1295
#define TERM_VT100LIKE
Definition: tmux.h:1297
const char * tty_term_ptr2(struct tty_term *term, enum tty_code_code code, const void *a, const void *b)
Definition: tty-term.c:787
u_int tty_term_ncodes(void)
Definition: tty-term.c:289
const char * tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b)
Definition: tty-term.c:768
void tty_term_free(struct tty_term *term)
Definition: tty-term.c:646
int tty_term_flag(struct tty_term *term, enum tty_code_code code)
Definition: tty-term.c:804
const char * tty_term_string(struct tty_term *term, enum tty_code_code code)
Definition: tty-term.c:752
const char * tty_term_ptr1(struct tty_term *term, enum tty_code_code code, const void *a)
Definition: tty-term.c:781
static char * tty_term_override_next(const char *s, size_t *offset)
Definition: tty-term.c:326
int tty_term_has(struct tty_term *term, enum tty_code_code code)
Definition: tty-term.c:746
int tty_term_read_list(const char *name, int fd, char ***caps, u_int *ncaps, char **cause)
Definition: tty-term.c:664
const char * tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, int c)
Definition: tty-term.c:774
struct tty_term * tty_term_create(struct tty *tty, char *name, char **caps, u_int ncaps, int *feat, char **cause)
Definition: tty-term.c:516
const char * tty_term_describe(struct tty_term *term, enum tty_code_code code)
Definition: tty-term.c:814
const char * tty_term_string1(struct tty_term *term, enum tty_code_code code, int a)
Definition: tty-term.c:762
void tty_term_apply(struct tty_term *term, const char *capabilities, int quiet)
Definition: tty-term.c:357
static char * tty_term_strip(const char *)
Definition: tty-term.c:295
void tty_term_apply_overrides(struct tty_term *term)
Definition: tty-term.c:433
static const struct tty_term_code_entry tty_term_codes[]
Definition: tty-term.c:58
struct tty_terms tty_terms
Definition: tty-term.c:35
void tty_term_free_list(char **caps, u_int ncaps)
Definition: tty-term.c:736
tty_code_type
Definition: tty-term.c:37
@ TTYCODE_FLAG
Definition: tty-term.c:41
@ TTYCODE_NONE
Definition: tty-term.c:38
@ TTYCODE_STRING
Definition: tty-term.c:39
@ TTYCODE_NUMBER
Definition: tty-term.c:40
int tty_term_number(struct tty_term *term, enum tty_code_code code)
Definition: tty-term.c:794
char * string
Definition: tmux.h:1802
int xsnprintf(char *str, size_t len, const char *fmt,...)
Definition: xmalloc.c:135
void * xreallocarray(void *ptr, size_t nmemb, size_t size)
Definition: xmalloc.c:61
int xasprintf(char **ret, const char *fmt,...)
Definition: xmalloc.c:109
void * xcalloc(size_t nmemb, size_t size)
Definition: xmalloc.c:41
char * xstrdup(const char *str)
Definition: xmalloc.c:89