summaryrefslogtreecommitdiffstats
path: root/tty-features.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tty-features.c168
1 files changed, 139 insertions, 29 deletions
diff --git a/tty-features.c b/tty-features.c
index 2848b4d..9bd0d84 100644
--- a/tty-features.c
+++ b/tty-features.c
@@ -21,6 +21,12 @@
#include <stdlib.h>
#include <string.h>
+#if defined(HAVE_CURSES_H)
+#include <curses.h>
+#elif defined(HAVE_NCURSES_H)
+#include <ncurses.h>
+#endif
+
#include "tmux.h"
/*
@@ -36,13 +42,13 @@
/* A named terminal feature. */
struct tty_feature {
- const char *name;
- const char **capabilities;
- int flags;
+ const char *name;
+ const char *const *capabilities;
+ int flags;
};
/* Terminal has xterm(1) title setting. */
-static const char *tty_feature_title_capabilities[] = {
+static const char *const tty_feature_title_capabilities[] = {
"tsl=\\E]0;", /* should be using TS really */
"fsl=\\a",
NULL
@@ -54,7 +60,7 @@ static const struct tty_feature tty_feature_title = {
};
/* Terminal has OSC 7 working directory. */
-static const char *tty_feature_osc7_capabilities[] = {
+static const char *const tty_feature_osc7_capabilities[] = {
"Swd=\\E]7;",
"fsl=\\a",
NULL
@@ -66,7 +72,7 @@ static const struct tty_feature tty_feature_osc7 = {
};
/* Terminal has mouse support. */
-static const char *tty_feature_mouse_capabilities[] = {
+static const char *const tty_feature_mouse_capabilities[] = {
"kmous=\\E[M",
NULL
};
@@ -77,7 +83,7 @@ static const struct tty_feature tty_feature_mouse = {
};
/* Terminal can set the clipboard with OSC 52. */
-static const char *tty_feature_clipboard_capabilities[] = {
+static const char *const tty_feature_clipboard_capabilities[] = {
"Ms=\\E]52;%p1%s;%p2%s\\a",
NULL
};
@@ -87,12 +93,27 @@ static const struct tty_feature tty_feature_clipboard = {
0
};
+/* Terminal supports OSC 8 hyperlinks. */
+static const char *tty_feature_hyperlinks_capabilities[] = {
+#if defined (__OpenBSD__) || (defined(NCURSES_VERSION_MAJOR) && \
+ (NCURSES_VERSION_MAJOR > 5 || \
+ (NCURSES_VERSION_MAJOR == 5 && NCURSES_VERSION_MINOR > 8)))
+ "*:Hls=\\E]8;%?%p1%l%tid=%p1%s%;;%p2%s\\E\\\\",
+#endif
+ NULL
+};
+static const struct tty_feature tty_feature_hyperlinks = {
+ "hyperlinks",
+ tty_feature_hyperlinks_capabilities,
+ 0
+};
+
/*
* Terminal supports RGB colour. This replaces setab and setaf also since
* terminals with RGB have versions that do not allow setting colours from the
* 256 palette.
*/
-static const char *tty_feature_rgb_capabilities[] = {
+static const char *const tty_feature_rgb_capabilities[] = {
"AX",
"setrgbf=\\E[38;2;%p1%d;%p2%d;%p3%dm",
"setrgbb=\\E[48;2;%p1%d;%p2%d;%p3%dm",
@@ -107,7 +128,7 @@ static const struct tty_feature tty_feature_rgb = {
};
/* Terminal supports 256 colours. */
-static const char *tty_feature_256_capabilities[] = {
+static const char *const tty_feature_256_capabilities[] = {
"AX",
"setab=\\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
"setaf=\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
@@ -120,7 +141,7 @@ static const struct tty_feature tty_feature_256 = {
};
/* Terminal supports overline. */
-static const char *tty_feature_overline_capabilities[] = {
+static const char *const tty_feature_overline_capabilities[] = {
"Smol=\\E[53m",
NULL
};
@@ -131,9 +152,10 @@ static const struct tty_feature tty_feature_overline = {
};
/* Terminal supports underscore styles. */
-static const char *tty_feature_usstyle_capabilities[] = {
+static const char *const tty_feature_usstyle_capabilities[] = {
"Smulx=\\E[4::%p1%dm",
"Setulc=\\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m",
+ "Setulc1=\\E[58::5::%p1%dm",
"ol=\\E[59m",
NULL
};
@@ -144,7 +166,7 @@ static const struct tty_feature tty_feature_usstyle = {
};
/* Terminal supports bracketed paste. */
-static const char *tty_feature_bpaste_capabilities[] = {
+static const char *const tty_feature_bpaste_capabilities[] = {
"Enbp=\\E[?2004h",
"Dsbp=\\E[?2004l",
NULL
@@ -156,7 +178,7 @@ static const struct tty_feature tty_feature_bpaste = {
};
/* Terminal supports focus reporting. */
-static const char *tty_feature_focus_capabilities[] = {
+static const char *const tty_feature_focus_capabilities[] = {
"Enfcs=\\E[?1004h",
"Dsfcs=\\E[?1004l",
NULL
@@ -168,7 +190,7 @@ static const struct tty_feature tty_feature_focus = {
};
/* Terminal supports cursor styles. */
-static const char *tty_feature_cstyle_capabilities[] = {
+static const char *const tty_feature_cstyle_capabilities[] = {
"Ss=\\E[%p1%d q",
"Se=\\E[2 q",
NULL
@@ -180,7 +202,7 @@ static const struct tty_feature tty_feature_cstyle = {
};
/* Terminal supports cursor colours. */
-static const char *tty_feature_ccolour_capabilities[] = {
+static const char *const tty_feature_ccolour_capabilities[] = {
"Cs=\\E]12;%p1%s\\a",
"Cr=\\E]112\\a",
NULL
@@ -192,7 +214,7 @@ static const struct tty_feature tty_feature_ccolour = {
};
/* Terminal supports strikethrough. */
-static const char *tty_feature_strikethrough_capabilities[] = {
+static const char *const tty_feature_strikethrough_capabilities[] = {
"smxx=\\E[9m",
NULL
};
@@ -203,8 +225,8 @@ static const struct tty_feature tty_feature_strikethrough = {
};
/* Terminal supports synchronized updates. */
-static const char *tty_feature_sync_capabilities[] = {
- "Sync=\\EP=%p1%ds\\E\\\\",
+static const char *const tty_feature_sync_capabilities[] = {
+ "Sync=\\E[?2026%?%p1%{1}%-%tl%eh%;",
NULL
};
static const struct tty_feature tty_feature_sync = {
@@ -214,7 +236,7 @@ static const struct tty_feature tty_feature_sync = {
};
/* Terminal supports extended keys. */
-static const char *tty_feature_extkeys_capabilities[] = {
+static const char *const tty_feature_extkeys_capabilities[] = {
"Eneks=\\E[>4;1m",
"Dseks=\\E[>4m",
NULL
@@ -226,7 +248,7 @@ static const struct tty_feature tty_feature_extkeys = {
};
/* Terminal supports DECSLRM margins. */
-static const char *tty_feature_margins_capabilities[] = {
+static const char *const tty_feature_margins_capabilities[] = {
"Enmg=\\E[?69h",
"Dsmg=\\E[?69l",
"Clmg=\\E[s",
@@ -240,7 +262,7 @@ static const struct tty_feature tty_feature_margins = {
};
/* Terminal supports DECFRA rectangle fill. */
-static const char *tty_feature_rectfill_capabilities[] = {
+static const char *const tty_feature_rectfill_capabilities[] = {
"Rect",
NULL
};
@@ -250,21 +272,109 @@ static const struct tty_feature tty_feature_rectfill = {
TERM_DECFRA
};
+/* Use builtin function keys only. */
+static const char *const tty_feature_ignorefkeys_capabilities[] = {
+ "kf0@",
+ "kf1@",
+ "kf2@",
+ "kf3@",
+ "kf4@",
+ "kf5@",
+ "kf6@",
+ "kf7@",
+ "kf8@",
+ "kf9@",
+ "kf10@",
+ "kf11@",
+ "kf12@",
+ "kf13@",
+ "kf14@",
+ "kf15@",
+ "kf16@",
+ "kf17@",
+ "kf18@",
+ "kf19@",
+ "kf20@",
+ "kf21@",
+ "kf22@",
+ "kf23@",
+ "kf24@",
+ "kf25@",
+ "kf26@",
+ "kf27@",
+ "kf28@",
+ "kf29@",
+ "kf30@",
+ "kf31@",
+ "kf32@",
+ "kf33@",
+ "kf34@",
+ "kf35@",
+ "kf36@",
+ "kf37@",
+ "kf38@",
+ "kf39@",
+ "kf40@",
+ "kf41@",
+ "kf42@",
+ "kf43@",
+ "kf44@",
+ "kf45@",
+ "kf46@",
+ "kf47@",
+ "kf48@",
+ "kf49@",
+ "kf50@",
+ "kf51@",
+ "kf52@",
+ "kf53@",
+ "kf54@",
+ "kf55@",
+ "kf56@",
+ "kf57@",
+ "kf58@",
+ "kf59@",
+ "kf60@",
+ "kf61@",
+ "kf62@",
+ "kf63@",
+ NULL
+};
+static const struct tty_feature tty_feature_ignorefkeys = {
+ "ignorefkeys",
+ tty_feature_ignorefkeys_capabilities,
+ 0
+};
+
+/* Terminal has sixel capability. */
+static const char *const tty_feature_sixel_capabilities[] = {
+ "Sxl",
+ NULL
+};
+static const struct tty_feature tty_feature_sixel = {
+ "sixel",
+ tty_feature_sixel_capabilities,
+ TERM_SIXEL
+};
+
/* Available terminal features. */
-static const struct tty_feature *tty_features[] = {
+static const struct tty_feature *const tty_features[] = {
&tty_feature_256,
&tty_feature_bpaste,
&tty_feature_ccolour,
&tty_feature_clipboard,
+ &tty_feature_hyperlinks,
&tty_feature_cstyle,
&tty_feature_extkeys,
&tty_feature_focus,
+ &tty_feature_ignorefkeys,
&tty_feature_margins,
&tty_feature_mouse,
&tty_feature_osc7,
&tty_feature_overline,
&tty_feature_rectfill,
&tty_feature_rgb,
+ &tty_feature_sixel,
&tty_feature_strikethrough,
&tty_feature_sync,
&tty_feature_title,
@@ -323,9 +433,9 @@ tty_get_features(int feat)
int
tty_apply_features(struct tty_term *term, int feat)
{
- const struct tty_feature *tf;
- const char **capability;
- u_int i;
+ const struct tty_feature *tf;
+ const char *const *capability;
+ u_int i;
if (feat == 0)
return (0);
@@ -356,7 +466,7 @@ tty_apply_features(struct tty_term *term, int feat)
void
tty_default_features(int *feat, const char *name, u_int version)
{
- static struct {
+ static const struct {
const char *name;
u_int version;
const char *features;
@@ -369,14 +479,14 @@ tty_default_features(int *feat, const char *name, u_int version)
},
{ .name = "tmux",
.features = TTY_FEATURES_BASE_MODERN_XTERM
- ",ccolour,cstyle,focus,overline,usstyle"
+ ",ccolour,cstyle,focus,overline,usstyle,hyperlinks"
},
{ .name = "rxvt-unicode",
- .features = "256,bpaste,ccolour,cstyle,mouse,title"
+ .features = "256,bpaste,ccolour,cstyle,mouse,title,ignorefkeys"
},
{ .name = "iTerm2",
.features = TTY_FEATURES_BASE_MODERN_XTERM
- ",cstyle,extkeys,margins,usstyle,sync,osc7"
+ ",cstyle,extkeys,margins,usstyle,sync,osc7,hyperlinks"
},
{ .name = "XTerm",
/*