1
0
mirror of https://github.com/tmux/tmux.git synced 2025-03-22 21:08:49 +00:00

Expose additional formatting variables

This commit is contained in:
shiro 2025-03-14 08:32:49 +09:00
parent 3eb93383a3
commit b02a4a3a76
2 changed files with 64 additions and 0 deletions

View File

@ -1119,6 +1119,17 @@ format_cb_cursor_character(struct format_tree *ft)
return (value);
}
/* Callback for cursor_colour. */
static void *format_cb_cursor_colour(struct format_tree *ft) {
if (ft->wp != NULL && ft->wp->screen != NULL) {
if(ft->wp->screen->ccolour != -1) {
return (xstrdup(colour_tostring(ft->wp->screen->ccolour)));
}
return (xstrdup(colour_tostring(ft->wp->screen->default_ccolour)));
}
return (NULL);
}
/* Callback for mouse_word. */
static void *
format_cb_mouse_word(struct format_tree *ft)
@ -1593,6 +1604,33 @@ format_cb_cursor_flag(struct format_tree *ft)
return (NULL);
}
/* Callback for cursor_shape. */
static void *format_cb_cursor_shape(struct format_tree *ft) {
if (ft->wp != NULL && ft->wp->screen != NULL) {
switch (ft->wp->screen->cstyle) {
case SCREEN_CURSOR_BLOCK:
return (xstrdup("block"));
case SCREEN_CURSOR_UNDERLINE:
return (xstrdup("underline"));
case SCREEN_CURSOR_BAR:
return (xstrdup("bar"));
default:
return (xstrdup("default"));
}
}
return (NULL);
}
/* Callback for cursor_very_visible. */
static void *format_cb_cursor_very_visible(struct format_tree *ft) {
if (ft->wp != NULL && ft->wp->screen != NULL) {
if (ft->wp->screen->mode & MODE_CURSOR_VERY_VISIBLE)
return (xstrdup("1"));
return (xstrdup("0"));
}
return (NULL);
}
/* Callback for cursor_x. */
static void *
format_cb_cursor_x(struct format_tree *ft)
@ -1611,6 +1649,16 @@ format_cb_cursor_y(struct format_tree *ft)
return (NULL);
}
/* Callback for cursor_blinking. */
static void *format_cb_cursor_blinking(struct format_tree *ft) {
if (ft->wp != NULL && ft->wp->screen != NULL) {
if (ft->wp->screen->mode & MODE_CURSOR_BLINKING)
return (xstrdup("1"));
return (xstrdup("0"));
}
return (NULL);
}
/* Callback for history_limit. */
static void *
format_cb_history_limit(struct format_tree *ft)
@ -2922,12 +2970,24 @@ static const struct format_table_entry format_table[] = {
{ "config_files", FORMAT_TABLE_STRING,
format_cb_config_files
},
{ "cursor_blinking", FORMAT_TABLE_STRING,
format_cb_cursor_blinking
},
{ "cursor_character", FORMAT_TABLE_STRING,
format_cb_cursor_character
},
{ "cursor_colour", FORMAT_TABLE_STRING,
format_cb_cursor_colour
},
{ "cursor_flag", FORMAT_TABLE_STRING,
format_cb_cursor_flag
},
{ "cursor_shape", FORMAT_TABLE_STRING,
format_cb_cursor_shape
},
{ "cursor_very_visible", FORMAT_TABLE_STRING,
format_cb_cursor_very_visible
},
{ "cursor_x", FORMAT_TABLE_STRING,
format_cb_cursor_x
},

4
tmux.1
View File

@ -5944,6 +5944,7 @@ The following variables are available, where appropriate:
.It Li "command_list_name" Ta "" Ta "Command name if listing commands"
.It Li "command_list_usage" Ta "" Ta "Command usage if listing commands"
.It Li "config_files" Ta "" Ta "List of configuration files loaded"
.It Li "cursor_blinking" Ta "" Ta "1 if the cursor is blinking"
.It Li "copy_cursor_hyperlink" Ta "" Ta "Hyperlink under cursor in copy mode"
.It Li "copy_cursor_line" Ta "" Ta "Line the cursor is on in copy mode"
.It Li "copy_cursor_word" Ta "" Ta "Word under cursor in copy mode"
@ -5951,7 +5952,10 @@ The following variables are available, where appropriate:
.It Li "copy_cursor_y" Ta "" Ta "Cursor Y position in copy mode"
.It Li "current_file" Ta "" Ta "Current configuration file"
.It Li "cursor_character" Ta "" Ta "Character at cursor in pane"
.It Li "cursor_colour" Ta "" Ta "Cursor colour in pane"
.It Li "cursor_flag" Ta "" Ta "Pane cursor flag"
.It Li "cursor_shape" Ta "" Ta "Cursor shape in pane"
.It Li "cursor_very_visible" Ta "" Ta "1 if the cursor is in very visible mode"
.It Li "cursor_x" Ta "" Ta "Cursor X position in pane"
.It Li "cursor_y" Ta "" Ta "Cursor Y position in pane"
.It Li "history_bytes" Ta "" Ta "Number of bytes in window history"