format: add image_support

This adds a new image_support format which returns:

   "sixel" -- if sixel is compiled in
   "kitty" -- if kitty is compiled in
   "kitty,sixel" -- if compiled with both kitty and sixel
This commit is contained in:
Thomas Adam
2026-03-02 16:34:36 +00:00
parent cf6cbe430c
commit 3b7e9fb175
2 changed files with 15 additions and 21 deletions

View File

@@ -2562,24 +2562,21 @@ format_cb_version(__unused struct format_tree *ft)
/* Callback for sixel_support. */
static void *
format_cb_sixel_support(__unused struct format_tree *ft)
format_cb_image_support(__unused struct format_tree *ft)
{
#ifdef ENABLE_SIXEL
return (xstrdup("1"));
#else
return (xstrdup("0"));
#if defined(ENABLE_SIXEL) && defined(ENABLE_KITTY)
return (xstrdup("kitty,sixel"));
#endif
}
/* Callback for kitty_support. */
static void *
format_cb_kitty_support(__unused struct format_tree *ft)
{
#ifdef ENABLE_KITTY
return (xstrdup("1"));
#else
return (xstrdup("0"));
#ifdef ENABLE_SIXEL
return (xstrdup("sixel"));
#endif
#ifdef ENABLE_KITTY
return (xstrdup("kitty"));
#endif
return (NULL);
}
/* Callback for active_window_index. */
@@ -3201,6 +3198,9 @@ static const struct format_table_entry format_table[] = {
{ "host_short", FORMAT_TABLE_STRING,
format_cb_host_short
},
{ "image_support", FORMAT_TABLE_STRING,
format_cb_image_support
},
{ "insert_flag", FORMAT_TABLE_STRING,
format_cb_insert_flag
},
@@ -3477,12 +3477,6 @@ static const struct format_table_entry format_table[] = {
{ "session_windows", FORMAT_TABLE_STRING,
format_cb_session_windows
},
{ "sixel_support", FORMAT_TABLE_STRING,
format_cb_sixel_support
},
{ "kitty_support", FORMAT_TABLE_STRING,
format_cb_kitty_support
},
{ "socket_path", FORMAT_TABLE_STRING,
format_cb_socket_path
},

2
tmux.1
View File

@@ -6266,6 +6266,7 @@ The following variables are available, where appropriate:
.It Li "hook_window_name" Ta "" Ta "Name of window where hook was run, if any"
.It Li "host" Ta "#H" Ta "Hostname of local host"
.It Li "host_short" Ta "#h" Ta "Hostname of local host (no domain name)"
.It Li "image_support" Ta "" Ta "Returns the string of the support image (sixel, kitty)"
.It Li "insert_flag" Ta "" Ta "Pane insert flag"
.It Li "key_string" Ta "" Ta "String representation of the key binding"
.It Li "key_repeat" Ta "" Ta "1 if key binding is repeatable"
@@ -6380,7 +6381,6 @@ The following variables are available, where appropriate:
.It Li "session_stack" Ta "" Ta "Window indexes in most recent order"
.It Li "session_windows" Ta "" Ta "Number of windows in session"
.It Li "socket_path" Ta "" Ta "Server socket path"
.It Li "sixel_support" Ta "" Ta "1 if server has support for SIXEL"
.It Li "start_time" Ta "" Ta "Server start time"
.It Li "synchronized_output_flag" Ta "" Ta "1 if pane has synchronized output enabled"
.It Li "uid" Ta "" Ta "Server UID"